]> source.dussan.org Git - archiva.git/commitdiff
implements bulk save mode for remote repositories management
authorOlivier Lamy <olamy@apache.org>
Mon, 13 Feb 2012 09:47:25 +0000 (09:47 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 13 Feb 2012 09:47:25 +0000 (09:47 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1243456 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/repositories.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html

index 9b3787ee02ccc205bf96d225d0f924f6f6660694..f8946c99b54e818f9025f7cbe166d961d655796d 100644 (file)
@@ -92,6 +92,9 @@ remoteDownloadNetworkProxyId=Proxy for Remote Download Index
 downloadRemoteIndexOnStartup=Download Remote Index on Startup
 remoteDownloadTimeout=Download Remote Timeout
 remoterepository.added=Remote Repository added.
+remoterepositories.bulk.save.confirm=Are you sure to update {0} Remote Repository(ies)
+remoterepositories.bulk.save.confirm.title=Remote Repositories Bulk Save
+remoterepository.updated=Remote Repository {0} updated.
 
 #network proxy
 networkproxy.updated=Network Proxy " {0} " updated.
index 5e3da5fff1d01e940c34ec9fa1eec3dd3cf1939e..d1c2d312ae9fd19e7504d26b244f3643a462da4b 100644 (file)
@@ -310,6 +310,7 @@ $(function() {
       activateProxyConnectorsEditTab();
       mainContent.find("#proxy-connectors-view-tabs-li-edit a").html($.i18n.prop("edit"));
     }
+
     deleteProxyConnector=function(proxyConnector){
 
       openDialogConfirm(
index 4217f9a050b4da86cf51310d7645da5dd392c80c..f7473c8ff1535d90dd8c9517179257500fd974da 100644 (file)
@@ -610,7 +610,7 @@ $(function() {
 
     this.availableLayouts = window.managedRepositoryTypes;
 
-    save=function(){
+    this.save=function(){
       var valid = $("#main-content #remote-repository-edit-form").valid();
       if (valid==false) {
         return;
@@ -624,8 +624,9 @@ $(function() {
             contentType: 'application/json',
             dataType: 'json',
             success: function(data) {
-              displaySuccessMessage($.i18n.prop('remoterepository.updated'));
+              displaySuccessMessage($.i18n.prop('remoterepository.updated',self.remoteRepository.id()));
               activateRemoteRepositoriesGridTab();
+              self.remoteRepository.modified(false);
             },
             error: function(data) {
               var res = $.parseJSON(data.responseText);
@@ -706,6 +707,38 @@ $(function() {
 
     }
 
+    this.bulkSave=function(){
+      return getModifiedRemoteRepositories().length>0;
+    }
+
+    getModifiedRemoteRepositories=function(){
+      var prx = $.grep(self.remoteRepositories(),
+          function (remoteRepository,i) {
+            return remoteRepository.modified();
+          });
+      return prx;
+    }
+
+    updateModifiedRemoteRepositories=function(){
+      var modifiedRemoteRepositories = getModifiedRemoteRepositories();
+
+      openDialogConfirm(function(){
+                          for(i=0;i<modifiedRemoteRepositories.length;i++){
+                            updateRemoteRepository(modifiedRemoteRepositories[i]);
+                          }
+                          closeDialogConfirm();
+                        },
+                        $.i18n.prop('ok'),
+                        $.i18n.prop('cancel'),
+                        $.i18n.prop('remoterepositories.bulk.save.confirm.title'),
+                        $.i18n.prop('remoterepositories.bulk.save.confirm',modifiedRemoteRepositories.length));
+    }
+
+    updateRemoteRepository=function(remoteRepository){
+      var viewModel = new RemoteRepositoryViewModel(remoteRepository,true,self);
+      viewModel.save();
+    }
+
     scheduleDownloadRemoteIndex=function(remoteRepository){
       openDialogConfirm(
         function(){
@@ -863,7 +896,7 @@ $(function() {
         }
       });
       var mainContent = $("#main-content");
-      ko.applyBindings(remoteRepositoriesViewModel,mainContent.find("#remote-repositories-table").get(0));
+      ko.applyBindings(remoteRepositoriesViewModel,mainContent.find("#remote-repositories-view").get(0));
       mainContent.find("#remote-repositories-pills #remote-repositories-view-a").tab('show')
       removeMediumSpinnerImg("#main-content #remote-repositories-content");
     });
index bc982558e3a45c7ba12bb6cd6c8a054dea39ed0a..089897de292b8aa2f75b0b4092aaa498fcb5796a 100644 (file)
@@ -65,6 +65,7 @@
             </ul>
             <div id="remote-repositories-tabs-content" class="pill-content">
               <div id="remote-repositories-view" class="pill-pane active">
+                  <div id="remote-repositories-bulk-save-btn" data-bind='template:{name:"remote-repositories-bulk-save-tmpl"}'></div>
                   <table class="table table-striped table-bordered" id="remote-repositories-table"
                          data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'ko_remote-repositoriesGrid',pageLinksId:'remote-repositoriesPagination',data:'remoteRepositories'">
                   </table>
         {{/each}}
         <th>${$.i18n.prop('edit')}</th>
         <th>${$.i18n.prop('delete')}</th>
+        <th>${$.i18n.prop('modified')}</th>
         <th>${$.i18n.prop('remoterepository.downloadremoteindex')}</th>
       </tr>
   </thead>
                 <img src="images/edit-cut.png" title="${$.i18n.prop('delete')}"/>
               </a>
             </td>
+            {{if row.modified()}}
+              <td>
+                <a href="#" class="btn btn-warning" data-bind="click: function(){ updateRemoteRepository(row) }">${$.i18n.prop('save')}</a>
+              </td>
+            {{else}}
+              <td></td>
+            {{/if}}
             <td>
               <a href="#" data-bind="click: function(){ scheduleDownloadRemoteIndex(row) }">
                 <img src="images/view-refresh.png" title="${$.i18n.prop('remoterepository.downloadremoteindex.now')}"/>
   {{if bulkSave()}}
     <a data-bind="click: updateModifiedManagedRepositories" class="btn btn-danger" href="#">${$.i18n.prop('save.all')}</a>
   {{/if}}
+</script>
+
+<script id="remote-repositories-bulk-save-tmpl" type='text/x-jquery-tmpl'>
+  {{if bulkSave()}}
+    <a data-bind="click: updateModifiedRemoteRepositories" class="btn btn-danger" href="#">${$.i18n.prop('save.all')}</a>
+  {{/if}}
 </script>
\ No newline at end of file