]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1579] rewrite repositories scanning admin page
authorOlivier Lamy <olamy@apache.org>
Wed, 7 Mar 2012 23:23:09 +0000 (23:23 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 7 Mar 2012 23:23:09 +0000 (23:23 +0000)
fileTypes pattern implemented.

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

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html

index 1a6cfcc51ece021e79cd1713ca23a66144884ca0..54897bfe47ac6f46f060e74e78e93f7549318960 100644 (file)
@@ -322,13 +322,114 @@ $(function() {
     return [];
   }
 
+  AdminRepositoryConsumer=function(enabled,id,description){
+    //private boolean enabled = false;
+    this.enabled=ko.observable(enabled);
+
+    //private String id;
+    this.id=ko.observable(id)
+
+    //private String description;
+    this.description=ko.observable(description);
+  }
+
+  mapAdminRepositoryConsumer=function(data){
+    return new AdminRepositoryConsumer(data.enabled,data.id,data.description);
+  }
+
+  mapAdminRepositoryConsumers=function(data){
+    if (data!=null){
+      return $.isArray(data)? $.map(data,function(item){
+        return mapAdminRepositoryConsumer(item)
+      }):[mapAdminRepositoryConsumer(data)];
+    }
+    return [];
+  }
+
+
+
+  RepositoryScanningViewModel=function(){
+    var self=this;
+    this.fileTypes=ko.observableArray([]);
+
+    this.findFileType=function(id){
+      var fileType=null;
+      for (var i=0;i<self.fileTypes().length;i++){
+        if (id==self.fileTypes()[i].id()){
+          fileType=self.fileTypes()[i];
+        }
+      }
+      return fileType;
+    }
+
+    removeFileTypePattern=function(id,pattern){
+      clearUserMessages();
+      var url="restServices/archivaServices/archivaAdministrationService/removeFileTypePattern?"
+      url+="fileTypeId="+encodeURIComponent(id);
+      url+="&pattern="+encodeURIComponent(pattern);
+      $.ajax(url, {
+          type: "GET",
+          dataType: 'json',
+          success: function(data){
+            self.findFileType(id ).patterns.remove(pattern);
+            displaySuccessMessage( $.i18n.prop("repository-scanning.file-types.removed.pattern",id,pattern));
+
+          }
+      });
+    }
+
+    addFileTypePattern=function(id){
+      var pattern=$("#main-content #pattern-"+id ).val();
+      $.log("addFileTypePattern:"+id+":"+pattern);
+      clearUserMessages();
+      var url="restServices/archivaServices/archivaAdministrationService/addFileTypePattern?"
+      url+="fileTypeId="+encodeURIComponent(id);
+      url+="&pattern="+encodeURIComponent(pattern);
+      $.ajax(url, {
+          type: "GET",
+          dataType: 'json',
+          success: function(data){
+            self.findFileType(id ).patterns.push(pattern);
+            displaySuccessMessage( $.i18n.prop("repository-scanning.file-types.added.pattern",id,pattern));
+
+          }
+      });
+    }
+  }
+
   displayRepositoryScanning=function(){
 
+    clearUserMessages();
+    var mainContent=$("#main-content");
+
+    mainContent.html($("#repository-scanning-main").tmpl());
+    mainContent.find("#file-types-content").html(mediumSpinnerImg());
+
+    var repositoryScanningViewModel=new RepositoryScanningViewModel();
+
     $.ajax("restServices/archivaServices/archivaAdministrationService/getFileTypes", {
         type: "GET",
         dataType: 'json',
         success: function(data){
           var fileTypes=mapFileTypes(data);
+          repositoryScanningViewModel.fileTypes(fileTypes);
+          ko.applyBindings(repositoryScanningViewModel,mainContent.find("#file-types-content").get(0));
+        }
+    });
+
+    $.ajax("restServices/archivaServices/archivaAdministrationService/getKnownContentAdminRepositoryConsumers", {
+        type: "GET",
+        dataType: 'json',
+        success: function(data){
+          var adminRepositoryConsumers=mapAdminRepositoryConsumers(data);
+        }
+    });
+
+    $.ajax("restServices/archivaServices/archivaAdministrationService/getInvalidContentAdminRepositoryConsumers", {
+        type: "GET",
+        dataType: 'json',
+        success: function(data){
+          var adminRepositoryConsumers=mapAdminRepositoryConsumers(data);
         }
     });
 
index 5e105daee002a43d01de6c9aa66472feefc9c4e5..59c16417a8a69cd51b363a0c39098ab7ad0b243d 100644 (file)
     </div>
 </script>
 
+<script id="repository-scanning-main" type="text/html">
+  <div id="repository-scanning-screen">
+    <div class="page-header">
+      <h2>${$.i18n.prop('repository-scanning.head')}</h2>
+    </div>
+  </div>
+
+  <ul id="repositories-tabs" class="nav nav-tabs">
+    <li class="active">
+      <a data-toggle="tab" href="#file-types-content">${$.i18n.prop('repository-scanning.file-types.head')}</a>
+    </li>
+    <li>
+      <a data-toggle="tab" href="#consumers-content">${$.i18n.prop('repository-scanning.consumers.head')}</a>
+    </li>
+  </ul>
+
+  <div class="tab-content">
+    <div id="file-types-content" class="tab-pane active" data-bind='template: {name:"file-types-tmpl"}'>
+      file types
+    </div>
+    <div id="consumers-content" class="tab-pane">
+      consumers
+    </div>
+  </div>
+
+</script>
+
+<script id="file-types-tmpl" type="text/html">
+  <!-- accordion ?? -->
+  <div class="span4">
+  {{each(i, fileType) fileTypes}}
+    <div class="page-header">
+      <h4>${fileType.id}</h4>
+    </div>
+    <table class="table table-condensed">
+      {{each(j,pattern) fileType.patterns}}
+      <tr>
+        <td>${pattern}</td>
+        <td>
+          <a href="#" data-bind="click: function(){ removeFileTypePattern(fileType.id(),pattern) }">
+            <img src="images/edit-cut-22-22.png" title="${$.i18n.prop('delete')}"/>
+          </a>
+        </td>
+      </tr>
+      {{/each}}
+      <tr>
+        <td><input type="text" id="pattern-${fileType.id}"/></td>
+        <td><a href="#" data-bind="click: function(){addFileTypePattern(fileType.id())}">add</a></td>
+      </tr>
+    </table>
+  {{/each}}
+  </div>
+</script>
+