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);
}
});
</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>
+