RemoteRepository=function(id,name,layout,indexDirectory,url,userName,password,timeout,downloadRemoteIndex,remoteIndexUrl,
remoteDownloadNetworkProxyId,cronExpression,remoteDownloadTimeout,downloadRemoteIndexOnStartup,
- description){
+ description,extraParametersEntries,extraHeadersEntries){
var self=this;
return "no label";
}
+ this.extraParametersEntries=ko.observableArray(extraParametersEntries==null?new Array():extraParametersEntries);
+ this.extraParametersEntries.subscribe(function(newValue){
+ self.modified(true);
+ });
+
+ this.extraHeadersEntries=ko.observableArray(extraHeadersEntries==null?new Array():extraHeadersEntries);
+ this.extraHeadersEntries.subscribe(function(newValue){
+ self.modified(true);
+ });
+
this.modified=ko.observable(false);
}
if (data==null){
return null;
}
+
+ var extraParametersEntries = data.extraParametersEntries == null ? []: $.each(data.extraParametersEntries,function(item){
+ return new Entry(item.key, item.value);
+ });
+ if (!$.isArray(extraParametersEntries)){
+ extraParametersEntries=[];
+ }
+
+ var extraHeadersEntries = data.extraHeadersEntries == null ? []: $.each(data.extraHeadersEntries,function(item){
+ return new Entry(item.key, item.value);
+ });
+ if (!$.isArray(extraHeadersEntries)){
+ extraHeadersEntries=[];
+ }
+
return new RemoteRepository(data.id,data.name,data.layout,data.indexDirectory,data.url,data.userName,data.password,
data.timeout,data.downloadRemoteIndex,data.remoteIndexUrl,data.remoteDownloadNetworkProxyId,
- data.cronExpression,data.remoteDownloadTimeout,data.downloadRemoteIndexOnStartup,data.description);
+ data.cronExpression,data.remoteDownloadTimeout,data.downloadRemoteIndexOnStartup,data.description,
+ extraParametersEntries,extraHeadersEntries);
}
mapRemoteRepositories=function(data){
displayGrid=function(){
activateRemoteRepositoriesGridTab();
}
+
+ addExtraParameter=function(){
+
+ var mainContent=$("#main-content");
+ var key=mainContent.find("#extraParameter-key").val();
+ var value=mainContent.find("#extraParameter-value").val();
+ $.log("addExtraParameter="+key+":"+value);
+ var oldTab = self.remoteRepository.extraParametersEntries();
+ oldTab.push(new Entry(key,value));
+ self.remoteRepository.extraParametersEntries(oldTab);
+ mainContent.find("#extraParameter-key").val("");
+ mainContent.find("#extraParameter-value").val("");
+ self.remoteRepository.modified(true);
+ }
+
}
RemoteRepositoriesViewModel=function(){
var viewModel = new RemoteRepositoryViewModel(remoteRepository,true,self);
viewModel.networkProxies(mapNetworkProxies(data));
var mainContent = $("#main-content");
+
ko.applyBindings(viewModel,mainContent.find("#remote-repository-edit").get(0));
activateRemoteRepositoryEditTab();
mainContent.find("#remote-repository-edit-li a").html($.i18n.prop('edit'));
- activateRemoteRepositoryFormValidation();
+ activateRemoteRepositoryFormValidation(false);
activatePopoverDoc();
}
})
}
}
- activateRemoteRepositoryFormValidation=function(){
+ /**
+ *
+ * @param validateId to validate if id already exists: not needed for update !
+ */
+ activateRemoteRepositoryFormValidation=function(validateId){
// FIXME find a way to activate cronExpression validation only if downloadRemote is activated !
- var validator = $("#main-content" ).find("#remote-repository-edit-form").validate({
- rules: {
- id: {
- required: true,
- remote: {
- url: "restServices/archivaUiServices/dataValidatorService/remoteRepositoryIdNotExists",
- type: "get"
+ var validator = null;
+ if (validateId){
+ validator = $("#main-content" ).find("#remote-repository-edit-form").validate({
+ rules: {
+ id: {
+ required: true,
+ remote: {
+ url: "restServices/archivaUiServices/dataValidatorService/remoteRepositoryIdNotExists",
+ type: "get"
+ }
}
+ },
+ showErrors: function(validator, errorMap, errorList) {
+ customShowError("#main-content #remote-repository-edit-form",validator,errorMap,errorMap);
}
- },
- showErrors: function(validator, errorMap, errorList) {
- customShowError("#main-content #remote-repository-edit-form",validator,errorMap,errorMap);
- }
- });
+ });
+ } else {
+ validator = $("#main-content" ).find("#remote-repository-edit-form").validate({
+ rules: {
+ id: {
+ required: true
+ }
+ },
+ showErrors: function(validator, errorMap, errorList) {
+ customShowError("#main-content #remote-repository-edit-form",validator,errorMap,errorMap);
+ }
+ });
+ }
validator.settings.messages["cronExpression"]=$.i18n.prop("cronExpression.notvalid");
validator.settings.messages["id"]=$.i18n.prop("id.required.or.alreadyexists");
}
remoteRepo.cronExpression("0 0 08 ? * SUN");
var viewModel = new RemoteRepositoryViewModel(remoteRepo,false,remoteRepositoriesViewModel);
viewModel.networkProxies(mapNetworkProxies(data));
- ko.applyBindings(viewModel,$("#main-content" ).find("#remote-repository-edit").get(0));
- activateRemoteRepositoryFormValidation();
+ ko.applyBindings(viewModel,mainContent.find("#remote-repository-edit").get(0));
+ activateRemoteRepositoryFormValidation(true);
activatePopoverDoc();
}
})
</table>
<div id="remote-repositoriesPagination"></div>
</div>
- <div id="remote-repository-edit" class="pill-pane" data-bind='template: {name:"remote-repository-edit-tmpl"}'>
+ <div id="remote-repository-edit" class="pill-pane">
+
+
+ <form id="remote-repository-edit-form" class="well form-horizontal">
+ <fieldset id="remote-repository-edit-fieldset">
+ <div class="control-group">
+ <label class="control-label" for="id">${$.i18n.prop('id')}</label>
+ <div class="controls">
+ {{if update}}
+ <span class="uneditable-input">${$data.remoteRepository.id}</span>
+ {{else}}
+ <input type="text" class="input-xlarge required" id="id" name="id" size="50"
+ data-bind="value: remoteRepository.id,css:{'uneditable-input': update},readonly:update"/>
+ {{/if}}
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="name">${$.i18n.prop('name')}</label>
+ <div class="controls">
+ <input type="text" class="input-xlarge required" id="name" name="name" size="50"
+ data-bind="value: remoteRepository.name"/>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="url">${$.i18n.prop('url')}</label>
+ <div class="controls">
+ <input type="text" class="input-xxlarge required" id="url" name="location" size="50" data-bind="value: remoteRepository.url"/>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="userName">${$.i18n.prop('username')}</label>
+ <div class="controls">
+ <input type="text" class="input-xlarge" id="userName" name="userName" size="50" data-bind="value: remoteRepository.userName"/>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="password">${$.i18n.prop('password')}</label>
+ <div class="controls">
+ <input type="password" class="input-xlarge" id="password" name="password" size="50" data-bind="value: remoteRepository.password"/>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="timeout">${$.i18n.prop('timeout')}</label>
+ <div class="controls">
+ <input type="text" id="timeout" class="digits" name="daysOlder" size="5" data-bind="value: remoteRepository.timeout"/>
+ </div>
+ </div>
+
+ <div class="control-group">
+ <label class="control-label" for="layout">${$.i18n.prop('type')}</label>
+ <div class="controls">
+ <select id="layout" data-bind="options: availableLayouts,optionsText: 'label',optionsValue:'type',value: remoteRepository.layout"/>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="downloadRemoteIndex">${$.i18n.prop('downloadRemoteIndex')}</label>
+ <div class="controls">
+ <input type="checkbox" id="downloadRemoteIndex" name="downloadRemoteIndex" size="5" data-bind="checked: remoteRepository.downloadRemoteIndex"/>
+ </div>
+ </div>
+
+ <div class="control-group">
+ <label class="control-label" for="remoteIndexUrl">${$.i18n.prop('remoteIndexUrl')}</label>
+ <div class="controls">
+ <input type="text" class="input-xxlarge" id="remoteIndexUrl" name="remoteIndexUrl" size="5" data-bind="value: remoteRepository.remoteIndexUrl"/>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="cronExpression">${$.i18n.prop('cronExpression')}</label>
+ <div class="controls">
+ <input type="text" id="cronExpression" name="cronExpression" size="40" data-bind="value: remoteRepository.cronExpression"/>
+ <a class="btn btn-warning btn-mini popover-doc" id="cronExpression-info-button"
+ data-original-title="${$.i18n.prop('cronExpression.help.title')}"
+ data-content="${$.i18n.prop('cronExpression.help.content')}">
+ <i class="icon-question-sign icon-white"></i>
+ </a>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="indexDirectory">${$.i18n.prop('index.directory')}</label>
+ <div class="controls">
+ <input type="text" class="input-xlarge" id="indexDirectory" name="indexDirectory" size="50" data-bind="value: remoteRepository.indexDirectory"/>
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="remoteDownloadTimeout">${$.i18n.prop('remoteDownloadTimeout')}</label>
+ <div class="controls">
+ <input type="text" id="remoteDownloadTimeout" class="digits" name="remoteDownloadTimeout" size="5"
+ data-bind="value: remoteRepository.remoteDownloadTimeout"/>
+ </div>
+ </div>
+
+ <div class="control-group">
+ <label class="control-label" for="remoteDownloadNetworkProxyId">${$.i18n.prop('remoteDownloadNetworkProxyId')}</label>
+ <div class="controls">
+ <select id="remoteDownloadNetworkProxyId" data-bind="options: networkProxies, optionsText: 'id',optionsValue:'id', value: remoteRepository.remoteDownloadNetworkProxyId, optionsCaption: 'Choose...'"></select>
+ </div>
+ </div>
+
+ <div class="control-group">
+ <label class="control-label" for="downloadRemoteIndexOnStartup">${$.i18n.prop('downloadRemoteIndexOnStartup')}</label>
+ <div class="controls">
+ <input type="checkbox" id="downloadRemoteIndexOnStartup" name="downloadRemoteIndexOnStartup"
+ data-bind="checked: remoteRepository.downloadRemoteIndexOnStartup"/>
+ </div>
+ </div>
+
+ <div class="control-group">
+ <label class="control-label" for="daysOlder">${$.i18n.prop('description')}</label>
+ <div class="controls">
+ <textarea rows="3" id="description" name="description" data-bind="value: remoteRepository.description"></textarea>
+ </div>
+ </div>
+
+ <div class="row-fluid">
+ <div class="control-group span6">
+ <h4>${$.i18n.prop('remoteRepository.extraParametersEntries')}</h4>
+ <table class="table">
+ <thead>
+ <th><input type="text" id="extraParameter-key"/></th>
+ <th><input type="text" id="extraParameter-value"/></th>
+ <th><a href="#" data-bind="click: function(){ addExtraParameter() }">${$.i18n.prop('add')}</a></th>
+ </thead>
+ <tbody data-bind="foreach: remoteRepository.extraParametersEntries">
+ <tr>
+ <td data-bind="text: key"></td>
+ <td data-bind="text: value"></td>
+ <td><a href="#" data-bind="click: function(){ $parent.deleteExtraParameter(key)}">${$.i18n.prop('delete')}</a></td>
+ </tr>
+ </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>
+ </form>
+
+
</div>
</div>
</div>
<script id="remote-repository-edit-tmpl" type='text/html'>
- <form id="remote-repository-edit-form" class="well form-horizontal">
- <fieldset id="remote-repository-edit-fieldset">
- <div class="control-group">
- <label class="control-label" for="id">${$.i18n.prop('id')}</label>
- <div class="controls">
- {{if update}}
- <span class="uneditable-input">${$data.remoteRepository.id}</span>
- {{else}}
- <input type="text" class="input-xlarge required" id="id" name="id" size="50"
- data-bind="value: remoteRepository.id,css:{'uneditable-input': update},readonly:update"/>
- {{/if}}
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="name">${$.i18n.prop('name')}</label>
- <div class="controls">
- <input type="text" class="input-xlarge required" id="name" name="name" size="50"
- data-bind="value: remoteRepository.name"/>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="url">${$.i18n.prop('url')}</label>
- <div class="controls">
- <input type="text" class="input-xxlarge required" id="url" name="location" size="50" data-bind="value: remoteRepository.url"/>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="userName">${$.i18n.prop('username')}</label>
- <div class="controls">
- <input type="text" class="input-xlarge" id="userName" name="userName" size="50" data-bind="value: remoteRepository.userName"/>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="password">${$.i18n.prop('password')}</label>
- <div class="controls">
- <input type="password" class="input-xlarge" id="password" name="password" size="50" data-bind="value: remoteRepository.password"/>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="timeout">${$.i18n.prop('timeout')}</label>
- <div class="controls">
- <input type="text" id="timeout" class="digits" name="daysOlder" size="5" data-bind="value: remoteRepository.timeout"/>
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for="layout">${$.i18n.prop('type')}</label>
- <div class="controls">
- <select id="layout" data-bind="options: availableLayouts,optionsText: 'label',optionsValue:'type',value: remoteRepository.layout"/>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="downloadRemoteIndex">${$.i18n.prop('downloadRemoteIndex')}</label>
- <div class="controls">
- <input type="checkbox" id="downloadRemoteIndex" name="downloadRemoteIndex" size="5" data-bind="checked: remoteRepository.downloadRemoteIndex"/>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="remoteIndexUrl">${$.i18n.prop('remoteIndexUrl')}</label>
- <div class="controls">
- <input type="text" class="input-xxlarge" id="remoteIndexUrl" name="remoteIndexUrl" size="5" data-bind="value: remoteRepository.remoteIndexUrl"/>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="cronExpression">${$.i18n.prop('cronExpression')}</label>
- <div class="controls">
- <input type="text" id="cronExpression" name="cronExpression" size="40" data-bind="value: remoteRepository.cronExpression"/>
- <a class="btn btn-warning btn-mini popover-doc" id="cronExpression-info-button"
- data-original-title="${$.i18n.prop('cronExpression.help.title')}"
- data-content="${$.i18n.prop('cronExpression.help.content')}">
- <i class="icon-question-sign icon-white"></i>
- </a>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="indexDirectory">${$.i18n.prop('index.directory')}</label>
- <div class="controls">
- <input type="text" class="input-xlarge" id="indexDirectory" name="indexDirectory" size="50" data-bind="value: remoteRepository.indexDirectory"/>
- </div>
- </div>
- <div class="control-group">
- <label class="control-label" for="remoteDownloadTimeout">${$.i18n.prop('remoteDownloadTimeout')}</label>
- <div class="controls">
- <input type="text" id="remoteDownloadTimeout" class="digits" name="remoteDownloadTimeout" size="5"
- data-bind="value: remoteRepository.remoteDownloadTimeout"/>
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for="remoteDownloadNetworkProxyId">${$.i18n.prop('remoteDownloadNetworkProxyId')}</label>
- <div class="controls">
- <select id="remoteDownloadNetworkProxyId" data-bind="options: networkProxies, optionsText: 'id',optionsValue:'id', value: remoteRepository.remoteDownloadNetworkProxyId, optionsCaption: 'Choose...'"></select>
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for="downloadRemoteIndexOnStartup">${$.i18n.prop('downloadRemoteIndexOnStartup')}</label>
- <div class="controls">
- <input type="checkbox" id="downloadRemoteIndexOnStartup" name="downloadRemoteIndexOnStartup"
- data-bind="checked: remoteRepository.downloadRemoteIndexOnStartup"/>
- </div>
- </div>
-
- <div class="control-group">
- <label class="control-label" for="daysOlder">${$.i18n.prop('description')}</label>
- <div class="controls">
- <textarea rows="3" id="description" name="description" data-bind="value: remoteRepository.description"></textarea>
- </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>
- </form>
</script>
<script id="remote-repository-scan-modal-tmpl" type='text/html'>