]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1681] addProxy Connectors Rules screen
authorOlivier Lamy <olamy@apache.org>
Tue, 2 Oct 2012 15:13:38 +0000 (15:13 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 2 Oct 2012 15:13:38 +0000 (15:13 +0000)
screen implementation.

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

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ProxyConnectorRuleService.java
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html
archiva-modules/archiva-web/archiva-webapp-js/src/test/tomcat/log4j2-test.xml

index d57fed33ad0662e0e2101d3fda0825df6948c89e..d2cacba57ff7a6d59f4bda0e383ac97f0d67f2cb 100644 (file)
@@ -48,7 +48,7 @@ public interface ProxyConnectorRuleService
         throws ArchivaRestServiceException;
 
     @Path ( "proxyConnectorRule" )
-    @PUT
+    @POST
     @Consumes ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
     @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
     @RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
index f28d81b20387b18cbb1054befeb8c46c3929d2df..9df238a8fd51ba4d69746587b5cf911373312852 100644 (file)
@@ -23,9 +23,13 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
 
   ProxyConnectorRulesViewModel=function(proxyConnectorRules,proxyConnectors){
     var self=this;
-    this.proxyConnectorRules=ko.observableArray(proxyConnectorRules?proxyConnectorRules:[]);
+    this.proxyConnectorRules=ko.observableArray(proxyConnectorRules);
     this.proxyConnectors=proxyConnectors;
 
+    // FIXME get that from a REST service
+    // FIXME i18n
+    this.ruleTypes=[new RuleType("WHITE_LIST"," white list"),new RuleType("BLACK_LIST"," black list")];
+
     this.displayGrid=function(){
       var mainContent = $("#main-content");
 
@@ -33,15 +37,14 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
         data: self.proxyConnectorRules,
         pageSize: 5,
         gridUpdateCallBack: function(){
-          $("#main-content" ).find("#proxy-connectors-rules-view-tabsTable" ).find("[title]").tooltip();
+          //$("#main-content" ).find("#proxy-connectors-rules-view-tabsTable" ).find("[title]").tooltip();
         }
       });
 
-      ko.applyBindings(self,mainContent.find("#proxy-connectors-rules-view-tabs-view").get(0));
+      ko.applyBindings(self,mainContent.find("#proxy-connector-rules-view").get(0));
 
       removeSmallSpinnerImg();
 
-
       mainContent.find("#proxy-connectors-rules-view-tabs").on('show', function (e) {
         $.log("on show:"+$(e.target).attr("href"));
         if ($(e.target).attr("href")=="#proxy-connector-rules-edit") {
@@ -49,10 +52,79 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
           ko.applyBindings(proxyConnectorRuleViewModel,mainContent.find("#proxy-connector-rules-edit" ).get(0));
           activateProxyConnectorRulesEditTab();
         }
+      });
+    }
+    addProxyConnectorRule=function(proxyConnectorRule){
+      $.log("addProxyConnectorRule");
+      self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/proxyConnectorRule");
+    }
+
+    this.saveProxyConnectorRule=function(proxyConnectorRule,url){
+      $.log("saveProxyConnectorRule:"+url);
+      $("#user-messages" ).html(mediumSpinnerImg());
+      $.ajax(url,
+        {
+          type: "POST",
+          contentType: 'application/json',
+          data: ko.toJSON(proxyConnectorRule),
+          dataType: 'json',
+          success: function(data) {
+            $.log("save proxyConnectorRule pattern:"+proxyConnectorRule.pattern());
+            var message=$.i18n.prop(self.update?'proxy-connector-rule.updated':'proxy-connector-rule.added',proxyConnectorRule.pattern());
+            displaySuccessMessage(message);
+            proxyConnectorRule.modified(false);
+            self.proxyConnectorRules.push(proxyConnectorRule);
+            activateProxyConnectorRulesGridTab();
+          },
+          error: function(data) {
+            var res = $.parseJSON(data.responseText);
+            displayRestError(res);
+          },
+          complete:function(data){
+            removeMediumSpinnerImg("#user-messages");
+          }
+        }
+      );
+    }
 
+    updateProxyConnectorRule=function(proxyConnectorRule){
+      $.log("updateProxyConnectorRule");
+      self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/updateProxyConnectorRule");
+    }
+
+    removeProxyConnectorRule=function(proxyConnectorRule){
+
+      //FIXME modal dialog to confirm
+
+      $("#user-messages" ).html(mediumSpinnerImg());
+      $.ajax("restServices/archivaServices/proxyConnectorRuleService/deleteProxyConnectorRule",
+       {
+         type:"POST",
+         contentType: 'application/json',
+         data: ko.toJSON(proxyConnectorRule),
+         dataType: 'json',
+         success:function(data){
+           var message=$.i18n.prop('proxy-connector-rule.deleted',proxyConnectorRule.pattern());
+           displaySuccessMessage(message);
+         },
+         error: function(data) {
+           var res = $.parseJSON(data.responseText);
+           displayRestError(res);
+         },
+         complete:function(data){
+           removeMediumSpinnerImg("#user-messages");
+         }
+       }
+      );
+    }
+
+    editProxyConnectorRule=function(proxyConnectorRule){
+      var proxyConnectorRuleViewModel=new ProxyConnectorRuleViewModel(proxyConnectorRule,self,true);
+      ko.applyBindings(proxyConnectorRuleViewModel,$("#main-content").find("#proxy-connector-rules-edit" ).get(0));
+      activateProxyConnectorRulesEditTab();
 
-      });
     }
