*/
$(function() {
- ProxyConnector=function(sourceRepoId,targetRepoId,proxyId,blackListPatterns,whiteListPatterns,policies,properties,
+ ProxyConnector=function(sourceRepoId,targetRepoId,proxyId,blackListPatterns,whiteListPatterns,policiesEntries,propertiesEntries,
disabled,order){
var self=this;
self.modified(true);
});
- //private Map<String, String> policies;
- this.policies=ko.observableArray(policies==null?[]:policies);
- this.policies.subscribe(function(newValue){
- $.log("modify policies");
+ //private List<PropertyEntry> policiesEntries;
+ this.policiesEntries=ko.observableArray(policiesEntries==null?new Array():policiesEntries);
+ this.policiesEntries.subscribe(function(newValue){
+ $.log("policiesEntries policies");
self.modified(true);
});
- //private Map<String, String> properties;
- this.properties=ko.observableArray(properties==null?new Array():properties);
- this.properties.subscribe(function(newValue){
- $.log("properties modified");
+ //private List<PropertyEntry> properties;
+ this.propertiesEntries=ko.observableArray(propertiesEntries==null?new Array():propertiesEntries);
+ this.propertiesEntries.subscribe(function(newValue){
+ $.log("propertiesEntries modified");
self.modified(true);
});
});
//private int order = 0;
- this.order=ko.observable(order);
+ this.order=ko.observable(order?order:0);
this.order.subscribe(function(newValue){
$.log("modify order");
self.modified(true);
this.modified=ko.observable(false);
this.modified.subscribe(function(newValue){$.log("ProxyConnector modified:"+newValue)});
- this.policiesEntries=[];
- this.propertiesEntries=[];
this.deleteProperty=function(key){
$.log("delete property key:"+key());
- for(i=0;i<self.properties().length;i++){
- var entry=self.properties()[i];
+ for(i=0;i<self.propertiesEntries().length;i++){
+ var entry=self.propertiesEntries()[i];
if (entry.key()==key()){
- self.properties.remove(entry);
+ self.propertiesEntries.remove(entry);
}
}
var mainContent=$("#main-content");
var key=mainContent.find("#property-key").val();
var value=mainContent.find("#property-value").val();
- var oldTab = self.properties();
+ var oldTab = self.propertiesEntries();
oldTab.push(new Entry(key,value));
- self.properties(oldTab);
+ self.propertiesEntries(oldTab);
}
}
getSelectedPolicyOption=function(id){
$.log("getSelectedPolicyOption:"+id);
- var policies=self.proxyConnector.policies();
- $.log("getSelectedPolicyOption policies.length:"+policies.length);
- if (policies!=null){
- for (i=0;i<policies.length;i++){
- if (id==policies[i].key()){
- return policies[i].value();
+ var policiesEntries=self.proxyConnector.policiesEntries();
+ $.log("getSelectedPolicyOption policies.length:"+policiesEntries.length);
+ if (policiesEntries!=null){
+ for (i=0;i<policiesEntries.length;i++){
+ if (id==policiesEntries[i].key()){
+ return policiesEntries[i].value();
}
}
}
if (this.update){
} else {
- self.proxyConnector.policiesEntries=self.proxyConnector.policies();
- self.proxyConnector.propertiesEntries=self.proxyConnector.properties();
var json = $.toJSON(ko.toJS(self.proxyConnector));
$.log("toJSON:"+json);
return repo.id()==id;
}
);
- $.log("getRemoteRepository:"+id+":"+remoteRepository);
return ($.isArray(remoteRepository) && remoteRepository.length>0) ? remoteRepository[0]:new RemoteRepository();
}
getProxyConnector=function(sourceRepoId,targetRepoId){
- $.log("getProxyConnector:"+sourceRepoId+":"+targetRepoId);
var proxyConnector=$.grep(self.proxyConnectors(),
function(proxyConnector,idx){
return proxyConnector.sourceRepoId()==sourceRepoId
}
);
var res = ($.isArray(proxyConnector) && proxyConnector.length>0) ? proxyConnector[0]:new ProxyConnector();
- $.log("getProxyConnector res:"+res);
return res;
}
+proxyConnector.sourceRepoId()+"-"+proxyConnector.targetRepoId());
targetContent.html("");
targetContent.append($("#proxy-connectors-remote-settings-popover-tmpl")
- .tmpl(proxyConnector));
+ .tmpl(ko.toJS(proxyConnector)));
var targetImg = $("#proxy-connectors-grid-remoterepo-settings-edit-"+proxyConnector.sourceRepoId()
+"-"+proxyConnector.targetRepoId());
targetImg.popover('show');
- $.log("showSettings:"+proxyConnector.policies().length);
-
}
this.displayGrid=function(){
for (i=0;i<self.policyInformations().length;i++){
defaultPolicies.push(new Entry(self.policyInformations()[i].id(),self.policyInformations()[i].defaultOption));
}
- proxyConnector.policies(defaultPolicies);
- $.log("proxyConnector.policies().length:"+proxyConnector.policies().length);
+ proxyConnector.policiesEntries(defaultPolicies);
var proxyConnectorViewModel=new ProxyConnectorViewModel(proxyConnector,false,self);
mainContent.find("#proxy-connectors-edit").html($("#proxy-connector-edit-form-tmpl").tmpl());
ko.applyBindings(proxyConnectorViewModel,mainContent.find("#proxy-connectors-edit").get(0));
}
displayProxyConnectors=function(){
+ clearUserMessages();
var mainContent = $("#main-content");
mainContent.html($("#proxyConnectorsMain").tmpl());
mainContent.append(smallSpinnerImg());
if (data==null){
return null;
}
- var policies = (data.policies == null || data.policies.entry == null ) ? []: $.each(data.policies.entry,function(item){
- $.log("each policies:");
+ var policiesEntries = data.policiesEntries == null ? []: $.each(data.policiesEntries,function(item){
return new Entry(item.key, item.value);
});
- if (!$.isArray(policies)){
- policies=[];
+ if (!$.isArray(policiesEntries)){
+ policiesEntries=[];
}
- var properties = data.properties == null ? []: $.each(data.properties,function(item){
+ var propertiesEntries = data.propertiesEntries == null ? []: $.each(data.propertiesEntries,function(item){
return new Entry(item.key, item.value);
});
- if (!$.isArray(properties)){
- properties=[];
+ if (!$.isArray(propertiesEntries)){
+ propertiesEntries=[];
}
return new ProxyConnector(data.sourceRepoId,data.targetRepoId,data.proxyId,mapStringArray(data.blackListPatterns),
- mapStringArray(data.whiteListPatterns),policies,properties,
+ mapStringArray(data.whiteListPatterns),policiesEntries,propertiesEntries,
data.disabled,data.order);
}
{{each(i, row) itemsOnCurrentPage()}}
<tr>
<td>${row.sourceRepoId()}</td>
- <td>${row.targetRepoId()}</td>
+ <td>${row.targetRepoId()}-${row.order()}</td>
<td>
<a popover-title="${$.i18n.prop('proxy-connectors.grid.remoterepo.settings.popover.title')}"
data-bind="event: { mouseover: function(){ showSettings(row)},},click: function(){ editProxyConnector(row)}"
<script id='proxy-connectors-remote-settings-popover-tmpl' type='text/x-jquery-tmpl'>
<div>
- {{if proxyId()}}
- ${$.i18n.prop('proxy-connectors.remoterepo.settings.networkproxy')}: ${proxyId()}
+ {{if proxyId}}
+ ${$.i18n.prop('proxy-connectors.remoterepo.settings.networkproxy')}: ${proxyId}
{{else}}
${$.i18n.prop('proxy-connectors.remoterepo.settings.networkproxy')}: ${$.i18n.prop('none')}
{{/if}}
<th colspan="2">${$.i18n.prop('proxy-connector.policies')}</th>
</thead>
<tbody>
- {{each policies()}}
+ {{each(i, entry) policiesEntries}}
<tr>
- <td>${$value.key}</td>
- <td>${$value.value}</td>
+ <td>${entry.key}</td>
+ {{if $.isFunction( entry.value ) }}
+ <td>function=====${entry.value()}</td>
+ {{else}}
+ <td>${entry.value}</td>
+ {{/if}}
</tr>
{{/each}}
</tbody>
<th><input type="text" id="property-value"/></th>
<th><a href="#" data-bind="click: function(){ proxyConnector.addProperty() }">${$.i18n.prop('add')}</a></th>
</thead>
- <tbody data-bind="foreach: proxyConnector.properties">
+ <tbody data-bind="foreach: proxyConnector.propertiesEntries">
<tr>
<td data-bind="text: key"></td>
<td data-bind="text: value"></td>
- <td><a href="#" data-bind="click: function(){deleteProperty(key)}">${$.i18n.prop('delete')}</a></td>
+ <td><a href="#" data-bind="click: function(){$data.deleteProperty(key)}">${$.i18n.prop('delete')}</a></td>
</tr>
</tbody>
</table>