mirror of https://github.com/apache/archiva.git
[MRM-1712] Add buttons for managing proxy connectors rules as can be a pain with long list of repositories.
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1411243 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1429763756
commit
3292b98b72
|
@ -40,6 +40,15 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
|
||||||
return ruleType;
|
return ruleType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.findProxyConnector=function(sourceRepoId,targetRepoId){
|
||||||
|
for(var i=0;i<self.proxyConnectors().length;i++){
|
||||||
|
var proxyConnector=self.proxyConnectors()[i];
|
||||||
|
if(proxyConnector.sourceRepoId()==sourceRepoId && proxyConnector.targetRepoId()==targetRepoId){
|
||||||
|
return proxyConnector;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.displayGrid=function(){
|
this.displayGrid=function(){
|
||||||
var mainContent = $("#main-content");
|
var mainContent = $("#main-content");
|
||||||
|
|
||||||
|
@ -57,7 +66,7 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
|
||||||
|
|
||||||
ko.applyBindings(self,mainContent.find("#proxy-connector-rules-view").get(0));
|
ko.applyBindings(self,mainContent.find("#proxy-connector-rules-view").get(0));
|
||||||
|
|
||||||
removeSmallSpinnerImg();
|
removeSmallSpinnerImg(mainContent);
|
||||||
|
|
||||||
mainContent.find("#proxy-connectors-rules-view-tabs").on('show', function (e) {
|
mainContent.find("#proxy-connectors-rules-view-tabs").on('show', function (e) {
|
||||||
$.log("on show:"+$(e.target).attr("href"));
|
$.log("on show:"+$(e.target).attr("href"));
|
||||||
|
@ -162,13 +171,18 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
|
||||||
var proxyConnectorRuleViewModel=new ProxyConnectorRuleViewModel(proxyConnectorRule,self,true);
|
var proxyConnectorRuleViewModel=new ProxyConnectorRuleViewModel(proxyConnectorRule,self,true);
|
||||||
ko.applyBindings(proxyConnectorRuleViewModel,$("#main-content").find("#proxy-connector-rules-edit" ).get(0));
|
ko.applyBindings(proxyConnectorRuleViewModel,$("#main-content").find("#proxy-connector-rules-edit" ).get(0));
|
||||||
activateProxyConnectorRulesEditTab();
|
activateProxyConnectorRulesEditTab();
|
||||||
|
proxyConnectorRuleViewModel.activateRemoveChoosen(self);
|
||||||
|
proxyConnectorRuleViewModel.activateRemoveAvailable(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
remove=function(){
|
remove=function(){
|
||||||
$.log("remove");
|
$.log("remove");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxyConnectorRuleViewModel=function(proxyConnectorRule,proxyConnectorRulesViewModel,update){
|
ProxyConnectorRuleViewModel=function(proxyConnectorRule,proxyConnectorRulesViewModel,update){
|
||||||
|
@ -180,34 +194,76 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
|
||||||
this.update=update;
|
this.update=update;
|
||||||
|
|
||||||
|
|
||||||
$.each(this.proxyConnectorRulesViewModel.proxyConnectors(), function(idx, value) {
|
$.each(this.proxyConnectorRulesViewModel.proxyConnectors(), function(idx, value) {
|
||||||
$.log(idx + ': ' + value.sourceRepoId() +":"+value.targetRepoId());
|
$.log(idx + ': ' + value.sourceRepoId() +":"+value.targetRepoId());
|
||||||
var available=true;
|
var available=true;
|
||||||
// is it in proxyConnectorRule.proxyConnectors
|
// is it in proxyConnectorRule.proxyConnectors
|
||||||
$.each(self.proxyConnectorRule.proxyConnectors(),function(index,proxyConnector){
|
$.each(self.proxyConnectorRule.proxyConnectors(),function(index,proxyConnector){
|
||||||
if(value.sourceRepoId()==proxyConnector.sourceRepoId() && value.targetRepoId()==proxyConnector.targetRepoId()){
|
if(value.sourceRepoId()==proxyConnector.sourceRepoId() && value.targetRepoId()==proxyConnector.targetRepoId()){
|
||||||
available=false;
|
available=false;
|
||||||
}
|
|
||||||
});
|
|
||||||
if(available==true){
|
|
||||||
self.availableProxyConnectors.push(value);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if(available==true){
|
||||||
|
self.availableProxyConnectors.push(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
proxyConnectorMoved=function(arg){
|
proxyConnectorMoved=function(arg){
|
||||||
$.log("repositoryMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
|
$.log("repositoryMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
|
||||||
self.proxyConnectorRule.modified(true);
|
self.proxyConnectorRule.modified(true);
|
||||||
///arg.sourceParent.remove(arg.item);
|
self.activateRemoveChoosen(self.proxyConnectorRulesViewModel);
|
||||||
//arg.targetParent.push(arg.item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
saveProxyConnectorRule=function(){
|
saveProxyConnectorRule=function(){
|
||||||
$.log("pattern:"+self.proxyConnectorRule.pattern());
|
|
||||||
$.log("proxyConnectorRuleType:"+proxyConnectorRule.proxyConnectorRuleType());
|
|
||||||
$.log("proxyConnectors:"+proxyConnectorRule.proxyConnectors().length);
|
|
||||||
self.proxyConnectorRulesViewModel.saveProxyConnectorRule(self.proxyConnectorRule)
|
self.proxyConnectorRulesViewModel.saveProxyConnectorRule(self.proxyConnectorRule)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.removeChoosen=function(proxyConnectorRulesViewModel,sourceRepoId,targetRepoId){
|
||||||
|
$.log("removeChoosen:"+sourceRepoId+":"+targetRepoId);
|
||||||
|
|
||||||
|
$.log("size before:"+self.proxyConnectorRule.proxyConnectors().length);
|
||||||
|
var proxyConnectorToRemove=null;
|
||||||
|
for(var i=0;i<self.proxyConnectorRule.proxyConnectors().length;i++){
|
||||||
|
if(self.proxyConnectorRule.proxyConnectors()[i].sourceRepoId()==sourceRepoId &&
|
||||||
|
self.proxyConnectorRule.proxyConnectors()[i].targetRepoId()==targetRepoId){
|
||||||
|
$.log("found");
|
||||||
|
proxyConnectorToRemove=self.proxyConnectorRule.proxyConnectors()[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.proxyConnectorRule.proxyConnectors.remove(proxyConnectorToRemove);
|
||||||
|
self.availableProxyConnectors.push(proxyConnectorToRemove);
|
||||||
|
$.log("size after:"+self.proxyConnectorRule.proxyConnectors().length);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.activateRemoveChoosen=function(proxyConnectorRulesViewModel){
|
||||||
|
$("#main-content" ).find("#proxy-connectors-rules-edit-order-div" ).find(".icon-minus-sign" ).on("click", function(){
|
||||||
|
self.removeChoosen(proxyConnectorRulesViewModel,$(this).attr("data-source-repoId"),$(this).attr("data-target-repoId"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.removeAvailable=function(proxyConnectorRulesViewModel,sourceRepoId,targetRepoId){
|
||||||
|
$.log("removeAvailable:"+sourceRepoId+":"+targetRepoId);
|
||||||
|
|
||||||
|
$.log("size before:"+self.availableProxyConnectors().length);
|
||||||
|
var proxyConnectorToAdd=null;
|
||||||
|
for(var i=0;i<self.availableProxyConnectors().length;i++){
|
||||||
|
if(self.availableProxyConnectors()[i].sourceRepoId()==sourceRepoId &&
|
||||||
|
self.availableProxyConnectors()[i].targetRepoId()==targetRepoId){
|
||||||
|
$.log("found");
|
||||||
|
proxyConnectorToAdd=self.availableProxyConnectors()[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.proxyConnectorRule.proxyConnectors.push(proxyConnectorToAdd);
|
||||||
|
self.availableProxyConnectors.remove(proxyConnectorToAdd);
|
||||||
|
$.log("size after:"+self.proxyConnectorRule.proxyConnectors().length);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.activateRemoveAvailable=function(proxyConnectorRulesViewModel){
|
||||||
|
$("#main-content" ).find("#proxy-connectors-rules-available-proxy-connectors" ).find(".icon-plus-sign" ).on("click", function(){
|
||||||
|
self.removeAvailable(proxyConnectorRulesViewModel,$(this).attr("data-source-repoId"),$(this).attr("data-target-repoId"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -247,7 +303,6 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
|
||||||
//private String sourceRepoId;
|
//private String sourceRepoId;
|
||||||
this.pattern=ko.observable(pattern);
|
this.pattern=ko.observable(pattern);
|
||||||
this.pattern.subscribe(function(newValue){
|
this.pattern.subscribe(function(newValue){
|
||||||
$.log("pattern modified");
|
|
||||||
self.modified(true);
|
self.modified(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1383,15 +1383,15 @@
|
||||||
<div class="span6 dotted">
|
<div class="span6 dotted">
|
||||||
<div id="proxy-connectors-rules-edit-div" data-bind='template:{name:"proxy-connectors-rules-edit-tmpl"}'></div>
|
<div id="proxy-connectors-rules-edit-div" data-bind='template:{name:"proxy-connectors-rules-edit-tmpl"}'></div>
|
||||||
<div id="proxy-connectors-rules-edit-order-div" style="min-height: 80px"
|
<div id="proxy-connectors-rules-edit-order-div" style="min-height: 80px"
|
||||||
data-bind="sortable: { template: 'proxy-connectors-rules-edit-proxy-connectors-tmpl',data:proxyConnectorRule.proxyConnectors,afterMove:proxyConnectorMoved}">
|
data-bind="sortable: { template: 'proxy-connectors-rules-edit-proxy-connectors-tmpl-choosen',data:proxyConnectorRule.proxyConnectors,afterMove:proxyConnectorMoved}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="span6 dotted">
|
<div class="span6 dotted">
|
||||||
<h5>${$.i18n.prop('proxy-connector-rules.available.proxyConnectors')}</h5>
|
<h5>${$.i18n.prop('proxy-connector-rules.available.proxyConnectors')}</h5>
|
||||||
<br/>
|
<br/>
|
||||||
<div id="proxy-connectors-rules-available-repositories" style="min-height: 80px"
|
<div id="proxy-connectors-rules-available-proxy-connectors" style="min-height: 80px"
|
||||||
data-bind="sortable: { template: 'proxy-connectors-rules-edit-proxy-connectors-tmpl',data:availableProxyConnectors,afterMove:proxyConnectorMoved}">
|
data-bind="sortable: { template: 'proxy-connectors-rules-edit-proxy-connectors-tmpl-availables',data:availableProxyConnectors,afterMove:proxyConnectorMoved}">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1507,11 +1507,22 @@
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script id="proxy-connectors-rules-edit-proxy-connectors-tmpl" type="text/html">
|
<script id="proxy-connectors-rules-edit-proxy-connectors-tmpl-choosen" type="text/html">
|
||||||
<div class="well draggable-item">
|
<div class="well draggable-item">
|
||||||
<blockquote>
|
<i class="icon-minus-sign cursor-hand pull-right" data-source-repoId="${$data.sourceRepoId()}" data-target-repoId="${$data.targetRepoId()}"/>
|
||||||
${$data.sourceRepoId()} <-> ${$data.targetRepoId()}
|
<blockquote>
|
||||||
</blockquote>
|
${$data.sourceRepoId()} <-> ${$data.targetRepoId()}
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script id="proxy-connectors-rules-edit-proxy-connectors-tmpl-availables" type="text/html">
|
||||||
|
<div class="well draggable-item">
|
||||||
|
<i class="icon-plus-sign cursor-hand pull-right" data-source-repoId="${$data.sourceRepoId()}" data-target-repoId="${$data.targetRepoId()}"/>
|
||||||
|
<blockquote>
|
||||||
|
${$data.sourceRepoId()} <-> ${$data.targetRepoId()}
|
||||||
|
</blockquote>
|
||||||
|
|
||||||
|
</div>
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue