]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1575] rewrite repositories group page
authorOlivier Lamy <olamy@apache.org>
Tue, 14 Feb 2012 08:20:38 +0000 (08:20 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 14 Feb 2012 08:20:38 +0000 (08:20 +0000)
impl grid with groups

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1243818 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repository-groups.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/menu.html
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repository-groups.html

index 2496ace4aa6562dcb3a1210352d09c0b641fada9..740d9ea7449ffb8f31e8b41858f6eba8c6d12a0e 100644 (file)
@@ -86,7 +86,7 @@ $.ajax(
            .script(buildLoadJsUrl("archiva/network-proxies.js")).wait()
            .script(buildLoadJsUrl("archiva/proxy-connectors.js")).wait()
            .script(buildLoadJsUrl("redback/operation.js")).wait()
-           .script(buildLoadJsUrl("repository-groups.js")).wait()
+           .script(buildLoadJsUrl("archiva/repository-groups.js")).wait()
            .script(buildLoadJsUrl("redback/redback-tmpl.js")).wait()
            .script(buildLoadJsUrl("bootstrap.js"))
            .script(buildLoadJsUrl("knockout.simpleGrid.js"))
index f1a26c1c98436a758937d95684d3a3cac9e477cc..1d78c139eab469eed59c4748b363d36b3081177d 100644 (file)
@@ -328,12 +328,7 @@ $(function() {
 
 
     getManagedRepository=function(id){
-      var managedRepository=$.grep(self.managedRepositories(),
-                                      function(repo,idx){
-                                        return repo.id()==id;
-                                      }
-                            );
-      return ($.isArray(managedRepository) && managedRepository.length>0) ? managedRepository[0]:new ManagedRepository();
+      return findManagedRepository(id,self.managedRepositories());
     }
 
     getRemoteRepository=function(id){
index 836cc840b2246ef976aad365ea5d565e79ff0faa..29ca8f69bcc258665f6ba2aaa799201539bc61be 100644 (file)
@@ -957,4 +957,13 @@ $(function() {
     });
   }
 
+  findManagedRepository=function(id,managedRepositories){
+    var managedRepository=$.grep(managedRepositories,
+                                    function(repo,idx){
+                                      return repo.id()==id;
+                                    }
+                          );
+    return ($.isArray(managedRepository) && managedRepository.length>0) ? managedRepository[0]:new ManagedRepository();
+  }
+
 });
\ No newline at end of file
index 1486f57d55d26cf85538e21e7d67bb54c21acf05..fb2bd9f41f7eaac856811ba2abe4a8a17efccc6f 100644 (file)
  */
 $(function() {
 
+  RepositoryGroup=function(id,repositories){
+
+    var self=this;
+
+    //private String id;
+    this.id=ko.observable(id);
+    this.id.subscribe(function(newValue){self.modified(true)});
+
+    // private List<String> repositories;
+    this.repositories=ko.observableArray(repositories);
+    this.repositories.subscribe(function(newValue){self.modified(true)});
+
+    this.modified=ko.observable(false);
+  }
+
+  RepositoryGroupViewModel=function(){
+    this.repositoryGroups=ko.observableArray([]);
+    this.managedRepositories=ko.observableArray([]);
+
+    findManagedRepository=function(id){
+      return findManagedRepository(id,self.managedRepositories());
+    }
+  }
+
+  displayRepositoryGroups=function(){
+    screenChange();
+    var mainContent = $("#main-content");
+    mainContent.html(mediumSpinnerImg());
+    this.repositoryGroupViewModel=new RepositoryGroupViewModel();
+    var self=this;
+
+    loadManagedRepositories(function(data) {
+      self.repositoryGroupViewModel.managedRepositories(mapManagedRepositories(data));
+
+      $.ajax("restServices/archivaServices/repositoryGroupService/getRepositoriesGroups", {
+          type: "GET",
+          dataType: 'json',
+          success: function(data) {
+            var mappedRepositoryGroups=mapRepositoryGroups(data);
+            mainContent.html($("#repositoryGroupsMain").tmpl());
+            self.repositoryGroupViewModel.repositoryGroups(mappedRepositoryGroups);
+            //ko.applyBindings(repositoryGroupViewModel,mainContent.find("#repository-groups-table" ).get(0));
+            ko.applyBindings(repositoryGroupViewModel,mainContent.get(0));
+
+          }
+        }
+      );
+
+    });
+
+
+  }
+
+  mapRepositoryGroups=function(data){
+    if (data == null){
+      return new Array();
+    }
+    var mappedRepositoryGroups = $.map(data.repositoryGroup, function(item) {
+      return mapRepositoryGroup(item);
+    });
+    return mappedRepositoryGroups;
+  }
+
+  mapRepositoryGroup=function(data){
+    return new RepositoryGroup(data.id, mapStringArray(data.repositories));
+  }
 
 });
index 74a26d8f77610458e191fe106738844300a62dcb..c9584125ab44b982723d404243f27e8dd4bff9f8 100644 (file)
@@ -30,6 +30,9 @@
 
     <ul class="nav nav-list" redback-permissions="{permissions: ['archiva-manage-configuration']}">
       <li class="nav-header">${$.i18n.prop('menu.administration')}</li>
+      <li style="display: none" redback-permissions="{permissions: ['archiva-manage-configuration']}">
+        <a href="#" id="menu-repository-groups-list-a" onclick="displayRepositoryGroups()">${$.i18n.prop('menu.repository.groups')}</a>
+      </li>
       <li style="display: none" redback-permissions="{permissions: ['archiva-manage-configuration']}">
         <a href="#" id="menu-repositories-list-a" onclick="displayRepositoriesGrid()">${$.i18n.prop('menu.repositories')}</a>
       </li>
index 3c4a2ea9a0b57efa459453a43151336c7f5b1d50..03390f482e7d303a6e780f1cc13a70f7359e0d9a 100644 (file)
   ~ specific language governing permissions and limitations
   ~ under the License.
 -->
+<script id="repositoryGroupsMain" type="text/x-jquery-tmpl">
+  <div class="page-header">
+    <h2>${$.i18n.prop('repository.groups.list')}</h2>
+  </div>
+  <div id="repository-groups-table" data-bind='template:{name:"repository-groups-table-tmpl"}'>
+
+  </div>
+  <br/><br/>
+    <table class="table table-striped table-bordered">
+      <thead>
+        <th>group</th>
+        <th>repos</th>
+      </thead>
+      <tbody>
+        <div id="repository-groups-table-bind" data-bind="foreach: repositoryGroups">
+          <tr>
+            <td data-bind="value: $data.id"></td>
+          </tr>
+        </div>
+      </tbody>
+    </table>
+
+  </div>
+</script>
+
+<script id="repository-groups-table-tmpl" type="text/html">
+  <table class="table table-striped table-bordered">
+    <thead>
+      <th>group</th>
+      <th>repos</th>
+    </thead>
+    <tbody>
+    {{each(i, repositoryGroup) repositoryGroups}}
+      <tr>
+        <td>${repositoryGroup.id}</td>
+        <td>
+          <ul>
+          {{each(j,id) repositoryGroup.repositories()}}
+            <li>${id}</li>
+          {{/each}}
+          </ul>
+        </td>
+      </tr>
+    {{/each}}
+    </tbody>
+  </table>
+</script>
\ No newline at end of file