You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/02/06 10:13:21 UTC

svn commit: r1240937 - in /archiva/trunk/archiva-modules/archiva-web: archiva-web-common/src/main/resources/org/apache/archiva/i18n/ archiva-webapp-js/src/main/webapp/js/archiva/ archiva-webapp-js/src/main/webapp/js/archiva/templates/

Author: olamy
Date: Mon Feb  6 09:13:21 2012
New Revision: 1240937

URL: http://svn.apache.org/viewvc?rev=1240937&view=rev
Log:
implements bulk save for managed repositories grid

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/proxy-connectors.html
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties?rev=1240937&r1=1240936&r2=1240937&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties Mon Feb  6 09:13:21 2012
@@ -76,6 +76,7 @@ deleteReleasedSnapshots=Delete Released 
 releases=Releases
 stageRepoNeeded=Staging Repository
 cronExpression.notvalid=Cron Expression not valid
+managedrepository.updated=Managed Repository {0} updated.
 
 
 # remote repositories screen

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js?rev=1240937&r1=1240936&r2=1240937&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js Mon Feb  6 09:13:21 2012
@@ -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();

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js?rev=1240937&r1=1240936&r2=1240937&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js Mon Feb  6 09:13:21 2012
@@ -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();

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/proxy-connectors.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/proxy-connectors.html?rev=1240937&r1=1240936&r2=1240937&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/proxy-connectors.html (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/proxy-connectors.html Mon Feb  6 09:13:21 2012
@@ -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>

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html?rev=1240937&r1=1240936&r2=1240937&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html Mon Feb  6 09:13:21 2012
@@ -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'">
@@ -87,13 +88,14 @@
         <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}}
@@ -123,6 +125,13 @@
                 <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')}"
@@ -444,4 +453,10 @@
     <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