+
   }
 
   ProxyConnectorRuleViewModel=function(proxyConnectorRule,proxyConnectorRulesViewModel,update){
@@ -63,7 +135,14 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
     this.update=update;
 
     proxyConnectorMoved=function(arg){
+      $.log("repositoryMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
+    }
 
+    saveProxyConnectorRule=function(){
+      $.log("pattern:"+self.proxyConnectorRule.pattern());
+      $.log("proxyConnectorRuleType:"+proxyConnectorRule.proxyConnectorRuleType());
+      $.log("proxyConnectors:"+proxyConnectorRule.proxyConnectors().length);
+      self.proxyConnectorRulesViewModel.saveProxyConnectorRule(self.proxyConnectorRule)
     }
 
   }
@@ -74,7 +153,7 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
     screenChange();
     var mainContent = $("#main-content");
     mainContent.html($("#proxyConnectorsRulesMain").tmpl());
-    mainContent.append(smallSpinnerImg());
+    $("#user-messages").html(mediumSpinnerImg());
     loadAllProxyConnectors(function(data){
       var proxyConnectors = mapProxyConnectors(data);
 
@@ -86,6 +165,9 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
             var proxyConnectorRulesViewModel = new ProxyConnectorRulesViewModel(proxyConnectorRules,proxyConnectors);
             proxyConnectorRulesViewModel.displayGrid();
             activateProxyConnectorRulesGridTab();
+          },
+          complete: function(data){
+            removeMediumSpinnerImg("#user-messages");
           }
 
         });
@@ -123,7 +205,7 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
     if (data==null){
       return null;
     }
-    return new ProxyConnector(data.pattern, data.proxyConnectorRuleType, mapProxyConnectors(data.proxyConnectors));
+    return new ProxyConnectorRule(data.pattern, data.proxyConnectorRuleType, mapProxyConnectors(data.proxyConnectors));
   }
 
   mapProxyConnectorRules=function(data){
@@ -137,9 +219,9 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
   activateProxyConnectorRulesGridTab=function(){
     var mainContent = $("#main-content");
     mainContent.find("#proxy-connectors-rules-view-tabs-content div[class*='tab-pane']").removeClass("active");
-    mainContent.find("#proxy-connectors-rules-view-tabs li").removeClass("active");
+    mainContent.find("#proxy-connectors-rules-view-tabs li").removeClass("active");
 
-    mainContent.find("#repository-groups-view").addClass("active");
+    mainContent.find("#proxy-connector-rules-view").addClass("active");
     mainContent.find("#proxy-connectors-rules-view-tabs-li-grid").addClass("active");
     mainContent.find("#proxy-connectors-rules-view-tabs-a-edit").html($.i18n.prop("add"));
 
@@ -155,5 +237,9 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
     mainContent.find("#proxy-connectors-rules-view-tabs-edit").addClass("active");
   }
 
+  RuleType=function(type,label){
+    this.type=type;
+    this.label=label;
+  }
 
 });
index ec153d777d5481f372ec7e138c5bc113a57ee328..01e4896698a86d8a24f00280cddd2d7d44a6af86 100644 (file)
 
     <ul id="proxy-connectors-rules-view-tabs" class="nav nav-tabs">
       <li id="proxy-connectors-rules-view-tabs-li-grid" class="active">
-        <a data-toggle="tab" href="#proxy-connector-rules-view" id="proxy-connectors-rules-view-tabs-a-network-proxies-grid">${$.i18n.prop('proxy-connectors-rules.grid.tab.title')}</a>
+        <a data-toggle="tab" href="#proxy-connector-rules-view" id="proxy-connectors-rules-view-tabs-a-grid">${$.i18n.prop('proxy-connectors-rules.grid.tab.title')}</a>
       </li>
       <li id="proxy-connectors-rules-view-tabs-li-edit">
         <a data-toggle="tab" href="#proxy-connector-rules-edit" id="proxy-connectors-rules-view-tabs-a-edit">${$.i18n.prop('add')}</a>
       </li>
     </ul>
     <div id="proxy-connectors-rules-view-tabs-content" class="tab-content">
