Author: olamy
Date: Fri Oct 26 12:58:50 2012
New Revision: 1402495

URL: http://svn.apache.org/viewvc?rev=1402495&view=rev
Log:
[MRM-1705] Feature to add custom parameters and/or headers when requesting an 
external repositories.
implements ui for extra headers.

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/repositories.js
    
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/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=1402495&r1=1402494&r2=1402495&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
 Fri Oct 26 12:58:50 2012
@@ -37,6 +37,9 @@ url=Url
 directory=Directory
 save.all=Save all
 common.loading=Loading...
+key=Key
+value=Value
+key.empty.error.message=Key cannot be empty
 
 authz.karma.needed=You need to be authenticated for this action or have more 
privileges.
 error.500=An error has happened you must contact the administrator to check 
the logs.
@@ -160,6 +163,8 @@ remoterepository.download.remote.full=Fu
 remoterepository.download.remote.scheduled=Download Remote Index of repository 
{0} scheduled.
 remoterepository.delete.confirm=Are you sure to delete Remote Repository {0} ?
 remoterepository.deleted=Remote repository {0} deleted.
+remoteRepository.extraParametersEntries=Additionnal url parameters
+remoteRepository.extraHeadersEntries=Additionnal Http Headers
 
 
 #network proxy

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=1402495&r1=1402494&r2=1402495&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
 Fri Oct 26 12:58:50 2012
@@ -877,7 +877,12 @@ function(jquery,i18n,jqueryTmpl,bootstra
     addExtraParameter=function(){
 
       var mainContent=$("#main-content");
+      mainContent.find("#extra-parameters-error" ).html("");
       var key=mainContent.find("#extraParameter-key").val();
+      if($.trim(key).length<1){
+        displayErrorMessage( 
$.i18n.prop("key.empty.error.message"),"extra-parameters-error");
+        return;
+      }
       var value=mainContent.find("#extraParameter-value").val();
       $.log("addExtraParameter="+key+":"+value);
       var oldTab = self.remoteRepository.extraParametersEntries();
@@ -898,6 +903,37 @@ function(jquery,i18n,jqueryTmpl,bootstra
       }
     }
 
+    addExtraHeader=function(){
+
+      var mainContent=$("#main-content");
+      mainContent.find("#extra-headers-error" ).html("");
+      var key=mainContent.find("#extraHeader-key").val();
+      if( $.trim(key).length<1){
+        if($.trim(key).length<1){
+          displayErrorMessage( 
$.i18n.prop("key.empty.error.message"),"extra-headers-error");
+          return;
+        }
+      }
+      var value=mainContent.find("#extraHeader-value").val();
+      $.log("addExtraParameter="+key+":"+value);
+      var oldTab = self.remoteRepository.extraHeadersEntries();
+      oldTab.push(new Entry(key,value));
+      self.remoteRepository.extraHeadersEntries(oldTab);
+      mainContent.find("#extraHeader-key").val("");
+      mainContent.find("#extraHeader-value").val("");
+      self.remoteRepository.modified(true);
+    }
+
+    deleteExtraHeader=function(key){
+      for(var i=0;i<self.remoteRepository.extraHeadersEntries().length;i++){
+        var entry=self.remoteRepository.extraHeadersEntries()[i];
+        if (entry.key==key){
+          self.remoteRepository.extraHeadersEntries.remove(entry);
+          self.remoteRepository.modified(true);
+        }
+      }
+    }
+
   }
 
   RemoteRepositoriesViewModel=function(){

Modified: 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html
URL: 
http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html?rev=1402495&r1=1402494&r2=1402495&view=diff
==============================================================================
--- 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html
 (original)
+++ 
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html
 Fri Oct 26 12:58:50 2012
@@ -629,10 +629,11 @@
         <div class="row-fluid">
           <div class="control-group span6">
             <h4>${$.i18n.prop('remoteRepository.extraParametersEntries')}</h4>
+            <div id="extra-parameters-error"></div>
             <table class="table">
               <thead>
-                <th><input type="text" id="extraParameter-key"/></th>
-                <th><input type="text" id="extraParameter-value"/></th>
+                <th>${$.i18n.prop('key')}:<input type="text" 
id="extraParameter-key"/></th>
+                <th>${$.i18n.prop('value')}:<input type="text" 
id="extraParameter-value"/></th>
                 <th><a href="#" data-bind="click: function(){ 
addExtraParameter() }">${$.i18n.prop('add')}</a></th>
               </thead>
               <tbody>
@@ -648,6 +649,29 @@
           </div>
         </div>
 
+        <div class="row-fluid">
+          <div class="control-group span6">
+            <h4>${$.i18n.prop('remoteRepository.extraHeadersEntries')}</h4>
+            <div id="extra-headers-error"></div>
+            <table class="table">
+              <thead>
+                <th>${$.i18n.prop('key')}:<input type="text" 
id="extraHeader-key"/></th>
+                <th>${$.i18n.prop('value')}:<input type="text" 
id="extraHeader-value"/></th>
+                <th><a href="#" data-bind="click: function(){ addExtraHeader() 
}">${$.i18n.prop('add')}</a></th>
+              </thead>
+              <tbody>
+                {{each(i, extraHeaderEntry) 
remoteRepository.extraHeadersEntries}}
+                <tr>
+                  <td>${extraHeaderEntry.key}</td>
+                  <td>${extraHeaderEntry.value}</td>
+                  <td><a href="#" data-bind="click: function(){ 
deleteExtraHeader(extraHeaderEntry.key)}">${$.i18n.prop('delete')}</a></td>
+                </tr>
+                {{/each}}
+              </tbody>
+            </table>
+          </div>
+        </div>
+
       </fieldset>
       <button data-bind="click: save" 
data-loading-text="${$.i18n.prop('common.loading')}" 
id="remote-repository-save-button" class="btn">${$.i18n.prop('save')}</button>
       <button data-bind="click: displayGrid" 
class="btn">${$.i18n.prop('cancel')}</button>


Reply via email to