]> source.dussan.org Git - archiva.git/commitdiff
use images for black/white list
authorOlivier Lamy <olamy@apache.org>
Wed, 3 Oct 2012 06:38:23 +0000 (06:38 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 3 Oct 2012 06:38:23 +0000 (06:38 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1393310 13f79535-47bb-0310-9956-ffa450edef68

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

index ddd4110ce878d6d427adb6d0eb1c7b5c31f4dbc1..3ba35ced99492414c2d9cd2fac25ad95d5618275 100644 (file)
 define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstrap","jquery.ui","knockout"
   ,"knockout.simpleGrid","knockout.sortable","archiva.proxy-connectors"], function() {
 
-
-
   ProxyConnectorRulesViewModel=function(proxyConnectorRules,proxyConnectors){
     var self=this;
-    this.proxyConnectorRules=ko.observableArray(proxyConnectorRules);
+    this.proxyConnectorRules=ko.observableArray(proxyConnectorRules?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.ruleTypes=[new RuleType("BLACK_LIST","Black list","images/red-22-22.png"),new RuleType("WHITE_LIST","White list","images/green-22-22.png")];
+
+    this.findRuleType=function(proxyConnectorRule){
+      var ruleType;
+      $.each(self.ruleTypes, function(index, value) {
+        if(value.type==proxyConnectorRule.proxyConnectorRuleType()){
+          ruleType=value;
+        }
+      });
+      return ruleType;
+    }
 
     this.displayGrid=function(){
       var mainContent = $("#main-content");
 
+      $.each(self.proxyConnectorRules(), function(index, value) {
+        value.ruleType=self.findRuleType(value);
+      });
+
       this.gridViewModel = new ko.simpleGrid.viewModel({
         data: self.proxyConnectorRules,
         pageSize: 5,
@@ -78,6 +90,8 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
             displaySuccessMessage(message);
             proxyConnectorRule.modified(false);
             if(add){
+              // add rule type for image
+              proxyConnectorRule.ruleType=self.findRuleType(proxyConnectorRule);
               self.proxyConnectorRules.push(proxyConnectorRule);
             }
             activateProxyConnectorRulesGridTab();
@@ -108,7 +122,7 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
     }
 
     this.deleteProxyConnectorRule=function(proxyConnectorRule){
-      //$("#proxy-connector-rule-delete-btn" ).button("loading");
+      $("#main-content" ).find("proxy-connectors-rules-view-tabsTable").find(".btn").button("loading");
       $("#user-messages" ).html(mediumSpinnerImg());
       $.ajax("restServices/archivaServices/proxyConnectorRuleService/deleteProxyConnectorRule",
        {
@@ -127,7 +141,7 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
          },
          complete:function(data){
            removeMediumSpinnerImg("#user-messages");
-           //$("#proxy-connector-rule-delete-btn" ).button("reset");
+           $("#main-content" ).find("proxy-connectors-rules-view-tabsTable").find(".btn").button("reset");
          }
        }
       );
@@ -211,6 +225,7 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
       self.modified(true);
     });
 
+    this.ruleType=null;
 
     //private ProxyConnectorRuleType proxyConnectorRuleType;
     this.proxyConnectorRuleType=ko.observable(proxyConnectorRuleType);
@@ -223,6 +238,8 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
     this.proxyConnectors.subscribe(function(newValue){
       self.modified(true);
     });
+
+    this.ruleType=null;
   }
 
   mapProxyConnectorRule=function(data){
@@ -261,9 +278,10 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
     mainContent.find("#proxy-connectors-rules-view-tabs-edit").addClass("active");
   }
 
-  RuleType=function(type,label){
+  RuleType=function(type,label,image){
     this.type=type;
     this.label=label;
+    this.image=image;
   }
 
 });
index 32e7d25700b9d7a7a4bdee4f45cbd3e745c54e11..6278fa5f162774ef69ab4baf778308a3a3f8228b 100644 (file)
     {{each(i, row) itemsOnCurrentPage()}}
         <tr data-bind="css:{ 'modified': row.modified()}">
           <td>${row.pattern()}</td>
-          <td>${row.proxyConnectorRuleType()}</td>
+          <td><img src="${row.ruleType.image}" title="${row.ruleType.label}"></img></td>
           <td>
             <ul>
             {{each(j,proxyConnector) row.proxyConnectors()}}
           </td>
           <td>
               <a href="#" data-bind="click: function(){ editProxyConnectorRule(row) }">
-                <span class="btn btn-primary">
+                <span class="btn btn-primary" data-loading-text="${$.i18n.prop('common.loading')}">
                   <i class="icon-pencil icon-white"/>
                 </span>
               </a>
           </td>
           <td>
               <a data-bind="click: function(){ removeProxyConnectorRule(row) }" data-loading-text="${$.i18n.prop('common.loading')}">
-                <span class="btn btn-danger">
+                <span class="btn btn-danger" data-loading-text="${$.i18n.prop('common.loading')}">
                   <i class="icon-trash icon-white"/>
                 </span>
               </a>