-      <div id="proxy-connectors-rules-view-tabs-view" class="tab-pane active">
+      <div id="proxy-connector-rules-view" class="tab-pane active">
         <div id="proxy-connectors-rules-view-tabs-bulk-save-btn" data-bind='template:{name:"proxy-connectors-rules-view-tabs-bulk-save-tmpl"}'></div>
         <table class="table table-striped table-bordered" id="proxy-connectors-rules-view-tabsTable"
                data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'ko-proxy-connectors-rules-grid',pageLinksId:'proxy-connectors-rules-pagination'">
     </thead>
     <tbody>
     {{each(i, row) itemsOnCurrentPage()}}
-    <tr data-bind="css:{ 'modified': row.modified()}">
-      <td>${row.pattern()}</td>
-      <td>${row.proxyConnectorRuleType()}</td>
-      <td>connector</td>
-      <td>edit</td>
-      <td>delete</td>
-      <td>save</td>
-    </tr>
+        <tr data-bind="css:{ 'modified': row.modified()}">
+          <td>${row.pattern()}</td>
+          <td>${row.proxyConnectorRuleType()}</td>
+          <td>
+            <ul>
+            {{each(j,proxyConnector) row.proxyConnectors()}}
+              <li>${proxyConnector.sourceRepoId()} <-> ${proxyConnector.targetRepoId()}</li>
+            {{/each}}
+            </ul>
+          </td>
+          <td>
+              <a href="#" data-bind="click: function(){ editProxyConnectorRule(row) }">
+                <span class="btn btn-primary">
+                  <i class="icon-pencil icon-white"/>
+                </span>
+              </a>
+          </td>
+          <td>
+              <a href="#" data-bind="click: function(){ removeProxyConnectorRule(row) }">
+                <span class="btn btn-danger">
+                  <i class="icon-trash icon-white"/>
+                </span>
+              </a>
+          </td>
+          <td>
+            {{if row.modified()}}
+              <a href="#" class="btn btn-warning" data-bind="click: function(){ updateProxyConnectorRule(row) }">${$.i18n.prop('save')}</a>
+            {{/if}}
+          </td>
+        </tr>
     {{/each}}
     </tbody>
 </script>
       <div class="dotted span8">
         <blockquote>
           ${proxyConnectorRule.pattern()}
+          <br/>
+          ${proxyConnectorRule.proxyConnectorRuleType()}
         </blockquote>
       </div>
     {{else}}
                      data-bind="value:proxyConnectorRule.pattern,css:{'uneditable-input': update},readonly:update"/>
               </div>
             </div>
+            <div class="control-group">
+              <label class="control-label" for="layout">${$.i18n.prop('type')}</label>
+              <div class="controls">
+                <select id="proxy-connector-rule-pattern-type"
+                        data-bind="options: proxyConnectorRulesViewModel.ruleTypes,optionsText: 'label',optionsValue:'type',value: proxyConnectorRule.proxyConnectorRuleType"/>
+              </div>
+            </div>
           </fieldset>
         </form>
       </div>
     {{/if}}
     {{if proxyConnectorRule.modified()}}
       <div class="span3">
-        <a href="#" class="btn btn-warning" data-bind="click: function(){saveRepositoryGroup(repositoryGroup)}">${$.i18n.prop('save')}</a>
+        <a href="#" class="btn btn-warning" data-bind="click: function(){addProxyConnectorRule(proxyConnectorRule)}">${$.i18n.prop('save')}</a>
       </div>
       <br/>
     {{/if}}
index 7d28f9c6372343d79a5809160b3e9c9574eb2cff..c352d298aa89b7eaed357337b0997b0d20394f85 100644 (file)
@@ -26,9 +26,9 @@
     </Console>
   </appenders>
   <loggers>
-    <logger name="org.apache.archiva.indexer.search.NexusRepositorySearch" level="debug"/>
+    <logger name="org.apache.archiva.indexer.search.NexusRepositorySearch" level="info"/>
 
-    <logger name="org.apache.archiva.common.plexusbridge.MavenIndexerUtils" level="debug"/>
+    <logger name="org.apache.archiva.common.plexusbridge.MavenIndexerUtils" level="info"/>
 
     <logger name="JPOX" level="error"/>
 
@@ -36,7 +36,7 @@
     <logger name="org.apache.commons.configuration.DefaultConfigurationBuilder" level="error"/>
 
 
-    <logger name="org.apache.archiva.admin.repository.managed" level="debug"/>
+    <logger name="org.apache.archiva.admin.repository.managed" level="info"/>
 
 
     <!-- apache httpclient debug content transfer-->
@@ -61,7 +61,7 @@
 
     <logger name="org.quartz" level="info"/>
 
-    <logger name="org.apache.archiva.indexer.merger" level="debug"/>
+    <logger name="org.apache.archiva.indexer.merger" level="info"/>
 
     <root level="info">
       <appender-ref ref="console"/>