]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1576] rewrite proxies connector page
authorOlivier Lamy <olamy@apache.org>
Thu, 9 Feb 2012 23:07:54 +0000 (23:07 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 9 Feb 2012 23:07:54 +0000 (23:07 +0000)
delete proxyConnector impl.

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

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 b8dc2f91949e9a0e0c922ce698f6d5a5de6ddef1..36e322689250402e49102b5e7d031c06b5161840 100644 (file)
@@ -112,12 +112,14 @@ $(function() {
 
   }
 
-  ManagedRepositoryConnectorView=function(source,targetRepos){
+  ManagedRepositoryConnectorView=function(source,sourceName,targetRepos){
     var self=this;
     this.modified=ko.observable(false);
-
-
+    //this.proxyConnector=ko.observable(proxyConnector);
+    //$.log("new ManagedRepositoryConnectorView:"+proxyConnector.id);
     this.source=ko.observable(source);
+    this.sourceName=ko.observable(sourceName);
+    //$.log("new ManagedRepositoryConnectorView source id:"+this.source.id);
     this.targetRepos=ko.observableArray(targetRepos);
   }
 
@@ -235,20 +237,44 @@ $(function() {
     this.remoteRepositories=ko.observableArray([]);
     this.networkProxies=ko.observableArray([]);
 
-    editProxyConnector=function(proxyConnector){
+    editProxyConnector=function(managedRepositoryConnectorView){
+      $.log("editProxyConnector");
+    }
 
+    removeProxyConnector=function(managedRepositoryConnectorView,targetRepoId){
+      $.log("removeProxyConnector:"+managedRepositoryConnectorView.source()+","+targetRepoId);
+      var url="restServices/archivaServices/proxyConnectorService/removeProxyConnector?";
+      url += "sourceRepoId="+encodeURIComponent(managedRepositoryConnectorView.source());
+      url += "&targetRepoId="+encodeURIComponent(targetRepoId);
+      $.ajax(url,
+        {
+          type: "GET",
+          contentType: 'application/json',
+          success: function(data) {
+            clearUserMessages();
+            displaySuccessMessage($.i18n.prop('proxyconnector.removed'));
+            //self.proxyConnectors.remove ProxyConnector=function(sourceRepoId,targetRepoId
+            self.displayGrid();
+          },
+          error: function(data) {
+            var res = $.parseJSON(data.responseText);
+            displayRestError(res);
+          }
+        }
+      );
     }
 
     this.findUniqueManagedRepos=function(){
       var sourcesRepos=[];
       //sourceRepoId
       for(i=0;i<self.proxyConnectors().length;i++){
-        var curSrcRepo=self.proxyConnectors()[i].sourceRepoId();
+        var curSrcRepo=self.proxyConnectors()[i];
+        var curSrcRepoId=curSrcRepo.sourceRepoId();
         var curTarget=self.proxyConnectors()[i];
         var sourceRepo = $.grep(sourcesRepos,
                                 function(srcRepo,idx){
                                   for (j=0;j<sourcesRepos.length;j++){
-                                    if (srcRepo.source()==curSrcRepo){
+                                    if (srcRepo.source()==curSrcRepoId){
                                       return true;
                                     }
                                   }
@@ -258,7 +284,7 @@ $(function() {
         if (sourceRepo.length>0){
           sourceRepo[0].targetRepos.push(curTarget);
         } else {
-          sourcesRepos.push(new ManagedRepositoryConnectorView(curSrcRepo,[curTarget]));
+          sourcesRepos.push(new ManagedRepositoryConnectorView(curSrcRepoId,getManagedRepository(curSrcRepoId).name(),[curTarget]));
         }
       }
       return sourcesRepos;
index 6635d40208d6c119c84c25ade4e386e6ac7cb9f9..667d742ce6f445fcbc8463001f5c67be80100433 100644 (file)
   </thead>
 
   {{each(i, row) itemsOnCurrentPage()}}
+    {{var sourceId = row.source()}}
     <tr data-bind="css:{ 'modified': row.modified()}">
-        {{var val = row.source()}}
       <td>
         <blockquote>
-          <p>${val}</p>
-          <p>${getManagedRepository(val).name()}</p>
+          <p>${row.source()}</p>
+          <p>${row.sourceName()}</p>
         </blockquote>
       <td>
           {{each(j, targetRepo) row.targetRepos()}}
             <p>${getRemoteRepository(targetRepoId).url()}</p>
             <p>
               <a popover-title="${$.i18n.prop('proxy-connectors.grid.remoterepo.settings.popover.title')}"
-                 data-bind="event: { mouseover: function(){ showSettings(val,targetRepoId)},}"
-                 id="proxy-connectors-grid-remoterepo-settings-edit-${val}-${targetRepoId}" href="#">
+                 data-bind="event: { mouseover: function(){ showSettings(sourceId,targetRepoId)},},click: function(){ editProxyConnector(row)}"
+                 id="proxy-connectors-grid-remoterepo-settings-edit-${sourceId}-${targetRepoId}" href="#">
                   ${$.i18n.prop('edit')}
-                 </a>
+              </a>
+                <a href="#" data-bind="click: function(){ removeProxyConnector(row,targetRepoId) }">
+                  <img src="images/edit-cut.png" title="${$.i18n.prop('delete')}"/>
+                </a>
               <div id="proxy-connectors-grid-remoterepo-settings-content-${val}-${targetRepoId}" style="display:none"></div>
             </p>
           </blockquote>