[MRM-1705] Feature to add custom parameters and/or headers when requesting an external repositories.

implements ui for extra headers.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1402495 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-10-26 12:58:50 +00:00
parent 24164038d9
commit 30ffd9ee14
3 changed files with 67 additions and 2 deletions

View File

@ -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=Full download ?
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

View File

@ -877,7 +877,12 @@ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
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,bootstrap,jqueryValidate,ko) {
}
}
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(){

View File

@ -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>