]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1576] rewrite proxies connector page
authorOlivier Lamy <olamy@apache.org>
Fri, 10 Feb 2012 17:23:36 +0000 (17:23 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 10 Feb 2012 17:23:36 +0000 (17:23 +0000)
add edition too.

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

archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
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/templates/proxy-connectors.html

index 3dc72f980a8ca21778f16fed3a9bb79573baf1a7..943441cf7d74e0472bc3d26743274cb0744d99a3 100644 (file)
@@ -138,6 +138,7 @@ proxy-connector.blacklist=Black List
 proxy-connector.whitelist=White List
 proxyconnector.removed=ProxyConnector removed.
 proxyconnector.added=ProxyConnector added.
+proxyconnector.updated=ProxyConnector updated.
 proxy-connectors.grid.remoterepo.settings.popover.title=Proxy Connector Settings
 proxy-connectors.remoterepo.settings.networkproxy=Network Proxy
 
index 6b0f89ffe02eb90503fd07d554418e9b6c35975e..523e9fd969b4ee67103cba5c8e9caee108fb3b77 100644 (file)
@@ -138,6 +138,7 @@ $(function() {
     this.proxyConnectorsViewModel=proxyConnectorsViewModel;
     this.update=update;
     this.modified=ko.observable(false);
+
     getSelectedPolicyOption=function(id){
       $.log("getSelectedPolicyOption:"+id);
 
@@ -145,8 +146,9 @@ $(function() {
       $.log("getSelectedPolicyOption policies.length:"+policiesEntries.length);
       if (policiesEntries!=null){
         for (i=0;i<policiesEntries.length;i++){
-          if (id==policiesEntries[i].key()){
-            return policiesEntries[i].value();
+          var curKey = $.isFunction(policiesEntries[i].key)? policiesEntries[i].key():policiesEntries[i].key;
+          if (id==curKey){
+            return $.isFunction(policiesEntries[i].value)? policiesEntries[i].value():policiesEntries[i].value;
           }
         }
       }
@@ -190,11 +192,26 @@ $(function() {
     save=function(){
       //FIXME data controls !!!
       clearUserMessages();
+      // update is delete then add
       if (this.update){
-
+        $.ajax("restServices/archivaServices/proxyConnectorService/updateProxyConnector",
+          {
+            type: "POST",
+            data: "{\"proxyConnector\": " + ko.toJSON(self.proxyConnector)+"}",
+            contentType: 'application/json',
+            dataType: 'json',
+            success: function(data) {
+              displaySuccessMessage($.i18n.prop('proxyconnector.updated'));
+              activateProxyConnectorsGridTab();
+              self.proxyConnector.modified(false);
+            },
+            error: function(data) {
+              var res = $.parseJSON(data.responseText);
+              displayRestError(res);
+            }
+          }
+        );
       } else {
-        var json = $.toJSON(ko.toJS(self.proxyConnector));
-        $.log("toJSON:"+json);
 
         $.ajax("restServices/archivaServices/proxyConnectorService/addProxyConnector",
           {
@@ -214,7 +231,6 @@ $(function() {
             }
           }
         );
-
       }
     }
 
@@ -231,29 +247,21 @@ $(function() {
     this.remoteRepositories=ko.observableArray([]);
     this.networkProxies=ko.observableArray([]);
 
-    editProxyConnector=function(managedRepositoryConnectorView){
-      $.log("editProxyConnector");
+    editProxyConnector=function(proxyConnector){
+      var proxyConnectorViewModel=new ProxyConnectorViewModel(proxyConnector,true,self);
+      var mainContent = $("#main-content");
+      mainContent.find("#proxy-connectors-edit").html($("#proxy-connector-edit-form-tmpl").tmpl());
+      ko.applyBindings(proxyConnectorViewModel,mainContent.find("#proxy-connectors-edit").get(0));
+      activateProxyConnectorsEditTab();
     }
     deleteProxyConnector=function(proxyConnector){
       clearUserMessages();
-      var url="restServices/archivaServices/proxyConnectorService/removeProxyConnector?";
-      url += "sourceRepoId="+encodeURIComponent(proxyConnector.sourceRepoId());
-      url += "&targetRepoId="+encodeURIComponent(proxyConnector.targetRepoId());
-      $.ajax(url,
-        {
-          type: "GET",
-          contentType: 'application/json',
-          success: function(data) {
-            displaySuccessMessage($.i18n.prop('proxyconnector.removed'));
-            self.proxyConnectors.remove(proxyConnector);
-            self.displayGrid();
-          },
-          error: function(data) {
-            var res = $.parseJSON(data.responseText);
-            displayRestError(res);
-          }
-        }
-      );
+      removeProxyConnector(proxyConnector,function(){
+        displaySuccessMessage($.i18n.prop('proxyconnector.removed'));
+        self.proxyConnectors.remove(proxyConnector);
+        //self.displayGrid();
+      });
+
 
     }
 
@@ -463,4 +471,25 @@ $(function() {
            });
   }
 
+  removeProxyConnector=function(proxyConnector,fnSuccessCallback){
+    clearUserMessages();
+    var url="restServices/archivaServices/proxyConnectorService/removeProxyConnector?";
+    url += "sourceRepoId="+encodeURIComponent(proxyConnector.sourceRepoId());
+    url += "&targetRepoId="+encodeURIComponent(proxyConnector.targetRepoId());
+    $.ajax(url,
+      {
+        type: "GET",
+        contentType: 'application/json',
+        success: function(data) {
+          fnSuccessCallback();
+        },
+        error: function(data) {
+          var res = $.parseJSON(data.responseText);
+          displayRestError(res);
+        }
+      }
+    );
+
+  }
+
 });
index 5412ac869fc9fd781419276ea74cd58aef0b85e1..712816d69972bcbc28ac8e69721b048bb2844c32 100644 (file)
         {{each(i, entry) policiesEntries}}
         <tr>
           <td>${entry.key}</td>
-          {{if $.isFunction( entry.value ) }}
-            <td>function=====${entry.value()}</td>
-          {{else}}
-            <td>${entry.value}</td>
-          {{/if}}
+          <td>${entry.value}</td>
         </tr>
         {{/each}}
       </tbody>