]> source.dussan.org Git - archiva.git/commitdiff
implements bulk save for managed repositories grid
authorOlivier Lamy <olamy@apache.org>
Mon, 6 Feb 2012 09:13:21 +0000 (09:13 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 6 Feb 2012 09:13:21 +0000 (09:13 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1240937 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/network-proxies.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/proxy-connectors.html
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html

index 34f83db200746990cf3525d43c82324dc92f8913..99a798a7d3a825924930304e74c5e26d814a52b0 100644 (file)
@@ -76,6 +76,7 @@ deleteReleasedSnapshots=Delete Released Snapshots
 releases=Releases
 stageRepoNeeded=Staging Repository
 cronExpression.notvalid=Cron Expression not valid
+managedrepository.updated=Managed Repository {0} updated.
 
 
 # remote repositories screen
index 06a6395c426f5f041b2ba0cb6d09e9e28f165a9f..6fa855cd8751a892d71301e1d4b9df3099f3689e 100644 (file)
@@ -141,11 +141,13 @@ $(function() {
     getModifiedNetworkProxies=function(){
       var prx = $.grep(self.networkProxies(),
           function (networkProxy,i) {
-            $.log("networkProxy.modified():"+networkProxy.modified())
             return networkProxy.modified();
           });
       return prx;
     }
+    updateModifiedManagedRepositories=function(){
+
+    }
 
     updateModifiedNetworkProxy=function(){
       var modifiedNetworkProxies = getModifiedNetworkProxies();
index 098e863cba8b9846be8df099a243050960b96f1f..de0467f2f5a38feaa44dc458035eae47018eeb70 100644 (file)
@@ -34,52 +34,67 @@ $(function() {
   ManagedRepository=function(id,name,layout,indexDirectory,location,snapshots,releases,blockRedeployments,cronExpression,
                              scanned,daysOlder,retentionCount,deleteReleasedSnapshots,stageRepoNeeded){
 
+    var self=this;
 
     //private String id;
     this.id=ko.observable(id);
+    this.id.subscribe(function(newValue){self.modified(true)});
 
     //private String name;
     this.name=ko.observable(name);
+    this.name.subscribe(function(newValue){self.modified(true)});
 
     //private String layout = "default";
     this.layout=ko.observable(layout);
+    this.layout.subscribe(function(newValue){self.modified(true)});
 
     //private String indexDirectory;
     this.indexDirectory=ko.observable(indexDirectory);
+    this.indexDirectory.subscribe(function(newValue){self.modified(true)});
 
     //private String location;
     this.location=ko.observable(location);
+    this.location.subscribe(function(newValue){self.modified(true)});
 
     //private String cronExpression = "0 0 * * * ?";
     this.cronExpression=ko.observable(cronExpression);
+    this.cronExpression.subscribe(function(newValue){self.modified(true)});
 
     //private ManagedRepository stagingRepository;
 
     //private int daysOlder = 100;
     this.daysOlder=ko.observable(daysOlder);
+    this.daysOlder.subscribe(function(newValue){self.modified(true)});
 
     //private int retentionCount = 2;
     this.retentionCount=ko.observable(retentionCount);
+    this.retentionCount.subscribe(function(newValue){self.modified(true)});
 
     //private boolean scanned = false;
     this.scanned=ko.observable(scanned);
+    this.scanned.subscribe(function(newValue){self.modified(true)});
 
     //private boolean deleteReleasedSnapshots;
     this.deleteReleasedSnapshots=ko.observable(deleteReleasedSnapshots);
+    this.deleteReleasedSnapshots.subscribe(function(newValue){self.modified(true)});
 
     //private boolean stageRepoNeeded;
     this.stageRepoNeeded=ko.observable(stageRepoNeeded);
+    this.stageRepoNeeded.subscribe(function(newValue){self.modified(true)});
 
     //private boolean snapshots = false;
     this.snapshots=ko.observable(snapshots);
+    this.snapshots.subscribe(function(newValue){self.modified(true)});
 
     //private boolean releases = true;
     this.releases=ko.observable(releases);
+    this.releases.subscribe(function(newValue){self.modified(true)});
 
     //private boolean blockRedeployments = false;
     this.blockRedeployments=ko.observable(blockRedeployments);
+    this.blockRedeployments.subscribe(function(newValue){self.modified(true)});
+
 
-    var self=this;
 
     this.getTypeLabel=function(){
       for(i=0;i<window.managedRepositoryTypes.length;i++){
@@ -90,6 +105,7 @@ $(function() {
       return "no label";
     }
 
+    this.modified=ko.observable(false);
   }
 
   ArchivaRepositoryStatistics=function(scanEndTime,scanStartTime,totalArtifactCount,totalArtifactFileSize,totalFileCount,
@@ -156,7 +172,7 @@ $(function() {
 
     this.availableLayouts = window.managedRepositoryTypes;
 
-    save=function(){
+    this.save=function(){
       $.log("repositories.js#save");
       var valid = $("#main-content #managed-repository-edit-form").valid();
       if (valid==false) {
@@ -172,8 +188,9 @@ $(function() {
             contentType: 'application/json',
             dataType: 'json',
             success: function(data) {
-              displaySuccessMessage($.i18n.prop('managedrepository.updated'));
+              displaySuccessMessage($.i18n.prop('managedrepository.updated',self.managedRepository.id()));
               activateManagedRepositoriesGridTab();
+              self.managedRepository.modified(false);
             },
             error: function(data) {
               var res = $.parseJSON(data.responseText);
@@ -360,6 +377,30 @@ $(function() {
           $("#managed-repository-delete-warning-tmpl").tmpl(managedRepository));
     }
 
+    updateManagedRepository=function(managedRepository){
+      var managedRepositoryViewModel = new ManagedRepositoryViewModel(managedRepository,true,this);
+      managedRepositoryViewModel.save();
+    }
+
+    this.bulkSave=function(){
+      $.log("bulkSave");
+      return getModifiedManagedRepositories().length>0;
+    }
+
+    getModifiedManagedRepositories=function(){
+      var prx = $.grep(self.managedRepositories(),
+          function (managedRepository,i) {
+            return managedRepository.modified();
+          });
+      return prx;
+    }
+    updateModifiedManagedRepositories=function(){
+      var repos = getModifiedManagedRepositories();
+      for (i=0;i<repos.length;i++){
+        updateManagedRepository(repos[i]);
+      }
+    }
+
     showStats=function(managedRepository){
       if ($(calculatePopoverId(managedRepository)).html()){
         // we ask stats all the time ? if no uncomment return
@@ -464,50 +505,63 @@ $(function() {
   RemoteRepository=function(id,name,layout,indexDirectory,url,userName,password,timeout,downloadRemoteIndex,remoteIndexUrl,
                             remoteDownloadNetworkProxyId,cronExpression,remoteDownloadTimeout,downloadRemoteIndexOnStartup){
 
+    var self=this;
 
     //private String id;
     this.id=ko.observable(id);
+    this.id.subscribe(function(newValue){self.modified(true)});
 
     //private String name;
     this.name=ko.observable(name);
+    this.name.subscribe(function(newValue){self.modified(true)});
 
     //private String layout = "default";
     this.layout=ko.observable(layout);
+    this.layout.subscribe(function(newValue){self.modified(true)});
 
     //private String indexDirectory;
     this.indexDirectory=ko.observable(indexDirectory);
+    this.indexDirectory.subscribe(function(newValue){self.modified(true)});
 
     //private String url;
     this.url=ko.observable(url);
+    this.url.subscribe(function(newValue){self.modified(true)});
 
     //private String userName;
     this.userName=ko.observable(userName);
+    this.userName.subscribe(function(newValue){self.modified(true)});
 
     //private String password;
     this.password=ko.observable(password);
+    this.password.subscribe(function(newValue){self.modified(true)});
 
     //private int timeout = 60;
     this.timeout=ko.observable(timeout);
+    this.timeout.subscribe(function(newValue){self.modified(true)});
 
     //private boolean downloadRemoteIndex = false;
     this.downloadRemoteIndex=ko.observable(downloadRemoteIndex);
+    this.downloadRemoteIndex.subscribe(function(newValue){self.modified(true)});
 
     //private String remoteIndexUrl = ".index";
     this.remoteIndexUrl=ko.observable(remoteIndexUrl);
+    this.remoteIndexUrl.subscribe(function(newValue){self.modified(true)});
 
     //private String remoteDownloadNetworkProxyId;
     this.remoteDownloadNetworkProxyId=ko.observable(remoteDownloadNetworkProxyId);
+    this.remoteDownloadNetworkProxyId.subscribe(function(newValue){self.modified(true)});
 
     //private String cronExpression = "0 0 08 ? * SUN";
     this.cronExpression=ko.observable(cronExpression);
+    this.cronExpression.subscribe(function(newValue){self.modified(true)});
 
     //private int remoteDownloadTimeout = 300;
     this.remoteDownloadTimeout=ko.observable(remoteDownloadTimeout);
+    this.remoteDownloadTimeout.subscribe(function(newValue){self.modified(true)});
 
     //private boolean downloadRemoteIndexOnStartup = false;
     this.downloadRemoteIndexOnStartup=ko.observable(downloadRemoteIndexOnStartup);
-
-    var self=this;
+    this.downloadRemoteIndexOnStartup.subscribe(function(newValue){self.modified(true)});
 
     this.getTypeLabel=function(){
       for(i=0;i<window.managedRepositoryTypes.length;i++){
@@ -517,6 +571,8 @@ $(function() {
       }
       return "no label";
     }
+
+    this.modified=ko.observable(false);
   }
 
   mapRemoteRepository=function(data){
@@ -760,6 +816,7 @@ $(function() {
             }
           });
           ko.applyBindings(managedRepositoriesViewModel,$("#main-content #managed-repositories-table").get(0));
+          ko.applyBindings(managedRepositoriesViewModel,$("#main-content #managed-repositories-bulk-save-btn").get(0));
           $("#main-content #managed-repositories-pills a:first").tab('show');
           removeMediumSpinnerImg("#main-content #managed-repositories-content");
           activateManagedRepositoriesGridTab();
index 3df9759ef41794895685ed601c64f26490afc40f..d5c764c26157f2152e53457a0168683a2444cb66 100644 (file)
@@ -90,7 +90,7 @@
     {{else}}
       ${$.i18n.prop('proxy-connectors.remoterepo.settings.networkproxy')}: ${$.i18n.prop('none')}
     {{/if}}
-    <table>
+    <table class="table">
       <thead>
         <th colspan="2">Policies</th>
       </thead>
index c7f5b3fe02f4877c5e2cb4bae8c62f3507b5b8ac..38a2fce9b2ffb92b84ef9f36c4040f67bcc8e751 100644 (file)
@@ -40,6 +40,7 @@
               </li>
             </ul>
             <div id="managed-repositories-tabs-content" class="pill-content">
+              <div id="managed-repositories-bulk-save-btn" data-bind='template:{name:"managed-repositories-bulk-save-tmpl"}'></div>
               <div id="managed-repositories-view" class="pill-pane active">
                   <table class="table table-striped table-bordered" id="managed-repositories-table"
                          data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'ko_managed-repositoriesGrid',pageLinksId:'managed-repositoriesPagination',data:'managedRepositories'">
         <th>Scan</th>
         <th>${$.i18n.prop('edit')}</th>
         <th>${$.i18n.prop('delete')}</th>
+        <th>${$.i18n.prop('modified')}</th>
         <th>${$.i18n.prop('managedrepository.pomsnippet')}</th>
         <th title="${$.i18n.prop('managedrepository.stats')}">Stats</th>
       </tr>
   </thead>
   <tbody>
       {{each(i, row) itemsOnCurrentPage()}}
-          <tr>
+          <tr data-bind="css:{ 'modified': row.modified()}">
             {{each(j, columnDefinition) columns}}
               <td>${ typeof columnDefinition.rowText == 'function' ? columnDefinition.rowText(row) : row[columnDefinition.rowText] }</td>
             {{/each}}
                 <img src="images/edit-cut.png" title="${$.i18n.prop('delete')}"/>
               </a>
             </td>
+            {{if row.modified()}}
+              <td>
+                <a href="#" data-bind="click: function(){ updateManagedRepository(row) }">${$.i18n.prop('save')}</a>
+              </td>
+            {{else}}
+              <td></td>
+            {{/if}}
             <td><a href="#" data-bind="click: function(){ showPomSnippet(row) }">${$.i18n.prop('managedrepository.pomsnippet')}</a></td>
             <td id="managedrepository-stats-${row.id()}">
               <img src="images/utilities-system-monitor.png" popover-title="${$.i18n.prop('managedrepository.stats')}"
     <div>
       ${$.i18n.prop('remoterepository.scan.full')}: <input type="checkbox" id="remoterepository-scan-full">
     </div>
+</script>
+
+<script id="managed-repositories-bulk-save-tmpl" type='text/x-jquery-tmpl'>
+  {{if bulkSave()}}
+    <button data-bind="click: updateModifiedManagedRepositories" class="btn">${$.i18n.prop('save.all')}</button>
+  {{/if}}
 </script>
\ No newline at end of file