From: Olivier Lamy Date: Tue, 2 Oct 2012 15:13:16 +0000 (+0000) Subject: [MRM-1681] addProxy Connectors Rules screen X-Git-Tag: archiva-1.4-M3~24 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2485995ed757cc350d5100d5ba178cdcba3b84d9;p=archiva.git [MRM-1681] addProxy Connectors Rules screen add all js templates. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1392954 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js new file mode 100644 index 000000000..f28d81b20 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","knockout" + ,"knockout.simpleGrid","knockout.sortable","archiva.proxy-connectors"], function() { + + + + ProxyConnectorRulesViewModel=function(proxyConnectorRules,proxyConnectors){ + var self=this; + this.proxyConnectorRules=ko.observableArray(proxyConnectorRules?proxyConnectorRules:[]); + this.proxyConnectors=proxyConnectors; + + this.displayGrid=function(){ + var mainContent = $("#main-content"); + + this.gridViewModel = new ko.simpleGrid.viewModel({ + data: self.proxyConnectorRules, + pageSize: 5, + gridUpdateCallBack: function(){ + $("#main-content" ).find("#proxy-connectors-rules-view-tabsTable" ).find("[title]").tooltip(); + } + }); + + ko.applyBindings(self,mainContent.find("#proxy-connectors-rules-view-tabs-view").get(0)); + + removeSmallSpinnerImg(); + + + mainContent.find("#proxy-connectors-rules-view-tabs").on('show', function (e) { + $.log("on show:"+$(e.target).attr("href")); + if ($(e.target).attr("href")=="#proxy-connector-rules-edit") { + var proxyConnectorRuleViewModel = new ProxyConnectorRuleViewModel(new ProxyConnectorRule(),self,false); + ko.applyBindings(proxyConnectorRuleViewModel,mainContent.find("#proxy-connector-rules-edit" ).get(0)); + activateProxyConnectorRulesEditTab(); + } + + + }); + } + } + + ProxyConnectorRuleViewModel=function(proxyConnectorRule,proxyConnectorRulesViewModel,update){ + var self=this; + this.proxyConnectorRule=proxyConnectorRule; + this.proxyConnectorRulesViewModel=proxyConnectorRulesViewModel; + this.availableProxyConnectors=ko.observableArray(proxyConnectorRulesViewModel.proxyConnectors); + this.update=update; + + proxyConnectorMoved=function(arg){ + + } + + } + + + displayProxyConnectorsRules=function(){ + $.log("displayProxyConnectorsRules"); + screenChange(); + var mainContent = $("#main-content"); + mainContent.html($("#proxyConnectorsRulesMain").tmpl()); + mainContent.append(smallSpinnerImg()); + loadAllProxyConnectors(function(data){ + var proxyConnectors = mapProxyConnectors(data); + + $.ajax("restServices/archivaServices/proxyConnectorRuleService/proxyConnectorRules", { + type: "GET", + dataType: 'json', + success: function (data){ + var proxyConnectorRules=mapProxyConnectorRules(data); + var proxyConnectorRulesViewModel = new ProxyConnectorRulesViewModel(proxyConnectorRules,proxyConnectors); + proxyConnectorRulesViewModel.displayGrid(); + activateProxyConnectorRulesGridTab(); + } + + }); + + }); + } + + ProxyConnectorRule=function(pattern,proxyConnectorRuleType,proxyConnectors){ + //private String pattern; + var self=this; + + this.modified=ko.observable(false); + + //private String sourceRepoId; + this.pattern=ko.observable(pattern); + this.pattern.subscribe(function(newValue){ + self.modified(true); + }); + + + //private ProxyConnectorRuleType proxyConnectorRuleType; + this.proxyConnectorRuleType=ko.observable(proxyConnectorRuleType); + this.proxyConnectorRuleType.subscribe(function(newValue){ + self.modified(true); + }); + + //private List proxyConnectors; + this.proxyConnectors=ko.observableArray(proxyConnectors?proxyConnectors:[]); + this.proxyConnectors.subscribe(function(newValue){ + self.modified(true); + }); + } + + mapProxyConnectorRule=function(data){ + if (data==null){ + return null; + } + return new ProxyConnector(data.pattern, data.proxyConnectorRuleType, mapProxyConnectors(data.proxyConnectors)); + } + + mapProxyConnectorRules=function(data){ + var mappedProxyConnectorRules = $.map(data, function(item) { + return mapProxyConnectorRule(item); + }); + return mappedProxyConnectorRules; + } + + + activateProxyConnectorRulesGridTab=function(){ + var mainContent = $("#main-content"); + mainContent.find("#proxy-connectors-rules-view-tabs-content div[class*='tab-pane']").removeClass("active"); + mainContent.find("#proxy-connectors-rules-view-tabs > li").removeClass("active"); + + mainContent.find("#repository-groups-view").addClass("active"); + mainContent.find("#proxy-connectors-rules-view-tabs-li-grid").addClass("active"); + mainContent.find("#proxy-connectors-rules-view-tabs-a-edit").html($.i18n.prop("add")); + + } + + activateProxyConnectorRulesEditTab=function(){ + var mainContent = $("#main-content"); + + mainContent.find("#proxy-connectors-rules-view-tabs-content div[class*='tab-pane']").removeClass("active"); + mainContent.find("#proxy-connectors-rules-view-tabs > li").removeClass("active"); + + mainContent.find("#proxy-connector-rules-edit").addClass("active"); + mainContent.find("#proxy-connectors-rules-view-tabs-edit").addClass("active"); + } + + +}); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js index 04e7f8cc0..32ad305ee 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js @@ -23,6 +23,8 @@ define("archiva.proxy-connectors",["jquery","i18n","jquery.tmpl","bootstrap","jq disabled,order){ var self=this; + this.modified=ko.observable(false); + //private String sourceRepoId; this.sourceRepoId=ko.observable(sourceRepoId); this.sourceRepoId.subscribe(function(newValue){ @@ -83,7 +85,7 @@ define("archiva.proxy-connectors",["jquery","i18n","jquery.tmpl","bootstrap","jq self.modified(true); }); - this.modified=ko.observable(false); + this.updatePolicyEntry=function(key,value){ $.log("updatePolicyEntry:"+key+":"+value); @@ -275,7 +277,7 @@ define("archiva.proxy-connectors",["jquery","i18n","jquery.tmpl","bootstrap","jq var self=this; this.proxyConnectors=ko.observableArray([]); this.proxyConnectors.subscribe(function(newValue){ - $.log("ProxyConnectorsViewModel#proxyConnectors modified") + $.log("ProxyConnectorsViewModel#proxyConnectors modified"); self.proxyConnectors().sort(function(a,b){ if ( a.sourceRepoId()== b.sourceRepoId()) return a.order() - b.order(); return (a.sourceRepoId() > b.sourceRepoId())? -1:1; diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js index 5a4fd09a7..7d45b2f44 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js @@ -66,8 +66,10 @@ define("knockout.simpleGrid",["jquery","utils","i18n","knockout"], function() { // Render the page links var pageLinksContainer = $("#"+allBindings.pageLinksId).get(0); - ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode") - .subscribe(viewModel.pageLinksUpdateCallBack?viewModel.pageLinksUpdateCallBack:function(){}); + var renderedTemplate = ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode"); + if (renderedTemplate.subscribe){ + renderedTemplate.subscribe(viewModel.pageLinksUpdateCallBack?viewModel.pageLinksUpdateCallBack:function(){}); + } if (viewModel.pageLinksUpdateCallBack) viewModel.pageLinksUpdateCallBack(); } }; diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html index 74e7d383e..ec153d777 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/repositories.html @@ -1068,14 +1068,14 @@
-
+
-
+
${$.i18n.prop('repository.groups.available.repositories')}

-
@@ -1219,4 +1219,125 @@ {{/if}}
+ + + + + + + + + + + + \ No newline at end of file