--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<actions>
+ <action>
+ <actionName>CUSTOM-T</actionName>
+ <displayName>T</displayName>
+ <goals>
+ <goal>tomcat7:run</goal>
+ <goal>-pl</goal>
+ <goal>:archiva-webapp</goal>
+ <goal>-am</goal>
+ </goals>
+ </action>
+ </actions>
<artifactId>apache-rat-plugin</artifactId>
<configuration>
<excludes>
+ <exclude>nbactions.xml</exclude>
<exclude>src/main/webapp/css/*.css</exclude>
<exclude>src/main/webapp/js/*.js</exclude>
<exclude>src/site/resources/css/*.css</exclude>
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.9.2.custom.min.js"></script>
<script type="text/javascript" src="js/sammy.0.7.4.js"></script>
- <script type="text/javascript" data-main="js/archiva/archiva.js" src="js/require.2.1.5.js"></script>
+ <script type="text/javascript" data-main="js/archiva/archiva.js" src="js/require.2.1.6.js"></script>
<title>Apache Archiva</title>
+++ /dev/null
-/*
- * 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/admin/features/10networkproxies/main",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","knockout"
- ,"knockout.simpleGrid"], function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
-
- showMenu = function(administrationMenuItems) {
- administrationMenuItems.push(
- { text : $.i18n.prop('menu.network-proxies') , id: "menu-network-proxies-list-a" , href: "#networkproxies" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayNetworkProxies()}}
- );
- }
-
- NetworkProxy=function(id,protocol,host,port,username,password,useNtlm){
- var self=this;
- //private String id;
- this.id = ko.observable(id);
- this.id.subscribe(function(newValue){self.modified(true)});
-
- //private String protocol = "http";
- this.protocol=ko.observable(protocol);
- this.protocol.subscribe(function(newValue){self.modified(true)});
-
- //private String host;
- this.host=ko.observable(host);
- this.host.subscribe(function(newValue){self.modified(true)});
-
- //private int port = 8080;
- this.port=ko.observable(port);
- this.port.subscribe(function(newValue){self.modified(true)});
-
- //private String username;
- this.username=ko.observable(username?username:"");
- this.username.subscribe(function(newValue){self.modified(true)});
-
- //private String password;
- this.password=ko.observable(password?password:"");
- this.password.subscribe(function(newValue){self.modified(true)});
-
- //use NTLM proxy
- this.useNtlm=ko.observable(useNtlm?useNtlm:false);
- this.useNtlm.subscribe(function(newValue){self.modified(true)});
-
- this.modified=ko.observable(false);
- }
-
- NetworkProxyViewModel=function(networkProxy, update, networkProxiesViewModel,bulkMode){
- this.update=update;
- this.networkProxy=networkProxy;
- this.networkProxiesViewModel=networkProxiesViewModel;
- var self=this;
- this.bulkMode=false || bulkMode;
-
- this.save=function(){
- if (!$("#main-content" ).find("#network-proxy-edit-form").valid()){
- return;
- }
- if (!this.bulkMode){
- clearUserMessages();
- }
- if (update){
- $.ajax("restServices/archivaServices/networkProxyService/updateNetworkProxy",
- {
- type: "POST",
- contentType: 'application/json',
- data: ko.toJSON(networkProxy),
- dataType: 'json',
- success: function(data) {
- $.log("update proxy id:"+self.networkProxy.id());
- var message=$.i18n.prop('networkproxy.updated',self.networkProxy.id());
- displaySuccessMessage(message);
- self.networkProxy.modified(false);
- if (!this.bulkMode){
- activateNetworkProxiesGridTab();
- }
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- }
- }
- );
- } else {
-
- $.ajax("restServices/archivaServices/networkProxyService/addNetworkProxy",
- {
- type: "POST",
- contentType: 'application/json',
- data: ko.toJSON(networkProxy),
- dataType: 'json',
- success: function(data) {
- self.networkProxy.modified(false);
- self.networkProxiesViewModel.networkProxies.push(self.networkProxy);
- displaySuccessMessage($.i18n.prop('networkproxy.added',self.networkProxy.id()));
- activateNetworkProxiesGridTab();
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- }
- }
- );
-
- }
- }
-
- displayGrid=function(){
- activateNetworkProxiesGridTab();
- }
- }
-
- NetworkProxiesViewModel=function(){
- this.networkProxies=ko.observableArray([]);
-
- var self=this;
-
- this.gridViewModel = null;
-
- editNetworkProxy=function(networkProxy){
- clearUserMessages();
- $.log("editNetworkProxy");
- var mainContent = $("#main-content");
- mainContent.find("#network-proxies-view-tabs-li-edit a").html($.i18n.prop("edit"));
- var viewModel = new NetworkProxyViewModel(networkProxy,true,self);
- ko.applyBindings(viewModel,mainContent.find("#network-proxies-edit").get(0));
- activateNetworkProxyFormValidation();
- activateNetworkProxyEditTab();
- mainContent.find("#network-proxy-btn-save").attr("disabled","true");
- mainContent.find("#network-proxy-btn-save").button('toggle');
- }
-
- this.bulkSave=function(){
- return getModifiedNetworkProxies().length>0;
- }
-
- getModifiedNetworkProxies=function(){
- var prx = $.grep(self.networkProxies(),
- function (networkProxy,i) {
- return networkProxy.modified();
- });
- return prx;
- }
-
-
- updateModifiedNetworkProxies=function(){
- var modifiedNetworkProxies = getModifiedNetworkProxies();
-
- openDialogConfirm(function(){
- for(var i=0;i<modifiedNetworkProxies.length;i++){
- var viewModel = new NetworkProxyViewModel(modifiedNetworkProxies[i],true,self,false);
- viewModel.save();
- }
- closeDialogConfirm();
- },
- $.i18n.prop('ok'),
- $.i18n.prop('cancel'),
- $.i18n.prop('networkproxy.bulk.save.confirm.title'),
- $.i18n.prop('networkproxy.bulk.save.confirm',modifiedNetworkProxies.length));
-
-
- }
-
- updateNetworkProxy=function(networkProxy){
- var viewModel = new NetworkProxyViewModel(networkProxy,true,self,false);
- viewModel.save();
- }
-
- removeNetworkProxy=function(networkProxy){
- openDialogConfirm(
- function(){
- $.ajax("restServices/archivaServices/networkProxyService/deleteNetworkProxy/"+encodeURIComponent(networkProxy.id()),
- {
- type: "get",
- success: function(data) {
- self.networkProxies.remove(networkProxy);
- clearUserMessages();
- displaySuccessMessage($.i18n.prop('networkproxy.deleted',networkProxy.id()));
- activateNetworkProxiesGridTab();
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete: function(){
- closeDialogConfirm();
- }
- }
- )}, $.i18n.prop('ok'), $.i18n.prop('cancel'), $.i18n.prop('networkproxy.delete.confirm',networkProxy.id()),
- $("#network-proxy-delete-warning-tmpl" ).tmpl(networkProxy));
- }
- }
-
-
- displayNetworkProxies=function(){
- screenChange();
- var mainContent = $("#main-content");
- mainContent.html(mediumSpinnerImg());
-
-
-
- loadNetworkProxies( function(data) {
- var networkProxiesViewModel = new NetworkProxiesViewModel();
- mainContent.html($("#networkProxiesMain").tmpl());
- mainContent.find("#network-proxies-view-tabs a:first").tab('show');
-
- mainContent.find("#network-proxies-view-tabs").on('show', function (e) {
- if ($(e.target).attr("href")=="#network-proxies-edit") {
- var viewModel = new NetworkProxyViewModel(new NetworkProxy(),false,networkProxiesViewModel);
- ko.applyBindings(viewModel,$("#main-content" ).find("#network-proxies-edit").get(0));
- activateNetworkProxyFormValidation();
- clearUserMessages();
- }
- if ($(e.target).attr("href")=="#network-proxies-view") {
- $("#main-content" ).find("#network-proxies-view-tabs-li-edit a").html($.i18n.prop("add"));
- clearUserMessages();
- }
-
- });
- networkProxiesViewModel.networkProxies(mapNetworkProxies(data));
- networkProxiesViewModel.gridViewModel = new ko.simpleGrid.viewModel({
- data: networkProxiesViewModel.networkProxies,
- columns: [
- {
- headerText: $.i18n.prop('identifier'),
- rowText: "id"
- },
- {
- headerText: $.i18n.prop('protocol'),
- rowText: "protocol"
- },
- {
- headerText: $.i18n.prop('host'),
- rowText: "host"
- },
- {
- headerText: $.i18n.prop('port'),
- rowText: "port"
- },
- {
- headerText: $.i18n.prop('username'),
- rowText: "username"
- }
- ],
- pageSize: 5,
- gridUpdateCallBack: function(networkProxy){
- $("#main-content" ).find("#networkProxiesTable [title]").tooltip();
- }
- });
- ko.applyBindings(networkProxiesViewModel,$("#main-content" ).find("#network-proxies-view").get(0));
- }
- )
- }
-
- loadNetworkProxies=function(successCallbackFn, errorCallbackFn){
- $.ajax("restServices/archivaServices/networkProxyService/getNetworkProxies", {
- type: "GET",
- dataType: 'json',
- success: successCallbackFn,
- error: errorCallbackFn
- });
- }
-
- activateNetworkProxyFormValidation=function(){
- var editForm=$("#main-content" ).find("#network-proxy-edit-form");
- var validator = editForm.validate({
- rules: {id: {
- required: true,
- remote: {
- url: "restServices/archivaUiServices/dataValidatorService/networkProxyIdNotExists",
- type: "get"
- }
- }},
- showErrors: function(validator, errorMap, errorList) {
- customShowError(editForm,validator,errorMap,errorMap);
- }
- });
- validator.settings.messages["id"]=$.i18n.prop("id.required.or.alreadyexists");
- }
-
- activateNetworkProxiesGridTab=function(){
- var mainContent = $("#main-content");
- mainContent.find("#network-proxies-view-tabs-li-edit").removeClass("active");
- mainContent.find("#network-proxies-edit").removeClass("active");
-
- mainContent.find("#network-proxies-view-tabs-li-grid").addClass("active");
- mainContent.find("#network-proxies-view").addClass("active");
- mainContent.find("#network-proxies-view-tabs-li-edit a").html($.i18n.prop("add"));
-
- }
-
- activateNetworkProxyEditTab=function(){
- var mainContent = $("#main-content");
- mainContent.find("#network-proxies-view-tabs-li-grid").removeClass("active");
- mainContent.find("#network-proxies-view").removeClass("active");
-
- mainContent.find("#network-proxies-view-tabs-li-edit").addClass("active");
- mainContent.find("#network-proxies-edit").addClass("active");
- }
-
- mapNetworkProxy=function(data){
- if (data==null){
- return null;
- }
- return new NetworkProxy(data.id,data.protocol,data.host,data.port,data.username,data.password,data.useNtlm);
- }
-
- mapNetworkProxies=function(data){
- var mappedNetworkProxies = $.map(data, function(item) {
- return mapNetworkProxy(item);
- });
- return mappedNetworkProxies;
- }
-
-});
\ No newline at end of file
+++ /dev/null
-/*
- * 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/admin/features/20generaladmin/main",["jquery","i18n","utils","jquery.tmpl","knockout","knockout.simpleGrid",
- "knockout.sortable","jquery.ui","jquery.validate","bootstrap","select2","knockout.select2"]
- , function(jquery,i18n,utils,jqueryTmpl,ko,simpleGrid,sortable,jqueryUi,validate,bootstrap,select2) {
-
- showMenu = function( administrationMenuItems) {
- administrationMenuItems.push({ text : $.i18n.prop('menu.repository-scanning') , id: "menu-repository-scanning-list-a" , href: "#scanningList" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRepositoryScanning();}});
- administrationMenuItems.push({ text : $.i18n.prop('menu.runtime-configuration') , id: "menu-runtime-configuration-list-a" , href: "#runtimeconfig" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRuntimeConfiguration();}});
- administrationMenuItems.push({ text : $.i18n.prop('menu.system-status') , id: "menu-system-status-list-a" , href: "#status" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displaySystemStatus();}});
- administrationMenuItems.push({ text : $.i18n.prop('menu.ui-configuration') , id: "menu-ui-configuration-list-a" , href: "#uiconfig" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayUiConfiguration();}});
- administrationMenuItems.push({ text : $.i18n.prop('menu.reports') , id: "menu-report-list-a" , href: "#reports" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayReportsPage();}});
-
- };
-
- //---------------------------
- // repository scanning part
- //---------------------------
-
- FileType=function(id,patterns){
- //private String id;
- this.id=ko.observable(id);
-
- //private List<String> patterns;
- this.patterns=ko.observableArray(patterns);
-
- };
-
- mapFileType=function(data){
- return new FileType(data.id,data.patterns);
- };
-
- mapFileTypes=function(data){
- if (data!=null){
- return $.isArray(data)? $.map(data,function(item){
- return mapFileType(item)
- }):[mapFileType(data)];
- }
- return [];
- };
-
- AdminRepositoryConsumer=function(enabled,id,description){
- //private boolean enabled = false;
- this.enabled=ko.observable(enabled);
-
- //private String id;
- this.id=ko.observable(id)
-
- //private String description;
- this.description=ko.observable(description);
- }
-
- mapAdminRepositoryConsumer=function(data){
- return new AdminRepositoryConsumer(data.enabled,data.id,data.description);
- }
-
- mapAdminRepositoryConsumers=function(data){
- if (data!=null){
- return $.isArray(data)? $.map(data,function(item){
- return mapAdminRepositoryConsumer(item)
- }):[mapAdminRepositoryConsumer(data)];
- }
- return [];
- }
-
-
-
- RepositoryScanningViewModel=function(){
- var self=this;
- this.fileTypes=ko.observableArray([]);
- this.knownAdminRepositoryConsumers=ko.observableArray([]);
- this.invalidAdminRepositoryConsumers=ko.observableArray([]);
-
- this.findFileType=function(id){
- var fileType=null;
- for (var i=0;i<self.fileTypes().length;i++){
- if (id==self.fileTypes()[i].id()){
- fileType=self.fileTypes()[i];
- }
- }
- return fileType;
- }
-
- removeFileTypePattern=function(id,pattern){
- clearUserMessages();
- var url="restServices/archivaServices/archivaAdministrationService/removeFileTypePattern?"
- url+="fileTypeId="+encodeURIComponent(id);
- url+="&pattern="+encodeURIComponent(pattern);
- $.ajax(url, {
- type: "GET",
- dataType: 'json',
- success: function(data){
- self.findFileType(id ).patterns.remove(pattern);
- displaySuccessMessage( $.i18n.prop("repository-scanning.file-types.removed.pattern",id,pattern));
-
- }
- });
- }
-
- addFileTypePattern=function(id){
- var pattern=$("#main-content #pattern-"+id ).val();
- $.log("addFileTypePattern:"+id+":"+pattern);
- clearUserMessages();
- var url="restServices/archivaServices/archivaAdministrationService/addFileTypePattern?"
- url+="fileTypeId="+encodeURIComponent(id);
- url+="&pattern="+encodeURIComponent(pattern);
- $.ajax(url, {
- type: "GET",
- dataType: 'json',
- success: function(data){
- self.findFileType(id ).patterns.push(pattern);
- displaySuccessMessage( $.i18n.prop("repository-scanning.file-types.added.pattern",id,pattern));
-
- }
- });
- }
-
- disableKnowContentConsumer=function(adminRepositoryConsumer){
- $.log("disableKnowContentConsumer");
- clearUserMessages();
- var userMessages=$("#user-messages" )
- userMessages.html(mediumSpinnerImg());
- var url="restServices/archivaServices/archivaAdministrationService/disabledKnownContentConsumer/"
- url+=encodeURIComponent(adminRepositoryConsumer.id());
- $.ajax(url, {
- type: "GET",
- dataType: 'json',
- success: function(data){
- adminRepositoryConsumer.enabled(false);
- displaySuccessMessage( $.i18n.prop("repository-scanning.consumers.know.disabled",adminRepositoryConsumer.id()));
- removeMediumSpinnerImg(userMessages);
- }
- });
- }
-
- enableKnowContentConsumer=function(adminRepositoryConsumer){
- clearUserMessages();
- var userMessages=$("#user-messages" )
- userMessages.html(mediumSpinnerImg());
- var url="restServices/archivaServices/archivaAdministrationService/enabledKnownContentConsumer/"
- url+=encodeURIComponent(adminRepositoryConsumer.id());
- $.ajax(url, {
- type: "GET",
- dataType: 'json',
- success: function(data){
- adminRepositoryConsumer.enabled(true);
- displaySuccessMessage( $.i18n.prop("repository-scanning.consumers.know.enabled",adminRepositoryConsumer.id()));
- removeMediumSpinnerImg(userMessages);
- }
- });
- }
-
- disableInvalidContentConsumer=function(adminRepositoryConsumer){
- clearUserMessages();
- var url="restServices/archivaServices/archivaAdministrationService/disabledInvalidContentConsumer/"
- url+=encodeURIComponent(adminRepositoryConsumer.id());
- $.ajax(url, {
- type: "GET",
- dataType: 'json',
- success: function(data){
- adminRepositoryConsumer.enabled(false);
- displaySuccessMessage( $.i18n.prop("repository-scanning.consumers.invalid.disabled",adminRepositoryConsumer.id()));
- }
- });
- }
-
- enableInvalidContentConsumer=function(adminRepositoryConsumer){
- clearUserMessages();
- var url="restServices/archivaServices/archivaAdministrationService/enabledInvalidContentConsumer/"
- url+=encodeURIComponent(adminRepositoryConsumer.id());
- $.ajax(url, {
- type: "GET",
- dataType: 'json',
- success: function(data){
- adminRepositoryConsumer.enabled(true);
- displaySuccessMessage( $.i18n.prop("repository-scanning.consumers.invalid.enabled",adminRepositoryConsumer.id()));
- }
- });
- }
-
- }
-
- displayRepositoryScanning=function(){
- screenChange();
- var mainContent=$("#main-content");
-
- mainContent.html($("#repository-scanning-main").tmpl());
- mainContent.find("#file-types-content").html(mediumSpinnerImg());
- mainContent.find("#consumers-known-content").html(mediumSpinnerImg());
- mainContent.find("#consumers-invalid-content").html(mediumSpinnerImg());
-
- var repositoryScanningViewModel=new RepositoryScanningViewModel();
-
- $.ajax("restServices/archivaServices/archivaAdministrationService/getFileTypes", {
- type: "GET",
- dataType: 'json',
- success: function(data){
- var fileTypes=mapFileTypes(data);
- repositoryScanningViewModel.fileTypes(fileTypes);
- ko.applyBindings(repositoryScanningViewModel,mainContent.find("#file-types-content").get(0));
- }
- });
-
- $.ajax("restServices/archivaServices/archivaAdministrationService/getKnownContentAdminRepositoryConsumers", {
- type: "GET",
- dataType: 'json',
- success: function(data){
- var knownAdminRepositoryConsumers=mapAdminRepositoryConsumers(data);
- repositoryScanningViewModel.knownAdminRepositoryConsumers(knownAdminRepositoryConsumers);
- ko.applyBindings(repositoryScanningViewModel,mainContent.find("#consumers-known-content").get(0));
- }
- });
-
- $.ajax("restServices/archivaServices/archivaAdministrationService/getInvalidContentAdminRepositoryConsumers", {
- type: "GET",
- dataType: 'json',
- success: function(data){
- var invalidAdminRepositoryConsumers=mapAdminRepositoryConsumers(data);
- repositoryScanningViewModel.invalidAdminRepositoryConsumers(invalidAdminRepositoryConsumers);
- ko.applyBindings(repositoryScanningViewModel,mainContent.find("#consumers-invalid-content").get(0));
- }
- });
-
- }
-
- //---------------------------
- // network configuration part
- //---------------------------
-
- NetworkConfiguration=function(maxTotal,maxTotalPerHost,usePooling){
- //private int maxTotal = 30;
- this.maxTotal=ko.observable(maxTotal);
-
- //private int maxTotalPerHost = 30;
- this.maxTotalPerHost=ko.observable(maxTotalPerHost);
-
- //private boolean usePooling = true;
- this.usePooling=ko.observable(usePooling);
- }
-
- NetworkConfigurationViewModel=function(networkConfiguration){
- var self=this;
- this.networkConfiguration=ko.observable(networkConfiguration);
-
- save=function(){
- var userMessages=$("#user-messages");
-
- var mainContent=$("#main-content");
-
- if (!mainContent.find("#network-configuration-edit-form").valid()){
- return;
- }
- userMessages.html(mediumSpinnerImg());
- mainContent.find("#network-configuration-btn-save" ).button('loading');
- $.ajax("restServices/archivaServices/archivaAdministrationService/setNetworkConfiguration", {
- type: "POST",
- contentType: 'application/json',
- data: ko.toJSON(self.networkConfiguration),
- dataType: 'json',
- success: function(data){
- displaySuccessMessage( $.i18n.prop("network-configuration.updated"));
- },
- complete: function(){
- removeMediumSpinnerImg(userMessages);
- mainContent.find("#network-configuration-btn-save" ).button('reset');
- }
- });
- }
- }
-
- displayRuntimeConfiguration=function(){
- screenChange();
- var mainContent=$("#main-content");
-
- mainContent.html($("#runtime-configuration-screen").tmpl());
- mainContent.find("#network-configuration-form" ).html(mediumSpinnerImg());
- $.ajax("restServices/archivaServices/archivaAdministrationService/getNetworkConfiguration", {
- type: "GET",
- dataType: 'json',
- success: function(data){
-
- var networkConfiguration=new NetworkConfiguration(data.maxTotal,data.maxTotalPerHost,data.usePooling);
- var networkConfigurationViewModel=new NetworkConfigurationViewModel(networkConfiguration);
- ko.applyBindings(networkConfigurationViewModel,mainContent.find("#network-configuration-form-content").get(0));
- var validator = mainContent.find("#network-configuration-edit-form")
- .validate({
- showErrors: function(validator, errorMap, errorList) {
- customShowError(mainContent.find("#network-configuration-edit-form" ),validator,errorMap,errorMap);
- }
- });
- }
- });
-
-
- $.ajax("restServices/archivaServices/archivaRuntimeConfigurationService/archivaRuntimeConfiguration", {
- type: "GET",
- dataType: 'json',
- success: function(data){
-
- var archivaRuntimeConfiguration=mapArchivaRuntimeConfiguration(data);
- var archivaRuntimeConfigurationViewModel=new ArchivaRuntimeConfigurationViewModel(archivaRuntimeConfiguration);
- ko.applyBindings(archivaRuntimeConfigurationViewModel,mainContent.find("#cache-failure-form").get(0));
- var validator = mainContent.find("#cache-failure-form-id")
- .validate({
- showErrors: function(validator, errorMap, errorList) {
- customShowError(mainContent.find("#cache-failure-form-id" ),validator,errorMap,errorMap);
- }
- });
- }
- });
-
- }
-
- ArchivaRuntimeConfigurationViewModel=function(archivaRuntimeConfiguration){
- var self=this;
- this.archivaRuntimeConfiguration=ko.observable(archivaRuntimeConfiguration);
-
- save=function(){
- var userMessages=$("#user-messages");
-
- var mainContent=$("#main-content");
-
- if (!mainContent.find("#cache-failure-form-id").valid()){
- return;
- }
- userMessages.html(mediumSpinnerImg());
- mainContent.find("#cache-failure-form-btn-save" ).button('loading');
- $.ajax("restServices/archivaServices/archivaRuntimeConfigurationService/archivaRuntimeConfiguration", {
- type: "PUT",
- contentType: 'application/json',
- data: ko.toJSON(self.archivaRuntimeConfiguration),
- dataType: 'json',
- success: function(data){
- displaySuccessMessage( $.i18n.prop("archiva.runtime-configuration.updated"));
- },
- error:function(){
- displayErrorMessage("error.500");
- }
- } ).always(
- function(){
- removeMediumSpinnerImg(userMessages);
- mainContent.find("#cache-failure-form-btn-save" ).button('reset');
- }
- );
- }
- }
-
- ArchivaRuntimeConfiguration=function(cacheConfiguration){
- this.urlFailureCacheConfiguration=ko.observable(cacheConfiguration);
- }
-
-
- mapArchivaRuntimeConfiguration=function(data){
- if(!data){
- return null;
- }
- return new ArchivaRuntimeConfiguration(data.urlFailureCacheConfiguration?mapCacheConfiguration(data.urlFailureCacheConfiguration):null);
- }
- //---------------------------
- // organisation/appearance configuration part
- //---------------------------
- OrganisationInformation=function(name,url,logoLocation){
- this.name=ko.observable(name);
- this.url=ko.observable(url);
- this.logoLocation=ko.observable(logoLocation);
- }
- mapOrganisationInformation=function(data){
- return new OrganisationInformation(data.name, data.url, data.logoLocation);
- }
- mapOrganisationInformations=function(data){
- if (data!=null){
- return $.isArray(data)? $.map(data, function(item){
- return mapOrganisationInformation(item);
- }):[mapOrganisationInformation(data)];
- }
- }
- activateOrganisationInformationFormValidation=function(){
- var validate = $("#main-content" ).find("#appearance-configuration-form-id")
- .validate({
- rules: {
- name: {
- required: true
- },
- url: {
- required:true,
- url:true
- },
- logoLocation: {
- required:false,
- url:true
- }
- },
- showErrors: function(validator, errorMap, errorList) {
- $.log("activateOrganisationInformationFormValidation#customShowError");
- customShowError($("#main-content" ).find("#appearance-configuration-form-id"), validator, errorMap, errorMap);
- }
- });
- }
- OrganisationInformationViewModel=function(organisationInformation){
-
- this.organisationInformation=ko.observable(organisationInformation);
-
- this.save=function(){
- $.log("OrganisationInformationViewModel#save");
- var mainContent=$("#main-content" );
- if (!mainContent.find("#appearance-configuration-form-id").valid()) {
- return;
- }
- clearUserMessages();
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- mainContent.find("#appearance-configuration-btn-save" ).button('loading');
- $.ajax("restServices/archivaServices/archivaAdministrationService/setOrganisationInformation", {
- type: "POST",
- contentType: "application/json",
- data: ko.toJSON(this.organisationInformation),
- dataType: "json",
- success: function(data){
- displaySuccessMessage($.i18n.prop('appearance-configuration.updated'));
- updateAppearanceToolBar();
- },
- error: function(data){
- displayErrorMessage($.i18n.prop('appearance-configuration.updating-error'));
- },
- complete: function(){
- removeMediumSpinnerImg(userMessages);
- mainContent.find("#appearance-configuration-btn-save" ).button('reset');
- }
- });
- }
- }
-
-
- //---------------------------
- // UiConfiguration part
- //---------------------------
-
- UiConfiguration=function(showFindArtifacts,appletFindEnabled,disableEasterEggs,applicationUrl,disableRegistration){
- this.showFindArtifacts = ko.observable(showFindArtifacts);
-
- this.appletFindEnabled = ko.observable(appletFindEnabled);
-
- this.disableEasterEggs = ko.observable(disableEasterEggs);
-
- this.applicationUrl = ko.observable(applicationUrl);
-
- // default to false
- this.disableRegistration = ko.observable(disableRegistration?disableRegistration:false);
- }
-
- UiConfigurationViewModel=function(uiConfiguration){
- this.uiConfiguration=ko.observable(uiConfiguration);
- var self=this;
- save=function(){
- var mainContent=$("#main-content" );
- var userMessages=$("#user-messages");
- userMessages.html( mediumSpinnerImg());
- mainContent.find("#ui-configuration-btn-save" ).button('loading');
- $.ajax("restServices/archivaServices/archivaAdministrationService/setUiConfiguration", {
- type: "POST",
- contentType: 'application/json',
- data: ko.toJSON(self.uiConfiguration),
- dataType: 'json',
- success: function(data){
- displaySuccessMessage( $.i18n.prop("ui-configuration.updated"));
- },
- complete: function(){
- removeMediumSpinnerImg(userMessages);
- mainContent.find("#ui-configuration-btn-save" ).button('reset');
- }
- });
- }
- }
-
- displayUiConfiguration=function(){
- var mainContent=$("#main-content");
-
- mainContent.html($("#ui-configuration" ).tmpl());
-
- mainContent.find("#ui-configuration-form").html(mediumSpinnerImg());
-
- $.ajax("restServices/archivaServices/archivaAdministrationService/getUiConfiguration", {
- type: "GET",
- dataType: 'json',
- success: function(data){
- var uiConfiguration=new UiConfiguration(data.showFindArtifacts,data.appletFindEnabled,data.disableEasterEggs,
- data.applicationUrl,data.disableRegistration);
- var uiConfigurationViewModel=new UiConfigurationViewModel(uiConfiguration);
- ko.applyBindings(uiConfigurationViewModel,mainContent.find("#ui-configuration-form").get(0));
- }
- });
-
- $.ajax("restServices/archivaServices/archivaAdministrationService/getOrganisationInformation", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- var organisationInformation=new OrganisationInformation(data.name,data.url,data.logoLocation);
- var organisationInformationViewModel=new OrganisationInformationViewModel(organisationInformation);
- ko.applyBindings(organisationInformationViewModel, mainContent.find("#change-appearance-form").get(0));
- activateOrganisationInformationFormValidation();
- }
- });
- }
-
- //---------------------------
- // System status part
- //---------------------------
-
- QueueEntry=function(key,entriesNumber){
- this.key=key;
- this.entriesNumber=entriesNumber;
- }
-
-
- mapQueueEntries=function(data){
- if (data!=null){
- return $.map(data,function(item){
- return new QueueEntry(item.key,item.entriesNumber);
- })
- }
- return [];
- }
-
- CacheEntry=function(key,size,cacheHits,cacheMiss,cacheHitRate,inMemorySize){
- this.key=key;
- this.size=size;
- this.cacheHits=cacheHits;
- this.cacheMiss=cacheMiss;
- this.cacheHitRate=cacheHitRate;
- this.inMemorySize=inMemorySize;
- }
-
- mapCacheEntries=function(data){
- if(data!=null){
- return $.map(data,function(item){
- return new CacheEntry(item.key,item.size,item.cacheHits,item.cacheMiss,item.cacheHitRate,item.inMemorySize);
- })
- }
- return [];
- }
-
-
-
- displayCacheEntries=function(){
- var divContent = $("#main-content" ).find("#status_caches");
- divContent.html(smallSpinnerImg());
- $.ajax("restServices/archivaServices/systemStatusService/cacheEntries", {
- type: "GET",
- success: function(data){
- var cacheEntries=mapCacheEntries(data);
- divContent.html($("#status_caches_tmpl" ).tmpl({cacheEntries: cacheEntries}));
- }
- });
- }
-
- flushCache=function(key){
- clearUserMessages();
- $("#main-content" ).find("#status_caches").html(smallSpinnerImg());
- $.ajax("restServices/archivaServices/systemStatusService/clearCache/"+encodeURIComponent(key), {
- type: "GET",
- success: function(data){
- displaySuccessMessage( $.i18n.prop("system-status.caches.flushed",key));
- displayCacheEntries();
- }
- });
- }
-
- flushAllCaches=function(){
- clearUserMessages();
- $("#main-content" ).find("#status_caches").html(smallSpinnerImg());
- $.ajax("restServices/archivaServices/systemStatusService/clearAllCaches", {
- type: "GET",
- success: function(data){
- displaySuccessMessage( $.i18n.prop("system-status.caches.all.flushed"));
- displayCacheEntries();
- }
- });
- }
-
- mapRepositoryScannerStatisticsList=function(data){
- if(data!=null){
- return $.isArray(data)? $.map(data,function(item){
- return mapRepositoryScannerStatistics(item);
- }):[data];
- }
- return [];
- }
-
-
- mapRepositoryScannerStatistics=function(data){
- return new RepositoryScannerStatistics(mapManagedRepository(data.managedRepository),data.totalFileCount,
- data.newFileCount,data.consumerScanningStatistics);
- }
-
- RepositoryScannerStatistics=function(managedRepository,totalFileCount,newFileCount,consumerScanningStatisticsList){
- //private ManagedRepository managedRepository;
- this.managedRepository=managedRepository
-
- this.consumerScanningStatisticsList= consumerScanningStatisticsList;
-
- //private long totalFileCount = 0;
- this.totalFileCount=totalFileCount;
-
- //private long newFileCount = 0;
- this.newFileCount=newFileCount;
- }
-
- displayScanningStats=function(){
- var divContent = $("#main-content" ).find("#status_scanning");
- divContent.html(smallSpinnerImg());
- $.ajax("restServices/archivaServices/systemStatusService/repositoryScannerStatistics", {
- type: "GET",
- success: function(data){
- var stats= mapRepositoryScannerStatisticsList(data);
- $.log("size:"+data.length);
- divContent.html($("#status_scanning_tmpl").tmpl({repositoryScannerStatisticsList:stats}));
- }
- });
- }
-
- displayMemoryUsage=function(){
- var divContent = $("#main-content" ).find("#status_memory_info");
- divContent.html(smallSpinnerImg());
- $.ajax("restServices/archivaServices/systemStatusService/memoryStatus", {
- type: "GET",
- dataType: "text",
- success: function(data){
- var memUsage = data;
- $.log("memUsage:"+memUsage);
- divContent.html(memUsage);
- }
- });
- }
-
- displayQueueEntries=function(){
- var divContent = $("#main-content" ).find("#status_queues");
- divContent.html(smallSpinnerImg());
- $.ajax("restServices/archivaServices/systemStatusService/queueEntries", {
- type: "GET",
- success: function(data){
- var queueEntries=mapQueueEntries(data);
- divContent.html($("#status_queues_tmpl" ).tmpl({queueEntries: queueEntries}));
- }
- });
- }
-
- displayServerTime=function(){
- var divContent = $("#main-content" ).find("#status_current_time");
- divContent.html(smallSpinnerImg());
- $.ajax("restServices/archivaServices/systemStatusService/currentServerTime/"+encodeURIComponent(usedLang()), {
- type: "GET",
- dataType: "text",
- success: function(data){
- var curTime=data;
- $.log("currentServerTime:"+curTime);
- divContent.html(curTime);
- }
- });
- }
-
- displaySystemStatus=function(){
- screenChange();
- var mainContent=$("#main-content");
- mainContent.html($("#system-status-main").tmpl());
-
- var versionInfo=window.archivaRuntimeInfo.version+" - "
- +$.i18n.prop('system-status.header.version.buildNumber')+": "+window.archivaRuntimeInfo.buildNumber
- +" - "+$.i18n.prop('system-status.header.version.timestampStr')+": "+window.archivaRuntimeInfo.timestampStr;
- mainContent.find("#status_version_info").html(versionInfo);
-
- displayMemoryUsage();
-
- displayServerTime();
-
- displayQueueEntries();
-
- displayScanningStats();
-
- displayCacheEntries();
- }
-
- refreshSystemStatus=function(){
- displayCacheEntries();
- displayScanningStats();
- displayMemoryUsage();
- displayQueueEntries();
- displayServerTime();
- }
-
- //---------------------------
- // report configuration page
- //---------------------------
- StatisticsReportRequest=function() {
- this.repositories = ko.observableArray( [] );
- this.rowCount = ko.observable(100);
- this.startDate = ko.observable();
- this.endDate = ko.observable();
- }
-
- reportStatisticsFormValidator=function(){
- $.log("reportStatisticsFormValidator");
- var validate = $("#main-content" ).find("#report-statistics-form-id").validate({
- rules: {
- rowCountStatistics: {
- required:true,
- number: true,
- min: 10
- },
- startDate: {
- date: true
- },
- endDate: {
- date: true
- }
- },
- showErrors: function(validator, errorMap, errorList) {
- $.log("showErrors");
- customShowError("#main-content #report-statistics-form-id", validator, errorMap, errorMap);
- }
- })
- }
- ReportStatisticsViewModel=function(repositoriesAvailable){
- var mainContent=$("#main-content");
- reportStatisticsFormValidator();
-
- var self=this;
- this.availableRepositories = ko.observableArray( repositoriesAvailable );
- this.statisticsReport = ko.observable( new StatisticsReportRequest() );
-
- mainContent.find("#startDate" ).datepicker();
- mainContent.find("#endDate" ).datepicker();
- mainContent.find("#rowcount-info-button" ).popover();
-
- this.showStatistics=function() {
- $.log("showStatistics");
- clearUserMessages( "repositoriesErrorMessage" );
- if (!mainContent.find("#report-statistics-form-id").valid()) {
- return;
- }
- if(this.statisticsReport().repositories().length==0){
- displayErrorMessage( $.i18n.prop('report.statistics.repositories.required'), "repositoriesErrorMessage" );
- return;
- }
-
- var resultTabContent = mainContent.find("#report-result");
-
- url = "restServices/archivaServices/reportServices/getStatisticsReport/?rowCount="
- + this.statisticsReport().rowCount();
-
- for(var i=0;i<this.statisticsReport().repositories().length;i++){
- url += "&repository=" + this.statisticsReport().repositories()[i];
- }
-
- if(this.statisticsReport().startDate()!=null){
- url += "&startDate=" + this.statisticsReport().startDate();
- }
- if(this.statisticsReport().endDate()!=null){
- url += "&endDate=" + this.statisticsReport().endDate();
- }
-
- $.ajax(url, {
- type: "GET",
- contentType: 'application/json',
- dataType: 'json',
- success: function(data){
- resultTabContent.html( $( "#report-statistics" ).tmpl() );
- var reportStatistics = new ReportStatisticsResultViewModel( data );
- ko.applyBindings( reportStatistics, resultTabContent.get( 0 ) );
- var reportResultTabLi=$( "#report-result-tab-li");
- reportResultTabLi.removeClass( "hide" );
- reportResultTabLi.addClass( "active" );
- $( "#report-stat-tab-li" ).removeClass( "active" );
- $( "#report-stat-tab-content" ).removeClass( "active" );
- resultTabContent.addClass( "active" );
- },
- error: function(data){
- var res = $.parseJSON(data.responseText);
- displayErrorMessage($.i18n.prop(res.errorMessage));
- }
- });
- }
- }
- ReportStatisticsResultViewModel=function(report){
- this.reports = ko.observableArray( report );
- var self = this;
-
- this.tableReportViewModel = new ko.simpleGrid.viewModel({
- data: this.reports,
- viewModel: this,
- columns: [
- { headerText: "Repository ID", rowText: "repositoryId" },
- { headerText: "Start Date", rowText: function(item){return new Date(item.scanStartTime);}},
- { headerText: "Total File Count", rowText: "totalFileCount" },
- { headerText: "Total Size", rowText: "totalArtifactFileSize" },
- { headerText: "Artifact Count", rowText: "totalArtifactCount" },
- { headerText: "Group Count", rowText: "totalGroupCount" },
- { headerText: "Project Count", rowText: "totalProjectCount" },
- { headerText: "Archetypes", rowText: function (item) { return !item.totalCountForType.pom || item.totalCountForType.pom === "" ? "0" : item.totalCountForType.pom } },
- { headerText: "Jars", rowText: function (item) { return !item.totalCountForType.war || item.totalCountForType.jar === "" ? "0" : item.totalCountForType.jar } },
- { headerText: "Wars", rowText: function (item) { return !item.totalCountForType.war || item.totalCountForType.war === "" ? "0" : item.totalCountForType.jar } },
- { headerText: "Ears", rowText: function (item) { return !item.totalCountForType.ear || item.totalCountForType.ear === "" ? "0" : item.totalCountForType.ear } },
- { headerText: "Exes", rowText: function (item) { return !item.totalCountForType.exe || item.totalCountForType.exe === "" ? "0" : item.totalCountForType.exe } },
- { headerText: "Dlls", rowText: function (item) { return !item.totalCountForType.dll || item.totalCountForType.dll === "" ? "0" : item.totalCountForType.dll} },
- { headerText: "Zips", rowText: function (item) { return !item.totalCountForType.zip || item.totalCountForType.zip === "" ? "0" : item.totalCountForType.zip } }
- ],
- pageSize: 10
- });
- }
-
- HealthReportRequest=function(){
- this.repositoryId = ko.observable();
- this.rowCount = ko.observable(100);
- this.groupId = ko.observable();
- }
- HealthReportResult=function(repositoryId,namespace,project,version,id,message,problem,name,facetId){
- this.repositoryId = repositoryId;
- this.namespace = namespace;
- this.project = project;
- this.version = version;
- this.id = id;
- this.message = message;
- this.problem = problem;
- this.name = name;
- this.facetId = facetId;
- }
- mapHealthReportResult=function(data){
- if(data==null) return;
- return new HealthReportResult( data.repositoryId, data.namespace, data.project, data.version, data.id, data.message,
- data.problem, data.name, data.facetId );
- }
- mapHealthReportResults=function(data){
- if (data != null)
- {
- return $.isArray(data)? $.map(data, function(item){
- return mapHealthReportResult(item);
- }):[mapHealthReportResult(data)];
- }
- return [];
- }
- ReportHealthResultViewModel=function(report){
- this.reports = ko.observableArray( report );
- var self = this;
- this.tableReportViewModel = new ko.simpleGrid.viewModel({
- data: this.reports,
- viewModel: this,
- columns: [
- { headerText: "ID", rowText: "id" },
- { headerText: "Namespace", rowText: "namespace" },
- { headerText: "Project", rowText: "project" },
- { headerText: "Version", rowText: "version" },
- { headerText: "Name", rowText: "name" },
- { headerText: "Problem", rowText: "problem" },
- { headerText: "Message", rowText: "message" }
- ],
- pageSize: 10
- });
- }
-
- reportHealthFormValidator=function(){
- var validate = $("#main-content" ).find("#report-health-form-id").validate({
- rules: {
- rowCountHealth: {
- required: true,
- number: true,
- min: 10
- },
- repositoryId: {
- required: true
- }
- },
- showErrors: function(validator, errorMap, errorList) {
- customShowError("#main-content #report-health-form-id", validator, errorMap, errorMap);
- }
- })
- }
- ReportHealthViewModel=function(){
- reportHealthFormValidator();
- this.healthReport = ko.observable(new HealthReportRequest());
-
- this.showHealth=function() {
- if (!$("#main-content" ).find("#report-health-form-id").valid()) {
- return;
- }
-
- var resultTabContent = $("#main-content" ).find("#report-result");
-
- var url =
- "restServices/archivaServices/reportServices/getHealthReports/" + this.healthReport().repositoryId() + "/"
- + this.healthReport().rowCount();
-
- if (this.healthReport().groupId())
- {
- url += "?groupId=" + this.healthReport().groupId();
- }
-
- $.ajax(url, {
- type: "GET",
- contentType: 'application/json',
- dataType: 'json',
- success: function(data){
- var reports = new ReportHealthResultViewModel( mapHealthReportResults( data ) );
- resultTabContent.html( $( "#report-health" ).tmpl() );
- ko.applyBindings( reports, resultTabContent.get( 0 ) );
- var reportResultTabLi=$( "#report-result-tab-li" );
- reportResultTabLi.removeClass( "hide" );
- reportResultTabLi.addClass( "active" );
- $( "#report-health-tab-li" ).removeClass( "active" );
- $( "#report-health-tab-content" ).removeClass( "active" );
- resultTabContent.addClass( "active" );
- },
- error: function(data){
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- }
- });
- }
- }
-
- displayReportsPage=function(){
- screenChange();
- clearUserMessages();
- var mainContent = $("#main-content");
- mainContent.html(mediumSpinnerImg());
- $.ajax("restServices/archivaServices/searchService/observableRepoIds", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- var repos = mapStringList( data );
- mainContent.html( $( "#report-base" ).tmpl( {repositoriesList:repos} ) );
- var statisticsReportViewModel = ReportStatisticsViewModel( repos );
- var healthReportViewModel = ReportHealthViewModel( );
- ko.applyBindings( statisticsReportViewModel, mainContent.get( 0 ) );
- ko.applyBindings( healthReportViewModel, mainContent.get( 0 ) );
- }
- });
- }
-
-
- RedbackRuntimeConfiguration=function(userManagerImpls,ldapConfiguration,migratedFromRedbackConfiguration,configurationPropertiesEntries
- ,useUsersCache,cacheConfiguration,rbacManagerImpls){
- $.log("new RedbackRuntimeConfiguration");
- var self=this;
- this.modified=ko.observable(false);
- this.modified.subscribe(function(newValue){$.log("RedbackRuntimeConfiguration modified")});
-
- this.userManagerImpls=ko.observableArray(userManagerImpls);
- this.userManagerImpls.subscribe(function(newValue){self.modified(true)});
-
- this.rbacManagerImpls=ko.observableArray(rbacManagerImpls);
- this.rbacManagerImpls.subscribe(function(newValue){self.modified(true)});
-
- this.ldapConfiguration=ko.observable(ldapConfiguration);
- this.ldapConfiguration.subscribe(function(newValue){self.modified(true)});
-
- this.migratedFromRedbackConfiguration=ko.observable(migratedFromRedbackConfiguration);
-
- this.configurationPropertiesEntries=ko.observableArray(configurationPropertiesEntries?configurationPropertiesEntries:[]);
- this.configurationPropertiesEntries.subscribe(function(newValue){
- self.modified(true);
- $.log("configurationPropertiesEntries modified")
- });
-
- this.findPropertyValue=function(key){
- for(var i=0;i<self.configurationPropertiesEntries().length;i++){
- if(self.configurationPropertiesEntries()[i].key==key){
- var val = self.configurationPropertiesEntries()[i].value;
- $.log("findPropertyValue " + key + "->" + val);
- return val;
- }
- }
- }
-
- this.useUsersCache=ko.observable(useUsersCache);
- this.useUsersCache.subscribe(function(newValue){self.modified(true)});
-
- this.usersCacheConfiguration=ko.observable(cacheConfiguration);
- this.usersCacheConfiguration.subscribe(function(newValue){self.modified(true)});
-
- this.ldapGroups=ko.observableArray([]);
- this.ldapGroups.subscribe(function(newValue){self.modified(true)});
-
- this.ldapGroupMappings=ko.observableArray([]);
- this.ldapGroupMappings.subscribe(function(newValue){
- self.modified(true);
- $.log('ldapGroupMappings modified:'+newValue.group);
- });
-
- }
-
- mapRedbackRuntimeConfiguration=function(data){
-
- var ldapConfiguration=mapLdapConfiguration(data.ldapConfiguration);
-
- var redbackRuntimeConfiguration =
- new RedbackRuntimeConfiguration(data.userManagerImpls,ldapConfiguration,data.migratedFromRedbackConfiguration,[]
- ,data.useUsersCache,mapCacheConfiguration(data.usersCacheConfiguration),data.rbacManagerImpls);
-
- $.log("redbackRuntimeConfiguration.rbacManagerImpls:"+redbackRuntimeConfiguration.rbacManagerImpls().length);
- var configurationPropertiesEntries = data.configurationPropertiesEntries == null ? []: $.each(data.configurationPropertiesEntries,function(item){
- var entry = new Entry(item.key, item.value,function(newValue){
- redbackRuntimeConfiguration.modified(true);
- });
- return entry;
- });
-
- if (!$.isArray(configurationPropertiesEntries)){
- configurationPropertiesEntries=[];
- }
-
- redbackRuntimeConfiguration.configurationPropertiesEntries(configurationPropertiesEntries);
- redbackRuntimeConfiguration.modified(false);
- return redbackRuntimeConfiguration;
-
- }
-
- LdapConfiguration=function(hostName,port,ssl,baseDn,baseGroupsDn,contextFactory,bindDn,password,authenticationMethod,
- extraPropertiesEntries,writable,useRoleNameAsGroup,bindAuthenticatorEnabled){
-
- var self=this;
- this.modified=ko.observable(false);
-
- //private String hostName;
- this.hostName=ko.observable(hostName);
- this.hostName.subscribe(function(newValue){self.modified(true)});
-
- //private String port;
- this.port=ko.observable(port);
- this.port.subscribe(function(newValue){self.modified(true)});
-
- //private boolean ssl = false;
- this.ssl=ko.observable(ssl);
- this.ssl.subscribe(function(newValue){self.modified(true)});
-
- //private String baseDn;
- this.baseDn=ko.observable(baseDn);
- this.baseDn.subscribe(function(newValue){self.modified(true)});
-
- //private String baseGroupsDn;
- this.baseGroupsDn=ko.observable(baseGroupsDn);
- this.baseGroupsDn.subscribe(function(newValue){self.modified(true)});
-
- //private String contextFactory;
- this.contextFactory=ko.observable(contextFactory);
- this.contextFactory.subscribe(function(newValue){self.modified(true)});
-
- //private String bindDn;
- this.bindDn=ko.observable(bindDn);
- this.bindDn.subscribe(function(newValue){self.modified(true)});
-
- //private String password;
- this.password=ko.observable(password);
- this.password.subscribe(function(newValue){self.modified(true)});
-
- //private String authenticationMethod;
- this.authenticationMethod=ko.observable(authenticationMethod);
- this.authenticationMethod.subscribe(function(newValue){self.modified(true)});
-
- this.extraPropertiesEntries=ko.observableArray(extraPropertiesEntries);
- this.extraPropertiesEntries.subscribe(function(newValue){self.modified(true)});
-
- //private boolean writable = false;
- this.writable=ko.observable(writable);
- this.writable.subscribe(function(newValue){self.modified(true)});
-
- // useRoleNameAsGroup
- this.useRoleNameAsGroup=ko.observable(useRoleNameAsGroup);
- this.useRoleNameAsGroup.subscribe(function(newValue){self.modified(true)});
-
- //bindAuthenticatorEnabled
- this.bindAuthenticatorEnabled=ko.observable(bindAuthenticatorEnabled);
- this.bindAuthenticatorEnabled.subscribe(function(newValue){self.modified(true)});
-
- }
-
- mapLdapConfiguration=function(data){
- $.log("mapLdapConfiguration");
- if(data){
- var extraPropertiesEntries = data.extraPropertiesEntries == null ? []: $.each(data.extraPropertiesEntries,function(item){
- return new Entry(item.key, item.value);
- });
- if (!$.isArray(extraPropertiesEntries)){
- extraPropertiesEntries=[];
- }
- $.log("mapLdapConfiguration done");
- return new LdapConfiguration(data.hostName,data.port,data.ssl,data.baseDn,data.baseGroupsDn,data.contextFactory,data.bindDn,data.password,
- data.authenticationMethod,extraPropertiesEntries,data.writable,data.useRoleNameAsGroup,data.bindAuthenticatorEnabled);
- }
- return null;
- }
-
- RedbackRuntimeConfigurationViewModel=function(redbackRuntimeConfiguration,userManagerImplementationInformations,rbacManagerImplementationInformations){
- var self=this;
- this.redbackRuntimeConfiguration=ko.observable(redbackRuntimeConfiguration);
- this.userManagerImplementationInformations=ko.observableArray(userManagerImplementationInformations);
- this.rbacManagerImplementationInformations=ko.observableArray(rbacManagerImplementationInformations);
-
- this.usedUserManagerImpls=ko.observableArray([]);
-
- this.usedRbacManagerImpls=ko.observableArray([]);
-
- this.modifiesLdapGroupMappings=ko.observableArray([]);
-
- this.availableUserManagerImpls=ko.observableArray([]);
- this.availableRbacManagerImpls=ko.observableArray([]);
-
- this.allRoleNames=ko.observableArray([]);
-
- findUserManagerImplementationInformation=function(id){
- for(var i= 0;i<self.userManagerImplementationInformations().length;i++){
- $.log(id+""+self.userManagerImplementationInformations()[i].beanId);
- if(id==self.userManagerImplementationInformations()[i].beanId){
- return self.userManagerImplementationInformations()[i];
- }
- }
- }
-
- findRbacManagerImplementationInformation=function(id){
- for(var i= 0;i<self.rbacManagerImplementationInformations().length;i++){
- $.log(id+""+self.rbacManagerImplementationInformations()[i].beanId);
- if(id==self.rbacManagerImplementationInformations()[i].beanId){
- return self.rbacManagerImplementationInformations()[i];
- }
- }
- }
-
- checkLdapServerConfiguration=function(){
- $.log("checkLdapServerConfiguration");
- clearUserMessages();
- var btn = $("#ldap-configuration-check-server");
- btn.button('loading');
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- $.log("checkChangedLdapConfiguration");
- $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/checkLdapConnection",
- {
- type: "GET",
- success: function(data) {
- var message=$.i18n.prop('redback.runtime.ldap.verified');
- displaySuccessMessage(message);
- },
- error: function(data) {
- try{
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- }catch (e){
- displayErrorMessage( $.i18n.prop("error.500"));
- }
-
- }
- }
- ).always(
- function(data){
- removeMediumSpinnerImg(userMessages);
- btn.button('reset');
- }
- );
- }
-
- checkChangedLdapConfiguration=function(){
- clearUserMessages();
- var btn = $("#ldap-configuration-check-modification");
- btn.button('loading');
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- $.log("checkChangedLdapConfiguration");
- $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/checkLdapConnection",
- {
- type: "POST",
- contentType: 'application/json',
- data:ko.toJSON(self.redbackRuntimeConfiguration().ldapConfiguration),
- dataType: 'json',
- success: function(data) {
- var message=$.i18n.prop('redback.runtime.ldap.verified');
- displaySuccessMessage(message);
- },
- error: function(data) {
- try{
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- }catch (e){
- displayErrorMessage( $.i18n.prop("error.500"));
- }
- }
- }
- ).always(
- function(data){
- removeMediumSpinnerImg(userMessages);
- btn.button('reset');
- }
- );
- }
-
- for(var i= 0;i<redbackRuntimeConfiguration.userManagerImpls().length;i++){
- var id=redbackRuntimeConfiguration.userManagerImpls()[i];
-
- var userManagerImplementationInformation=findUserManagerImplementationInformation(id);
-
- if(userManagerImplementationInformation!=null){
- this.usedUserManagerImpls.push(userManagerImplementationInformation);
- }
- }
-
- $.log("init usedUserManagerImpls done");
-
- for(var i= 0;i<redbackRuntimeConfiguration.rbacManagerImpls().length;i++){
- var id=redbackRuntimeConfiguration.rbacManagerImpls()[i];
-
- var rbacManagerImplementationInformation=findRbacManagerImplementationInformation(id);
-
- if(rbacManagerImplementationInformation!=null){
- this.usedRbacManagerImpls.push(rbacManagerImplementationInformation);
- }
- }
-
- $.log("init usedUserManagerImpls done");
-
- isUsedUserManagerImpl=function(userManagerImplementationInformation){
- for(var i=0;i<self.usedUserManagerImpls().length;i++){
- if(self.usedUserManagerImpls()[i].beanId==userManagerImplementationInformation.beanId){
- return true;
- }
- }
- return false;
- }
-
- for(var i=0;i<self.userManagerImplementationInformations().length;i++){
- if(!isUsedUserManagerImpl(self.userManagerImplementationInformations()[i])){
- self.availableUserManagerImpls.push(self.userManagerImplementationInformations()[i]);
- }
- }
-
- userManagerImplMoved=function(arg){
- $.log("userManagerImplMoved");
- self.redbackRuntimeConfiguration().modified(true);
- }
-
- isUsedRbacManagerImpl=function(rbacManagerImplementationInformation){
- for(var i=0;i<self.usedRbacManagerImpls().length;i++){
- if(self.usedRbacManagerImpls()[i].beanId==rbacManagerImplementationInformation.beanId){
- return true;
- }
- }
- return false;
- }
-
-
-
- for(var i=0;i<self.rbacManagerImplementationInformations().length;i++){
- if(!isUsedRbacManagerImpl(self.rbacManagerImplementationInformations()[i])){
- self.availableRbacManagerImpls.push(self.rbacManagerImplementationInformations()[i]);
- }
- }
-
- rbacManagerImplMoved=function(arg){
- $.log("rbacManagerImplMoved");
- self.redbackRuntimeConfiguration().modified(true);
- }
-
- saveRedbackRuntimeConfiguration=function(){
-
- var mainContent=$("#main-content");
- var valid = mainContent.find("#redback-runtime-general-form-id").valid();
- if (valid==false) {
- return;
- }
- var useLdap = false;
- for(var i=0;i<self.usedUserManagerImpls().length;i++){
- var beanId=self.usedUserManagerImpls()[i].beanId;
- $.log("beanId:"+beanId);
- if(beanId=='ldap'){
- useLdap=true;
- }
- }
- $.log("useLdap:"+useLdap);
- if(useLdap==true) {
- valid = mainContent.find("#redback-runtime-ldap-form-id").valid();
- $.log("ldap valid:"+valid);
- if (valid==false) {
- return;
- }
- }
-
- clearUserMessages();
-
- if (self.usedUserManagerImpls().length<1){
- displayErrorMessage( $.i18n.prop("error.redback.runtimeconfiguration.user-managers.empty"));
- valid=false;
- }
-
- if (self.usedRbacManagerImpls().length<1){
- displayErrorMessage( $.i18n.prop("error.redback.runtimeconfiguration.rbac-managers.empty"));
- valid=false;
- }
-
- if(valid==false){
- return;
- }
-
- $.log("saveRedbackRuntimeConfiguration");
- var saveButton = mainContent.find("#redback-runtime-configuration-save" );
- saveButton.button('loading');
- clearUserMessages();
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
-
- self.redbackRuntimeConfiguration().userManagerImpls=ko.observableArray([]);
-
- for(var i=0;i<self.usedUserManagerImpls().length;i++){
- var beanId=self.usedUserManagerImpls()[i].beanId;
- $.log("beanId:"+beanId);
- self.redbackRuntimeConfiguration().userManagerImpls.push(beanId);
- }
-
-
- self.redbackRuntimeConfiguration().rbacManagerImpls=ko.observableArray([]);
-
- for(var i=0;i<self.usedRbacManagerImpls().length;i++){
- var beanId=self.usedRbacManagerImpls()[i].beanId;
- $.log("beanId:"+beanId);
- self.redbackRuntimeConfiguration().rbacManagerImpls.push(beanId);
- }
-
-
- $.log("rememberme enabled:"+self.redbackRuntimeConfiguration().findPropertyValue("security.rememberme.enabled"));
- $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/redbackRuntimeConfiguration",
- {
- type: "PUT",
- contentType: 'application/json',
- data:ko.toJSON(self.redbackRuntimeConfiguration),
- dataType: 'json',
- success: function(data) {
- var message=$.i18n.prop('redback-runtime-configuration.updated');
- window.sammyArchivaApplication.runRoute("get","#redbackruntimeconfig");
- displaySuccessMessage(message);
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- }
- }
- ).always(
- function(){
- removeMediumSpinnerImg(userMessages);
- saveButton.button('reset');
- self.redbackRuntimeConfiguration().modified(false);
- self.redbackRuntimeConfiguration().ldapConfiguration().modified(false);
- saveModifyLdapGroupMapping();
- }
- );
-
-
-
- }
-
- saveModifyLdapGroupMapping=function(){
- //save modified ldap group mappings if any
- if(self.modifiesLdapGroupMappings().length>0){
- $.log("save modifiesLdapGroupMappings");
- var message=$.i18n.prop('redback-runtime-ldap-group-mapping.updated');
- var userMessages=$("#user-messages");
- var ldapGroupMappings=[];
- $.each(self.modifiesLdapGroupMappings(),function(idx,item){
-
- if(!(item.automatic&item.roleNames().length<2)){
- $.log("update mapping for group:"+item.group());
- ldapGroupMappings.push(item);
- }
- });
-
- if (ldapGroupMappings.length>0){
-
- var mainContent=$("#main-content");
- var saveButton = mainContent.find("#redback-runtime-configuration-save" );
- saveButton.button('loading');
- userMessages.html(mediumSpinnerImg());
- $.ajax("restServices/redbackServices/ldapGroupMappingService",
- {
- type: "POST",
- contentType: 'application/json',
- data:ko.toJSON(new LdapGroupMappingUpdateRequest(ldapGroupMappings)),
- dataType: 'json',
- success: function(data) {
- displaySuccessMessage(message);
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete:function(data){
- removeMediumSpinnerImg(userMessages);
- saveButton.button('reset');
- self.redbackRuntimeConfiguration().modified(false);
- self.redbackRuntimeConfiguration().ldapConfiguration().modified(false);
- }
- }
- );
- }
-
-
- } else {
- $.log("not save modifiesLdapGroupMappings");
- }
- self.modifiesLdapGroupMappings=ko.observableArray([]);
- }
- this.modifiesLdapGroupMappings=ko.observableArray([]);
-
- this.modifyLdapGroupMapping=function(roleNames,ldapGroupMapping){
- var toAdd=true;
- $.each(self.modifiesLdapGroupMappings(),function(idx,item){
- if(item.group()==ldapGroupMapping.group()){
- toAdd=false;
- }
- });
- if(toAdd){
- self.modifiesLdapGroupMappings().push(ldapGroupMapping);
- }
- $.log('modifyLdapGroupMapping:'+ldapGroupMapping.group()+','+self.modifiesLdapGroupMappings().length);
- };
- //olamy could be better but some reason doesn't work and I didn't find enough to understand why :-)
- /*self.gridldapMappingsViewModel = new ko.simpleGrid.viewModel({
- data: self.redbackRuntimeConfiguration().ldapGroupMappings,
- pageSize: 10,
- gridUpdateCallBack: function(){
- $.log("ldapGroupsMapping: gridUpdateCallBack");
- $("#main-content").find("#ldap-group-mappings-div select" ).select2({width: "element"});
- }
- });*/
-
- self.gridViewModel = new ko.simpleGrid.viewModel({
- data: self.redbackRuntimeConfiguration().configurationPropertiesEntries,
- columns: [
- {
- headerText: $.i18n.prop('redback.runtime.properties.key.label'),
- rowText: "key"
- },
- {
- headerText: $.i18n.prop('redback.runtime.properties.value.label'),
- rowText: "value"
- }
- ],
- pageSize: 10,
- gridUpdateCallBack: function(){
- activatePopoverDoc();
- }
- });
-
- this.newLdapGroupMapping=ko.observable(new LdapGroupMapping("",[],false,null));
-
- addLdapGroupMapping=function(){
- // FIXME validate datas from ldapGroupMapping
- $.log("addLdapGroupMapping:"+self.newLdapGroupMapping().group()+",roles:"+self.newLdapGroupMapping().roleNames().length);
- clearUserMessages();
-
- if (self.newLdapGroupMapping().roleNames().length<1){
- displayErrorMessage( $.i18n.prop('redback-runtime-ldap-group-mapping.role.mandatory'));
- return;
- }
-
- var mainContent=$("#main-content");
- var saveButton = mainContent.find("#redback-runtime-configuration-save" );
- saveButton.button('loading');
- clearUserMessages();
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- $.ajax("restServices/redbackServices/ldapGroupMappingService",
- {
- type: "PUT",
- contentType: 'application/json',
- data:ko.toJSON(new LdapGroupMapping(self.newLdapGroupMapping().group(),self.newLdapGroupMapping().roleNames(),false,null)),
- dataType: 'json',
- success: function(data) {
- self.redbackRuntimeConfiguration().ldapGroupMappings
- .unshift(new LdapGroupMapping(self.newLdapGroupMapping().group(),self.newLdapGroupMapping().roleNames(),false,self.modifyLdapGroupMapping));
- $.log("addLdapGroupMapping:"+self.redbackRuntimeConfiguration().ldapGroupMappings().length);
- var message=$.i18n.prop('redback-runtime-ldap-group-mapping.added');
- displaySuccessMessage(message);
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- }
- }
- ).always(
- function(){
- removeMediumSpinnerImg(userMessages);
- $.log("addLdapGroupMapping#always");
- //self.newLdapGroupMapping.group("");
- //self.newLdapGroupMapping.roleNames([]);
- //self.newLdapGroupMapping(new LdapGroupMapping("",[],false,null));
- saveButton.button('reset');
- }
- );
-
-
- }
-
- deleteLdapGroupMapping=function(ldapGroupMapping){
-
-
- var mainContent=$("#main-content");
- var saveButton = mainContent.find("#redback-runtime-configuration-save" );
- saveButton.button('loading');
- clearUserMessages();
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- $.ajax("restServices/redbackServices/ldapGroupMappingService/"+ldapGroupMapping.group(),
- {
- type: "DELETE",
- contentType: 'application/json',
- dataType: 'json',
- success: function(data) {
- $.log("deleteLdapGroupMapping:"+ldapGroupMapping.group());
- self.redbackRuntimeConfiguration().ldapGroupMappings.remove(ldapGroupMapping);
- var message=$.i18n.prop('redback-runtime-ldap-group-mapping.deleted');
- displaySuccessMessage(message);
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- }
- }
- ).always(
- function(){
- removeMediumSpinnerImg(userMessages);
- saveButton.button('reset');
- }
- );
- }
- }
-
- ManagerImplementationInformation=function(beanId,descriptionKey,readOnly){
- this.beanId=beanId;
- this.descriptionKey=descriptionKey;
- this.description= $.i18n.prop(descriptionKey);
- this.readOnly=readOnly;
- }
-
- mapManagerImplementationInformations=function(data){
- return $.map(data, function(item) {
- return mapManagerImplementationInformation(item);
- });
- }
-
- mapManagerImplementationInformation=function(data){
- if(data==null){
- return null;
- }
- return new ManagerImplementationInformation(data.beanId,data.descriptionKey,data.readOnly);
- }
-
- activateRedbackRuntimeGeneralFormValidation=function(){
- var formSelector=$("#main-content" ).find("#redback-runtime-general-form-id");
- var validator = formSelector.validate({
- rules: {
- usersCacheTimeToLiveSeconds : {
- digits: true,
- min: 1,
- required: true
- },
- usersCacheTimeToIdleSeconds : {
- digits: true,
- min: 1,
- required: true
- },
- maxElementsInMemory : {
- digits: true,
- min: 1,
- required: true
- },
- maxElementsOnDisk : {
- digits: true,
- min: 1,
- required: true
- }
- },
- showErrors: function(validator, errorMap, errorList) {
- customShowError(formSelector,validator,errorMap,errorMap);
- }
- });
- }
-
- activateLdapConfigurationFormValidation=function(){
- var formSelector=$("#main-content" ).find("#redback-runtime-ldap-form-id");
- var validator = formSelector.validate({
- rules: {
- ldapHost : {
- required: true
- },
- ldapPort : {
- digits: true,
- min: 1,
- required: true
- }
- },
- showErrors: function(validator, errorMap, errorList) {
- customShowError(formSelector,validator,errorMap,errorMap);
- }
- });
- }
-
- displayRedbackRuntimeConfiguration=function(){
- var jqueryUi = require("jquery.ui");
- $.log("displayRuntimeConfiguration");
- var mainContent = $("#main-content");
- mainContent.html(mediumSpinnerImg());
-
- $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/redbackImplementationsInformations", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- var userManagerImplementationInformations=data?mapManagerImplementationInformations(data.userManagerImplementationInformations):[];
- var rbacManagerImplementationInformations=data?mapManagerImplementationInformations(data.rbacManagerImplementationInformations):[];
- $.log("rbacManagerImplementationInformations:"+rbacManagerImplementationInformations.length);
- $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/redbackRuntimeConfiguration", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- var redbackRuntimeConfiguration = mapRedbackRuntimeConfiguration(data);
- $.log("before new RedbackRuntimeConfigurationViewModel");
- var redbackRuntimeConfigurationViewModel =
- new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations,rbacManagerImplementationInformations);
-
- var groups=[];
- $.log("before useLdap:"+$.inArray("ldap",redbackRuntimeConfiguration.userManagerImpls())
- +','+$.inArray("ldap",redbackRuntimeConfiguration.rbacManagerImpls()));
- var useLdap = $.inArray("ldap",redbackRuntimeConfiguration.userManagerImpls())>=0
- ||$.inArray("ldap",redbackRuntimeConfiguration.rbacManagerImpls())>=0;
- $.log("useLdap:"+useLdap);
- if(useLdap){
- $.log("in get ldap groups");
-
- // load ldap roles
- $.ajax("restServices/redbackServices/ldapGroupMappingService/ldapGroups", {
- type: "GET",
- dataType: 'json',
- success: function(data){
- groups = mapStringList(data);
- $.log("groups number:"+groups.length);
- redbackRuntimeConfiguration.ldapGroups=ko.observableArray(groups);
- }
- } )
- .always(
- function() {
- $.log("complete");
-
- // load ldap group mappings if any
- $.ajax("restServices/redbackServices/ldapGroupMappingService", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- var groupMappings=mapLdapGroupMappings(data,redbackRuntimeConfigurationViewModel.modifyLdapGroupMapping);
-
- $.ajax("restServices/redbackServices/roleManagementService/allRoles", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- displayRuntimeConfigurationScreen(redbackRuntimeConfigurationViewModel,data,groupMappings,groups);
- }
- });
- }
- });
- }
- );
- } else {
- $.log("before displayRuntimeConfigurationScreen");
- displayRuntimeConfigurationScreen(redbackRuntimeConfigurationViewModel,null,null);
- }
- }
- });
-
- }
- });
-
- }
-
- displayRuntimeConfigurationScreen=function(redbackRuntimeConfigurationViewModel,allRoles,groupMappings,groups){
- var allRoleNames = $.map(allRoles?allRoles:[], function(item) {
- return item.name;
- });
-
- redbackRuntimeConfigurationViewModel.allRoleNames=ko.observableArray(allRoleNames);
-
- if (redbackRuntimeConfigurationViewModel.redbackRuntimeConfiguration().ldapConfiguration().useRoleNameAsGroup()&&groups) {
- // if using groups == roles add all as mapping except already mapped
- $.each(groups,function(idx,item){
- var exists=false;
- // avoid duplicate if mapping really exists !
- $.each(groupMappings,function(idx2,groupMapping){
- if(groupMapping.group()==item){
- exists=true;
- }
- });
- if(!exists){
- groupMappings.push(new LdapGroupMapping(item,[item],true,redbackRuntimeConfigurationViewModel.modifyLdapGroupMapping));
- }
-
- });
- }
-
- redbackRuntimeConfigurationViewModel.redbackRuntimeConfiguration().ldapGroupMappings=ko.observableArray(groupMappings?groupMappings:[]);
- redbackRuntimeConfigurationViewModel.redbackRuntimeConfiguration().modified(false);
-
- $("#main-content").html( $("#redback-runtime-configuration-main" ).tmpl() );
- $.log("applyBindings:#redback-runtime-configuration-content:"+redbackRuntimeConfigurationViewModel.redbackRuntimeConfiguration().ldapGroupMappings().length);
- ko.applyBindings(redbackRuntimeConfigurationViewModel,$("#redback-runtime-configuration-content" ).get(0));
- activateRedbackRuntimeGeneralFormValidation();
- activateLdapConfigurationFormValidation();
- }
-
- LdapGroupMapping=function(group,roleNames,automatic,subscribeFn){
- var self=this;
- this.modified=ko.observable(false);
- //private String group;
- this.group=ko.observable(group);
- this.group.subscribe(function(newValue){
- self.modified(true);
- if(subscribeFn){
- subscribeFn(newValue,self)
- }
- });
-
- //private Collection<String> roleNames;
- this.roleNames=ko.observableArray(roleNames);
- this.roleNames.subscribe(function(newValue){
- self.modified(true);
- $.log("roleNames modified");
- if(subscribeFn){
- subscribeFn(newValue,self);
- }
- });
-
- this.automatic=automatic?automatic:false;
- this.update=true;
- }
-
- LdapGroupMappingUpdateRequest=function(ldapGroupMappings){
- this.ldapGroupMappings=ko.observableArray(ldapGroupMappings?ldapGroupMappings:[]);
- }
-
- mapLdapGroupMappings=function(data,modifyLdapGroupMapping){
- if(data!=null){
- return $.map(data,function(item){
- return new LdapGroupMapping(item.group,item.roleNames?item.roleNames:[],false,modifyLdapGroupMapping);
- })
- }
- return [];
- }
-
- CacheConfiguration=function(timeToIdleSeconds,timeToLiveSeconds,maxElementsInMemory,maxElementsOnDisk){
- var self=this;
- this.modified=ko.observable(false);
-
- this.timeToIdleSeconds=ko.observable(timeToIdleSeconds);
- this.timeToIdleSeconds.subscribe(function(newValue){self.modified(true)});
-
- this.timeToLiveSeconds=ko.observable(timeToLiveSeconds);
- this.timeToLiveSeconds.subscribe(function(newValue){self.modified(true)});
-
- this.maxElementsInMemory=ko.observable(maxElementsInMemory);
- this.maxElementsInMemory.subscribe(function(newValue){self.modified(true)});
-
- this.maxElementsOnDisk=ko.observable(maxElementsOnDisk);
- this.maxElementsOnDisk.subscribe(function(newValue){self.modified(true)});
-
- }
-
- mapCacheConfiguration=function(data){
- if(!data){
- return new CacheConfiguration();
- }
- return new CacheConfiguration(data.timeToIdleSeconds,data.timeToLiveSeconds,data.maxElementsInMemory,data.maxElementsOnDisk);
- }
-
-
-
-});
--- /dev/null
+/*
+ * 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/admin/features/generaladmin/main",["jquery","i18n","utils","jquery.tmpl","knockout","knockout.simpleGrid",
+ "knockout.sortable","jquery.ui","jquery.validate","bootstrap","select2","knockout.select2"]
+ , function(jquery,i18n,utils,jqueryTmpl,ko,simpleGrid,sortable,jqueryUi,validate,bootstrap,select2) {
+
+ showMenu = function( administrationMenuItems) {
+ administrationMenuItems.push({ text : $.i18n.prop('menu.repository-scanning') , order:2000, id: "menu-repository-scanning-list-a" , href: "#scanningList" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRepositoryScanning();}});
+ administrationMenuItems.push({ text : $.i18n.prop('menu.runtime-configuration') , order:2010, id: "menu-runtime-configuration-list-a" , href: "#runtimeconfig" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayRuntimeConfiguration();}});
+ administrationMenuItems.push({ text : $.i18n.prop('menu.system-status') , order:2020, id: "menu-system-status-list-a" , href: "#status" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displaySystemStatus();}});
+ administrationMenuItems.push({ text : $.i18n.prop('menu.ui-configuration') , order:2030, id: "menu-ui-configuration-list-a" , href: "#uiconfig" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayUiConfiguration();}});
+ administrationMenuItems.push({ text : $.i18n.prop('menu.reports') , order:2040, id: "menu-report-list-a" , href: "#reports" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayReportsPage();}});
+
+ };
+
+ //---------------------------
+ // repository scanning part
+ //---------------------------
+
+ FileType=function(id,patterns){
+ //private String id;
+ this.id=ko.observable(id);
+
+ //private List<String> patterns;
+ this.patterns=ko.observableArray(patterns);
+
+ };
+
+ mapFileType=function(data){
+ return new FileType(data.id,data.patterns);
+ };
+
+ mapFileTypes=function(data){
+ if (data!=null){
+ return $.isArray(data)? $.map(data,function(item){
+ return mapFileType(item)
+ }):[mapFileType(data)];
+ }
+ return [];
+ };
+
+ AdminRepositoryConsumer=function(enabled,id,description){
+ //private boolean enabled = false;
+ this.enabled=ko.observable(enabled);
+
+ //private String id;
+ this.id=ko.observable(id)
+
+ //private String description;
+ this.description=ko.observable(description);
+ }
+
+ mapAdminRepositoryConsumer=function(data){
+ return new AdminRepositoryConsumer(data.enabled,data.id,data.description);
+ }
+
+ mapAdminRepositoryConsumers=function(data){
+ if (data!=null){
+ return $.isArray(data)? $.map(data,function(item){
+ return mapAdminRepositoryConsumer(item)
+ }):[mapAdminRepositoryConsumer(data)];
+ }
+ return [];
+ }
+
+
+
+ RepositoryScanningViewModel=function(){
+ var self=this;
+ this.fileTypes=ko.observableArray([]);
+ this.knownAdminRepositoryConsumers=ko.observableArray([]);
+ this.invalidAdminRepositoryConsumers=ko.observableArray([]);
+
+ this.findFileType=function(id){
+ var fileType=null;
+ for (var i=0;i<self.fileTypes().length;i++){
+ if (id==self.fileTypes()[i].id()){
+ fileType=self.fileTypes()[i];
+ }
+ }
+ return fileType;
+ }
+
+ removeFileTypePattern=function(id,pattern){
+ clearUserMessages();
+ var url="restServices/archivaServices/archivaAdministrationService/removeFileTypePattern?"
+ url+="fileTypeId="+encodeURIComponent(id);
+ url+="&pattern="+encodeURIComponent(pattern);
+ $.ajax(url, {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+ self.findFileType(id ).patterns.remove(pattern);
+ displaySuccessMessage( $.i18n.prop("repository-scanning.file-types.removed.pattern",id,pattern));
+
+ }
+ });
+ }
+
+ addFileTypePattern=function(id){
+ var pattern=$("#main-content #pattern-"+id ).val();
+ $.log("addFileTypePattern:"+id+":"+pattern);
+ clearUserMessages();
+ var url="restServices/archivaServices/archivaAdministrationService/addFileTypePattern?"
+ url+="fileTypeId="+encodeURIComponent(id);
+ url+="&pattern="+encodeURIComponent(pattern);
+ $.ajax(url, {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+ self.findFileType(id ).patterns.push(pattern);
+ displaySuccessMessage( $.i18n.prop("repository-scanning.file-types.added.pattern",id,pattern));
+
+ }
+ });
+ }
+
+ disableKnowContentConsumer=function(adminRepositoryConsumer){
+ $.log("disableKnowContentConsumer");
+ clearUserMessages();
+ var userMessages=$("#user-messages" )
+ userMessages.html(mediumSpinnerImg());
+ var url="restServices/archivaServices/archivaAdministrationService/disabledKnownContentConsumer/"
+ url+=encodeURIComponent(adminRepositoryConsumer.id());
+ $.ajax(url, {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+ adminRepositoryConsumer.enabled(false);
+ displaySuccessMessage( $.i18n.prop("repository-scanning.consumers.know.disabled",adminRepositoryConsumer.id()));
+ removeMediumSpinnerImg(userMessages);
+ }
+ });
+ }
+
+ enableKnowContentConsumer=function(adminRepositoryConsumer){
+ clearUserMessages();
+ var userMessages=$("#user-messages" )
+ userMessages.html(mediumSpinnerImg());
+ var url="restServices/archivaServices/archivaAdministrationService/enabledKnownContentConsumer/"
+ url+=encodeURIComponent(adminRepositoryConsumer.id());
+ $.ajax(url, {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+ adminRepositoryConsumer.enabled(true);
+ displaySuccessMessage( $.i18n.prop("repository-scanning.consumers.know.enabled",adminRepositoryConsumer.id()));
+ removeMediumSpinnerImg(userMessages);
+ }
+ });
+ }
+
+ disableInvalidContentConsumer=function(adminRepositoryConsumer){
+ clearUserMessages();
+ var url="restServices/archivaServices/archivaAdministrationService/disabledInvalidContentConsumer/"
+ url+=encodeURIComponent(adminRepositoryConsumer.id());
+ $.ajax(url, {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+ adminRepositoryConsumer.enabled(false);
+ displaySuccessMessage( $.i18n.prop("repository-scanning.consumers.invalid.disabled",adminRepositoryConsumer.id()));
+ }
+ });
+ }
+
+ enableInvalidContentConsumer=function(adminRepositoryConsumer){
+ clearUserMessages();
+ var url="restServices/archivaServices/archivaAdministrationService/enabledInvalidContentConsumer/"
+ url+=encodeURIComponent(adminRepositoryConsumer.id());
+ $.ajax(url, {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+ adminRepositoryConsumer.enabled(true);
+ displaySuccessMessage( $.i18n.prop("repository-scanning.consumers.invalid.enabled",adminRepositoryConsumer.id()));
+ }
+ });
+ }
+
+ }
+
+ displayRepositoryScanning=function(){
+ screenChange();
+ var mainContent=$("#main-content");
+
+ mainContent.html($("#repository-scanning-main").tmpl());
+ mainContent.find("#file-types-content").html(mediumSpinnerImg());
+ mainContent.find("#consumers-known-content").html(mediumSpinnerImg());
+ mainContent.find("#consumers-invalid-content").html(mediumSpinnerImg());
+
+ var repositoryScanningViewModel=new RepositoryScanningViewModel();
+
+ $.ajax("restServices/archivaServices/archivaAdministrationService/getFileTypes", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+ var fileTypes=mapFileTypes(data);
+ repositoryScanningViewModel.fileTypes(fileTypes);
+ ko.applyBindings(repositoryScanningViewModel,mainContent.find("#file-types-content").get(0));
+ }
+ });
+
+ $.ajax("restServices/archivaServices/archivaAdministrationService/getKnownContentAdminRepositoryConsumers", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+ var knownAdminRepositoryConsumers=mapAdminRepositoryConsumers(data);
+ repositoryScanningViewModel.knownAdminRepositoryConsumers(knownAdminRepositoryConsumers);
+ ko.applyBindings(repositoryScanningViewModel,mainContent.find("#consumers-known-content").get(0));
+ }
+ });
+
+ $.ajax("restServices/archivaServices/archivaAdministrationService/getInvalidContentAdminRepositoryConsumers", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+ var invalidAdminRepositoryConsumers=mapAdminRepositoryConsumers(data);
+ repositoryScanningViewModel.invalidAdminRepositoryConsumers(invalidAdminRepositoryConsumers);
+ ko.applyBindings(repositoryScanningViewModel,mainContent.find("#consumers-invalid-content").get(0));
+ }
+ });
+
+ }
+
+ //---------------------------
+ // network configuration part
+ //---------------------------
+
+ NetworkConfiguration=function(maxTotal,maxTotalPerHost,usePooling){
+ //private int maxTotal = 30;
+ this.maxTotal=ko.observable(maxTotal);
+
+ //private int maxTotalPerHost = 30;
+ this.maxTotalPerHost=ko.observable(maxTotalPerHost);
+
+ //private boolean usePooling = true;
+ this.usePooling=ko.observable(usePooling);
+ }
+
+ NetworkConfigurationViewModel=function(networkConfiguration){
+ var self=this;
+ this.networkConfiguration=ko.observable(networkConfiguration);
+
+ save=function(){
+ var userMessages=$("#user-messages");
+
+ var mainContent=$("#main-content");
+
+ if (!mainContent.find("#network-configuration-edit-form").valid()){
+ return;
+ }
+ userMessages.html(mediumSpinnerImg());
+ mainContent.find("#network-configuration-btn-save" ).button('loading');
+ $.ajax("restServices/archivaServices/archivaAdministrationService/setNetworkConfiguration", {
+ type: "POST",
+ contentType: 'application/json',
+ data: ko.toJSON(self.networkConfiguration),
+ dataType: 'json',
+ success: function(data){
+ displaySuccessMessage( $.i18n.prop("network-configuration.updated"));
+ },
+ complete: function(){
+ removeMediumSpinnerImg(userMessages);
+ mainContent.find("#network-configuration-btn-save" ).button('reset');
+ }
+ });
+ }
+ }
+
+ displayRuntimeConfiguration=function(){
+ screenChange();
+ var mainContent=$("#main-content");
+
+ mainContent.html($("#runtime-configuration-screen").tmpl());
+ mainContent.find("#network-configuration-form" ).html(mediumSpinnerImg());
+ $.ajax("restServices/archivaServices/archivaAdministrationService/getNetworkConfiguration", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+
+ var networkConfiguration=new NetworkConfiguration(data.maxTotal,data.maxTotalPerHost,data.usePooling);
+ var networkConfigurationViewModel=new NetworkConfigurationViewModel(networkConfiguration);
+ ko.applyBindings(networkConfigurationViewModel,mainContent.find("#network-configuration-form-content").get(0));
+ var validator = mainContent.find("#network-configuration-edit-form")
+ .validate({
+ showErrors: function(validator, errorMap, errorList) {
+ customShowError(mainContent.find("#network-configuration-edit-form" ),validator,errorMap,errorMap);
+ }
+ });
+ }
+ });
+
+
+ $.ajax("restServices/archivaServices/archivaRuntimeConfigurationService/archivaRuntimeConfiguration", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+
+ var archivaRuntimeConfiguration=mapArchivaRuntimeConfiguration(data);
+ var archivaRuntimeConfigurationViewModel=new ArchivaRuntimeConfigurationViewModel(archivaRuntimeConfiguration);
+ ko.applyBindings(archivaRuntimeConfigurationViewModel,mainContent.find("#cache-failure-form").get(0));
+ var validator = mainContent.find("#cache-failure-form-id")
+ .validate({
+ showErrors: function(validator, errorMap, errorList) {
+ customShowError(mainContent.find("#cache-failure-form-id" ),validator,errorMap,errorMap);
+ }
+ });
+ }
+ });
+
+ }
+
+ ArchivaRuntimeConfigurationViewModel=function(archivaRuntimeConfiguration){
+ var self=this;
+ this.archivaRuntimeConfiguration=ko.observable(archivaRuntimeConfiguration);
+
+ save=function(){
+ var userMessages=$("#user-messages");
+
+ var mainContent=$("#main-content");
+
+ if (!mainContent.find("#cache-failure-form-id").valid()){
+ return;
+ }
+ userMessages.html(mediumSpinnerImg());
+ mainContent.find("#cache-failure-form-btn-save" ).button('loading');
+ $.ajax("restServices/archivaServices/archivaRuntimeConfigurationService/archivaRuntimeConfiguration", {
+ type: "PUT",
+ contentType: 'application/json',
+ data: ko.toJSON(self.archivaRuntimeConfiguration),
+ dataType: 'json',
+ success: function(data){
+ displaySuccessMessage( $.i18n.prop("archiva.runtime-configuration.updated"));
+ },
+ error:function(){
+ displayErrorMessage("error.500");
+ }
+ } ).always(
+ function(){
+ removeMediumSpinnerImg(userMessages);
+ mainContent.find("#cache-failure-form-btn-save" ).button('reset');
+ }
+ );
+ }
+ }
+
+ ArchivaRuntimeConfiguration=function(cacheConfiguration){
+ this.urlFailureCacheConfiguration=ko.observable(cacheConfiguration);
+ }
+
+
+ mapArchivaRuntimeConfiguration=function(data){
+ if(!data){
+ return null;
+ }
+ return new ArchivaRuntimeConfiguration(data.urlFailureCacheConfiguration?mapCacheConfiguration(data.urlFailureCacheConfiguration):null);
+ }
+ //---------------------------
+ // organisation/appearance configuration part
+ //---------------------------
+ OrganisationInformation=function(name,url,logoLocation){
+ this.name=ko.observable(name);
+ this.url=ko.observable(url);
+ this.logoLocation=ko.observable(logoLocation);
+ }
+ mapOrganisationInformation=function(data){
+ return new OrganisationInformation(data.name, data.url, data.logoLocation);
+ }
+ mapOrganisationInformations=function(data){
+ if (data!=null){
+ return $.isArray(data)? $.map(data, function(item){
+ return mapOrganisationInformation(item);
+ }):[mapOrganisationInformation(data)];
+ }
+ }
+ activateOrganisationInformationFormValidation=function(){
+ var validate = $("#main-content" ).find("#appearance-configuration-form-id")
+ .validate({
+ rules: {
+ name: {
+ required: true
+ },
+ url: {
+ required:true,
+ url:true
+ },
+ logoLocation: {
+ required:false,
+ url:true
+ }
+ },
+ showErrors: function(validator, errorMap, errorList) {
+ $.log("activateOrganisationInformationFormValidation#customShowError");
+ customShowError($("#main-content" ).find("#appearance-configuration-form-id"), validator, errorMap, errorMap);
+ }
+ });
+ }
+ OrganisationInformationViewModel=function(organisationInformation){
+
+ this.organisationInformation=ko.observable(organisationInformation);
+
+ this.save=function(){
+ $.log("OrganisationInformationViewModel#save");
+ var mainContent=$("#main-content" );
+ if (!mainContent.find("#appearance-configuration-form-id").valid()) {
+ return;
+ }
+ clearUserMessages();
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ mainContent.find("#appearance-configuration-btn-save" ).button('loading');
+ $.ajax("restServices/archivaServices/archivaAdministrationService/setOrganisationInformation", {
+ type: "POST",
+ contentType: "application/json",
+ data: ko.toJSON(this.organisationInformation),
+ dataType: "json",
+ success: function(data){
+ displaySuccessMessage($.i18n.prop('appearance-configuration.updated'));
+ updateAppearanceToolBar();
+ },
+ error: function(data){
+ displayErrorMessage($.i18n.prop('appearance-configuration.updating-error'));
+ },
+ complete: function(){
+ removeMediumSpinnerImg(userMessages);
+ mainContent.find("#appearance-configuration-btn-save" ).button('reset');
+ }
+ });
+ }
+ }
+
+
+ //---------------------------
+ // UiConfiguration part
+ //---------------------------
+
+ UiConfiguration=function(showFindArtifacts,appletFindEnabled,disableEasterEggs,applicationUrl,disableRegistration){
+ this.showFindArtifacts = ko.observable(showFindArtifacts);
+
+ this.appletFindEnabled = ko.observable(appletFindEnabled);
+
+ this.disableEasterEggs = ko.observable(disableEasterEggs);
+
+ this.applicationUrl = ko.observable(applicationUrl);
+
+ // default to false
+ this.disableRegistration = ko.observable(disableRegistration?disableRegistration:false);
+ }
+
+ UiConfigurationViewModel=function(uiConfiguration){
+ this.uiConfiguration=ko.observable(uiConfiguration);
+ var self=this;
+ save=function(){
+ var mainContent=$("#main-content" );
+ var userMessages=$("#user-messages");
+ userMessages.html( mediumSpinnerImg());
+ mainContent.find("#ui-configuration-btn-save" ).button('loading');
+ $.ajax("restServices/archivaServices/archivaAdministrationService/setUiConfiguration", {
+ type: "POST",
+ contentType: 'application/json',
+ data: ko.toJSON(self.uiConfiguration),
+ dataType: 'json',
+ success: function(data){
+ displaySuccessMessage( $.i18n.prop("ui-configuration.updated"));
+ },
+ complete: function(){
+ removeMediumSpinnerImg(userMessages);
+ mainContent.find("#ui-configuration-btn-save" ).button('reset');
+ }
+ });
+ }
+ }
+
+ displayUiConfiguration=function(){
+ var mainContent=$("#main-content");
+
+ mainContent.html($("#ui-configuration" ).tmpl());
+
+ mainContent.find("#ui-configuration-form").html(mediumSpinnerImg());
+
+ $.ajax("restServices/archivaServices/archivaAdministrationService/getUiConfiguration", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+ var uiConfiguration=new UiConfiguration(data.showFindArtifacts,data.appletFindEnabled,data.disableEasterEggs,
+ data.applicationUrl,data.disableRegistration);
+ var uiConfigurationViewModel=new UiConfigurationViewModel(uiConfiguration);
+ ko.applyBindings(uiConfigurationViewModel,mainContent.find("#ui-configuration-form").get(0));
+ }
+ });
+
+ $.ajax("restServices/archivaServices/archivaAdministrationService/getOrganisationInformation", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ var organisationInformation=new OrganisationInformation(data.name,data.url,data.logoLocation);
+ var organisationInformationViewModel=new OrganisationInformationViewModel(organisationInformation);
+ ko.applyBindings(organisationInformationViewModel, mainContent.find("#change-appearance-form").get(0));
+ activateOrganisationInformationFormValidation();
+ }
+ });
+ }
+
+ //---------------------------
+ // System status part
+ //---------------------------
+
+ QueueEntry=function(key,entriesNumber){
+ this.key=key;
+ this.entriesNumber=entriesNumber;
+ }
+
+
+ mapQueueEntries=function(data){
+ if (data!=null){
+ return $.map(data,function(item){
+ return new QueueEntry(item.key,item.entriesNumber);
+ })
+ }
+ return [];
+ }
+
+ CacheEntry=function(key,size,cacheHits,cacheMiss,cacheHitRate,inMemorySize){
+ this.key=key;
+ this.size=size;
+ this.cacheHits=cacheHits;
+ this.cacheMiss=cacheMiss;
+ this.cacheHitRate=cacheHitRate;
+ this.inMemorySize=inMemorySize;
+ }
+
+ mapCacheEntries=function(data){
+ if(data!=null){
+ return $.map(data,function(item){
+ return new CacheEntry(item.key,item.size,item.cacheHits,item.cacheMiss,item.cacheHitRate,item.inMemorySize);
+ })
+ }
+ return [];
+ }
+
+
+
+ displayCacheEntries=function(){
+ var divContent = $("#main-content" ).find("#status_caches");
+ divContent.html(smallSpinnerImg());
+ $.ajax("restServices/archivaServices/systemStatusService/cacheEntries", {
+ type: "GET",
+ success: function(data){
+ var cacheEntries=mapCacheEntries(data);
+ divContent.html($("#status_caches_tmpl" ).tmpl({cacheEntries: cacheEntries}));
+ }
+ });
+ }
+
+ flushCache=function(key){
+ clearUserMessages();
+ $("#main-content" ).find("#status_caches").html(smallSpinnerImg());
+ $.ajax("restServices/archivaServices/systemStatusService/clearCache/"+encodeURIComponent(key), {
+ type: "GET",
+ success: function(data){
+ displaySuccessMessage( $.i18n.prop("system-status.caches.flushed",key));
+ displayCacheEntries();
+ }
+ });
+ }
+
+ flushAllCaches=function(){
+ clearUserMessages();
+ $("#main-content" ).find("#status_caches").html(smallSpinnerImg());
+ $.ajax("restServices/archivaServices/systemStatusService/clearAllCaches", {
+ type: "GET",
+ success: function(data){
+ displaySuccessMessage( $.i18n.prop("system-status.caches.all.flushed"));
+ displayCacheEntries();
+ }
+ });
+ }
+
+ mapRepositoryScannerStatisticsList=function(data){
+ if(data!=null){
+ return $.isArray(data)? $.map(data,function(item){
+ return mapRepositoryScannerStatistics(item);
+ }):[data];
+ }
+ return [];
+ }
+
+
+ mapRepositoryScannerStatistics=function(data){
+ return new RepositoryScannerStatistics(mapManagedRepository(data.managedRepository),data.totalFileCount,
+ data.newFileCount,data.consumerScanningStatistics);
+ }
+
+ RepositoryScannerStatistics=function(managedRepository,totalFileCount,newFileCount,consumerScanningStatisticsList){
+ //private ManagedRepository managedRepository;
+ this.managedRepository=managedRepository
+
+ this.consumerScanningStatisticsList= consumerScanningStatisticsList;
+
+ //private long totalFileCount = 0;
+ this.totalFileCount=totalFileCount;
+
+ //private long newFileCount = 0;
+ this.newFileCount=newFileCount;
+ }
+
+ displayScanningStats=function(){
+ var divContent = $("#main-content" ).find("#status_scanning");
+ divContent.html(smallSpinnerImg());
+ $.ajax("restServices/archivaServices/systemStatusService/repositoryScannerStatistics", {
+ type: "GET",
+ success: function(data){
+ var stats= mapRepositoryScannerStatisticsList(data);
+ $.log("size:"+data.length);
+ divContent.html($("#status_scanning_tmpl").tmpl({repositoryScannerStatisticsList:stats}));
+ }
+ });
+ }
+
+ displayMemoryUsage=function(){
+ var divContent = $("#main-content" ).find("#status_memory_info");
+ divContent.html(smallSpinnerImg());
+ $.ajax("restServices/archivaServices/systemStatusService/memoryStatus", {
+ type: "GET",
+ dataType: "text",
+ success: function(data){
+ var memUsage = data;
+ $.log("memUsage:"+memUsage);
+ divContent.html(memUsage);
+ }
+ });
+ }
+
+ displayQueueEntries=function(){
+ var divContent = $("#main-content" ).find("#status_queues");
+ divContent.html(smallSpinnerImg());
+ $.ajax("restServices/archivaServices/systemStatusService/queueEntries", {
+ type: "GET",
+ success: function(data){
+ var queueEntries=mapQueueEntries(data);
+ divContent.html($("#status_queues_tmpl" ).tmpl({queueEntries: queueEntries}));
+ }
+ });
+ }
+
+ displayServerTime=function(){
+ var divContent = $("#main-content" ).find("#status_current_time");
+ divContent.html(smallSpinnerImg());
+ $.ajax("restServices/archivaServices/systemStatusService/currentServerTime/"+encodeURIComponent(usedLang()), {
+ type: "GET",
+ dataType: "text",
+ success: function(data){
+ var curTime=data;
+ $.log("currentServerTime:"+curTime);
+ divContent.html(curTime);
+ }
+ });
+ }
+
+ displaySystemStatus=function(){
+ screenChange();
+ var mainContent=$("#main-content");
+ mainContent.html($("#system-status-main").tmpl());
+
+ var versionInfo=window.archivaRuntimeInfo.version+" - "
+ +$.i18n.prop('system-status.header.version.buildNumber')+": "+window.archivaRuntimeInfo.buildNumber
+ +" - "+$.i18n.prop('system-status.header.version.timestampStr')+": "+window.archivaRuntimeInfo.timestampStr;
+ mainContent.find("#status_version_info").html(versionInfo);
+
+ displayMemoryUsage();
+
+ displayServerTime();
+
+ displayQueueEntries();
+
+ displayScanningStats();
+
+ displayCacheEntries();
+ }
+
+ refreshSystemStatus=function(){
+ displayCacheEntries();
+ displayScanningStats();
+ displayMemoryUsage();
+ displayQueueEntries();
+ displayServerTime();
+ }
+
+ //---------------------------
+ // report configuration page
+ //---------------------------
+ StatisticsReportRequest=function() {
+ this.repositories = ko.observableArray( [] );
+ this.rowCount = ko.observable(100);
+ this.startDate = ko.observable();
+ this.endDate = ko.observable();
+ }
+
+ reportStatisticsFormValidator=function(){
+ $.log("reportStatisticsFormValidator");
+ var validate = $("#main-content" ).find("#report-statistics-form-id").validate({
+ rules: {
+ rowCountStatistics: {
+ required:true,
+ number: true,
+ min: 10
+ },
+ startDate: {
+ date: true
+ },
+ endDate: {
+ date: true
+ }
+ },
+ showErrors: function(validator, errorMap, errorList) {
+ $.log("showErrors");
+ customShowError("#main-content #report-statistics-form-id", validator, errorMap, errorMap);
+ }
+ })
+ }
+ ReportStatisticsViewModel=function(repositoriesAvailable){
+ var mainContent=$("#main-content");
+ reportStatisticsFormValidator();
+
+ var self=this;
+ this.availableRepositories = ko.observableArray( repositoriesAvailable );
+ this.statisticsReport = ko.observable( new StatisticsReportRequest() );
+
+ mainContent.find("#startDate" ).datepicker();
+ mainContent.find("#endDate" ).datepicker();
+ mainContent.find("#rowcount-info-button" ).popover();
+
+ this.showStatistics=function() {
+ $.log("showStatistics");
+ clearUserMessages( "repositoriesErrorMessage" );
+ if (!mainContent.find("#report-statistics-form-id").valid()) {
+ return;
+ }
+ if(this.statisticsReport().repositories().length==0){
+ displayErrorMessage( $.i18n.prop('report.statistics.repositories.required'), "repositoriesErrorMessage" );
+ return;
+ }
+
+ var resultTabContent = mainContent.find("#report-result");
+
+ url = "restServices/archivaServices/reportServices/getStatisticsReport/?rowCount="
+ + this.statisticsReport().rowCount();
+
+ for(var i=0;i<this.statisticsReport().repositories().length;i++){
+ url += "&repository=" + this.statisticsReport().repositories()[i];
+ }
+
+ if(this.statisticsReport().startDate()!=null){
+ url += "&startDate=" + this.statisticsReport().startDate();
+ }
+ if(this.statisticsReport().endDate()!=null){
+ url += "&endDate=" + this.statisticsReport().endDate();
+ }
+
+ $.ajax(url, {
+ type: "GET",
+ contentType: 'application/json',
+ dataType: 'json',
+ success: function(data){
+ resultTabContent.html( $( "#report-statistics" ).tmpl() );
+ var reportStatistics = new ReportStatisticsResultViewModel( data );
+ ko.applyBindings( reportStatistics, resultTabContent.get( 0 ) );
+ var reportResultTabLi=$( "#report-result-tab-li");
+ reportResultTabLi.removeClass( "hide" );
+ reportResultTabLi.addClass( "active" );
+ $( "#report-stat-tab-li" ).removeClass( "active" );
+ $( "#report-stat-tab-content" ).removeClass( "active" );
+ resultTabContent.addClass( "active" );
+ },
+ error: function(data){
+ var res = $.parseJSON(data.responseText);
+ displayErrorMessage($.i18n.prop(res.errorMessage));
+ }
+ });
+ }
+ }
+ ReportStatisticsResultViewModel=function(report){
+ this.reports = ko.observableArray( report );
+ var self = this;
+
+ this.tableReportViewModel = new ko.simpleGrid.viewModel({
+ data: this.reports,
+ viewModel: this,
+ columns: [
+ { headerText: "Repository ID", rowText: "repositoryId" },
+ { headerText: "Start Date", rowText: function(item){return new Date(item.scanStartTime);}},
+ { headerText: "Total File Count", rowText: "totalFileCount" },
+ { headerText: "Total Size", rowText: "totalArtifactFileSize" },
+ { headerText: "Artifact Count", rowText: "totalArtifactCount" },
+ { headerText: "Group Count", rowText: "totalGroupCount" },
+ { headerText: "Project Count", rowText: "totalProjectCount" },
+ { headerText: "Archetypes", rowText: function (item) { return !item.totalCountForType.pom || item.totalCountForType.pom === "" ? "0" : item.totalCountForType.pom } },
+ { headerText: "Jars", rowText: function (item) { return !item.totalCountForType.war || item.totalCountForType.jar === "" ? "0" : item.totalCountForType.jar } },
+ { headerText: "Wars", rowText: function (item) { return !item.totalCountForType.war || item.totalCountForType.war === "" ? "0" : item.totalCountForType.jar } },
+ { headerText: "Ears", rowText: function (item) { return !item.totalCountForType.ear || item.totalCountForType.ear === "" ? "0" : item.totalCountForType.ear } },
+ { headerText: "Exes", rowText: function (item) { return !item.totalCountForType.exe || item.totalCountForType.exe === "" ? "0" : item.totalCountForType.exe } },
+ { headerText: "Dlls", rowText: function (item) { return !item.totalCountForType.dll || item.totalCountForType.dll === "" ? "0" : item.totalCountForType.dll} },
+ { headerText: "Zips", rowText: function (item) { return !item.totalCountForType.zip || item.totalCountForType.zip === "" ? "0" : item.totalCountForType.zip } }
+ ],
+ pageSize: 10
+ });
+ }
+
+ HealthReportRequest=function(){
+ this.repositoryId = ko.observable();
+ this.rowCount = ko.observable(100);
+ this.groupId = ko.observable();
+ }
+ HealthReportResult=function(repositoryId,namespace,project,version,id,message,problem,name,facetId){
+ this.repositoryId = repositoryId;
+ this.namespace = namespace;
+ this.project = project;
+ this.version = version;
+ this.id = id;
+ this.message = message;
+ this.problem = problem;
+ this.name = name;
+ this.facetId = facetId;
+ }
+ mapHealthReportResult=function(data){
+ if(data==null) return;
+ return new HealthReportResult( data.repositoryId, data.namespace, data.project, data.version, data.id, data.message,
+ data.problem, data.name, data.facetId );
+ }
+ mapHealthReportResults=function(data){
+ if (data != null)
+ {
+ return $.isArray(data)? $.map(data, function(item){
+ return mapHealthReportResult(item);
+ }):[mapHealthReportResult(data)];
+ }
+ return [];
+ }
+ ReportHealthResultViewModel=function(report){
+ this.reports = ko.observableArray( report );
+ var self = this;
+ this.tableReportViewModel = new ko.simpleGrid.viewModel({
+ data: this.reports,
+ viewModel: this,
+ columns: [
+ { headerText: "ID", rowText: "id" },
+ { headerText: "Namespace", rowText: "namespace" },
+ { headerText: "Project", rowText: "project" },
+ { headerText: "Version", rowText: "version" },
+ { headerText: "Name", rowText: "name" },
+ { headerText: "Problem", rowText: "problem" },
+ { headerText: "Message", rowText: "message" }
+ ],
+ pageSize: 10
+ });
+ }
+
+ reportHealthFormValidator=function(){
+ var validate = $("#main-content" ).find("#report-health-form-id").validate({
+ rules: {
+ rowCountHealth: {
+ required: true,
+ number: true,
+ min: 10
+ },
+ repositoryId: {
+ required: true
+ }
+ },
+ showErrors: function(validator, errorMap, errorList) {
+ customShowError("#main-content #report-health-form-id", validator, errorMap, errorMap);
+ }
+ })
+ }
+ ReportHealthViewModel=function(){
+ reportHealthFormValidator();
+ this.healthReport = ko.observable(new HealthReportRequest());
+
+ this.showHealth=function() {
+ if (!$("#main-content" ).find("#report-health-form-id").valid()) {
+ return;
+ }
+
+ var resultTabContent = $("#main-content" ).find("#report-result");
+
+ var url =
+ "restServices/archivaServices/reportServices/getHealthReports/" + this.healthReport().repositoryId() + "/"
+ + this.healthReport().rowCount();
+
+ if (this.healthReport().groupId())
+ {
+ url += "?groupId=" + this.healthReport().groupId();
+ }
+
+ $.ajax(url, {
+ type: "GET",
+ contentType: 'application/json',
+ dataType: 'json',
+ success: function(data){
+ var reports = new ReportHealthResultViewModel( mapHealthReportResults( data ) );
+ resultTabContent.html( $( "#report-health" ).tmpl() );
+ ko.applyBindings( reports, resultTabContent.get( 0 ) );
+ var reportResultTabLi=$( "#report-result-tab-li" );
+ reportResultTabLi.removeClass( "hide" );
+ reportResultTabLi.addClass( "active" );
+ $( "#report-health-tab-li" ).removeClass( "active" );
+ $( "#report-health-tab-content" ).removeClass( "active" );
+ resultTabContent.addClass( "active" );
+ },
+ error: function(data){
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ }
+ });
+ }
+ }
+
+ displayReportsPage=function(){
+ screenChange();
+ clearUserMessages();
+ var mainContent = $("#main-content");
+ mainContent.html(mediumSpinnerImg());
+ $.ajax("restServices/archivaServices/searchService/observableRepoIds", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ var repos = mapStringList( data );
+ mainContent.html( $( "#report-base" ).tmpl( {repositoriesList:repos} ) );
+ var statisticsReportViewModel = ReportStatisticsViewModel( repos );
+ var healthReportViewModel = ReportHealthViewModel( );
+ ko.applyBindings( statisticsReportViewModel, mainContent.get( 0 ) );
+ ko.applyBindings( healthReportViewModel, mainContent.get( 0 ) );
+ }
+ });
+ }
+
+
+ RedbackRuntimeConfiguration=function(userManagerImpls,ldapConfiguration,migratedFromRedbackConfiguration,configurationPropertiesEntries
+ ,useUsersCache,cacheConfiguration,rbacManagerImpls){
+ $.log("new RedbackRuntimeConfiguration");
+ var self=this;
+ this.modified=ko.observable(false);
+ this.modified.subscribe(function(newValue){$.log("RedbackRuntimeConfiguration modified")});
+
+ this.userManagerImpls=ko.observableArray(userManagerImpls);
+ this.userManagerImpls.subscribe(function(newValue){self.modified(true)});
+
+ this.rbacManagerImpls=ko.observableArray(rbacManagerImpls);
+ this.rbacManagerImpls.subscribe(function(newValue){self.modified(true)});
+
+ this.ldapConfiguration=ko.observable(ldapConfiguration);
+ this.ldapConfiguration.subscribe(function(newValue){self.modified(true)});
+
+ this.migratedFromRedbackConfiguration=ko.observable(migratedFromRedbackConfiguration);
+
+ this.configurationPropertiesEntries=ko.observableArray(configurationPropertiesEntries?configurationPropertiesEntries:[]);
+ this.configurationPropertiesEntries.subscribe(function(newValue){
+ self.modified(true);
+ $.log("configurationPropertiesEntries modified")
+ });
+
+ this.findPropertyValue=function(key){
+ for(var i=0;i<self.configurationPropertiesEntries().length;i++){
+ if(self.configurationPropertiesEntries()[i].key==key){
+ var val = self.configurationPropertiesEntries()[i].value;
+ $.log("findPropertyValue " + key + "->" + val);
+ return val;
+ }
+ }
+ }
+
+ this.useUsersCache=ko.observable(useUsersCache);
+ this.useUsersCache.subscribe(function(newValue){self.modified(true)});
+
+ this.usersCacheConfiguration=ko.observable(cacheConfiguration);
+ this.usersCacheConfiguration.subscribe(function(newValue){self.modified(true)});
+
+ this.ldapGroups=ko.observableArray([]);
+ this.ldapGroups.subscribe(function(newValue){self.modified(true)});
+
+ this.ldapGroupMappings=ko.observableArray([]);
+ this.ldapGroupMappings.subscribe(function(newValue){
+ self.modified(true);
+ $.log('ldapGroupMappings modified:'+newValue.group);
+ });
+
+ }
+
+ mapRedbackRuntimeConfiguration=function(data){
+
+ var ldapConfiguration=mapLdapConfiguration(data.ldapConfiguration);
+
+ var redbackRuntimeConfiguration =
+ new RedbackRuntimeConfiguration(data.userManagerImpls,ldapConfiguration,data.migratedFromRedbackConfiguration,[]
+ ,data.useUsersCache,mapCacheConfiguration(data.usersCacheConfiguration),data.rbacManagerImpls);
+
+ $.log("redbackRuntimeConfiguration.rbacManagerImpls:"+redbackRuntimeConfiguration.rbacManagerImpls().length);
+ var configurationPropertiesEntries = data.configurationPropertiesEntries == null ? []: $.each(data.configurationPropertiesEntries,function(item){
+ var entry = new Entry(item.key, item.value,function(newValue){
+ redbackRuntimeConfiguration.modified(true);
+ });
+ return entry;
+ });
+
+ if (!$.isArray(configurationPropertiesEntries)){
+ configurationPropertiesEntries=[];
+ }
+
+ redbackRuntimeConfiguration.configurationPropertiesEntries(configurationPropertiesEntries);
+ redbackRuntimeConfiguration.modified(false);
+ return redbackRuntimeConfiguration;
+
+ }
+
+ LdapConfiguration=function(hostName,port,ssl,baseDn,baseGroupsDn,contextFactory,bindDn,password,authenticationMethod,
+ extraPropertiesEntries,writable,useRoleNameAsGroup,bindAuthenticatorEnabled){
+
+ var self=this;
+ this.modified=ko.observable(false);
+
+ //private String hostName;
+ this.hostName=ko.observable(hostName);
+ this.hostName.subscribe(function(newValue){self.modified(true)});
+
+ //private String port;
+ this.port=ko.observable(port);
+ this.port.subscribe(function(newValue){self.modified(true)});
+
+ //private boolean ssl = false;
+ this.ssl=ko.observable(ssl);
+ this.ssl.subscribe(function(newValue){self.modified(true)});
+
+ //private String baseDn;
+ this.baseDn=ko.observable(baseDn);
+ this.baseDn.subscribe(function(newValue){self.modified(true)});
+
+ //private String baseGroupsDn;
+ this.baseGroupsDn=ko.observable(baseGroupsDn);
+ this.baseGroupsDn.subscribe(function(newValue){self.modified(true)});
+
+ //private String contextFactory;
+ this.contextFactory=ko.observable(contextFactory);
+ this.contextFactory.subscribe(function(newValue){self.modified(true)});
+
+ //private String bindDn;
+ this.bindDn=ko.observable(bindDn);
+ this.bindDn.subscribe(function(newValue){self.modified(true)});
+
+ //private String password;
+ this.password=ko.observable(password);
+ this.password.subscribe(function(newValue){self.modified(true)});
+
+ //private String authenticationMethod;
+ this.authenticationMethod=ko.observable(authenticationMethod);
+ this.authenticationMethod.subscribe(function(newValue){self.modified(true)});
+
+ this.extraPropertiesEntries=ko.observableArray(extraPropertiesEntries);
+ this.extraPropertiesEntries.subscribe(function(newValue){self.modified(true)});
+
+ //private boolean writable = false;
+ this.writable=ko.observable(writable);
+ this.writable.subscribe(function(newValue){self.modified(true)});
+
+ // useRoleNameAsGroup
+ this.useRoleNameAsGroup=ko.observable(useRoleNameAsGroup);
+ this.useRoleNameAsGroup.subscribe(function(newValue){self.modified(true)});
+
+ //bindAuthenticatorEnabled
+ this.bindAuthenticatorEnabled=ko.observable(bindAuthenticatorEnabled);
+ this.bindAuthenticatorEnabled.subscribe(function(newValue){self.modified(true)});
+
+ }
+
+ mapLdapConfiguration=function(data){
+ $.log("mapLdapConfiguration");
+ if(data){
+ var extraPropertiesEntries = data.extraPropertiesEntries == null ? []: $.each(data.extraPropertiesEntries,function(item){
+ return new Entry(item.key, item.value);
+ });
+ if (!$.isArray(extraPropertiesEntries)){
+ extraPropertiesEntries=[];
+ }
+ $.log("mapLdapConfiguration done");
+ return new LdapConfiguration(data.hostName,data.port,data.ssl,data.baseDn,data.baseGroupsDn,data.contextFactory,data.bindDn,data.password,
+ data.authenticationMethod,extraPropertiesEntries,data.writable,data.useRoleNameAsGroup,data.bindAuthenticatorEnabled);
+ }
+ return null;
+ }
+
+ RedbackRuntimeConfigurationViewModel=function(redbackRuntimeConfiguration,userManagerImplementationInformations,rbacManagerImplementationInformations){
+ var self=this;
+ this.redbackRuntimeConfiguration=ko.observable(redbackRuntimeConfiguration);
+ this.userManagerImplementationInformations=ko.observableArray(userManagerImplementationInformations);
+ this.rbacManagerImplementationInformations=ko.observableArray(rbacManagerImplementationInformations);
+
+ this.usedUserManagerImpls=ko.observableArray([]);
+
+ this.usedRbacManagerImpls=ko.observableArray([]);
+
+ this.modifiesLdapGroupMappings=ko.observableArray([]);
+
+ this.availableUserManagerImpls=ko.observableArray([]);
+ this.availableRbacManagerImpls=ko.observableArray([]);
+
+ this.allRoleNames=ko.observableArray([]);
+
+ findUserManagerImplementationInformation=function(id){
+ for(var i= 0;i<self.userManagerImplementationInformations().length;i++){
+ $.log(id+""+self.userManagerImplementationInformations()[i].beanId);
+ if(id==self.userManagerImplementationInformations()[i].beanId){
+ return self.userManagerImplementationInformations()[i];
+ }
+ }
+ }
+
+ findRbacManagerImplementationInformation=function(id){
+ for(var i= 0;i<self.rbacManagerImplementationInformations().length;i++){
+ $.log(id+""+self.rbacManagerImplementationInformations()[i].beanId);
+ if(id==self.rbacManagerImplementationInformations()[i].beanId){
+ return self.rbacManagerImplementationInformations()[i];
+ }
+ }
+ }
+
+ checkLdapServerConfiguration=function(){
+ $.log("checkLdapServerConfiguration");
+ clearUserMessages();
+ var btn = $("#ldap-configuration-check-server");
+ btn.button('loading');
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ $.log("checkChangedLdapConfiguration");
+ $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/checkLdapConnection",
+ {
+ type: "GET",
+ success: function(data) {
+ var message=$.i18n.prop('redback.runtime.ldap.verified');
+ displaySuccessMessage(message);
+ },
+ error: function(data) {
+ try{
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ }catch (e){
+ displayErrorMessage( $.i18n.prop("error.500"));
+ }
+
+ }
+ }
+ ).always(
+ function(data){
+ removeMediumSpinnerImg(userMessages);
+ btn.button('reset');
+ }
+ );
+ }
+
+ checkChangedLdapConfiguration=function(){
+ clearUserMessages();
+ var btn = $("#ldap-configuration-check-modification");
+ btn.button('loading');
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ $.log("checkChangedLdapConfiguration");
+ $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/checkLdapConnection",
+ {
+ type: "POST",
+ contentType: 'application/json',
+ data:ko.toJSON(self.redbackRuntimeConfiguration().ldapConfiguration),
+ dataType: 'json',
+ success: function(data) {
+ var message=$.i18n.prop('redback.runtime.ldap.verified');
+ displaySuccessMessage(message);
+ },
+ error: function(data) {
+ try{
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ }catch (e){
+ displayErrorMessage( $.i18n.prop("error.500"));
+ }
+ }
+ }
+ ).always(
+ function(data){
+ removeMediumSpinnerImg(userMessages);
+ btn.button('reset');
+ }
+ );
+ }
+
+ for(var i= 0;i<redbackRuntimeConfiguration.userManagerImpls().length;i++){
+ var id=redbackRuntimeConfiguration.userManagerImpls()[i];
+
+ var userManagerImplementationInformation=findUserManagerImplementationInformation(id);
+
+ if(userManagerImplementationInformation!=null){
+ this.usedUserManagerImpls.push(userManagerImplementationInformation);
+ }
+ }
+
+ $.log("init usedUserManagerImpls done");
+
+ for(var i= 0;i<redbackRuntimeConfiguration.rbacManagerImpls().length;i++){
+ var id=redbackRuntimeConfiguration.rbacManagerImpls()[i];
+
+ var rbacManagerImplementationInformation=findRbacManagerImplementationInformation(id);
+
+ if(rbacManagerImplementationInformation!=null){
+ this.usedRbacManagerImpls.push(rbacManagerImplementationInformation);
+ }
+ }
+
+ $.log("init usedUserManagerImpls done");
+
+ isUsedUserManagerImpl=function(userManagerImplementationInformation){
+ for(var i=0;i<self.usedUserManagerImpls().length;i++){
+ if(self.usedUserManagerImpls()[i].beanId==userManagerImplementationInformation.beanId){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ for(var i=0;i<self.userManagerImplementationInformations().length;i++){
+ if(!isUsedUserManagerImpl(self.userManagerImplementationInformations()[i])){
+ self.availableUserManagerImpls.push(self.userManagerImplementationInformations()[i]);
+ }
+ }
+
+ userManagerImplMoved=function(arg){
+ $.log("userManagerImplMoved");
+ self.redbackRuntimeConfiguration().modified(true);
+ }
+
+ isUsedRbacManagerImpl=function(rbacManagerImplementationInformation){
+ for(var i=0;i<self.usedRbacManagerImpls().length;i++){
+ if(self.usedRbacManagerImpls()[i].beanId==rbacManagerImplementationInformation.beanId){
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+
+ for(var i=0;i<self.rbacManagerImplementationInformations().length;i++){
+ if(!isUsedRbacManagerImpl(self.rbacManagerImplementationInformations()[i])){
+ self.availableRbacManagerImpls.push(self.rbacManagerImplementationInformations()[i]);
+ }
+ }
+
+ rbacManagerImplMoved=function(arg){
+ $.log("rbacManagerImplMoved");
+ self.redbackRuntimeConfiguration().modified(true);
+ }
+
+ saveRedbackRuntimeConfiguration=function(){
+
+ var mainContent=$("#main-content");
+ var valid = mainContent.find("#redback-runtime-general-form-id").valid();
+ if (valid==false) {
+ return;
+ }
+ var useLdap = false;
+ for(var i=0;i<self.usedUserManagerImpls().length;i++){
+ var beanId=self.usedUserManagerImpls()[i].beanId;
+ $.log("beanId:"+beanId);
+ if(beanId=='ldap'){
+ useLdap=true;
+ }
+ }
+ $.log("useLdap:"+useLdap);
+ if(useLdap==true) {
+ valid = mainContent.find("#redback-runtime-ldap-form-id").valid();
+ $.log("ldap valid:"+valid);
+ if (valid==false) {
+ return;
+ }
+ }
+
+ clearUserMessages();
+
+ if (self.usedUserManagerImpls().length<1){
+ displayErrorMessage( $.i18n.prop("error.redback.runtimeconfiguration.user-managers.empty"));
+ valid=false;
+ }
+
+ if (self.usedRbacManagerImpls().length<1){
+ displayErrorMessage( $.i18n.prop("error.redback.runtimeconfiguration.rbac-managers.empty"));
+ valid=false;
+ }
+
+ if(valid==false){
+ return;
+ }
+
+ $.log("saveRedbackRuntimeConfiguration");
+ var saveButton = mainContent.find("#redback-runtime-configuration-save" );
+ saveButton.button('loading');
+ clearUserMessages();
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+
+ self.redbackRuntimeConfiguration().userManagerImpls=ko.observableArray([]);
+
+ for(var i=0;i<self.usedUserManagerImpls().length;i++){
+ var beanId=self.usedUserManagerImpls()[i].beanId;
+ $.log("beanId:"+beanId);
+ self.redbackRuntimeConfiguration().userManagerImpls.push(beanId);
+ }
+
+
+ self.redbackRuntimeConfiguration().rbacManagerImpls=ko.observableArray([]);
+
+ for(var i=0;i<self.usedRbacManagerImpls().length;i++){
+ var beanId=self.usedRbacManagerImpls()[i].beanId;
+ $.log("beanId:"+beanId);
+ self.redbackRuntimeConfiguration().rbacManagerImpls.push(beanId);
+ }
+
+
+ $.log("rememberme enabled:"+self.redbackRuntimeConfiguration().findPropertyValue("security.rememberme.enabled"));
+ $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/redbackRuntimeConfiguration",
+ {
+ type: "PUT",
+ contentType: 'application/json',
+ data:ko.toJSON(self.redbackRuntimeConfiguration),
+ dataType: 'json',
+ success: function(data) {
+ var message=$.i18n.prop('redback-runtime-configuration.updated');
+ window.sammyArchivaApplication.runRoute("get","#redbackruntimeconfig");
+ displaySuccessMessage(message);
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ }
+ }
+ ).always(
+ function(){
+ removeMediumSpinnerImg(userMessages);
+ saveButton.button('reset');
+ self.redbackRuntimeConfiguration().modified(false);
+ self.redbackRuntimeConfiguration().ldapConfiguration().modified(false);
+ saveModifyLdapGroupMapping();
+ }
+ );
+
+
+
+ }
+
+ saveModifyLdapGroupMapping=function(){
+ //save modified ldap group mappings if any
+ if(self.modifiesLdapGroupMappings().length>0){
+ $.log("save modifiesLdapGroupMappings");
+ var message=$.i18n.prop('redback-runtime-ldap-group-mapping.updated');
+ var userMessages=$("#user-messages");
+ var ldapGroupMappings=[];
+ $.each(self.modifiesLdapGroupMappings(),function(idx,item){
+
+ if(!(item.automatic&item.roleNames().length<2)){
+ $.log("update mapping for group:"+item.group());
+ ldapGroupMappings.push(item);
+ }
+ });
+
+ if (ldapGroupMappings.length>0){
+
+ var mainContent=$("#main-content");
+ var saveButton = mainContent.find("#redback-runtime-configuration-save" );
+ saveButton.button('loading');
+ userMessages.html(mediumSpinnerImg());
+ $.ajax("restServices/redbackServices/ldapGroupMappingService",
+ {
+ type: "POST",
+ contentType: 'application/json',
+ data:ko.toJSON(new LdapGroupMappingUpdateRequest(ldapGroupMappings)),
+ dataType: 'json',
+ success: function(data) {
+ displaySuccessMessage(message);
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete:function(data){
+ removeMediumSpinnerImg(userMessages);
+ saveButton.button('reset');
+ self.redbackRuntimeConfiguration().modified(false);
+ self.redbackRuntimeConfiguration().ldapConfiguration().modified(false);
+ }
+ }
+ );
+ }
+
+
+ } else {
+ $.log("not save modifiesLdapGroupMappings");
+ }
+ self.modifiesLdapGroupMappings=ko.observableArray([]);
+ }
+ this.modifiesLdapGroupMappings=ko.observableArray([]);
+
+ this.modifyLdapGroupMapping=function(roleNames,ldapGroupMapping){
+ var toAdd=true;
+ $.each(self.modifiesLdapGroupMappings(),function(idx,item){
+ if(item.group()==ldapGroupMapping.group()){
+ toAdd=false;
+ }
+ });
+ if(toAdd){
+ self.modifiesLdapGroupMappings().push(ldapGroupMapping);
+ }
+ $.log('modifyLdapGroupMapping:'+ldapGroupMapping.group()+','+self.modifiesLdapGroupMappings().length);
+ };
+ //olamy could be better but some reason doesn't work and I didn't find enough to understand why :-)
+ /*self.gridldapMappingsViewModel = new ko.simpleGrid.viewModel({
+ data: self.redbackRuntimeConfiguration().ldapGroupMappings,
+ pageSize: 10,
+ gridUpdateCallBack: function(){
+ $.log("ldapGroupsMapping: gridUpdateCallBack");
+ $("#main-content").find("#ldap-group-mappings-div select" ).select2({width: "element"});
+ }
+ });*/
+
+ self.gridViewModel = new ko.simpleGrid.viewModel({
+ data: self.redbackRuntimeConfiguration().configurationPropertiesEntries,
+ columns: [
+ {
+ headerText: $.i18n.prop('redback.runtime.properties.key.label'),
+ rowText: "key"
+ },
+ {
+ headerText: $.i18n.prop('redback.runtime.properties.value.label'),
+ rowText: "value"
+ }
+ ],
+ pageSize: 10,
+ gridUpdateCallBack: function(){
+ activatePopoverDoc();
+ }
+ });
+
+ this.newLdapGroupMapping=ko.observable(new LdapGroupMapping("",[],false,null));
+
+ addLdapGroupMapping=function(){
+ // FIXME validate datas from ldapGroupMapping
+ $.log("addLdapGroupMapping:"+self.newLdapGroupMapping().group()+",roles:"+self.newLdapGroupMapping().roleNames().length);
+ clearUserMessages();
+
+ if (self.newLdapGroupMapping().roleNames().length<1){
+ displayErrorMessage( $.i18n.prop('redback-runtime-ldap-group-mapping.role.mandatory'));
+ return;
+ }
+
+ var mainContent=$("#main-content");
+ var saveButton = mainContent.find("#redback-runtime-configuration-save" );
+ saveButton.button('loading');
+ clearUserMessages();
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ $.ajax("restServices/redbackServices/ldapGroupMappingService",
+ {
+ type: "PUT",
+ contentType: 'application/json',
+ data:ko.toJSON(new LdapGroupMapping(self.newLdapGroupMapping().group(),self.newLdapGroupMapping().roleNames(),false,null)),
+ dataType: 'json',
+ success: function(data) {
+ self.redbackRuntimeConfiguration().ldapGroupMappings
+ .unshift(new LdapGroupMapping(self.newLdapGroupMapping().group(),self.newLdapGroupMapping().roleNames(),false,self.modifyLdapGroupMapping));
+ $.log("addLdapGroupMapping:"+self.redbackRuntimeConfiguration().ldapGroupMappings().length);
+ var message=$.i18n.prop('redback-runtime-ldap-group-mapping.added');
+ displaySuccessMessage(message);
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ }
+ }
+ ).always(
+ function(){
+ removeMediumSpinnerImg(userMessages);
+ $.log("addLdapGroupMapping#always");
+ //self.newLdapGroupMapping.group("");
+ //self.newLdapGroupMapping.roleNames([]);
+ //self.newLdapGroupMapping(new LdapGroupMapping("",[],false,null));
+ saveButton.button('reset');
+ }
+ );
+
+
+ }
+
+ deleteLdapGroupMapping=function(ldapGroupMapping){
+
+
+ var mainContent=$("#main-content");
+ var saveButton = mainContent.find("#redback-runtime-configuration-save" );
+ saveButton.button('loading');
+ clearUserMessages();
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ $.ajax("restServices/redbackServices/ldapGroupMappingService/"+ldapGroupMapping.group(),
+ {
+ type: "DELETE",
+ contentType: 'application/json',
+ dataType: 'json',
+ success: function(data) {
+ $.log("deleteLdapGroupMapping:"+ldapGroupMapping.group());
+ self.redbackRuntimeConfiguration().ldapGroupMappings.remove(ldapGroupMapping);
+ var message=$.i18n.prop('redback-runtime-ldap-group-mapping.deleted');
+ displaySuccessMessage(message);
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ }
+ }
+ ).always(
+ function(){
+ removeMediumSpinnerImg(userMessages);
+ saveButton.button('reset');
+ }
+ );
+ }
+ }
+
+ ManagerImplementationInformation=function(beanId,descriptionKey,readOnly){
+ this.beanId=beanId;
+ this.descriptionKey=descriptionKey;
+ this.description= $.i18n.prop(descriptionKey);
+ this.readOnly=readOnly;
+ }
+
+ mapManagerImplementationInformations=function(data){
+ return $.map(data, function(item) {
+ return mapManagerImplementationInformation(item);
+ });
+ }
+
+ mapManagerImplementationInformation=function(data){
+ if(data==null){
+ return null;
+ }
+ return new ManagerImplementationInformation(data.beanId,data.descriptionKey,data.readOnly);
+ }
+
+ activateRedbackRuntimeGeneralFormValidation=function(){
+ var formSelector=$("#main-content" ).find("#redback-runtime-general-form-id");
+ var validator = formSelector.validate({
+ rules: {
+ usersCacheTimeToLiveSeconds : {
+ digits: true,
+ min: 1,
+ required: true
+ },
+ usersCacheTimeToIdleSeconds : {
+ digits: true,
+ min: 1,
+ required: true
+ },
+ maxElementsInMemory : {
+ digits: true,
+ min: 1,
+ required: true
+ },
+ maxElementsOnDisk : {
+ digits: true,
+ min: 1,
+ required: true
+ }
+ },
+ showErrors: function(validator, errorMap, errorList) {
+ customShowError(formSelector,validator,errorMap,errorMap);
+ }
+ });
+ }
+
+ activateLdapConfigurationFormValidation=function(){
+ var formSelector=$("#main-content" ).find("#redback-runtime-ldap-form-id");
+ var validator = formSelector.validate({
+ rules: {
+ ldapHost : {
+ required: true
+ },
+ ldapPort : {
+ digits: true,
+ min: 1,
+ required: true
+ }
+ },
+ showErrors: function(validator, errorMap, errorList) {
+ customShowError(formSelector,validator,errorMap,errorMap);
+ }
+ });
+ }
+
+ displayRedbackRuntimeConfiguration=function(){
+ var jqueryUi = require("jquery.ui");
+ $.log("displayRuntimeConfiguration");
+ var mainContent = $("#main-content");
+ mainContent.html(mediumSpinnerImg());
+
+ $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/redbackImplementationsInformations", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ var userManagerImplementationInformations=data?mapManagerImplementationInformations(data.userManagerImplementationInformations):[];
+ var rbacManagerImplementationInformations=data?mapManagerImplementationInformations(data.rbacManagerImplementationInformations):[];
+ $.log("rbacManagerImplementationInformations:"+rbacManagerImplementationInformations.length);
+ $.ajax("restServices/archivaServices/redbackRuntimeConfigurationService/redbackRuntimeConfiguration", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ var redbackRuntimeConfiguration = mapRedbackRuntimeConfiguration(data);
+ $.log("before new RedbackRuntimeConfigurationViewModel");
+ var redbackRuntimeConfigurationViewModel =
+ new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations,rbacManagerImplementationInformations);
+
+ var groups=[];
+ $.log("before useLdap:"+$.inArray("ldap",redbackRuntimeConfiguration.userManagerImpls())
+ +','+$.inArray("ldap",redbackRuntimeConfiguration.rbacManagerImpls()));
+ var useLdap = $.inArray("ldap",redbackRuntimeConfiguration.userManagerImpls())>=0
+ ||$.inArray("ldap",redbackRuntimeConfiguration.rbacManagerImpls())>=0;
+ $.log("useLdap:"+useLdap);
+ if(useLdap){
+ $.log("in get ldap groups");
+
+ // load ldap roles
+ $.ajax("restServices/redbackServices/ldapGroupMappingService/ldapGroups", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+ groups = mapStringList(data);
+ $.log("groups number:"+groups.length);
+ redbackRuntimeConfiguration.ldapGroups=ko.observableArray(groups);
+ }
+ } )
+ .always(
+ function() {
+ $.log("complete");
+
+ // load ldap group mappings if any
+ $.ajax("restServices/redbackServices/ldapGroupMappingService", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ var groupMappings=mapLdapGroupMappings(data,redbackRuntimeConfigurationViewModel.modifyLdapGroupMapping);
+
+ $.ajax("restServices/redbackServices/roleManagementService/allRoles", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ displayRuntimeConfigurationScreen(redbackRuntimeConfigurationViewModel,data,groupMappings,groups);
+ }
+ });
+ }
+ });
+ }
+ );
+ } else {
+ $.log("before displayRuntimeConfigurationScreen");
+ displayRuntimeConfigurationScreen(redbackRuntimeConfigurationViewModel,null,null);
+ }
+ }
+ });
+
+ }
+ });
+
+ }
+
+ displayRuntimeConfigurationScreen=function(redbackRuntimeConfigurationViewModel,allRoles,groupMappings,groups){
+ var allRoleNames = $.map(allRoles?allRoles:[], function(item) {
+ return item.name;
+ });
+
+ redbackRuntimeConfigurationViewModel.allRoleNames=ko.observableArray(allRoleNames);
+
+ if (redbackRuntimeConfigurationViewModel.redbackRuntimeConfiguration().ldapConfiguration().useRoleNameAsGroup()&&groups) {
+ // if using groups == roles add all as mapping except already mapped
+ $.each(groups,function(idx,item){
+ var exists=false;
+ // avoid duplicate if mapping really exists !
+ $.each(groupMappings,function(idx2,groupMapping){
+ if(groupMapping.group()==item){
+ exists=true;
+ }
+ });
+ if(!exists){
+ groupMappings.push(new LdapGroupMapping(item,[item],true,redbackRuntimeConfigurationViewModel.modifyLdapGroupMapping));
+ }
+
+ });
+ }
+
+ redbackRuntimeConfigurationViewModel.redbackRuntimeConfiguration().ldapGroupMappings=ko.observableArray(groupMappings?groupMappings:[]);
+ redbackRuntimeConfigurationViewModel.redbackRuntimeConfiguration().modified(false);
+
+ $("#main-content").html( $("#redback-runtime-configuration-main" ).tmpl() );
+ $.log("applyBindings:#redback-runtime-configuration-content:"+redbackRuntimeConfigurationViewModel.redbackRuntimeConfiguration().ldapGroupMappings().length);
+ ko.applyBindings(redbackRuntimeConfigurationViewModel,$("#redback-runtime-configuration-content" ).get(0));
+ activateRedbackRuntimeGeneralFormValidation();
+ activateLdapConfigurationFormValidation();
+ }
+
+ LdapGroupMapping=function(group,roleNames,automatic,subscribeFn){
+ var self=this;
+ this.modified=ko.observable(false);
+ //private String group;
+ this.group=ko.observable(group);
+ this.group.subscribe(function(newValue){
+ self.modified(true);
+ if(subscribeFn){
+ subscribeFn(newValue,self)
+ }
+ });
+
+ //private Collection<String> roleNames;
+ this.roleNames=ko.observableArray(roleNames);
+ this.roleNames.subscribe(function(newValue){
+ self.modified(true);
+ $.log("roleNames modified");
+ if(subscribeFn){
+ subscribeFn(newValue,self);
+ }
+ });
+
+ this.automatic=automatic?automatic:false;
+ this.update=true;
+ }
+
+ LdapGroupMappingUpdateRequest=function(ldapGroupMappings){
+ this.ldapGroupMappings=ko.observableArray(ldapGroupMappings?ldapGroupMappings:[]);
+ }
+
+ mapLdapGroupMappings=function(data,modifyLdapGroupMapping){
+ if(data!=null){
+ return $.map(data,function(item){
+ return new LdapGroupMapping(item.group,item.roleNames?item.roleNames:[],false,modifyLdapGroupMapping);
+ })
+ }
+ return [];
+ }
+
+ CacheConfiguration=function(timeToIdleSeconds,timeToLiveSeconds,maxElementsInMemory,maxElementsOnDisk){
+ var self=this;
+ this.modified=ko.observable(false);
+
+ this.timeToIdleSeconds=ko.observable(timeToIdleSeconds);
+ this.timeToIdleSeconds.subscribe(function(newValue){self.modified(true)});
+
+ this.timeToLiveSeconds=ko.observable(timeToLiveSeconds);
+ this.timeToLiveSeconds.subscribe(function(newValue){self.modified(true)});
+
+ this.maxElementsInMemory=ko.observable(maxElementsInMemory);
+ this.maxElementsInMemory.subscribe(function(newValue){self.modified(true)});
+
+ this.maxElementsOnDisk=ko.observable(maxElementsOnDisk);
+ this.maxElementsOnDisk.subscribe(function(newValue){self.modified(true)});
+
+ }
+
+ mapCacheConfiguration=function(data){
+ if(!data){
+ return new CacheConfiguration();
+ }
+ return new CacheConfiguration(data.timeToIdleSeconds,data.timeToLiveSeconds,data.maxElementsInMemory,data.maxElementsOnDisk);
+ }
+
+
+
+});
--- /dev/null
+/*
+ * 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/admin/features/networkproxies/main",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","knockout"
+ ,"knockout.simpleGrid"], function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
+
+ showMenu = function(administrationMenuItems) {
+ administrationMenuItems.push(
+ { text : $.i18n.prop('menu.network-proxies') ,order:1000, id: "menu-network-proxies-list-a" , href: "#networkproxies" , redback: "{permissions: ['archiva-manage-configuration']}", func: function(){displayNetworkProxies()}}
+ );
+ }
+
+ NetworkProxy=function(id,protocol,host,port,username,password,useNtlm){
+ var self=this;
+ //private String id;
+ this.id = ko.observable(id);
+ this.id.subscribe(function(newValue){self.modified(true)});
+
+ //private String protocol = "http";
+ this.protocol=ko.observable(protocol);
+ this.protocol.subscribe(function(newValue){self.modified(true)});
+
+ //private String host;
+ this.host=ko.observable(host);
+ this.host.subscribe(function(newValue){self.modified(true)});
+
+ //private int port = 8080;
+ this.port=ko.observable(port);
+ this.port.subscribe(function(newValue){self.modified(true)});
+
+ //private String username;
+ this.username=ko.observable(username?username:"");
+ this.username.subscribe(function(newValue){self.modified(true)});
+
+ //private String password;
+ this.password=ko.observable(password?password:"");
+ this.password.subscribe(function(newValue){self.modified(true)});
+
+ //use NTLM proxy
+ this.useNtlm=ko.observable(useNtlm?useNtlm:false);
+ this.useNtlm.subscribe(function(newValue){self.modified(true)});
+
+ this.modified=ko.observable(false);
+ }
+
+ NetworkProxyViewModel=function(networkProxy, update, networkProxiesViewModel,bulkMode){
+ this.update=update;
+ this.networkProxy=networkProxy;
+ this.networkProxiesViewModel=networkProxiesViewModel;
+ var self=this;
+ this.bulkMode=false || bulkMode;
+
+ this.save=function(){
+ if (!$("#main-content" ).find("#network-proxy-edit-form").valid()){
+ return;
+ }
+ if (!this.bulkMode){
+ clearUserMessages();
+ }
+ if (update){
+ $.ajax("restServices/archivaServices/networkProxyService/updateNetworkProxy",
+ {
+ type: "POST",
+ contentType: 'application/json',
+ data: ko.toJSON(networkProxy),
+ dataType: 'json',
+ success: function(data) {
+ $.log("update proxy id:"+self.networkProxy.id());
+ var message=$.i18n.prop('networkproxy.updated',self.networkProxy.id());
+ displaySuccessMessage(message);
+ self.networkProxy.modified(false);
+ if (!this.bulkMode){
+ activateNetworkProxiesGridTab();
+ }
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ }
+ }
+ );
+ } else {
+
+ $.ajax("restServices/archivaServices/networkProxyService/addNetworkProxy",
+ {
+ type: "POST",
+ contentType: 'application/json',
+ data: ko.toJSON(networkProxy),
+ dataType: 'json',
+ success: function(data) {
+ self.networkProxy.modified(false);
+ self.networkProxiesViewModel.networkProxies.push(self.networkProxy);
+ displaySuccessMessage($.i18n.prop('networkproxy.added',self.networkProxy.id()));
+ activateNetworkProxiesGridTab();
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ }
+ }
+ );
+
+ }
+ }
+
+ displayGrid=function(){
+ activateNetworkProxiesGridTab();
+ }
+ }
+
+ NetworkProxiesViewModel=function(){
+ this.networkProxies=ko.observableArray([]);
+
+ var self=this;
+
+ this.gridViewModel = null;
+
+ editNetworkProxy=function(networkProxy){
+ clearUserMessages();
+ $.log("editNetworkProxy");
+ var mainContent = $("#main-content");
+ mainContent.find("#network-proxies-view-tabs-li-edit a").html($.i18n.prop("edit"));
+ var viewModel = new NetworkProxyViewModel(networkProxy,true,self);
+ ko.applyBindings(viewModel,mainContent.find("#network-proxies-edit").get(0));
+ activateNetworkProxyFormValidation();
+ activateNetworkProxyEditTab();
+ mainContent.find("#network-proxy-btn-save").attr("disabled","true");
+ mainContent.find("#network-proxy-btn-save").button('toggle');
+ }
+
+ this.bulkSave=function(){
+ return getModifiedNetworkProxies().length>0;
+ }
+
+ getModifiedNetworkProxies=function(){
+ var prx = $.grep(self.networkProxies(),
+ function (networkProxy,i) {
+ return networkProxy.modified();
+ });
+ return prx;
+ }
+
+
+ updateModifiedNetworkProxies=function(){
+ var modifiedNetworkProxies = getModifiedNetworkProxies();
+
+ openDialogConfirm(function(){
+ for(var i=0;i<modifiedNetworkProxies.length;i++){
+ var viewModel = new NetworkProxyViewModel(modifiedNetworkProxies[i],true,self,false);
+ viewModel.save();
+ }
+ closeDialogConfirm();
+ },
+ $.i18n.prop('ok'),
+ $.i18n.prop('cancel'),
+ $.i18n.prop('networkproxy.bulk.save.confirm.title'),
+ $.i18n.prop('networkproxy.bulk.save.confirm',modifiedNetworkProxies.length));
+
+
+ }
+
+ updateNetworkProxy=function(networkProxy){
+ var viewModel = new NetworkProxyViewModel(networkProxy,true,self,false);
+ viewModel.save();
+ }
+
+ removeNetworkProxy=function(networkProxy){
+ openDialogConfirm(
+ function(){
+ $.ajax("restServices/archivaServices/networkProxyService/deleteNetworkProxy/"+encodeURIComponent(networkProxy.id()),
+ {
+ type: "get",
+ success: function(data) {
+ self.networkProxies.remove(networkProxy);
+ clearUserMessages();
+ displaySuccessMessage($.i18n.prop('networkproxy.deleted',networkProxy.id()));
+ activateNetworkProxiesGridTab();
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete: function(){
+ closeDialogConfirm();
+ }
+ }
+ )}, $.i18n.prop('ok'), $.i18n.prop('cancel'), $.i18n.prop('networkproxy.delete.confirm',networkProxy.id()),
+ $("#network-proxy-delete-warning-tmpl" ).tmpl(networkProxy));
+ }
+ }
+
+
+ displayNetworkProxies=function(){
+ screenChange();
+ var mainContent = $("#main-content");
+ mainContent.html(mediumSpinnerImg());
+
+
+
+ loadNetworkProxies( function(data) {
+ var networkProxiesViewModel = new NetworkProxiesViewModel();
+ mainContent.html($("#networkProxiesMain").tmpl());
+ mainContent.find("#network-proxies-view-tabs a:first").tab('show');
+
+ mainContent.find("#network-proxies-view-tabs").on('show', function (e) {
+ if ($(e.target).attr("href")=="#network-proxies-edit") {
+ var viewModel = new NetworkProxyViewModel(new NetworkProxy(),false,networkProxiesViewModel);
+ ko.applyBindings(viewModel,$("#main-content" ).find("#network-proxies-edit").get(0));
+ activateNetworkProxyFormValidation();
+ clearUserMessages();
+ }
+ if ($(e.target).attr("href")=="#network-proxies-view") {
+ $("#main-content" ).find("#network-proxies-view-tabs-li-edit a").html($.i18n.prop("add"));
+ clearUserMessages();
+ }
+
+ });
+ networkProxiesViewModel.networkProxies(mapNetworkProxies(data));
+ networkProxiesViewModel.gridViewModel = new ko.simpleGrid.viewModel({
+ data: networkProxiesViewModel.networkProxies,
+ columns: [
+ {
+ headerText: $.i18n.prop('identifier'),
+ rowText: "id"
+ },
+ {
+ headerText: $.i18n.prop('protocol'),
+ rowText: "protocol"
+ },
+ {
+ headerText: $.i18n.prop('host'),
+ rowText: "host"
+ },
+ {
+ headerText: $.i18n.prop('port'),
+ rowText: "port"
+ },
+ {
+ headerText: $.i18n.prop('username'),
+ rowText: "username"
+ }
+ ],
+ pageSize: 5,
+ gridUpdateCallBack: function(networkProxy){
+ $("#main-content" ).find("#networkProxiesTable [title]").tooltip();
+ }
+ });
+ ko.applyBindings(networkProxiesViewModel,$("#main-content" ).find("#network-proxies-view").get(0));
+ }
+ )
+ }
+
+ loadNetworkProxies=function(successCallbackFn, errorCallbackFn){
+ $.ajax("restServices/archivaServices/networkProxyService/getNetworkProxies", {
+ type: "GET",
+ dataType: 'json',
+ success: successCallbackFn,
+ error: errorCallbackFn
+ });
+ }
+
+ activateNetworkProxyFormValidation=function(){
+ var editForm=$("#main-content" ).find("#network-proxy-edit-form");
+ var validator = editForm.validate({
+ rules: {id: {
+ required: true,
+ remote: {
+ url: "restServices/archivaUiServices/dataValidatorService/networkProxyIdNotExists",
+ type: "get"
+ }
+ }},
+ showErrors: function(validator, errorMap, errorList) {
+ customShowError(editForm,validator,errorMap,errorMap);
+ }
+ });
+ validator.settings.messages["id"]=$.i18n.prop("id.required.or.alreadyexists");
+ }
+
+ activateNetworkProxiesGridTab=function(){
+ var mainContent = $("#main-content");
+ mainContent.find("#network-proxies-view-tabs-li-edit").removeClass("active");
+ mainContent.find("#network-proxies-edit").removeClass("active");
+
+ mainContent.find("#network-proxies-view-tabs-li-grid").addClass("active");
+ mainContent.find("#network-proxies-view").addClass("active");
+ mainContent.find("#network-proxies-view-tabs-li-edit a").html($.i18n.prop("add"));
+
+ }
+
+ activateNetworkProxyEditTab=function(){
+ var mainContent = $("#main-content");
+ mainContent.find("#network-proxies-view-tabs-li-grid").removeClass("active");
+ mainContent.find("#network-proxies-view").removeClass("active");
+
+ mainContent.find("#network-proxies-view-tabs-li-edit").addClass("active");
+ mainContent.find("#network-proxies-edit").addClass("active");
+ }
+
+ mapNetworkProxy=function(data){
+ if (data==null){
+ return null;
+ }
+ return new NetworkProxy(data.id,data.protocol,data.host,data.port,data.username,data.password,data.useNtlm);
+ }
+
+ mapNetworkProxies=function(data){
+ var mappedNetworkProxies = $.map(data, function(item) {
+ return mapNetworkProxy(item);
+ });
+ return mappedNetworkProxies;
+ }
+
+});
\ No newline at end of file
+++ /dev/null
-/*
- * 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/admin/repository/10maven2/main",["jquery",'i18n',"archiva/admin/repository/10maven2/repository-groups","archiva/admin/repository/10maven2/proxy-connectors-rules","archiva/admin/repository/10maven2/proxy-connectors"],
- function() {
- showMenu = function(administrationMenuItems) {
- administrationMenuItems.push(
- {text: $.i18n.prop('menu.repository.groups'),
- id: "menu-repository-groups-list-a",
- href: "#repositorygroup",
- redback: "{permissions: ['archiva-manage-configuration']}",
- func: function() {
- displayRepositoryGroups();
- }
- });
- administrationMenuItems.push({text: $.i18n.prop('menu.repositories'), id: "menu-repositories-list-a", href: "#repositorylist", redback: "{permissions: ['archiva-manage-configuration']}", func: function() {
- displayRepositoriesGrid();
- }});
- administrationMenuItems.push({text: $.i18n.prop('menu.proxy-connectors'), id: "menu-proxy-connectors-list-a", href: "#proxyconnectors", redback: "{permissions: ['archiva-manage-configuration']}", func: function() {
- displayProxyConnectors();
- }});
- administrationMenuItems.push({text: $.i18n.prop('menu.proxy-connectors-rules'), id: "menu.proxy-connectors-rules-list-a", href: "#proxyconnectorsrules", redback: "{permissions: ['archiva-manage-configuration']}", func: function() {
- displayProxyConnectorsRules();
- }});
-
- };
- }
-
-);
\ No newline at end of file
+++ /dev/null
-/*
- * 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/admin/repository/10maven2/proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstrap","jquery.ui","knockout"
- ,"knockout.simpleGrid","knockout.sortable","archiva/admin/repository/10maven2/proxy-connectors"],
- function(jquery,i18n,jqueryTmpl,bootstrap,jqueryUi,ko) {
-
- ProxyConnectorRulesViewModel=function(proxyConnectorRules,proxyConnectors){
- var self=this;
- self.proxyConnectorRules=ko.observableArray(proxyConnectorRules?proxyConnectorRules:[]);
- self.proxyConnectors=ko.observableArray(proxyConnectors);
- self.proxyConnectors.id="select";
-
- // FIXME get that from a REST service
- // FIXME i18n
- this.ruleTypes=[new RuleType("BLACK_LIST","Black list","images/red-22-22.png"),new RuleType("WHITE_LIST","White list","images/green-22-22.png")];
-
- this.findRuleType=function(proxyConnectorRule){
- var ruleType;
- $.each(self.ruleTypes, function(index, value) {
- if(value.type==proxyConnectorRule.proxyConnectorRuleType()){
- ruleType=value;
- }
- });
- 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(){
- var mainContent = $("#main-content");
-
- $.each(self.proxyConnectorRules(), function(index, value) {
- value.ruleType=self.findRuleType(value);
- });
-
- 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-connector-rules-view").get(0));
-
- removeSmallSpinnerImg(mainContent);
-
- 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();
- }
- });
- }
- addProxyConnectorRule=function(proxyConnectorRule){
- $("#proxy-connector-rule-add-btn" ).button("loading");
- $.log("addProxyConnectorRule");
- self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/proxyConnectorRule",true,
- function(){
- $("#proxy-connector-rule-add-btn" ).button("reset");
- });
- }
-
- this.saveProxyConnectorRule=function(proxyConnectorRule,url,add,completeFnCallback){
- $.log("saveProxyConnectorRule:"+url);
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- $.ajax(url,
- {
- type: "POST",
- contentType: 'application/json',
- data: ko.toJSON(proxyConnectorRule),
- dataType: 'json',
- success: function(data) {
- $.log("save proxyConnectorRule pattern:"+proxyConnectorRule.pattern());
- var message=$.i18n.prop(add?'proxy-connector-rule.added':'proxy-connector-rule.updated',proxyConnectorRule.pattern());
- displaySuccessMessage(message);
- proxyConnectorRule.modified(false);
- if(add){
- // add rule type for image
- proxyConnectorRule.ruleType=self.findRuleType(proxyConnectorRule);
- self.proxyConnectorRules.push(proxyConnectorRule);
- }
- activateProxyConnectorRulesGridTab();
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete:function(data){
- removeMediumSpinnerImg(userMessages);
- if(completeFnCallback){
- completeFnCallback();
- }
- }
- }
- );
- }
-
- updateProxyConnectorRule=function(proxyConnectorRule){
- $.log("updateProxyConnectorRule");
- $("#main-content" ).find("#proxy-connectors-rules-edit-div").find("#proxy-connector-rule-update-btn").button("loading");
- self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/updateProxyConnectorRule",
- false,
- function(){
- $("#proxy-connector-rule-update-btn" ).button("reset");
- }
- );
- }
-
- this.deleteProxyConnectorRule=function(proxyConnectorRule){
- $("#main-content" ).find("proxy-connectors-rules-view-tabsTable").find(".btn").button("loading");
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- $.ajax("restServices/archivaServices/proxyConnectorRuleService/deleteProxyConnectorRule",
- {
- type:"POST",
- contentType: 'application/json',
- data: ko.toJSON(proxyConnectorRule),
- dataType: 'json',
- success:function(data){
- var message=$.i18n.prop('proxy-connector-rule.deleted',proxyConnectorRule.pattern());
- self.proxyConnectorRules.remove(proxyConnectorRule);
- displaySuccessMessage(message);
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete:function(data){
- removeMediumSpinnerImg(userMessages);
- $("#main-content" ).find("proxy-connectors-rules-view-tabsTable").find(".btn").button("reset");
- }
- }
- );
- }
-
- removeProxyConnectorRule=function(proxyConnectorRule){
-
- openDialogConfirm(
- function(){self.deleteProxyConnectorRule(proxyConnectorRule);window.modalConfirmDialog.modal('hide')},
- $.i18n.prop('ok'), $.i18n.prop('cancel'),
- $.i18n.prop('proxy-connector-rule.delete.confirm',proxyConnectorRule.pattern()),"");
-
- }
-
- editProxyConnectorRule=function(proxyConnectorRule){
- var proxyConnectorRuleViewModel=new ProxyConnectorRuleViewModel(proxyConnectorRule,self,true);
- ko.applyBindings(proxyConnectorRuleViewModel,$("#main-content").find("#proxy-connector-rules-edit" ).get(0));
- activateProxyConnectorRulesEditTab();
- proxyConnectorRuleViewModel.activateRemoveChoosen(self);
- proxyConnectorRuleViewModel.activateRemoveAvailable(self);
- }
-
- remove=function(){
- $.log("remove");
- }
-
- }
-
- ProxyConnectorRuleViewModel=function(proxyConnectorRule,proxyConnectorRulesViewModel,update){
- var self=this;
- this.proxyConnectorRule=proxyConnectorRule;
- this.proxyConnectorRulesViewModel=proxyConnectorRulesViewModel;
- this.availableProxyConnectors=ko.observableArray([]);
- this.availableProxyConnectors.id="availableProxyConnectors";
- this.update=update;
-
- $.each(this.proxyConnectorRulesViewModel.proxyConnectors(), function(idx, value) {
- //$.log(idx + ': ' + value.sourceRepoId() +":"+value.targetRepoId());
- var available=true;
- // is it in proxyConnectorRule.proxyConnectors
- $.each(self.proxyConnectorRule.proxyConnectors(),function(index,proxyConnector){
- if(value.sourceRepoId()==proxyConnector.sourceRepoId() && value.targetRepoId()==proxyConnector.targetRepoId()){
- available=false;
- }
- });
- if(available==true){
- self.availableProxyConnectors.push(value);
- }
- });
-
- proxyConnectorMoved=function(arg){
- $.log("repositoryMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
- self.proxyConnectorRule.modified(true);
- self.activateRemoveChoosen(self.proxyConnectorRulesViewModel);
- self.activateRemoveAvailable(self.proxyConnectorRulesViewModel);
- }
-
- saveProxyConnectorRule=function(){
- 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){
- proxyConnectorToRemove=self.proxyConnectorRule.proxyConnectors()[i];
- }
- }
- self.proxyConnectorRule.proxyConnectors.remove(proxyConnectorToRemove);
- self.availableProxyConnectors.push(proxyConnectorToRemove);
- $.log("size after:"+self.proxyConnectorRule.proxyConnectors().length);
- var mainContent=$("#main-content");
- mainContent.find("#proxy-connectors-rules-available-proxy-connectors" ).find("[data-source-repoId="+sourceRepoId+"][data-target-repoId="+targetRepoId+"]" ).on("click", function(){
- self.removeAvailable(proxyConnectorRulesViewModel,$(this).attr("data-source-repoId"),$(this).attr("data-target-repoId"));
- });
- mainContent.find("#proxy-connectors-rules-edit-order-div" ).find("[data-source-repoId="+sourceRepoId+"][data-target-repoId="+targetRepoId+"]" ).off("click");
- }
-
- 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.availableProxyConnectors().length);
- var mainContent=$("#main-content");
- mainContent.find("#proxy-connectors-rules-edit-order-div" ).find("[data-source-repoId="+sourceRepoId+"][data-target-repoId="+targetRepoId+"]" ).on("click", function(){
- self.removeChoosen(proxyConnectorRulesViewModel,$(this).attr("data-source-repoId"),$(this).attr("data-target-repoId"));
- });
- mainContent.find("#proxy-connectors-rules-available-proxy-connectors" ).find("[data-source-repoId="+sourceRepoId+"][data-target-repoId="+targetRepoId+"]" ).off("click");
- }
-
- 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"));
- });
- }
-
- }
-
-
- displayProxyConnectorsRules=function(){
- $.log("displayProxyConnectorsRules");
- screenChange();
- var mainContent = $("#main-content");
- mainContent.html($("#proxyConnectorsRulesMain").tmpl());
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- 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();
- },
- complete: function(data){
- removeMediumSpinnerImg(userMessages);
- }
-
- });
-
- });
- }
-
- 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);
- });
-
- this.ruleType=null;
-
- //private ProxyConnectorRuleType proxyConnectorRuleType;
- this.proxyConnectorRuleType=ko.observable(proxyConnectorRuleType);
- this.proxyConnectorRuleType.subscribe(function(newValue){
- self.modified(true);
- });
-
- //private List<ProxyConnector> proxyConnectors;
- this.proxyConnectors=ko.observableArray(proxyConnectors?proxyConnectors:[]);
- this.proxyConnectors.subscribe(function(newValue){
- self.modified(true);
- });
-
- this.ruleType=null;
- }
-
- mapProxyConnectorRule=function(data){
- if (data==null){
- return null;
- }
- return new ProxyConnectorRule(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("#proxy-connector-rules-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");
- }
-
- RuleType=function(type,label,image){
- this.type=type;
- this.label=label;
- this.image=image;
- }
-
-});
+++ /dev/null
-/*
- * 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/admin/repository/10maven2/proxy-connectors",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","knockout"
- ,"knockout.simpleGrid","knockout.sortable","select2"],
- function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
-
- ProxyConnector=function(sourceRepoId,targetRepoId,proxyId,blackListPatterns,whiteListPatterns,policiesEntries,propertiesEntries,
- disabled,order){
- var self=this;
-
- this.modified=ko.observable(false);
-
- //private String sourceRepoId;
- this.sourceRepoId=ko.observable(sourceRepoId);
- this.sourceRepoId.subscribe(function(newValue){
- self.modified(true);
- });
-
- //private String targetRepoId;
- this.targetRepoId=ko.observable(targetRepoId);
- this.targetRepoId.subscribe(function(newValue){
- self.modified(true);
- });
-
- this.previousProxyId=proxyId;
-
- //private String proxyId;
- this.proxyId=ko.observable(proxyId);
- this.proxyId.subscribe(function(newValue){
- if(newValue!=self.previousProxyId){
- $.log("proxyId modified:"+newValue+",previous:"+self.previousProxyId);
- self.previousProxyId=newValue;
- self.modified(true);
- }
- });
-
- //private List<String> blackListPatterns;
- this.blackListPatterns=ko.observableArray(blackListPatterns==null?[]:blackListPatterns);
- this.blackListPatterns.subscribe(function(newValue){
- self.modified(true);
- });
-
- //private List<String> whiteListPatterns;
- this.whiteListPatterns=ko.observableArray(whiteListPatterns==null?[]:whiteListPatterns);
- this.whiteListPatterns.subscribe(function(newValue){
- self.modified(true);
- });
-
- //private List<PropertyEntry> policiesEntries;
- this.policiesEntries=ko.observableArray(policiesEntries==null?new Array():policiesEntries);
- this.policiesEntries.subscribe(function(newValue){
- self.modified(true);
- });
-
- //private List<PropertyEntry> properties;
- this.propertiesEntries=ko.observableArray(propertiesEntries==null?new Array():propertiesEntries);
- this.propertiesEntries.subscribe(function(newValue){
- self.modified(true);
- });
-
- //private boolean disabled = false;
- this.disabled=ko.observable(disabled);
- this.disabled.subscribe(function(newValue){
- self.modified(true);
- });
-
- //private int order = 0;
- this.order=ko.observable(order?order:0);
- this.order.subscribe(function(newValue){
- self.modified(true);
- });
-
-
-
- this.updatePolicyEntry=function(key,value){
- $.log("updatePolicyEntry:"+key+":"+value);
- var found=false;
- for(var i=0;i<self.policiesEntries().length;i++){
- if (self.policiesEntries()[i].key==key){
- self.policiesEntries()[i].value=value;
- found=true;
- self.modified(true);
- }
- }
- if(!found){
- self.policiesEntries().push(new Entry(key,value));
- }
- }
-
- }
-
- PolicyInformation=function(options,defaultOption,id,name){
-
- var self=this;
- this.modified=ko.observable(false);
-
- //private List<String> options;
- this.options=ko.observableArray(options);
- this.options.subscribe(function(newValue){self.modified(true)});
-
- //private String defaultOption;
- this.defaultOption=ko.observable(defaultOption);
- this.defaultOption.subscribe(function(newValue){self.modified(true)});
-
- //private String id;
- this.id=ko.observable(id);
- this.id.subscribe(function(newValue){self.modified(true)});
-
- //private String name;
- this.name=ko.observable(name);
- this.name.subscribe(function(newValue){self.modified(true)});
-
- }
-
- ProxyConnectorViewModel=function(proxyConnector,update,proxyConnectorsViewModel){
- var self=this;
- this.proxyConnector=proxyConnector;
- this.proxyConnectorsViewModel=proxyConnectorsViewModel;
- this.update=update;
- this.modified=ko.observable(false);
-
- isUpdate=function(){
- return self.update;
- }
-
- getSelectedPolicyOption=function(id){
- var policiesEntries=self.proxyConnector.policiesEntries();
- if (policiesEntries!=null){
- for (i=0;i<policiesEntries.length;i++){
- var curKey = $.isFunction(policiesEntries[i].key)? policiesEntries[i].key():policiesEntries[i].key;
- if (id==curKey){
- return $.isFunction(policiesEntries[i].value)? policiesEntries[i].value():policiesEntries[i].value;
- }
- }
- }
- return "";
- }
-
- changePolicyOption=function(id){
- var selectedOption=$("#main-content").find("#policy-"+id ).find("option:selected");
- if (selectedOption.length>0){
- var value = selectedOption.val();
- $.log("changePolicyOption:"+id+":"+value);
- self.proxyConnector.updatePolicyEntry(id,value);
-
- }
- }
-
-
- getPolicyOptions=function(id){
- var policyInformations=self.proxyConnectorsViewModel.policyInformations();
- for(var i=0;i<policyInformations.length;i++){
- if (policyInformations[i].id()==id){
- return policyInformations[i].options();
- }
- }
- }
-
-
-
- addBlacklistPattern=function(){
- var pattern = $("#main-content").find("#blacklist-value").val();
- var tab = self.proxyConnector.blackListPatterns();
- tab.push(pattern);
- self.proxyConnector.blackListPatterns(tab);
- self.proxyConnector.modified(true);
- }
-
- removeBlacklistPattern=function(pattern){
- self.proxyConnector.blackListPatterns.remove(pattern);
- self.proxyConnector.modified(true);
- }
-
- addWhitelistPattern=function(){
- var pattern = $("#main-content" ).find("#whitelist-value").val();
- var tab = self.proxyConnector.whiteListPatterns();
- tab.push(pattern);
- self.proxyConnector.whiteListPatterns(tab);
- self.proxyConnector.modified(true);
-
- }
-
- removeWhitelistPattern=function(pattern){
- self.proxyConnector.whiteListPatterns.remove(pattern);
- self.proxyConnector.modified(true);
- }
-
- this.save=function(){
- //FIXME data controls !!!
- clearUserMessages();
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- $("#proxy-connector-btn-save" ).button("loading");
- // update is delete then add
- if (this.update){
- $.ajax("restServices/archivaServices/proxyConnectorService/updateProxyConnector",
- {
- type: "POST",
- data: ko.toJSON(self.proxyConnector),
- contentType: 'application/json',
- dataType: 'json',
- success: function(data) {
- displaySuccessMessage($.i18n.prop('proxyconnector.updated'));
- activateProxyConnectorsGridTab();
- self.proxyConnector.modified(false);
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete: function(){
- removeMediumSpinnerImg(userMessages);
- $("#proxy-connector-btn-save" ).button("reset");
- }
- }
- );
- } else {
-
- $.ajax("restServices/archivaServices/proxyConnectorService/addProxyConnector",
- {
- type: "POST",
- data: ko.toJSON(self.proxyConnector),
- contentType: 'application/json',
- dataType: 'json',
- success: function(data) {
- displaySuccessMessage($.i18n.prop('proxyconnector.added'));
- activateProxyConnectorsGridTab();
- self.proxyConnector.modified(false);
- self.proxyConnectorsViewModel.proxyConnectors.push(self.proxyConnector);
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete: function(){
- removeMediumSpinnerImg(userMessages);
- $("#proxy-connector-btn-save" ).button("reset");
- }
- }
- );
- }
- }
-
- this.deleteProperty=function(key){
- for(var i=0;i<self.proxyConnector.propertiesEntries().length;i++){
- var entry=self.proxyConnector.propertiesEntries()[i];
- if (entry.key()==key()){
- self.proxyConnector.propertiesEntries.remove(entry);
- self.proxyConnector.modified(true);
- }
- }
-
- }
-
- this.addProperty=function(){
- var mainContent=$("#main-content");
- var key=mainContent.find("#property-key").val();
- var value=mainContent.find("#property-value").val();
- var oldTab = self.proxyConnector.propertiesEntries();
- oldTab.push(new Entry(key,value));
- self.proxyConnector.propertiesEntries(oldTab);
- mainContent.find("#property-key").val("");
- mainContent.find("#property-value").val("");
- self.proxyConnector.modified(true);
- }
-
- displayGrid=function(){
- activateProxyConnectorsGridTab();
- }
- }
-
- ProxyConnectorsViewModel=function(){
- var self=this;
- this.proxyConnectors=ko.observableArray([]);
- this.proxyConnectors.subscribe(function(newValue){
- $.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;
- });
- });
- this.policyInformations=ko.observableArray([]);
- this.managedRepositories=ko.observableArray([]);
- this.remoteRepositories=ko.observableArray([]);
- this.networkProxies=ko.observableArray([]);
-
- this.bulkSave=function(){
- return getModifiedProxyConnectors().length>0;
- }
-
- getModifiedProxyConnectors=function(){
- var prx = $.grep(self.proxyConnectors(),
- function (proxyConnector,i) {
- return proxyConnector.modified();
- });
- return prx;
- }
-
- this.updateModifiedProxyConnectors=function(){
- var modifiedProxyConnectors = getModifiedProxyConnectors();
-
- openDialogConfirm(function(){
- for(var i=0;i<modifiedProxyConnectors.length;i++){
- var viewModel = new ProxyConnectorViewModel(modifiedProxyConnectors[i],true,self,false);
- viewModel.save();
- }
- closeDialogConfirm();
- },
- $.i18n.prop('ok'),
- $.i18n.prop('cancel'),
- $.i18n.prop('proxy-connectors.bulk.save.confirm.title'),
- $.i18n.prop('proxy.connector.bulk.save.confirm',modifiedProxyConnectors.length));
- }
-
- updateProxyConnector=function(proxyConnector){
- var viewModel = new ProxyConnectorViewModel(proxyConnector,true,self,false);
- viewModel.save();
- }
-
- editProxyConnector=function(proxyConnector){
- var proxyConnectorViewModel=new ProxyConnectorViewModel(proxyConnector,true,self);
- var mainContent = $("#main-content");
- mainContent.find("#proxy-connectors-edit").html($("#proxy-connector-edit-form-tmpl").tmpl());
- ko.applyBindings(proxyConnectorViewModel,mainContent.find("#proxy-connectors-edit").get(0));
- activateProxyConnectorsEditTab();
- mainContent.find("#proxy-connectors-view-tabs-li-edit a").html($.i18n.prop("edit"));
- }
-
- deleteProxyConnector=function(proxyConnector){
-
- openDialogConfirm(
- function(){
- clearUserMessages();
- removeProxyConnector(proxyConnector,function(){
- displaySuccessMessage($.i18n.prop('proxyconnector.removed'));
- self.proxyConnectors.remove(proxyConnector);
- closeDialogConfirm();
- })}, $.i18n.prop('ok'), $.i18n.prop('cancel'), $.i18n.prop('proxyconnector.delete.confirm'),
- $("#proxy-connector-delete-warning-tmpl").tmpl(proxyConnector));
-
-
- }
-
-
- getManagedRepository=function(id){
- return findManagedRepository(id,self.managedRepositories());
- }
-
- getRemoteRepository=function(id){
- var remoteRepository=$.grep(self.remoteRepositories(),
- function(repo,idx){
- return repo.id()==id;
- }
- );
- return ($.isArray(remoteRepository) && remoteRepository.length>0) ? remoteRepository[0]:new RemoteRepository();
- }
-
- getProxyConnector=function(sourceRepoId,targetRepoId){
- var proxyConnectors=$.grep(self.proxyConnectors(),
- function(proxyConnector,idx){
- return proxyConnector.sourceRepoId()==sourceRepoId
- && proxyConnector.targetRepoId()==targetRepoId;
- }
- );
- var res = ($.isArray(proxyConnectors) && proxyConnectors.length>0) ? proxyConnectors[0]:new ProxyConnector();
- return res;
- }
- showSettings=function(){
- $.log("showSettings");
- $("#body_content" ).find(".popover" ).hide();
- //$("#main-content").find("[id^='proxy-connectors-grid-remoterepo-settings-edit-']" ).popover("hide");
- }
- buildSettings=function(proxyConnector){
- var tmplHtml = $("#proxy-connectors-remote-settings-popover-tmpl")
- .tmpl({
- proxyConnectorsViewModel: self,
- proxyConnector:ko.toJS(proxyConnector)
- } ).html();
-
- var targetImg = $(("#proxy-connectors-grid-remoterepo-settings-edit-")
- +proxyConnector.sourceRepoId().replace(/\./g,"\\\.")+"-"+proxyConnector.targetRepoId().replace(/\./g,"\\\."));
- return tmplHtml;
- }
-
- this.displaySettings=function(sourceRepoId,targetRepoId,targetContentStartId, targetImgStartId){
- var proxyConnector=getProxyConnector(sourceRepoId,targetRepoId);
- showSettings(proxyConnector,targetContentStartId,targetImgStartId);
- }
-
- this.findPolicyInformationName=function(id){
- for(var i=0;i<self.policyInformations().length;i++){
- if (id==self.policyInformations()[i].id()){
- return self.policyInformations()[i].name();
- }
- }
- return null;
- }
-
- orderChangeAware=function(proxyConnector){
- return findProxyConnectorsWithSourceId(proxyConnector).length>1;
- }
-
- findProxyConnectorsWithSourceId=function(proxyConnector){
- return $.grep(self.proxyConnectors(),function(curProxyConnector,idx){
- return curProxyConnector.sourceRepoId()==proxyConnector.sourceRepoId();
- }
- );
- }
-
- displayOrderEdit=function(proxyConnector){
- var proxyConnectors=findProxyConnectorsWithSourceId(proxyConnector);
- $.log("displayOrderEdit:"+proxyConnector.sourceRepoId()+",number:"+proxyConnectors.length);
-
- var managedRepository = getManagedRepository(proxyConnector.sourceRepoId());
- var proxyConnectorEditOrderViewModel=new ProxyConnectorEditOrderViewModel(proxyConnectors,self,managedRepository);
- ko.applyBindings(proxyConnectorEditOrderViewModel,$("#main-content").find("#proxy-connector-edit-order").get(0));
- activateProxyConnectorsEditOrderTab();
- }
-
- this.displayGrid=function(){
- this.gridViewModel = new ko.simpleGrid.viewModel({
- data: self.proxyConnectors,
- pageSize: 5,
- gridUpdateCallBack: function(){
- $("#main-content" ).find("#proxyConnectorsTable" ).find("[title]").tooltip();
- }
- });
- var mainContent = $("#main-content");
-
- ko.applyBindings(this,mainContent.find("#proxy-connectors-view").get(0));
- var prxGrids=mainContent.find("[id^='proxy-connectors-grid-remoterepo-settings-edit-']");
- prxGrids.popover();
- removeSmallSpinnerImg();
- mainContent.find("#proxy-connectors-view-tabs #proxy-connectors-view-tabs-a-network-proxies-grid").tab('show');
-
- mainContent.find("#proxy-connectors-view-tabs").on('show', function (e) {
- $.log("on show:"+$(e.target).attr("href"));
- if ($(e.target).attr("href")=="#proxy-connectors-edit") {
- $.log("#proxy-connectors-edit");
- var proxyConnector=new ProxyConnector();
- var defaultPolicies=new Array();
- // populate with defaut policies options
- for (i=0;i<self.policyInformations().length;i++){
- defaultPolicies.push(new Entry(self.policyInformations()[i].id(),self.policyInformations()[i].defaultOption));
- }
- 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));
- mainContent.find("#sourceRepoId" ).select2();
- mainContent.find("#targetRepoId" ).select2();
- }
- if ($(e.target).attr("href")=="#proxy-connectors-view") {
- $("#proxy-connectors-view-tabs-a-network-proxies-grid").html($.i18n.prop("proxy-connectors.grid.tab.title"));
- mainContent.find("#proxy-connectors-view-tabs-li-edit a").html($.i18n.prop("add"));
- }
- if ($(e.target).attr("href")=="#proxy-connectors-edit-order") {
- activateProxyConnectorsEditOrderTab();
- }
-
- });
- }
-
- }
-
- ProxyConnectorEditOrderViewModel=function(proxyConnectors,proxyConnectorsViewModel,managedRepository){
- var self=this;
- this.proxyConnectors=ko.observableArray(proxyConnectors);
- this.proxyConnectorsViewModel=proxyConnectorsViewModel;
- this.managedRepository=managedRepository;
- proxyConnectorMoved=function(arg){
- $.log("proxyConnectorMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
- // if only 1 move just update two whereas update all with the new order
- if (arg.targetIndex-arg.sourceIndex==1){
- self.proxyConnectors()[arg.targetIndex].order(arg.targetIndex+1);
- self.proxyConnectors()[arg.sourceIndex].order(arg.sourceIndex+1);
- } else {
- for (i=0;i<self.proxyConnectors().length;i++){
- self.proxyConnectors()[i].order(i+1);
- }
- }
- }
-
- this.findRemoteRepository=function(id){
- $.log("findRemoteRepository:"+id());
- for(var i=0;i<self.proxyConnectorsViewModel.remoteRepositories().length;i++){
- if (self.proxyConnectorsViewModel.remoteRepositories()[i].id()==id()){
- return self.proxyConnectorsViewModel.remoteRepositories()[i];
- }
- }
- return null;
- }
-
- this.updateModifiedProxyConnectors=function(){
- self.proxyConnectorsViewModel.updateModifiedProxyConnectors();
- }
-
- displaySettings=function(sourceRepoId,targetRepoId){
- $.log("ProxyConnectorEditOrderViewModel#showSettings:"+sourceRepoId+"-"+targetRepoId);
- self.proxyConnectorsViewModel.displaySettings(sourceRepoId,targetRepoId,
- "#proxy-connectors-order-remoterepo-settings-content-",
- "#proxy-connectors-order-remoterepo-settings-edit-");
- }
-
- }
-
- displayProxyConnectors=function(){
- screenChange();
- var mainContent = $("#main-content");
- mainContent.html($("#proxyConnectorsMain").tmpl());
- mainContent.append(smallSpinnerImg());
-
- this.proxyConnectorsViewModel = new ProxyConnectorsViewModel();
- var self=this;
-
- loadManagedRepositories(function(data) {
- self.proxyConnectorsViewModel.managedRepositories(mapManagedRepositories(data));
-
- loadRemoteRepositories(function(data) {
- self.proxyConnectorsViewModel.remoteRepositories(mapRemoteRepositories(data));
-
- loadNetworkProxies(function(data) {
- self.proxyConnectorsViewModel.networkProxies(mapNetworkProxies(data));
-
- loadAllPolicies( function(data) {
- self.proxyConnectorsViewModel.policyInformations(mapPolicyInformations(data));
-
- loadAllProxyConnectors( function(data) {
- self.proxyConnectorsViewModel.proxyConnectors(mapProxyConnectors(data));
- self.proxyConnectorsViewModel.displayGrid();
- });
-
- });
-
- });
-
- });
-
- });
-
- }
-
- loadAllPolicies=function(successCallBackFn,errorCallBackFn){
- $.ajax("restServices/archivaServices/proxyConnectorService/allPolicies", {
- type: "GET",
- dataType: 'json',
- success: successCallBackFn,
- error: errorCallBackFn
- }
- );
- }
-
- loadAllProxyConnectors=function(successCallBackFn,errorCallBackFn){
- $.ajax("restServices/archivaServices/proxyConnectorService/getProxyConnectors", {
- type: "GET",
- dataType: 'json',
- success: successCallBackFn,
- error: errorCallBackFn
- });
- }
-
- activateProxyConnectorsGridTab=function(){
- var mainContent = $("#main-content");
- mainContent.find("#proxy-connectors-view-tabs-content div[class*='tab-pane']").removeClass("active");
- mainContent.find("#proxy-connectors-view-tabs li").removeClass("active");
-
- mainContent.find("#proxy-connectors-view").addClass("active");
- mainContent.find("#proxy-connectors-view-tabs-li-grid").addClass("active");
- mainContent.find("#proxy-connectors-view-tabs-li-edit a").html($.i18n.prop("add"));
-
- }
-
- activateProxyConnectorsEditTab=function(){
- var mainContent = $("#main-content");
-
- mainContent.find("#proxy-connectors-view-tabs-content div[class*='tab-pane']").removeClass("active");
- mainContent.find("#proxy-connectors-view-tabs li").removeClass("active");
-
- mainContent.find("#proxy-connectors-edit").addClass("active");
- mainContent.find("#proxy-connectors-view-tabs-li-edit").addClass("active");
- }
-
- activateProxyConnectorsEditOrderTab=function(){
- var mainContent = $("#main-content");
-
- mainContent.find("#proxy-connectors-view-tabs-content div[class*='tab-pane']").removeClass("active");
- mainContent.find("#proxy-connectors-view-tabs li").removeClass("active");
-
- mainContent.find("#proxy-connector-edit-order").addClass("active");
- mainContent.find("#proxy-connectors-view-tabs-li-edit-order").addClass("active");
- }
-
- mapProxyConnector=function(data){
- if (data==null){
- return null;
- }
- var policiesEntries = data.policiesEntries == null ? []: $.each(data.policiesEntries,function(item){
- return new Entry(item.key, item.value);
- });
- if (!$.isArray(policiesEntries)){
- policiesEntries=[];
- }
- var propertiesEntries = data.propertiesEntries == null ? []: $.each(data.propertiesEntries,function(item){
- return new Entry(item.key, item.value);
- });
- if (!$.isArray(propertiesEntries)){
- propertiesEntries=[];
- }
- return new ProxyConnector(data.sourceRepoId,data.targetRepoId,data.proxyId,mapStringArray(data.blackListPatterns),
- mapStringArray(data.whiteListPatterns),policiesEntries,propertiesEntries,
- data.disabled,data.order);
- }
-
- mapProxyConnectors=function(data){
- var mappedProxyConnectors = $.map(data, function(item) {
- return mapProxyConnector(item);
- });
- return mappedProxyConnectors;
- }
-
- mapPolicyInformation=function(data){
- if (data==null){
- return null;
- }
- var policyInformation = new PolicyInformation(mapStringArray(data.options),data.defaultOption,data.id,data.name);
- $.log("policyInformation.options:"+policyInformation.options());
- return policyInformation;
- }
-
- mapPolicyInformations=function(data){
- return $.map(data, function(item) {
- return mapPolicyInformation(item);
- });
- }
-
- removeProxyConnector=function(proxyConnector,fnSuccessCallback){
- clearUserMessages();
- var url="restServices/archivaServices/proxyConnectorService/removeProxyConnector?";
- url += "sourceRepoId="+encodeURIComponent(proxyConnector.sourceRepoId());
- url += "&targetRepoId="+encodeURIComponent(proxyConnector.targetRepoId());
- $.ajax(url,
- {
- type: "GET",
- contentType: 'application/json',
- success: function(data) {
- fnSuccessCallback();
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- }
- }
- );
-
- }
-
-});
+++ /dev/null
-/*
- * 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/admin/repository/10maven2/repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","knockout","knockout.simpleGrid"],
-function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
-
- // FIXME this must be dynamic if we do a plugin mechanism with dynamic repositories types
- // FIXME i18n
-
- ManagedRepositoryType=function(type,label){
- this.type=type;
- this.label=label;
- }
-
- window.managedRepositoryTypes = [
- new ManagedRepositoryType("default","Maven 2.x Repository"),
- new ManagedRepositoryType("legacy", "Maven 1.x Repository")
- ];
-
- ManagedRepository=function(id,name,layout,indexDirectory,location,snapshots,releases,blockRedeployments,cronExpression,
- scanned,daysOlder,retentionCount,deleteReleasedSnapshots,stageRepoNeeded,description,
- skipPackedIndexCreation,feedsUrl,url){
-
- var self=this;
-
- //private String id;
- this.id=ko.observable(id);
- this.id.subscribe(function(newValue){self.modified(true)});
-
- //private String name;
- this.name=ko.observable(name);
- this.name.subscribe(function(newValue){self.modified(true)});
-
- //private String layout = "default";
- this.layout=ko.observable(layout);
- this.layout.subscribe(function(newValue){self.modified(true)});
-
- //private String indexDirectory;
- this.indexDirectory=ko.observable(indexDirectory);
- this.indexDirectory.subscribe(function(newValue){self.modified(true)});
-
- //private String location;
- this.location=ko.observable(location);
- this.location.subscribe(function(newValue){self.modified(true)});
-
- //private String cronExpression = "0 0 * * * ?";
- this.cronExpression=ko.observable(cronExpression);
- this.cronExpression.subscribe(function(newValue){self.modified(true)});
-
- //private ManagedRepository stagingRepository;
-
- //private int daysOlder = 100;
- this.daysOlder=ko.observable(daysOlder);
- this.daysOlder.subscribe(function(newValue){self.modified(true)});
-
- //private int retentionCount = 2;
- this.retentionCount=ko.observable(retentionCount);
- this.retentionCount.subscribe(function(newValue){self.modified(true)});
-
- //private boolean scanned = true;
- this.scanned=ko.observable(scanned?scanned:true);
- this.scanned.subscribe(function(newValue){self.modified(true)});
-
- //private boolean deleteReleasedSnapshots;
- this.deleteReleasedSnapshots=ko.observable(deleteReleasedSnapshots);
- this.deleteReleasedSnapshots.subscribe(function(newValue){self.modified(true)});
-
- //private boolean stageRepoNeeded;
- this.stageRepoNeeded=ko.observable(stageRepoNeeded);
- this.stageRepoNeeded.subscribe(function(newValue){self.modified(true)});
-
- //private boolean snapshots = false;
- this.snapshots=ko.observable(snapshots?snapshots:false);
- this.snapshots.subscribe(function(newValue){self.modified(true)});
-
- //private boolean releases = true;
- this.releases=ko.observable(releases?releases:false);
- this.releases.subscribe(function(newValue){self.modified(true)});
-
- //private boolean blockRedeployments = false;
- this.blockRedeployments=ko.observable(blockRedeployments?blockRedeployments:false);
- this.blockRedeployments.subscribe(function(newValue){self.modified(true)});
-
- //private String name;
- this.description=ko.observable(description);
- this.description.subscribe(function(newValue){self.modified(true)});
-
- this.skipPackedIndexCreation=ko.observable(skipPackedIndexCreation?skipPackedIndexCreation:false);
- this.skipPackedIndexCreation.subscribe(function(newValue){self.modified(true)});
-
- this.feedsUrl=feedsUrl;
-
- this.url=url;
-
- this.getTypeLabel=function(){
- for(var i=0;i<window.managedRepositoryTypes.length;i++){
- if (window.managedRepositoryTypes[i].type==self.layout()){
- return window.managedRepositoryTypes[i].label;
- }
- }
- return "no label";
- }
-
- this.modified=ko.observable(false);
- }
-
- ArchivaRepositoryStatistics=function(scanEndTime,scanStartTime,totalArtifactCount,totalArtifactFileSize,totalFileCount,
- totalGroupCount,totalProjectCount,newFileCount,duration,managedRepository,lastScanDate){
- //private Date scanEndTime;
- this.scanEndTime = ko.observable(scanEndTime);
-
- //private Date scanStartTime;
- this.scanStartTime = ko.observable(scanStartTime);
-
- //private long totalArtifactCount;
- this.totalArtifactCount = ko.observable(totalArtifactCount);
-
- //private long totalArtifactFileSize;
- this.totalArtifactFileSize = ko.observable(totalArtifactFileSize);
-
- //private long totalFileCount;
- this.totalFileCount = ko.observable(totalFileCount);
-
- //private long totalGroupCount;
- this.totalGroupCount = ko.observable(totalGroupCount);
-
- //private long totalProjectCount;
- this.totalProjectCount = ko.observable(totalProjectCount);
-
- //private long newFileCount;
- this.newFileCount = ko.observable(newFileCount);
-
- this.duration = ko.observable(duration);
-
- this.managedRepository = managedRepository;
-
- this.lastScanDate=ko.observable(lastScanDate);
- }
-
- mapManagedRepositories=function(data,applicationUrl){
- var mappedManagedRepositories = $.map(data, function(item) {
- var managedRepository = mapManagedRepository(item);
- managedRepository.feedsUrl=applicationUrl+"/feeds/"+managedRepository.id();
- managedRepository.url=applicationUrl+"/repository/"+managedRepository.id()
- return managedRepository;
- });
- return mappedManagedRepositories;
- }
- mapManagedRepository=function(data){
- if (data==null){
- return null;
- }
- return new ManagedRepository(data.id,data.name,data.layout,data.indexDirectory,data.location,data.snapshots
- ,data.releases,
- data.blockRedeployments,data.cronExpression,
- data.scanned,data.daysOlder,data.retentionCount,data.deleteReleasedSnapshots,
- data.stageRepoNeeded,data.description,data.skipPackedIndexCreation);
- }
-
- mapArchivaRepositoryStatistics=function(data){
- if (data==null){
- return null;
- }
- return new ArchivaRepositoryStatistics(data.scanEndTime,data.scanStartTime,data.totalArtifactCount,data.totalArtifactFileSize,
- data.totalFileCount,data.totalGroupCount,data.totalProjectCount,data.newFileCount,
- data.duration,data.managedRepository,data.lastScanDate)
- }
-
- ManagedRepositoryViewModel=function(managedRepository, update, managedRepositoriesViewModel){
- this.managedRepository=managedRepository;
- this.managedRepositoriesViewModel = managedRepositoriesViewModel;
- this.update = update;
-
- var self = this;
-
- this.availableLayouts = window.managedRepositoryTypes;
-
- showCronExpressionDoc=function(){
- //$.log("showCronExpressionDoc") ;
- }
-
- this.save=function(){
- $.log('managedrepo save');
- var valid = $("#main-content").find("#managed-repository-edit-form").valid();
- if (valid==false) {
- return;
- }
- $.log("save:"+this.managedRepository.name());
- clearUserMessages();
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- $("#managed-repository-save-button" ).button('loading');
- if (this.update){
- $.ajax("restServices/archivaServices/managedRepositoriesService/updateManagedRepository",
- {
- type: "POST",
- data: ko.toJSON(this.managedRepository),
- contentType: 'application/json',
- dataType: 'json',
- success: function(data) {
- displaySuccessMessage($.i18n.prop('managedrepository.updated',self.managedRepository.id()));
- activateManagedRepositoriesGridTab();
- self.managedRepository.modified(false);
- },
- complete: function(){
- $("#managed-repository-save-button" ).button('reset');
- removeMediumSpinnerImg(userMessages);
- }
- }
- );
- } else {
- var url="restServices/archivaServices/managedRepositoriesService/fileLocationExists";
- url+="?fileLocation="+encodeURIComponent(self.managedRepository.location());
- $.ajax(url,
- {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- if (data){
- var completeCallbackFn = function(){window.modalConfirmDialog.modal('hide')};
- openDialogConfirm(
- function(){addManagedRepository(self.managedRepository,completeCallbackFn)},
- $.i18n.prop('ok'), $.i18n.prop('cancel'),
- $.i18n.prop('managedrepository.add.title'),
- $("#managed-repository-location-warning-tmpl").tmpl(self.managedRepository));
- }else{
- addManagedRepository(self.managedRepository);
- }
- },
- complete: function(){
- $("#managed-repository-save-button" ).button('reset');
- removeMediumSpinnerImg(userMessages);
- }
- });
- }
- }
-
- addManagedRepository=function(managedRepository,completeCallbackFn){
- var curManagedRepository=managedRepository;
- var callbackFn = completeCallbackFn;
- var dataJson=ko.toJSON(managedRepository);
- $.log("managedRepository.release:"+managedRepository.releases()+",dataJson:"+dataJson);
- $.ajax("restServices/archivaServices/managedRepositoriesService/addManagedRepository",
- {
- type: "POST",
- contentType: 'application/json',
- data: dataJson,
- dataType: 'json',
- success: function(data) {
- if (managedRepository.stageRepoNeeded()){
- $.log("stageRepoNeeded:"+managedRepository.stageRepoNeeded());
- // reload all to see the new staged repo
- loadManagedRepositories(function(data){
- self.managedRepositoriesViewModel.managedRepositories(mapManagedRepositories(data));
- });
- } else {
- curManagedRepository.location(data.location);
- self.managedRepositoriesViewModel.managedRepositories.push(curManagedRepository);
- }
-
- displaySuccessMessage($.i18n.prop('managedrepository.added',curManagedRepository.id()));
- curManagedRepository.modified(false);
- activateManagedRepositoriesGridTab();
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete:function(data){
- if(callbackFn){
- callbackFn();
- }
- }
- }
- );
- }
-
- displayGrid=function(){
- activateManagedRepositoriesGridTab();
- }
-
- }
-
- activateManagedRepositoryFormValidation=function(){
- var validator = $("#main-content" ).find("#managed-repository-edit-form").validate({
- rules: {
- daysOlder : {
- digits: true,
- min: 1
- },
- retentionCount : {
- digits: true,
- min: 1,
- max: 100
- },
- cronExpression: {
- required: true,
- remote: {
- url: "restServices/archivaServices/commonServices/validateCronExpression",
- type: "get"
- }
- },
- id: {
- required: true,
- remote: {
- url: "restServices/archivaUiServices/dataValidatorService/managedRepositoryIdNotExists",
- type: "get"
- }
- }
- },
- showErrors: function(validator, errorMap, errorList) {
- customShowError("#main-content #managed-repository-edit-form",validator,errorMap,errorMap);
- }
- });
- validator.settings.messages["cronExpression"]=$.i18n.prop("cronExpression.notvalid");
- validator.settings.messages["id"]=$.i18n.prop("id.required.or.alreadyexists");
- }
-
- ManagedRepositoriesViewModel=function(){
- this.managedRepositories=ko.observableArray([]);
-
- this.gridViewModel = null;
- var self = this;
-
- editManagedRepository=function(managedRepository){
- var mainContent = $("#main-content");
- var viewModel = new ManagedRepositoryViewModel(managedRepository,true,self);
- ko.applyBindings(viewModel,mainContent.find("#managed-repository-edit").get(0));
- activateManagedRepositoryEditTab();
- mainContent.find("#managed-repository-edit-li a").html($.i18n.prop('edit'));
- activateManagedRepositoryFormValidation();
- activatePopoverDoc();
- }
-
- this.editManagedRepositoryWithId=function(managedRepositoryId){
- $.each(self.managedRepositories(), function(index, value) {
- if(value.id()==managedRepositoryId){
- editManagedRepository(value);
- }
- });
- }
-
- scanNow=function(managedRepository){
- clearUserMessages();
- openDialogConfirm(
- function(){
- $("#dialog-confirm-modal" ).find("#modal-login-footer").append(smallSpinnerImg());
- var checked = $("#managed-repository-scan-now-all").get(0).checked;
- var url = "restServices/archivaServices/repositoriesService/scanRepositoryNow?";
- url += "repositoryId="+encodeURIComponent(managedRepository.id());
- url += "&fullScan="+(checked==true?"true":"false");
- $.ajax(url,
- {
- type: "GET",
- beforeSend:function(){
- displayInfoMessage($.i18n.prop("managedrepository.scan.started",managedRepository.id()));
- closeDialogConfirm();
- },
- success: function(data) {
- displaySuccessMessage($.i18n.prop("managedrepository.scanned",managedRepository.name()));
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete: function(){
- removeSmallSpinnerImg();
- closeDialogConfirm();
- }
- }
- );
- },
- $.i18n.prop("ok"),
- $.i18n.prop("cancel"),
- $.i18n.prop("managedrepository.scan.now"),
- $("#managed-repository-scan-now-modal-tmpl").tmpl(managedRepository));
-
- }
-
- removeManagedRepository=function(managedRepository){
- clearUserMessages();
- openDialogConfirm(
- function(){
- var url = "restServices/archivaServices/managedRepositoriesService/deleteManagedRepository?";
- url += "repositoryId="+encodeURIComponent(managedRepository.id());
- var checked = $("#managedrepository-deletecontent").get(0).checked;
- url += "&deleteContent="+(checked==true?"true":"false");
- var dialogText=$("#dialog-confirm-modal-body-text" );
- dialogText.html(mediumSpinnerImg());
- $.ajax(url,
- {
- type: "GET",
- success: function(data) {
- self.managedRepositories.remove(managedRepository);
- displaySuccessMessage($.i18n.prop("managedrepository.deleted",managedRepository.name()));
-
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete: function(){
- removeMediumSpinnerImg(dialogText);
- closeDialogConfirm();
- }
- }
- );
-
- },
- $.i18n.prop("ok"),
- $.i18n.prop("cancel"),
- $.i18n.prop("managedrepository.delete.confirm",managedRepository.name()),
- $("#managed-repository-delete-warning-tmpl").tmpl(managedRepository));
- }
-
- updateManagedRepository=function(managedRepository){
- var managedRepositoryViewModel = new ManagedRepositoryViewModel(managedRepository,true,this);
- managedRepositoryViewModel.save();
- }
-
- this.bulkSave=function(){
- $.log("bulkSave");
- return getModifiedManagedRepositories().length>0;
- }
-
- getModifiedManagedRepositories=function(){
- var prx = $.grep(self.managedRepositories(),
- function (managedRepository,i) {
- return managedRepository.modified();
- });
- return prx;
- }
- updateModifiedManagedRepositories=function(){
- var repos = getModifiedManagedRepositories();
-
- openDialogConfirm(function(){
- for (i=0;i<repos.length;i++){
- updateManagedRepository(repos[i]);
- }
- closeDialogConfirm();
- },
- $.i18n.prop('ok'),
- $.i18n.prop('cancel'),
- $.i18n.prop('managed.repository.bulk.save.confirm.title'),
- $.i18n.prop('managed.repository.bulk.save.confirm',repos.length));
- }
-
- directoriesScan=function(managedRepository){
- $.log("directoriesScan:"+managedRepository.id());
- clearUserMessages();
- var url = "restServices/archivaServices/repositoriesService/scanRepositoryDirectoriesNow/"+managedRepository.id();
- $.ajax(url,
- {
- type: "GET",
- dataType: 'json',
- beforeSend:function(){
- displayInfoMessage($.i18n.prop("managedrepository.scan.directories.started", managedRepository.id()));
- },
- success: function(data) {
- $.log(" scanRepositoryDirectoriesNow finished ");
- displaySuccessMessage( $.i18n.prop("managedrepository.scan.directories.finished", managedRepository.id()));
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete: function(){
- removeSmallSpinnerImg();
- }
-
- }
- );
- }
-
- showStats=function(managedRepository){
- if ($(calculatePopoverId(managedRepository)).html()){
- // we ask stats all the time ? if no uncomment return
- //return;
- $("#managedrepository-stats-"+escapeDot(managedRepository.id())).append(smallSpinnerImg());
- }
- var curRepo=managedRepository;
- var url = "restServices/archivaServices/managedRepositoriesService/getManagedRepositoryStatistics/"+managedRepository.id();
- url+="/"+encodeURIComponent(usedLang());
- $.ajax(url,
- {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- if (data==null){
- return;
- }
- var archivaRepositoryStatistics=mapArchivaRepositoryStatistics(data);
- archivaRepositoryStatistics.managedRepository=curRepo;
- var mainContent = $("#main-content");
- mainContent.find("#managedrepository-stats-"+escapeDot(curRepo.id())).append($("#managed-repository-stats-tmpl").tmpl(archivaRepositoryStatistics));
- mainContent.find("#managedrepository-stats-img-"+escapeDot(curRepo.id())).attr("data-content",$(calculatePopoverId(curRepo)).html());
- mainContent.find("#managedrepository-stats-img-"+escapeDot(curRepo.id())).popover(
- {
- placement: "left",
- html: true,
- trigger:'manual'
- }
- );
-
- mainContent.find("#managedrepository-stats-img-"+escapeDot(curRepo.id())).popover('show');
- removeSmallSpinnerImg();
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete: function(){
- }
- }
- );
- }
-
- calculatePopoverId=function(managedRepository){
- return "#main-content #managedrepository-stats-"+escapeDot(managedRepository.id()) + " #managedrepository-stats-"+escapeDot(managedRepository.id())+"-popover";
- }
-
- hideStats=function(managedRepository){
- $("#body_content" ).find(".popover" ).hide();
- }
-
- showPomSnippet=function(managedRepository){
- var mainContent = $("#main-content");
- mainContent.find("#managed-repositories-pom-snippet").html(mediumSpinnerImg());
- mainContent.find('#managed-repositories-pom-snippet').show();
- var url = "restServices/archivaServices/managedRepositoriesService/getPomSnippet/"+encodeURIComponent(managedRepository.id());
- $.ajax(url,
- {
- type: "GET",
- dataType: 'text',
- success: function(data) {
- $("#managed-repositories-pom-snippet").html($("#pom-snippet-tmpl").tmpl(data));
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete: function(){
- }
- }
- );
-
- }
-
- mergeRepo=function(managedRepository){
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- // is there any artifacts to merge ?
- var artifactsNumberUrl = "restServices/archivaServices/browseService/artifacts/"+encodeURIComponent(managedRepository.id());
- $.ajax(artifactsNumberUrl,{
- type: "GET",
- dataType: 'json',
- success: function(data){
- var artifacts=mapArtifacts(data);
- $.log("artifactsNumber for '" + managedRepository.id() + "': " + artifacts.length);
-
- if (artifacts<1){
- displayWarningMessage($.i18n.prop("managedrepository.merge.noartifacts", managedRepository.id()));
- return;
- }
-
- $.log("merge repo open dialog");
- var dialogMergeRepo=$("#dialog-modal-merge-repo");
- if (window.modalMergeRepoDialog==null) {
- window.modalMergeRepoDialog = dialogMergeRepo.modal();
-
- }
-
- loadManagedRepositories(function(data){
-
- var managedRepositories = $.map(mapManagedRepositories(data), function(item) {
- return item.id()==managedRepository.id()?null:item;
- });
- $("#dialog-modal-merge-repo-body-text").html($("#merge-repo-dialog-content" )
- .tmpl({sourceRepoId:managedRepository.id(),repositories:managedRepositories}));
- window.modalMergeRepoDialog.modal('show');
- });
-
- },
- complete: function(){
- removeMediumSpinnerImg(userMessages);
- }
- }
- );
-
- }
-
-
- }
-
-
- mergeRepositories=function(sourceRepository,targetRepository){
- $.log("mergeRepositories:"+sourceRepository+":"+targetRepository);
-
- var mergeRepoDialogBodyId="dialog-modal-merge-repo-body-text";
- var mergeRepoDialogBody=$("#"+mergeRepoDialogBodyId);
- mergeRepoDialogBody.html(mediumSpinnerImg());
-
- // check conflicts
- var url = "restServices/archivaServices/mergeRepositoriesService/mergeConflictedArtifacts/"+encodeURIComponent(sourceRepository);
- url+="/"+encodeURIComponent(targetRepository);
- $.ajax(url, {
- type: "GET",
- dataType: 'json',
- success: function(data){
- var artifacts=mapArtifacts(data);
- if (artifacts && artifacts.length){
- // we have conflicts ask to skip or not
- $.log("conflicts:"+artifacts.length);
- displayWarningMessage($.i18n.prop("managedrepository.merge.conflicts", artifacts.length),"dialog-modal-merge-repo-body-text");
- $.tmpl($("#merge-repo-skip-conflicts").html(),
- { artifacts:artifacts, sourceRepository: sourceRepository, targetRepository:targetRepository })
- .appendTo( "#dialog-modal-merge-repo-body-text" );
- $("#dialog-modal-merge-repo-header-title" ).html($.i18n.prop("managedrepository.merge.conflicts.header",sourceRepository,targetRepository));
- } else {
- doMerge(sourceRepository,targetRepository,false);
- }
- },
- complete: function(){
- $.log("complete removeMediumSpinnerImg");
- removeMediumSpinnerImg("#dialog-modal-merge-repo-body-text");
- }
- });
-
-
-
- }
-
- doMerge=function(sourceRepository,targetRepository,skipConflicts){
- $.log("doMerge:"+sourceRepository+" to " + targetRepository + ", skipConflicts: " + skipConflicts);
- window.modalMergeRepoDialog.modal('hide');
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- var url = "restServices/archivaServices/mergeRepositoriesService/mergeRepositories/"+encodeURIComponent(sourceRepository);
- url+="/"+encodeURIComponent(targetRepository);
- url+="/"+skipConflicts;
- $.ajax(url, {
- type: "GET",
- dataType: 'json',
- success: function(data){
- displaySuccessMessage($.i18n.prop("managedrepository.merge.success", sourceRepository,targetRepository));
- },
- complete: function(){
- removeMediumSpinnerImg(userMessages);
- }
- });
- }
-
- activateManagedRepositoriesGridTab=function(){
- var mainContent = $("#main-content");
- mainContent.find("#managed-repository-edit-li").removeClass("active");
- mainContent.find("#managed-repository-edit").removeClass("active");
-
- mainContent.find("#managed-repositories-view-li").addClass("active");
- mainContent.find("#managed-repositories-view").addClass("active");
- mainContent.find("#managed-repository-edit-li a").html($.i18n.prop("add"));
- }
-
- activateManagedRepositoryEditTab=function(){
- var mainContent = $("#main-content");
- mainContent.find("#managed-repositories-view-li").removeClass("active");
- mainContent.find("#managed-repositories-view").removeClass("active");
-
- mainContent.find("#managed-repository-edit-li").addClass("active");
- mainContent.find("#managed-repository-edit").addClass("active");
- }
-
-
- //---------------------------
- // Remote repositories part
- //---------------------------
-
-
-
- RemoteRepository=function(id,name,layout,indexDirectory,url,userName,password,timeout,downloadRemoteIndex,remoteIndexUrl,
- remoteDownloadNetworkProxyId,cronExpression,remoteDownloadTimeout,downloadRemoteIndexOnStartup,
- description,extraParametersEntries,extraHeadersEntries){
-
- var self=this;
-
- //private String id;
- this.id=ko.observable(id);
- this.id.subscribe(function(newValue){self.modified(true)});
-
- //private String name;
- this.name=ko.observable(name);
- this.name.subscribe(function(newValue){self.modified(true)});
-
- //private String layout = "default";
- this.layout=ko.observable(layout);
- this.layout.subscribe(function(newValue){self.modified(true)});
-
- //private String indexDirectory;
- this.indexDirectory=ko.observable(indexDirectory);
- this.indexDirectory.subscribe(function(newValue){self.modified(true)});
-
- //private String url;
- this.url=ko.observable(url);
- this.url.subscribe(function(newValue){self.modified(true)});
-
- //private String userName;
- this.userName=ko.observable(userName);
- this.userName.subscribe(function(newValue){self.modified(true)});
-
- //private String password;
- this.password=ko.observable(password);
- this.password.subscribe(function(newValue){self.modified(true)});
-
- //private int timeout = 60;
- this.timeout=ko.observable(timeout);
- this.timeout.subscribe(function(newValue){self.modified(true)});
-
- //private boolean downloadRemoteIndex = false;
- this.downloadRemoteIndex=ko.observable(downloadRemoteIndex?false:downloadRemoteIndex);
- this.downloadRemoteIndex.subscribe(function(newValue){self.modified(true)});
-
- //private String remoteIndexUrl = ".index";
- this.remoteIndexUrl=ko.observable(remoteIndexUrl);
- this.remoteIndexUrl.subscribe(function(newValue){self.modified(true)});
-
- //private String remoteDownloadNetworkProxyId;
- this.remoteDownloadNetworkProxyId=ko.observable(remoteDownloadNetworkProxyId);
- this.remoteDownloadNetworkProxyId.subscribe(function(newValue){self.modified(true)});
-
- //private String cronExpression = "0 0 08 ? * SUN";
- this.cronExpression=ko.observable(cronExpression);
- this.cronExpression.subscribe(function(newValue){self.modified(true)});
-
- //private int remoteDownloadTimeout = 300;
- this.remoteDownloadTimeout=ko.observable(remoteDownloadTimeout);
- this.remoteDownloadTimeout.subscribe(function(newValue){self.modified(true)});
-
- //private boolean downloadRemoteIndexOnStartup = false;
- this.downloadRemoteIndexOnStartup=ko.observable(downloadRemoteIndexOnStartup?false:downloadRemoteIndexOnStartup);
- this.downloadRemoteIndexOnStartup.subscribe(function(newValue){self.modified(true)});
-
- this.description=ko.observable(description);
- this.description.subscribe(function(newValue){self.modified(true)});
-
- this.getTypeLabel=function(){
- for(var i=0;i<window.managedRepositoryTypes.length;i++){
- if (window.managedRepositoryTypes[i].type==self.layout()){
- return window.managedRepositoryTypes[i].label;
- }
- }
- 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);
- }
-
- mapRemoteRepository=function(data){
- 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,
- extraParametersEntries,extraHeadersEntries);
- }
-
- mapRemoteRepositories=function(data){
- var mappedRemoteRepositories = $.map(data, function(item) {
- return mapRemoteRepository(item);
- });
- return mappedRemoteRepositories;
- }
-
- RemoteRepositoryViewModel=function(remoteRepository, update, remoteRepositoriesViewModel){
- this.remoteRepository=remoteRepository;
- this.remoteRepositoriesViewModel = remoteRepositoriesViewModel;
- this.networkProxies=ko.observableArray([]);
- this.update = update;
-
- var self = this;
-
- this.availableLayouts = window.managedRepositoryTypes;
-
- this.save=function(){
- var valid = $("#main-content" ).find("#remote-repository-edit-form").valid();
- if (valid==false) {
- return;
- }
- clearUserMessages();
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- $("#remote-repository-save-button" ).button('loading');
- if (update){
- $.ajax("restServices/archivaServices/remoteRepositoriesService/updateRemoteRepository",
- {
- type: "POST",
- data: ko.toJSON(this.remoteRepository),
- contentType: 'application/json',
- dataType: 'json',
- success: function(data) {
- displaySuccessMessage($.i18n.prop('remoterepository.updated',self.remoteRepository.id()));
- activateRemoteRepositoriesGridTab();
- self.remoteRepository.modified(false);
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete: function(){
- $("#remote-repository-save-button" ).button('reset');
- removeMediumSpinnerImg(userMessages);
- }
- }
- );
- }else {
- $.ajax("restServices/archivaServices/remoteRepositoriesService/addRemoteRepository",
- {
- type: "POST",
- data: ko.toJSON(this.remoteRepository),
- contentType: 'application/json',
- dataType: 'json',
- success: function(data) {
- self.remoteRepository.modified(false);
- self.remoteRepositoriesViewModel.remoteRepositories.push(self.remoteRepository);
- displaySuccessMessage($.i18n.prop('remoterepository.added'));
- activateRemoteRepositoriesGridTab();
- removeMediumSpinnerImg(userMessages);
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- }
- }
- );
- }
- }
-
- displayGrid=function(){
- activateRemoteRepositoriesGridTab();
- }
-
- addExtraParameter=function(){
-
- var mainContent=$("#main-content");
- mainContent.find("#extra-parameters-error" ).empty();
- 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();
- oldTab.push(new Entry(key,value));
- self.remoteRepository.extraParametersEntries(oldTab);
- mainContent.find("#extraParameter-key").val("");
- mainContent.find("#extraParameter-value").val("");
- self.remoteRepository.modified(true);
- }
-
- deleteExtraParameter=function(key){
- for(var i=0;i<self.remoteRepository.extraParametersEntries().length;i++){
- var entry=self.remoteRepository.extraParametersEntries()[i];
- if (entry.key==key){
- self.remoteRepository.extraParametersEntries.remove(entry);
- self.remoteRepository.modified(true);
- }
- }
- }
-
- addExtraHeader=function(){
-
- var mainContent=$("#main-content");
- mainContent.find("#extra-headers-error" ).empty();
- 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(){
- this.remoteRepositories=ko.observableArray([]);
- this.applicationUrl=null;
- this.gridViewModel = null;
- var self = this;
-
- editRemoteRepository=function(remoteRepository){
- $.log("editRemoteRepository");
- $.ajax("restServices/archivaServices/networkProxyService/getNetworkProxies", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- 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(false);
- activatePopoverDoc();
- }
- })
-
- }
-
- removeRemoteRepository=function(remoteRepository){
- clearUserMessages();
- openDialogConfirm(
- function(){
- var dialogText=$("#dialog-confirm-modal-body-text" );
- dialogText.html(mediumSpinnerImg());
- $.ajax("restServices/archivaServices/remoteRepositoriesService/deleteRemoteRepository/"+encodeURIComponent(remoteRepository.id()),
- {
- type: "GET",
- success: function(data) {
- self.remoteRepositories.remove(remoteRepository);
- displaySuccessMessage($.i18n.prop('remoterepository.deleted',remoteRepository.id()));
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete:function(){
- removeMediumSpinnerImg(dialogText);
- closeDialogConfirm();
- }
- }
- )}, $.i18n.prop('ok'),
- $.i18n.prop('cancel'),
- $.i18n.prop('remoterepository.delete.confirm',remoteRepository.id()),
- $("#remote-repository-delete-modal-tmpl").tmpl(remoteRepository));
-
- }
-
- this.bulkSave=function(){
- return getModifiedRemoteRepositories().length>0;
- }
-
- getModifiedRemoteRepositories=function(){
- var prx = $.grep(self.remoteRepositories(),
- function (remoteRepository,i) {
- return remoteRepository.modified();
- });
- return prx;
- }
-
- updateModifiedRemoteRepositories=function(){
- var modifiedRemoteRepositories = getModifiedRemoteRepositories();
-
- openDialogConfirm(function(){
- for(var i=0;i<modifiedRemoteRepositories.length;i++){
- updateRemoteRepository(modifiedRemoteRepositories[i]);
- }
- closeDialogConfirm();
- },
- $.i18n.prop('ok'),
- $.i18n.prop('cancel'),
- $.i18n.prop('remoterepositories.bulk.save.confirm.title'),
- $.i18n.prop('remoterepositories.bulk.save.confirm',modifiedRemoteRepositories.length));
- }
-
- updateRemoteRepository=function(remoteRepository){
- var viewModel = new RemoteRepositoryViewModel(remoteRepository,true,self);
- viewModel.save();
- }
-
- scheduleDownloadRemoteIndex=function(remoteRepository){
- openDialogConfirm(
- function(){
-
- var url = "restServices/archivaServices/repositoriesService/scheduleDownloadRemoteIndex?";
- url += "repositoryId="+encodeURIComponent(remoteRepository.id());
-
- var now = $("#remoterepository-scan-now").get(0).checked;
-
- var full = $("#remoterepository-scan-full").get(0).checked;
-
- url += "&now="+(now==true?"true":"false");
- url += "&fullDownload="+(full==true?"true":"false");
- $.ajax(url,
- {
- type: "GET",
- success: function(data) {
- clearUserMessages();
- displaySuccessMessage($.i18n.prop("remoterepository.download.remote.scheduled",remoteRepository.name()));
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete: function(){
- closeDialogConfirm();
- }
- }
- );
-
- },
- $.i18n.prop("ok"),
- $.i18n.prop("cancel"),
- $.i18n.prop("remoterepository.download.remote.confirm",remoteRepository.name()),
- $("#remote-repository-scan-modal-tmpl").tmpl(remoteRepository));
- }
- }
-
- /**
- *
- * @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 = 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);
- }
- });
- } 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");
- }
-
- activateRemoteRepositoriesGridTab=function(){
- var mainContent = $("#main-content");
- mainContent.find("#remote-repository-edit-li").removeClass("active");
- mainContent.find("#remote-repository-edit").removeClass("active");
-
- mainContent.find("#remote-repositories-view-li").addClass("active");
- mainContent.find("#remote-repositories-view").addClass("active");
- mainContent.find("#remote-repository-edit-li a").html($.i18n.prop("add"));
- }
-
- activateRemoteRepositoryEditTab=function(){
- var mainContent = $("#main-content");
- mainContent.find("#remote-repositories-view-li").removeClass("active");
- mainContent.find("#remote-repositories-view").removeClass("active");
-
- mainContent.find("#remote-repository-edit-li").addClass("active");
- mainContent.find("#remote-repository-edit").addClass("active");
- }
-
- //---------------------------
- // Screen loading
- //---------------------------
-
- /**
- *
- * @param successFnManagedRepositories function called with param managedRepositoriesViewModel when managed repositories grid has been displayed
- * @param successFnRemoteRepositories function called with param remoteRepositoriesViewModel when remote repositories grid has been displayed
- */
- displayRepositoriesGrid=function(successFnManagedRepositories,successFnRemoteRepositories){
- screenChange();
- var mainContent = $("#main-content");
- mainContent.html(mediumSpinnerImg());
- mainContent.html($("#repositoriesMain").tmpl());
- mainContent.find("#repositories-tabs a:first").tab("show");
-
- mainContent.find("#managed-repositories-content").append(mediumSpinnerImg());
- mainContent.find("#remote-repositories-content").append(mediumSpinnerImg());
-
- var managedRepositoriesViewModel = new ManagedRepositoriesViewModel();
- var remoteRepositoriesViewModel = new RemoteRepositoriesViewModel();
-
- $.ajax({
- url: "restServices/archivaServices/archivaAdministrationService/applicationUrl",
- type: "GET",
- dataType: 'text',
- success: function(applicationUrl){
- $.log("applicationUrl:"+applicationUrl);
- loadManagedRepositories(function(data) {
-
-
- managedRepositoriesViewModel.managedRepositories(
- mapManagedRepositories(data,applicationUrl?applicationUrl:window.location.toString().substringBeforeLast("/")));
-
- managedRepositoriesViewModel.gridViewModel = new ko.simpleGrid.viewModel({
- data: managedRepositoriesViewModel.managedRepositories,
- columns: [
- {
- headerText: $.i18n.prop('identifier'),
- rowText: "id"
- },
- {
- headerText: $.i18n.prop('name'),
- rowText: "name"
- },
- {
- headerText: $.i18n.prop('type'),
- rowText: "getTypeLabel",
- // FIXME i18n
- title: "Repository type (default is Maven 2)"
- }
- ],
- pageSize: 5,
- gridUpdateCallBack: function(){
- // a bit ugly
- //$("#main-content" ).find("#managed-repositories-table").find("[title]").tooltip({animation:"false"});
- }
- });
- var mainContent = $("#main-content");
- ko.applyBindings(managedRepositoriesViewModel,mainContent.find("#managed-repositories-view").get(0));
- activatePopoverDoc();
- mainContent.find("#managed-repositories-pills #managed-repositories-view-a").tab('show');
- removeMediumSpinnerImg(mainContent.find("#managed-repositories-content"));
- activateManagedRepositoriesGridTab();
- if(successFnManagedRepositories){
- successFnManagedRepositories(managedRepositoriesViewModel);
- }
- });
-
- loadRemoteRepositories(function(data) {
- remoteRepositoriesViewModel.remoteRepositories(mapRemoteRepositories(data));
- remoteRepositoriesViewModel.gridViewModel = new ko.simpleGrid.viewModel({
- data: remoteRepositoriesViewModel.remoteRepositories,
- columns: [
- {
- headerText: $.i18n.prop('identifier'),
- rowText: "id"
- },
- {
- headerText: $.i18n.prop('name'),
- rowText: "name"
- },
- {
- headerText: $.i18n.prop('url'),
- rowText: "url"
- },
- {
- headerText: $.i18n.prop('type'),
- rowText: "getTypeLabel",
- // FIXME i18n
- title: "Repository type (default is Maven 2)"
- }
- ],
- pageSize: 5,
- gridUpdateCallBack: function(){
- //$("#main-content" ).find("#remote-repositories-table").find("[title]").tooltip();
- }
- });
- var mainContent = $("#main-content");
- ko.applyBindings(remoteRepositoriesViewModel,mainContent.find("#remote-repositories-view").get(0));
- mainContent.find("#remote-repositories-pills #remote-repositories-view-a").tab('show')
- removeMediumSpinnerImg(mainContent.find("#remote-repositories-content"));
- activatePopoverDoc();
- if(successFnRemoteRepositories){
- successFnRemoteRepositories(managedRepositoriesViewModel);
- }
- });
- }
- }
- );
-
-
- mainContent.find("#managed-repositories-pills").on('show', function (e) {
- var mainContent = $("#main-content");
- if ($(e.target).attr("href")=="#managed-repository-edit") {
- var managedRepo=new ManagedRepository();
- managedRepo.cronExpression("0 0 * * * ?");
- var viewModel = new ManagedRepositoryViewModel(managedRepo,false,managedRepositoriesViewModel);
- ko.applyBindings(viewModel,mainContent.find("#managed-repository-edit").get(0));
- activateManagedRepositoryFormValidation();
- activatePopoverDoc();
- }
- if ($(e.target).attr("href")=="#managed-repositories-view") {
- mainContent.find("#managed-repository-edit-li a").html($.i18n.prop("add"));
- }
-
- });
-
- mainContent.find("#remote-repositories-pills").on('show', function (e) {
- if ($(e.target).attr("href")=="#remote-repository-edit") {
- $.ajax("restServices/archivaServices/networkProxyService/getNetworkProxies", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- var remoteRepo=new RemoteRepository();
- remoteRepo.cronExpression("0 0 08 ? * SUN");
- var viewModel = new RemoteRepositoryViewModel(remoteRepo,false,remoteRepositoriesViewModel);
- viewModel.networkProxies(mapNetworkProxies(data));
- ko.applyBindings(viewModel,mainContent.find("#remote-repository-edit").get(0));
- activateRemoteRepositoryFormValidation(true);
- activatePopoverDoc();
- }
- })
- }
- if ($(e.target).attr("href")=="#remote-repositories-view") {
- $("#main-content" ).find("#remote-repository-edit-li" ).find("a").html($.i18n.prop("add"));
- }
-
- });
-
- }
-
- loadManagedRepositories=function(successCallBackFn,errorCallBackFn){
- $.ajax("restServices/archivaServices/managedRepositoriesService/getManagedRepositories", {
- type: "GET",
- dataType: 'json',
- success: successCallBackFn,
- error: errorCallBackFn
- });
- }
-
- loadRemoteRepositories=function(successCallBackFn,errorCallBackFn){
- $.ajax("restServices/archivaServices/remoteRepositoriesService/getRemoteRepositories", {
- type: "GET",
- dataType: 'json',
- success: successCallBackFn,
- error: errorCallBackFn
- });
- }
-
- findManagedRepository=function(id,managedRepositories){
- var managedRepository=$.grep(managedRepositories,
- function(repo,idx){
- return repo.id()==id;
- }
- );
- return ($.isArray(managedRepository) && managedRepository.length>0) ? managedRepository[0]:new ManagedRepository();
- }
-
-});
\ No newline at end of file
+++ /dev/null
-/*
- * 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/admin/repository/10maven2/repository-groups",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","jquery.ui","knockout"
- ,"knockout.simpleGrid","knockout.sortable","archiva/admin/repository/10maven2/repositories"],
-function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
-
- RepositoryGroup=function(id,repositories,mergedIndexPath){
-
- var self=this;
-
- //private String id;
- this.id=ko.observable(id);
- this.id.subscribe(function(newValue){self.modified(true)});
-
- //private String mergedIndexPath = "/.indexer";
- this.mergedIndexPath=ko.observable(mergedIndexPath?mergedIndexPath:".indexer");
- this.mergedIndexPath.subscribe(function(newValue){self.modified(true)});
-
- // private List<String> repositories;
- this.repositories=ko.observableArray(repositories);
- this.repositories.subscribe(function(newValue){self.modified(true)});
-
- // to store managedRepositories description not sended to server
- this.managedRepositories=ko.observableArray([]);
- this.managedRepositories.subscribe(function(newValue){self.modified(true)});
-
- this.modified=ko.observable(false);
- }
-
- RepositoryGroupViewModel=function(repositoryGroup,update,repositoryGroupsViewModel){
- var self = this;
- this.repositoryGroup=repositoryGroup;
- this.update=update;
- this.repositoryGroupsViewModel=repositoryGroupsViewModel;
- this.availableRepositories=ko.observableArray([]);
- this.applicationUrl=null;
-
- for (var i=0;i<repositoryGroupsViewModel.managedRepositories().length;i++){
- if ( $.inArray(repositoryGroupsViewModel.managedRepositories()[i].id(),this.repositoryGroup.repositories())<0){
- this.availableRepositories.push(repositoryGroupsViewModel.managedRepositories()[i]);
- }
- }
-
- repositoryMoved=function(arg){
- $.log("repositoryMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
- var repositories=[];
- for(var i=0;i<self.repositoryGroup.managedRepositories().length;i++){
- repositories.push(self.repositoryGroup.managedRepositories()[i].id());
- }
- self.repositoryGroup.repositories(repositories);
- self.repositoryGroup.modified(true);
- var mainContent=$("#main-content");
- mainContent.find("#repository-groups-edit-available-repositories").find(".icon-plus-sign" ).off("click");
- mainContent.find("#repository-groups-edit-order-div").find(".icon-minus-sign" ).off("click");
- self.renderSortableAvailables(self.repositoryGroupsViewModel);
- self.renderSortableChoosed(self.repositoryGroupsViewModel);
- }
-
- this.saveRepositoryGroup=function(repositoryGroup){
- if (self.update){
- self.repositoryGroupsViewModel.saveRepositoryGroup(repositoryGroup);
- } else {
- self.repositoryGroupsViewModel.addRepositoryGroup(repositoryGroup);
- }
- }
-
- this.removeRepository=function(id){
- $.log("removeRepository:"+id);
- }
-
- this.removeAvailable=function(idVal){
- for (var i=0;i<self.repositoryGroupsViewModel.managedRepositories().length;i++){
- if(self.repositoryGroupsViewModel.managedRepositories()[i].id()==idVal){
- self.availableRepositories.remove(repositoryGroupsViewModel.managedRepositories()[i]);
- }
- }
-
- for(var i= 0;i<self.repositoryGroupsViewModel.managedRepositories().length;i++){
- if(self.repositoryGroupsViewModel.managedRepositories()[i].id()==idVal){
- $.log("find repo to add");
- self.repositoryGroup.repositories.push(idVal);
- self.repositoryGroup.managedRepositories.push(findManagedRepository(idVal,self.repositoryGroupsViewModel.managedRepositories()));
- }
- }
- $("#main-content").find("#repository-groups-edit-order-div").find("#minus-"+idVal ).on("click",function(){
- var idVal = $(this).attr("id");
- idVal=idVal.substringAfterFirst("minus-");
- self.removeChoosed(idVal);
- });
- }
-
- this.renderSortableAvailables=function(repositoryGroupsViewModel){
- $("#main-content").find("#repository-groups-edit-available-repositories").find(".icon-plus-sign" ).on("click",function(){
- var idVal = $(this).attr("id");
- idVal=idVal.substringAfterFirst("plus-");
- self.removeAvailable(idVal);
- });
- }
-
- this.removeChoosed=function(idVal){
- for (var i=0;i<self.repositoryGroupsViewModel.managedRepositories().length;i++){
- if(self.repositoryGroupsViewModel.managedRepositories()[i].id()==idVal){
- self.availableRepositories.push(repositoryGroupsViewModel.managedRepositories()[i]);
- }
- }
-
- for(var i= 0;i<self.repositoryGroup.repositories().length;i++){
- if(self.repositoryGroup.repositories()[i]==idVal){
- self.repositoryGroup.repositories.remove(self.repositoryGroup.repositories()[i]);
- self.repositoryGroup.managedRepositories.remove(findManagedRepository(idVal,self.repositoryGroupsViewModel.managedRepositories()));
- }
- }
- $("#main-content").find("#repository-groups-edit-available-repositories").find("#plus-"+idVal ).on("click",function(){
- var idVal = $(this).attr("id");
- idVal=idVal.substringAfterFirst("plus-");
- self.removeAvailable(idVal);
- });
- }
-
- this.renderSortableChoosed=function(repositoryGroupsViewModel){
- $("#main-content").find("#repository-groups-edit-order-div").find(".icon-minus-sign" ).on("click",function(){
- var idVal = $(this).attr("id");
- idVal=idVal.substringAfterFirst("minus-");
- self.removeChoosed(idVal);
- });
- }
- }
-
- RepositoryGroupsViewModel=function(){
- var self=this;
- this.repositoryGroups=ko.observableArray([]);
- this.managedRepositories=ko.observableArray([]);
- this.applicationUrl="";
-
- this.removeFromList=function(managedRepository){
- $.log("removeFromList");
- }
-
- this.findManagedRepository=function(id){
- return findManagedRepository(id,self.managedRepositories());
- }
- this.deleteRepositoryGroup=function(repositoryGroup){
- openDialogConfirm(
- function(){self.removeRepositoryGroup(repositoryGroup);window.modalConfirmDialog.modal('hide')},
- $.i18n.prop('ok'), $.i18n.prop('cancel'),
- $.i18n.prop('repository.group.delete.confirm',repositoryGroup.id()),
- $("#repository-group-delete-warning-tmpl").tmpl(self.repositoryGroup));
- }
- this.removeRepositoryGroup=function(repositoryGroup){
- clearUserMessages();
- $.ajax("restServices/archivaServices/repositoryGroupService/deleteRepositoryGroup/"+encodeURIComponent(repositoryGroup.id()),
- {
- type: "GET",
- success: function(data) {
- var message=$.i18n.prop('repository.group.deleted',repositoryGroup.id());
- displaySuccessMessage(message);
- self.repositoryGroups.remove(repositoryGroup);
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- }
- }
- );
- }
-
- this.editRepositoryGroup=function(repositoryGroup){
-
- var mainContent=$("#main-content");
- $.ajax({
- url: "restServices/archivaServices/archivaAdministrationService/applicationUrl",
- type: "GET",
- dataType: 'text',
- success: function(applicationUrl){
- $.log("editRepositoryGroup:"+repositoryGroup.id()+",repositories:"+repositoryGroup.repositories().length+",managed:"+repositoryGroup.managedRepositories().length);
- var repositoryGroupViewModel=new RepositoryGroupViewModel(repositoryGroup,true,self);
- repositoryGroupViewModel.applicationUrl=applicationUrl;
- activateRepositoryGroupEditTab();
- ko.applyBindings(repositoryGroupViewModel,mainContent.find("#repository-groups-edit" ).get(0));
- repositoryGroupViewModel.renderSortableChoosed(self);
- repositoryGroupViewModel.renderSortableAvailables(self);
- mainContent.find("#repository-groups-view-tabs-li-edit" ).find("a").html($.i18n.prop("edit"));
- repositoryGroupValidator();
- }
- });
- }
-
- this.editRepositoryGroupWithId=function(repositoryGroupId){
-
- $.each(self.repositoryGroups(), function(index, value) {
- if(value.id()==repositoryGroupId){
- self.editRepositoryGroup(value);
- }
- });
- }
-
- this.saveRepositoryGroup=function(repositoryGroup){
- if(valid==false){
- $.log("saveRepositoryGroup, valid:"+valid);
- return;
- }
- clearUserMessages();
- var userMessages=$("#user-messages");
- userMessages.html(mediumSpinnerImg());
- var valid = $("#main-content").find("#repository-group-edit-form" ).valid();
-
-
- $("#repository-group-save" ).button('loading');
- $.ajax("restServices/archivaServices/repositoryGroupService/updateRepositoryGroup",
- {
- type: "POST",
- contentType: 'application/json',
- data:ko.toJSON(repositoryGroup),
- dataType: 'json',
- success: function(data) {
- $.log("update repositoryGroup id:"+repositoryGroup.id());
- var message=$.i18n.prop('repository.group.updated',repositoryGroup.id());
- displaySuccessMessage(message);
- repositoryGroup.modified(false);
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete:function(data){
- $("#repository-group-save" ).button('reset');
- removeMediumSpinnerImg(userMessages);
- }
- }
- );
-
- };
-
- this.addRepositoryGroup=function(repositoryGroup){
- clearUserMessages();
- $.ajax("restServices/archivaServices/repositoryGroupService/addRepositoryGroup",
- {
- type: "POST",
- contentType: 'application/json',
- data: ko.toJSON(repositoryGroup),
- dataType: 'json',
- success: function(data) {
- $.log("update repositoryGroup id:"+repositoryGroup.id());
- var message=$.i18n.prop('repository.group.added',repositoryGroup.id());
- displaySuccessMessage(message);
- repositoryGroup.modified(false);
- self.repositoryGroups.push(repositoryGroup);
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- }
- }
- );
-
- }
-
- getManagedRepository=function(id){
- $.log("getManagedRepository:"+id);
- return findManagedRepository(self.managedRepositories());
- }
-
- }
-
- displayRepositoryGroups=function(successFn){
- screenChange();
- var mainContent = $("#main-content");
- mainContent.html(mediumSpinnerImg());
- this.repositoryGroupsViewModel=new RepositoryGroupsViewModel();
- var self=this;
-
- loadManagedRepositories(function(data) {
-
- $.ajax({
- url: "restServices/archivaServices/archivaAdministrationService/applicationUrl",
- type: "GET",
- dataType: 'text',
- success: function(applicationUrl){
-
- self.repositoryGroupsViewModel.managedRepositories(
- mapManagedRepositories(data,applicationUrl?applicationUrl:window.location.toString().substringBeforeLast("/")));
- self.repositoryGroupsViewModel.applicationUrl=applicationUrl;
- $.ajax("restServices/archivaServices/repositoryGroupService/getRepositoriesGroups", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- var mappedRepositoryGroups=mapRepositoryGroups(data);
- for(var i=0;i<mappedRepositoryGroups.length;i++){
- mappedRepositoryGroups[i]
- .managedRepositories(self.mapManagedRepositoriesToRepositoryGroup(mappedRepositoryGroups[i]));
- mappedRepositoryGroups[i].modified(false);
- $.log("mappedRepositoryGroups.repositories().length:"+mappedRepositoryGroups[i].repositories().length);
- }
- mainContent.html($("#repositoryGroupsMain").tmpl());
- self.repositoryGroupsViewModel.repositoryGroups(mappedRepositoryGroups);
- $.log("displayRepositoryGroups#applyBindings before");
- ko.applyBindings(self.repositoryGroupsViewModel,mainContent.find("#repository-groups-view" ).get(0));
- $.log("displayRepositoryGroups#applyBindings after");
-
- mainContent.find("#repository-groups-view-tabs").on('show', function (e) {
- if ($(e.target).attr("href")=="#repository-groups-edit") {
- var repositoryGroup = new RepositoryGroup();
- var repositoryGroupViewModel=new RepositoryGroupViewModel(repositoryGroup,false,self.repositoryGroupsViewModel);
-
- activateRepositoryGroupEditTab();
- ko.applyBindings(repositoryGroupViewModel,mainContent.find("#repository-groups-edit" ).get(0));
- repositoryGroupViewModel.renderSortableChoosed(self.repositoryGroupsViewModel);
- repositoryGroupViewModel.renderSortableAvailables(self.repositoryGroupsViewModel);
- }
- if ($(e.target).attr("href")=="#repository-groups-view") {
- mainContent.find("#repository-groups-view-tabs-li-edit a").html($.i18n.prop("add"));
- clearUserMessages();
- }
-
- });
-
- if(successFn){
- successFn(self.repositoryGroupsViewModel);
- }
-
- }
- }
- );
-
- }
- });
- });
-
- this.mapManagedRepositoriesToRepositoryGroup=function(repositoryGroup){
- $.log("mapManagedRepositoriesToRepositoryGroup");
- var managedRepositories=new Array();
- if (!repositoryGroup.repositories()) {
- repositoryGroup.repositories(new Array());
- return managedRepositories;
- }
- for(var i=0;i<repositoryGroup.repositories().length;i++){
- managedRepositories.push(self.repositoryGroupsViewModel.findManagedRepository(repositoryGroup.repositories()[i]));
- }
- $.log("end mapManagedRepositoriesToRepositoryGroup");
- return managedRepositories;
- }
-
- }
-
-
-
- activateRepositoryGroupsGridTab=function(){
- var mainContent = $("#main-content");
- mainContent.find("#repository-groups-view-tabs-content div[class*='tab-pane']").removeClass("active");
- mainContent.find("#repository-groups-view-tabs li").removeClass("active");
-
- mainContent.find("#repository-groups-view").addClass("active");
- mainContent.find("#repository-groups-view-tabs-li-grid").addClass("active");
- mainContent.find("#repository-groups-view-tabs-li-edit a").html($.i18n.prop("add"));
-
- }
-
- activateRepositoryGroupEditTab=function(){
- $.log("activateRepositoryGroupEditTab");
- var mainContent = $("#main-content");
-
- mainContent.find("#repository-groups-view-tabs-content div[class*='tab-pane']").removeClass("active");
- mainContent.find("#repository-groups-view-tabs li").removeClass("active");
-
- mainContent.find("#repository-groups-edit").addClass("active");
- mainContent.find("#repository-groups-view-tabs-li-edit").addClass("active");
-
-
- }
-
- repositoryGroupValidator=function(){
- $.log("validator");
- var theForm=$("#main-content").find("#repository-group-edit-form");
- var validator = theForm.validate({
- rules: {
- id: {
- required: true
- },
- mergedIndexPath:{
- required:true
- }
- },
- showErrors: function(validator, errorMap, errorList) {
- customShowError("#main-content #repository-group-edit-form",validator,errorMap,errorMap);
- }
- });
- return validator;
- }
-
- mapRepositoryGroups=function(data){
- if (data == null){
- return new Array();
- }
- var mappedRepositoryGroups = $.map(data, function(item) {
- return mapRepositoryGroup(item);
- });
- return mappedRepositoryGroups;
- }
-
- mapRepositoryGroup=function(data){
- return new RepositoryGroup(data.id, mapStringArray(data.repositories),data.mergedIndexPath);
- }
-
-});
+++ /dev/null
-/*
- * 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/admin/repository/20legacy/main", ["jquery", 'i18n','knockout'],
- function(jquery,i18n,ko) {
-
- showMenu = function(administrationMenuItems) {
- administrationMenuItems.push(
- {
- text: $.i18n.prop('menu.legacy-artifact-support'),
- id: "menu-legacy-support-list-a",
- href: "#legacy",
- redback: "{permissions: ['archiva-manage-configuration']}",
- func: function() {
- displayLegacyArtifactPathSupport();
- }
- });
- };
-
-
- //-------------------------
- // legacy path part
- //-------------------------
-
- LegacyArtifactPath = function(path, groupId, artifactId, version, classifier, type, update) {
- //private String path;
- this.path = ko.observable(path);
-
- /**
- * The artifact reference, as " [groupId] :
- * [artifactId] : [version] : [classifier] : [type] ".
- */
- //private String artifact;
- //this.artifact=ko.observable(artifact);
- this.update = update;
- //private String groupId;
- this.groupId = ko.observable(groupId);
-
- //private String artifactId;
- this.artifactId = ko.observable(artifactId);
-
- //private String version;
- this.version = ko.observable(version);
-
- //private String classifier;
- this.classifier = ko.observable(classifier);
-
- //private String type;
- this.type = ko.observable(type);
-
- this.modified = ko.observable();
-
- this.artifact = ko.computed(function() {
- var artifactValue = "";
- if (this.groupId()) {
- artifactValue += this.groupId();
- }
- if (this.artifactId()) {
- artifactValue += ":" + this.artifactId();
- }
- if (this.version()) {
- artifactValue += ":" + this.version();
- }
- if (this.classifier()) {
- artifactValue += ":" + this.classifier();
- }
- if (this.type()) {
- artifactValue += ":" + this.type();
- }
- return artifactValue;
- }, this);
- };
-
- mapLegacyArtifactPaths = function(data) {
- if (data) {
- return $.isArray(data) ? $.map(data, function(item) {
- return mapLegacyArtifactPath(item);
- }) : [mapLegacyArtifactPath(data)];
- }
- return [];
- };
-
- mapLegacyArtifactPath = function(data) {
- return data ? new LegacyArtifactPath(data.path, data.groupId, data.artifactId, data.version, data.classifier, data.type) : null;
- };
-
- activateLegacyArtifactPathFormValidation = function() {
- var theForm = $("#main-content").find("#legacy-artifact-paths-edit-form");
- var validator = theForm.validate({
- showErrors: function(validator, errorMap, errorList) {
- customShowError("#main-content #legacy-artifact-paths-edit-form", validator, errorMap, errorMap);
- }
- });
- };
-
- LegacyArtifactPathViewModel = function(legacyArtifactPath, update, legacyArtifactPathsViewModel) {
- var self = this;
- this.update = update;
- this.legacyArtifactPath = legacyArtifactPath;
- this.legacyArtifactPathsViewModel = legacyArtifactPathsViewModel;
-
- this.display = function() {
- var mainContent = $("#main-content");
- ko.applyBindings(self, mainContent.find("#legacy-artifact-paths-edit").get(0));
- mainContent.find("#legacy-artifact-paths-view-tabs-li-edit a").html($.i18n.prop("edit"));
- activateLegacyArtifactPathFormValidation();
- activateLegacyArtifactPathsEditTab();
- };
-
- displayGrid = function() {
- activateLegacyArtifactPathsGridTab();
- };
-
- calculatePath = function() {
- var path = "";
- if (self.legacyArtifactPath.groupId()) {
- path += self.legacyArtifactPath.groupId() + "/jars/";
- }
- if (self.legacyArtifactPath.artifactId()) {
- path += self.legacyArtifactPath.artifactId();
- }
- if (self.legacyArtifactPath.version()) {
- path += "-" + self.legacyArtifactPath.version();
- }
- if (self.legacyArtifactPath.classifier()) {
- path += "-" + self.legacyArtifactPath.classifier();
- }
- if (self.legacyArtifactPath.type()) {
- path += "." + self.legacyArtifactPath.type();
- }
- self.legacyArtifactPath.path(path);
- };
-
- this.save = function() {
- var theForm = $("#main-content").find("#legacy-artifact-paths-edit-form");
- if (!theForm.valid()) {
- return;
- }
- // do that on server side
- /*if (theForm.find("#artifact" ).val()
- !=theForm.find("#path" ).val()){
- var errorList=[{
- message: $.i18n.prop("path must match artifact"),
- element: theForm.find("#path" ).get(0)
- }];
- customShowError("#main-content #legacy-artifact-paths-edit-form", null, null, errorList);
- return;
- }*/
- // TODO call id exists if add ?
- clearUserMessages();
- $.log("save ok");
- if (self.update) {
- $.log("update");
- } else {
- $.ajax("restServices/archivaServices/archivaAdministrationService/addLegacyArtifactPath",
- {
- type: "POST",
- contentType: 'application/json',
- data: ko.toJSON(self.legacyArtifactPath),
- dataType: 'json',
- success: function(data) {
- self.legacyArtifactPath.modified(false);
- self.legacyArtifactPathsViewModel.legacyArtifactPaths.push(self.legacyArtifactPath);
- displaySuccessMessage($.i18n.prop('legacy-artifact-path.added', self.legacyArtifactPath.path()));
- activateLegacyArtifactPathsGridTab();
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- }
- }
- );
- }
- };
- };
-
- LegacyArtifactPathsViewModel = function() {
- var self = this;
- this.legacyArtifactPaths = ko.observableArray([]);
-
- this.gridViewModel = new ko.simpleGrid.viewModel({
- data: self.legacyArtifactPaths,
- columns: [
- {
- headerText: $.i18n.prop('legacy-artifact-paths.path'),
- rowText: "path"
- },
- {
- headerText: $.i18n.prop('legacy-artifact-paths.artifact'),
- rowText: "artifact"
- }
- ],
- pageSize: 5,
- gridUpdateCallBack: function(networkProxy) {
- $("#main-content").find("#legacy-artifact-paths-table").find("[title]").tooltip();
- }
- });
-
-
- editLegacyArtifactPath = function(legacyArtifactPath) {
- var legacyArtifactPathViewModel = new LegacyArtifactPathViewModel(legacyArtifactPath, true);
- legacyArtifactPathViewModel.display();
- };
-
- removeLegacyArtifactPath = function(legacyArtifactPath) {
-
- openDialogConfirm(
- function() {
-
- $.ajax("restServices/archivaServices/archivaAdministrationService/deleteLegacyArtifactPath?path=" + encodeURIComponent(legacyArtifactPath.path()),
- {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- self.legacyArtifactPaths.remove(legacyArtifactPath);
- displaySuccessMessage($.i18n.prop('legacy-artifact-path.removed', legacyArtifactPath.path()));
- activateLegacyArtifactPathsGridTab();
- },
- error: function(data) {
- var res = $.parseJSON(data.responseText);
- displayRestError(res);
- },
- complete: function() {
- closeDialogConfirm();
- }
- }
- );
- }, $.i18n.prop('ok'), $.i18n.prop('cancel'), $.i18n.prop('legacy-artifact-path.delete.confirm', legacyArtifactPath.path()),
- $("#legacy-artifact-path-delete-warning-tmpl").tmpl(legacyArtifactPath));
-
- };
-
- updateLegacyArtifactPath = function(legacyArtifactPath) {
-
- };
-
- };
-
- displayLegacyArtifactPathSupport = function() {
- screenChange();
- var mainContent = $("#main-content");
- mainContent.html(mediumSpinnerImg());
-
- $.ajax("restServices/archivaServices/archivaAdministrationService/getLegacyArtifactPaths", {
- type: "GET",
- dataType: 'json',
- success: function(data) {
- mainContent.html($("#legacy-artifact-path-main").tmpl());
- var legacyArtifactPathsViewModel = new LegacyArtifactPathsViewModel();
- var legacyPaths = mapLegacyArtifactPaths(data);
- $.log("legacyPaths:" + legacyPaths.length);
- legacyArtifactPathsViewModel.legacyArtifactPaths(legacyPaths);
- ko.applyBindings(legacyArtifactPathsViewModel, mainContent.find("#legacy-artifact-paths-view").get(0));
-
- mainContent.find("#legacy-artifact-paths-view-tabs").on('show', function(e) {
- if ($(e.target).attr("href") == "#legacy-artifact-paths-edit") {
- var viewModel = new LegacyArtifactPathViewModel(new LegacyArtifactPath(), false, legacyArtifactPathsViewModel);
- viewModel.display();
- activateLegacyArtifactPathFormValidation();
- clearUserMessages();
- }
- if ($(e.target).attr("href") == "#legacy-artifact-paths-view") {
- mainContent.find("#legacy-artifact-paths-view-tabs-li-edit a").html($.i18n.prop("add"));
- clearUserMessages();
- }
-
- });
-
-
- activateLegacyArtifactPathsGridTab();
- }
- });
-
-
- };
-
-
- activateLegacyArtifactPathsGridTab = function() {
- var mainContent = $("#main-content");
- mainContent.find("#legacy-artifact-paths-view-tabs-li-edit").removeClass("active");
- mainContent.find("#legacy-artifact-paths-edit").removeClass("active");
-
- mainContent.find("#legacy-artifact-paths-view-tabs-li-grid").addClass("active");
- mainContent.find("#legacy-artifact-paths-view").addClass("active");
- mainContent.find("#legacy-artifact-paths-view-tabs-li-edit a").html($.i18n.prop("add"));
-
- };
-
- activateLegacyArtifactPathsEditTab = function() {
- var mainContent = $("#main-content");
- mainContent.find("#legacy-artifact-paths-view-tabs-li-grid").removeClass("active");
- mainContent.find("#legacy-artifact-paths-view").removeClass("active");
-
- mainContent.find("#legacy-artifact-paths-view-tabs-li-edit").addClass("active");
- mainContent.find("#legacy-artifact-paths-edit").addClass("active");
- };
-
-
-
-
- }
-);
--- /dev/null
+/*
+ * 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/admin/repository/legacy/main", ["jquery", 'i18n','knockout'],
+ function(jquery,i18n,ko) {
+
+ showMenu = function(administrationMenuItems) {
+ administrationMenuItems.push(
+ {
+ text: $.i18n.prop('menu.legacy-artifact-support'),
+ order:600,
+ id: "menu-legacy-support-list-a",
+ href: "#legacy",
+ redback: "{permissions: ['archiva-manage-configuration']}",
+ func: function() {
+ displayLegacyArtifactPathSupport();
+ }
+ });
+ };
+
+
+ //-------------------------
+ // legacy path part
+ //-------------------------
+
+ LegacyArtifactPath = function(path, groupId, artifactId, version, classifier, type, update) {
+ //private String path;
+ this.path = ko.observable(path);
+
+ /**
+ * The artifact reference, as " [groupId] :
+ * [artifactId] : [version] : [classifier] : [type] ".
+ */
+ //private String artifact;
+ //this.artifact=ko.observable(artifact);
+ this.update = update;
+ //private String groupId;
+ this.groupId = ko.observable(groupId);
+
+ //private String artifactId;
+ this.artifactId = ko.observable(artifactId);
+
+ //private String version;
+ this.version = ko.observable(version);
+
+ //private String classifier;
+ this.classifier = ko.observable(classifier);
+
+ //private String type;
+ this.type = ko.observable(type);
+
+ this.modified = ko.observable();
+
+ this.artifact = ko.computed(function() {
+ var artifactValue = "";
+ if (this.groupId()) {
+ artifactValue += this.groupId();
+ }
+ if (this.artifactId()) {
+ artifactValue += ":" + this.artifactId();
+ }
+ if (this.version()) {
+ artifactValue += ":" + this.version();
+ }
+ if (this.classifier()) {
+ artifactValue += ":" + this.classifier();
+ }
+ if (this.type()) {
+ artifactValue += ":" + this.type();
+ }
+ return artifactValue;
+ }, this);
+ };
+
+ mapLegacyArtifactPaths = function(data) {
+ if (data) {
+ return $.isArray(data) ? $.map(data, function(item) {
+ return mapLegacyArtifactPath(item);
+ }) : [mapLegacyArtifactPath(data)];
+ }
+ return [];
+ };
+
+ mapLegacyArtifactPath = function(data) {
+ return data ? new LegacyArtifactPath(data.path, data.groupId, data.artifactId, data.version, data.classifier, data.type) : null;
+ };
+
+ activateLegacyArtifactPathFormValidation = function() {
+ var theForm = $("#main-content").find("#legacy-artifact-paths-edit-form");
+ var validator = theForm.validate({
+ showErrors: function(validator, errorMap, errorList) {
+ customShowError("#main-content #legacy-artifact-paths-edit-form", validator, errorMap, errorMap);
+ }
+ });
+ };
+
+ LegacyArtifactPathViewModel = function(legacyArtifactPath, update, legacyArtifactPathsViewModel) {
+ var self = this;
+ this.update = update;
+ this.legacyArtifactPath = legacyArtifactPath;
+ this.legacyArtifactPathsViewModel = legacyArtifactPathsViewModel;
+
+ this.display = function() {
+ var mainContent = $("#main-content");
+ ko.applyBindings(self, mainContent.find("#legacy-artifact-paths-edit").get(0));
+ mainContent.find("#legacy-artifact-paths-view-tabs-li-edit a").html($.i18n.prop("edit"));
+ activateLegacyArtifactPathFormValidation();
+ activateLegacyArtifactPathsEditTab();
+ };
+
+ displayGrid = function() {
+ activateLegacyArtifactPathsGridTab();
+ };
+
+ calculatePath = function() {
+ var path = "";
+ if (self.legacyArtifactPath.groupId()) {
+ path += self.legacyArtifactPath.groupId() + "/jars/";
+ }
+ if (self.legacyArtifactPath.artifactId()) {
+ path += self.legacyArtifactPath.artifactId();
+ }
+ if (self.legacyArtifactPath.version()) {
+ path += "-" + self.legacyArtifactPath.version();
+ }
+ if (self.legacyArtifactPath.classifier()) {
+ path += "-" + self.legacyArtifactPath.classifier();
+ }
+ if (self.legacyArtifactPath.type()) {
+ path += "." + self.legacyArtifactPath.type();
+ }
+ self.legacyArtifactPath.path(path);
+ };
+
+ this.save = function() {
+ var theForm = $("#main-content").find("#legacy-artifact-paths-edit-form");
+ if (!theForm.valid()) {
+ return;
+ }
+ // do that on server side
+ /*if (theForm.find("#artifact" ).val()
+ !=theForm.find("#path" ).val()){
+ var errorList=[{
+ message: $.i18n.prop("path must match artifact"),
+ element: theForm.find("#path" ).get(0)
+ }];
+ customShowError("#main-content #legacy-artifact-paths-edit-form", null, null, errorList);
+ return;
+ }*/
+ // TODO call id exists if add ?
+ clearUserMessages();
+ $.log("save ok");
+ if (self.update) {
+ $.log("update");
+ } else {
+ $.ajax("restServices/archivaServices/archivaAdministrationService/addLegacyArtifactPath",
+ {
+ type: "POST",
+ contentType: 'application/json',
+ data: ko.toJSON(self.legacyArtifactPath),
+ dataType: 'json',
+ success: function(data) {
+ self.legacyArtifactPath.modified(false);
+ self.legacyArtifactPathsViewModel.legacyArtifactPaths.push(self.legacyArtifactPath);
+ displaySuccessMessage($.i18n.prop('legacy-artifact-path.added', self.legacyArtifactPath.path()));
+ activateLegacyArtifactPathsGridTab();
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ }
+ }
+ );
+ }
+ };
+ };
+
+ LegacyArtifactPathsViewModel = function() {
+ var self = this;
+ this.legacyArtifactPaths = ko.observableArray([]);
+
+ this.gridViewModel = new ko.simpleGrid.viewModel({
+ data: self.legacyArtifactPaths,
+ columns: [
+ {
+ headerText: $.i18n.prop('legacy-artifact-paths.path'),
+ rowText: "path"
+ },
+ {
+ headerText: $.i18n.prop('legacy-artifact-paths.artifact'),
+ rowText: "artifact"
+ }
+ ],
+ pageSize: 5,
+ gridUpdateCallBack: function(networkProxy) {
+ $("#main-content").find("#legacy-artifact-paths-table").find("[title]").tooltip();
+ }
+ });
+
+
+ editLegacyArtifactPath = function(legacyArtifactPath) {
+ var legacyArtifactPathViewModel = new LegacyArtifactPathViewModel(legacyArtifactPath, true);
+ legacyArtifactPathViewModel.display();
+ };
+
+ removeLegacyArtifactPath = function(legacyArtifactPath) {
+
+ openDialogConfirm(
+ function() {
+
+ $.ajax("restServices/archivaServices/archivaAdministrationService/deleteLegacyArtifactPath?path=" + encodeURIComponent(legacyArtifactPath.path()),
+ {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ self.legacyArtifactPaths.remove(legacyArtifactPath);
+ displaySuccessMessage($.i18n.prop('legacy-artifact-path.removed', legacyArtifactPath.path()));
+ activateLegacyArtifactPathsGridTab();
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete: function() {
+ closeDialogConfirm();
+ }
+ }
+ );
+ }, $.i18n.prop('ok'), $.i18n.prop('cancel'), $.i18n.prop('legacy-artifact-path.delete.confirm', legacyArtifactPath.path()),
+ $("#legacy-artifact-path-delete-warning-tmpl").tmpl(legacyArtifactPath));
+
+ };
+
+ updateLegacyArtifactPath = function(legacyArtifactPath) {
+
+ };
+
+ };
+
+ displayLegacyArtifactPathSupport = function() {
+ screenChange();
+ var mainContent = $("#main-content");
+ mainContent.html(mediumSpinnerImg());
+
+ $.ajax("restServices/archivaServices/archivaAdministrationService/getLegacyArtifactPaths", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ mainContent.html($("#legacy-artifact-path-main").tmpl());
+ var legacyArtifactPathsViewModel = new LegacyArtifactPathsViewModel();
+ var legacyPaths = mapLegacyArtifactPaths(data);
+ $.log("legacyPaths:" + legacyPaths.length);
+ legacyArtifactPathsViewModel.legacyArtifactPaths(legacyPaths);
+ ko.applyBindings(legacyArtifactPathsViewModel, mainContent.find("#legacy-artifact-paths-view").get(0));
+
+ mainContent.find("#legacy-artifact-paths-view-tabs").on('show', function(e) {
+ if ($(e.target).attr("href") == "#legacy-artifact-paths-edit") {
+ var viewModel = new LegacyArtifactPathViewModel(new LegacyArtifactPath(), false, legacyArtifactPathsViewModel);
+ viewModel.display();
+ activateLegacyArtifactPathFormValidation();
+ clearUserMessages();
+ }
+ if ($(e.target).attr("href") == "#legacy-artifact-paths-view") {
+ mainContent.find("#legacy-artifact-paths-view-tabs-li-edit a").html($.i18n.prop("add"));
+ clearUserMessages();
+ }
+
+ });
+
+
+ activateLegacyArtifactPathsGridTab();
+ }
+ });
+
+
+ };
+
+
+ activateLegacyArtifactPathsGridTab = function() {
+ var mainContent = $("#main-content");
+ mainContent.find("#legacy-artifact-paths-view-tabs-li-edit").removeClass("active");
+ mainContent.find("#legacy-artifact-paths-edit").removeClass("active");
+
+ mainContent.find("#legacy-artifact-paths-view-tabs-li-grid").addClass("active");
+ mainContent.find("#legacy-artifact-paths-view").addClass("active");
+ mainContent.find("#legacy-artifact-paths-view-tabs-li-edit a").html($.i18n.prop("add"));
+
+ };
+
+ activateLegacyArtifactPathsEditTab = function() {
+ var mainContent = $("#main-content");
+ mainContent.find("#legacy-artifact-paths-view-tabs-li-grid").removeClass("active");
+ mainContent.find("#legacy-artifact-paths-view").removeClass("active");
+
+ mainContent.find("#legacy-artifact-paths-view-tabs-li-edit").addClass("active");
+ mainContent.find("#legacy-artifact-paths-edit").addClass("active");
+ };
+
+
+
+
+ }
+);
--- /dev/null
+/*
+ * 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/admin/repository/maven2/main",["jquery",'i18n',"archiva/admin/repository/maven2/repository-groups","archiva/admin/repository/maven2/proxy-connectors-rules","archiva/admin/repository/maven2/proxy-connectors"],
+ function() {
+ showMenu = function(administrationMenuItems) {
+ administrationMenuItems.push(
+ {text: $.i18n.prop('menu.repository.groups'),
+ order:500,
+ id: "menu-repository-groups-list-a",
+ href: "#repositorygroup",
+ redback: "{permissions: ['archiva-manage-configuration']}",
+ func: function() {
+ displayRepositoryGroups();
+ }
+ });
+ administrationMenuItems.push({text: $.i18n.prop('menu.repositories'), order:510, id: "menu-repositories-list-a", href: "#repositorylist", redback: "{permissions: ['archiva-manage-configuration']}", func: function() {
+ displayRepositoriesGrid();
+ }});
+ administrationMenuItems.push({text: $.i18n.prop('menu.proxy-connectors'), order:520, id: "menu-proxy-connectors-list-a", href: "#proxyconnectors", redback: "{permissions: ['archiva-manage-configuration']}", func: function() {
+ displayProxyConnectors();
+ }});
+ administrationMenuItems.push({text: $.i18n.prop('menu.proxy-connectors-rules'), order:530, id: "menu.proxy-connectors-rules-list-a", href: "#proxyconnectorsrules", redback: "{permissions: ['archiva-manage-configuration']}", func: function() {
+ displayProxyConnectorsRules();
+ }});
+
+ };
+ }
+
+);
\ No newline at end of file
--- /dev/null
+/*
+ * 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/admin/repository/maven2/proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstrap","jquery.ui","knockout"
+ ,"knockout.simpleGrid","knockout.sortable","archiva/admin/repository/maven2/proxy-connectors"],
+ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryUi,ko) {
+
+ ProxyConnectorRulesViewModel=function(proxyConnectorRules,proxyConnectors){
+ var self=this;
+ self.proxyConnectorRules=ko.observableArray(proxyConnectorRules?proxyConnectorRules:[]);
+ self.proxyConnectors=ko.observableArray(proxyConnectors);
+ self.proxyConnectors.id="select";
+
+ // FIXME get that from a REST service
+ // FIXME i18n
+ this.ruleTypes=[new RuleType("BLACK_LIST","Black list","images/red-22-22.png"),new RuleType("WHITE_LIST","White list","images/green-22-22.png")];
+
+ this.findRuleType=function(proxyConnectorRule){
+ var ruleType;
+ $.each(self.ruleTypes, function(index, value) {
+ if(value.type==proxyConnectorRule.proxyConnectorRuleType()){
+ ruleType=value;
+ }
+ });
+ 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(){
+ var mainContent = $("#main-content");
+
+ $.each(self.proxyConnectorRules(), function(index, value) {
+ value.ruleType=self.findRuleType(value);
+ });
+
+ 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-connector-rules-view").get(0));
+
+ removeSmallSpinnerImg(mainContent);
+
+ 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();
+ }
+ });
+ }
+ addProxyConnectorRule=function(proxyConnectorRule){
+ $("#proxy-connector-rule-add-btn" ).button("loading");
+ $.log("addProxyConnectorRule");
+ self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/proxyConnectorRule",true,
+ function(){
+ $("#proxy-connector-rule-add-btn" ).button("reset");
+ });
+ }
+
+ this.saveProxyConnectorRule=function(proxyConnectorRule,url,add,completeFnCallback){
+ $.log("saveProxyConnectorRule:"+url);
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ $.ajax(url,
+ {
+ type: "POST",
+ contentType: 'application/json',
+ data: ko.toJSON(proxyConnectorRule),
+ dataType: 'json',
+ success: function(data) {
+ $.log("save proxyConnectorRule pattern:"+proxyConnectorRule.pattern());
+ var message=$.i18n.prop(add?'proxy-connector-rule.added':'proxy-connector-rule.updated',proxyConnectorRule.pattern());
+ displaySuccessMessage(message);
+ proxyConnectorRule.modified(false);
+ if(add){
+ // add rule type for image
+ proxyConnectorRule.ruleType=self.findRuleType(proxyConnectorRule);
+ self.proxyConnectorRules.push(proxyConnectorRule);
+ }
+ activateProxyConnectorRulesGridTab();
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete:function(data){
+ removeMediumSpinnerImg(userMessages);
+ if(completeFnCallback){
+ completeFnCallback();
+ }
+ }
+ }
+ );
+ }
+
+ updateProxyConnectorRule=function(proxyConnectorRule){
+ $.log("updateProxyConnectorRule");
+ $("#main-content" ).find("#proxy-connectors-rules-edit-div").find("#proxy-connector-rule-update-btn").button("loading");
+ self.saveProxyConnectorRule(proxyConnectorRule,"restServices/archivaServices/proxyConnectorRuleService/updateProxyConnectorRule",
+ false,
+ function(){
+ $("#proxy-connector-rule-update-btn" ).button("reset");
+ }
+ );
+ }
+
+ this.deleteProxyConnectorRule=function(proxyConnectorRule){
+ $("#main-content" ).find("proxy-connectors-rules-view-tabsTable").find(".btn").button("loading");
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ $.ajax("restServices/archivaServices/proxyConnectorRuleService/deleteProxyConnectorRule",
+ {
+ type:"POST",
+ contentType: 'application/json',
+ data: ko.toJSON(proxyConnectorRule),
+ dataType: 'json',
+ success:function(data){
+ var message=$.i18n.prop('proxy-connector-rule.deleted',proxyConnectorRule.pattern());
+ self.proxyConnectorRules.remove(proxyConnectorRule);
+ displaySuccessMessage(message);
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete:function(data){
+ removeMediumSpinnerImg(userMessages);
+ $("#main-content" ).find("proxy-connectors-rules-view-tabsTable").find(".btn").button("reset");
+ }
+ }
+ );
+ }
+
+ removeProxyConnectorRule=function(proxyConnectorRule){
+
+ openDialogConfirm(
+ function(){self.deleteProxyConnectorRule(proxyConnectorRule);window.modalConfirmDialog.modal('hide')},
+ $.i18n.prop('ok'), $.i18n.prop('cancel'),
+ $.i18n.prop('proxy-connector-rule.delete.confirm',proxyConnectorRule.pattern()),"");
+
+ }
+
+ editProxyConnectorRule=function(proxyConnectorRule){
+ var proxyConnectorRuleViewModel=new ProxyConnectorRuleViewModel(proxyConnectorRule,self,true);
+ ko.applyBindings(proxyConnectorRuleViewModel,$("#main-content").find("#proxy-connector-rules-edit" ).get(0));
+ activateProxyConnectorRulesEditTab();
+ proxyConnectorRuleViewModel.activateRemoveChoosen(self);
+ proxyConnectorRuleViewModel.activateRemoveAvailable(self);
+ }
+
+ remove=function(){
+ $.log("remove");
+ }
+
+ }
+
+ ProxyConnectorRuleViewModel=function(proxyConnectorRule,proxyConnectorRulesViewModel,update){
+ var self=this;
+ this.proxyConnectorRule=proxyConnectorRule;
+ this.proxyConnectorRulesViewModel=proxyConnectorRulesViewModel;
+ this.availableProxyConnectors=ko.observableArray([]);
+ this.availableProxyConnectors.id="availableProxyConnectors";
+ this.update=update;
+
+ $.each(this.proxyConnectorRulesViewModel.proxyConnectors(), function(idx, value) {
+ //$.log(idx + ': ' + value.sourceRepoId() +":"+value.targetRepoId());
+ var available=true;
+ // is it in proxyConnectorRule.proxyConnectors
+ $.each(self.proxyConnectorRule.proxyConnectors(),function(index,proxyConnector){
+ if(value.sourceRepoId()==proxyConnector.sourceRepoId() && value.targetRepoId()==proxyConnector.targetRepoId()){
+ available=false;
+ }
+ });
+ if(available==true){
+ self.availableProxyConnectors.push(value);
+ }
+ });
+
+ proxyConnectorMoved=function(arg){
+ $.log("repositoryMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
+ self.proxyConnectorRule.modified(true);
+ self.activateRemoveChoosen(self.proxyConnectorRulesViewModel);
+ self.activateRemoveAvailable(self.proxyConnectorRulesViewModel);
+ }
+
+ saveProxyConnectorRule=function(){
+ 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){
+ proxyConnectorToRemove=self.proxyConnectorRule.proxyConnectors()[i];
+ }
+ }
+ self.proxyConnectorRule.proxyConnectors.remove(proxyConnectorToRemove);
+ self.availableProxyConnectors.push(proxyConnectorToRemove);
+ $.log("size after:"+self.proxyConnectorRule.proxyConnectors().length);
+ var mainContent=$("#main-content");
+ mainContent.find("#proxy-connectors-rules-available-proxy-connectors" ).find("[data-source-repoId="+sourceRepoId+"][data-target-repoId="+targetRepoId+"]" ).on("click", function(){
+ self.removeAvailable(proxyConnectorRulesViewModel,$(this).attr("data-source-repoId"),$(this).attr("data-target-repoId"));
+ });
+ mainContent.find("#proxy-connectors-rules-edit-order-div" ).find("[data-source-repoId="+sourceRepoId+"][data-target-repoId="+targetRepoId+"]" ).off("click");
+ }
+
+ 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.availableProxyConnectors().length);
+ var mainContent=$("#main-content");
+ mainContent.find("#proxy-connectors-rules-edit-order-div" ).find("[data-source-repoId="+sourceRepoId+"][data-target-repoId="+targetRepoId+"]" ).on("click", function(){
+ self.removeChoosen(proxyConnectorRulesViewModel,$(this).attr("data-source-repoId"),$(this).attr("data-target-repoId"));
+ });
+ mainContent.find("#proxy-connectors-rules-available-proxy-connectors" ).find("[data-source-repoId="+sourceRepoId+"][data-target-repoId="+targetRepoId+"]" ).off("click");
+ }
+
+ 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"));
+ });
+ }
+
+ }
+
+
+ displayProxyConnectorsRules=function(){
+ $.log("displayProxyConnectorsRules");
+ screenChange();
+ var mainContent = $("#main-content");
+ mainContent.html($("#proxyConnectorsRulesMain").tmpl());
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ 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();
+ },
+ complete: function(data){
+ removeMediumSpinnerImg(userMessages);
+ }
+
+ });
+
+ });
+ }
+
+ 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);
+ });
+
+ this.ruleType=null;
+
+ //private ProxyConnectorRuleType proxyConnectorRuleType;
+ this.proxyConnectorRuleType=ko.observable(proxyConnectorRuleType);
+ this.proxyConnectorRuleType.subscribe(function(newValue){
+ self.modified(true);
+ });
+
+ //private List<ProxyConnector> proxyConnectors;
+ this.proxyConnectors=ko.observableArray(proxyConnectors?proxyConnectors:[]);
+ this.proxyConnectors.subscribe(function(newValue){
+ self.modified(true);
+ });
+
+ this.ruleType=null;
+ }
+
+ mapProxyConnectorRule=function(data){
+ if (data==null){
+ return null;
+ }
+ return new ProxyConnectorRule(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("#proxy-connector-rules-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");
+ }
+
+ RuleType=function(type,label,image){
+ this.type=type;
+ this.label=label;
+ this.image=image;
+ }
+
+});
--- /dev/null
+/*
+ * 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/admin/repository/maven2/proxy-connectors",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","knockout"
+ ,"knockout.simpleGrid","knockout.sortable","select2"],
+ function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
+
+ ProxyConnector=function(sourceRepoId,targetRepoId,proxyId,blackListPatterns,whiteListPatterns,policiesEntries,propertiesEntries,
+ disabled,order){
+ var self=this;
+
+ this.modified=ko.observable(false);
+
+ //private String sourceRepoId;
+ this.sourceRepoId=ko.observable(sourceRepoId);
+ this.sourceRepoId.subscribe(function(newValue){
+ self.modified(true);
+ });
+
+ //private String targetRepoId;
+ this.targetRepoId=ko.observable(targetRepoId);
+ this.targetRepoId.subscribe(function(newValue){
+ self.modified(true);
+ });
+
+ this.previousProxyId=proxyId;
+
+ //private String proxyId;
+ this.proxyId=ko.observable(proxyId);
+ this.proxyId.subscribe(function(newValue){
+ if(newValue!=self.previousProxyId){
+ $.log("proxyId modified:"+newValue+",previous:"+self.previousProxyId);
+ self.previousProxyId=newValue;
+ self.modified(true);
+ }
+ });
+
+ //private List<String> blackListPatterns;
+ this.blackListPatterns=ko.observableArray(blackListPatterns==null?[]:blackListPatterns);
+ this.blackListPatterns.subscribe(function(newValue){
+ self.modified(true);
+ });
+
+ //private List<String> whiteListPatterns;
+ this.whiteListPatterns=ko.observableArray(whiteListPatterns==null?[]:whiteListPatterns);
+ this.whiteListPatterns.subscribe(function(newValue){
+ self.modified(true);
+ });
+
+ //private List<PropertyEntry> policiesEntries;
+ this.policiesEntries=ko.observableArray(policiesEntries==null?new Array():policiesEntries);
+ this.policiesEntries.subscribe(function(newValue){
+ self.modified(true);
+ });
+
+ //private List<PropertyEntry> properties;
+ this.propertiesEntries=ko.observableArray(propertiesEntries==null?new Array():propertiesEntries);
+ this.propertiesEntries.subscribe(function(newValue){
+ self.modified(true);
+ });
+
+ //private boolean disabled = false;
+ this.disabled=ko.observable(disabled);
+ this.disabled.subscribe(function(newValue){
+ self.modified(true);
+ });
+
+ //private int order = 0;
+ this.order=ko.observable(order?order:0);
+ this.order.subscribe(function(newValue){
+ self.modified(true);
+ });
+
+
+
+ this.updatePolicyEntry=function(key,value){
+ $.log("updatePolicyEntry:"+key+":"+value);
+ var found=false;
+ for(var i=0;i<self.policiesEntries().length;i++){
+ if (self.policiesEntries()[i].key==key){
+ self.policiesEntries()[i].value=value;
+ found=true;
+ self.modified(true);
+ }
+ }
+ if(!found){
+ self.policiesEntries().push(new Entry(key,value));
+ }
+ }
+
+ }
+
+ PolicyInformation=function(options,defaultOption,id,name){
+
+ var self=this;
+ this.modified=ko.observable(false);
+
+ //private List<String> options;
+ this.options=ko.observableArray(options);
+ this.options.subscribe(function(newValue){self.modified(true)});
+
+ //private String defaultOption;
+ this.defaultOption=ko.observable(defaultOption);
+ this.defaultOption.subscribe(function(newValue){self.modified(true)});
+
+ //private String id;
+ this.id=ko.observable(id);
+ this.id.subscribe(function(newValue){self.modified(true)});
+
+ //private String name;
+ this.name=ko.observable(name);
+ this.name.subscribe(function(newValue){self.modified(true)});
+
+ }
+
+ ProxyConnectorViewModel=function(proxyConnector,update,proxyConnectorsViewModel){
+ var self=this;
+ this.proxyConnector=proxyConnector;
+ this.proxyConnectorsViewModel=proxyConnectorsViewModel;
+ this.update=update;
+ this.modified=ko.observable(false);
+
+ isUpdate=function(){
+ return self.update;
+ }
+
+ getSelectedPolicyOption=function(id){
+ var policiesEntries=self.proxyConnector.policiesEntries();
+ if (policiesEntries!=null){
+ for (i=0;i<policiesEntries.length;i++){
+ var curKey = $.isFunction(policiesEntries[i].key)? policiesEntries[i].key():policiesEntries[i].key;
+ if (id==curKey){
+ return $.isFunction(policiesEntries[i].value)? policiesEntries[i].value():policiesEntries[i].value;
+ }
+ }
+ }
+ return "";
+ }
+
+ changePolicyOption=function(id){
+ var selectedOption=$("#main-content").find("#policy-"+id ).find("option:selected");
+ if (selectedOption.length>0){
+ var value = selectedOption.val();
+ $.log("changePolicyOption:"+id+":"+value);
+ self.proxyConnector.updatePolicyEntry(id,value);
+
+ }
+ }
+
+
+ getPolicyOptions=function(id){
+ var policyInformations=self.proxyConnectorsViewModel.policyInformations();
+ for(var i=0;i<policyInformations.length;i++){
+ if (policyInformations[i].id()==id){
+ return policyInformations[i].options();
+ }
+ }
+ }
+
+
+
+ addBlacklistPattern=function(){
+ var pattern = $("#main-content").find("#blacklist-value").val();
+ var tab = self.proxyConnector.blackListPatterns();
+ tab.push(pattern);
+ self.proxyConnector.blackListPatterns(tab);
+ self.proxyConnector.modified(true);
+ }
+
+ removeBlacklistPattern=function(pattern){
+ self.proxyConnector.blackListPatterns.remove(pattern);
+ self.proxyConnector.modified(true);
+ }
+
+ addWhitelistPattern=function(){
+ var pattern = $("#main-content" ).find("#whitelist-value").val();
+ var tab = self.proxyConnector.whiteListPatterns();
+ tab.push(pattern);
+ self.proxyConnector.whiteListPatterns(tab);
+ self.proxyConnector.modified(true);
+
+ }
+
+ removeWhitelistPattern=function(pattern){
+ self.proxyConnector.whiteListPatterns.remove(pattern);
+ self.proxyConnector.modified(true);
+ }
+
+ this.save=function(){
+ //FIXME data controls !!!
+ clearUserMessages();
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ $("#proxy-connector-btn-save" ).button("loading");
+ // update is delete then add
+ if (this.update){
+ $.ajax("restServices/archivaServices/proxyConnectorService/updateProxyConnector",
+ {
+ type: "POST",
+ data: ko.toJSON(self.proxyConnector),
+ contentType: 'application/json',
+ dataType: 'json',
+ success: function(data) {
+ displaySuccessMessage($.i18n.prop('proxyconnector.updated'));
+ activateProxyConnectorsGridTab();
+ self.proxyConnector.modified(false);
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete: function(){
+ removeMediumSpinnerImg(userMessages);
+ $("#proxy-connector-btn-save" ).button("reset");
+ }
+ }
+ );
+ } else {
+
+ $.ajax("restServices/archivaServices/proxyConnectorService/addProxyConnector",
+ {
+ type: "POST",
+ data: ko.toJSON(self.proxyConnector),
+ contentType: 'application/json',
+ dataType: 'json',
+ success: function(data) {
+ displaySuccessMessage($.i18n.prop('proxyconnector.added'));
+ activateProxyConnectorsGridTab();
+ self.proxyConnector.modified(false);
+ self.proxyConnectorsViewModel.proxyConnectors.push(self.proxyConnector);
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete: function(){
+ removeMediumSpinnerImg(userMessages);
+ $("#proxy-connector-btn-save" ).button("reset");
+ }
+ }
+ );
+ }
+ }
+
+ this.deleteProperty=function(key){
+ for(var i=0;i<self.proxyConnector.propertiesEntries().length;i++){
+ var entry=self.proxyConnector.propertiesEntries()[i];
+ if (entry.key()==key()){
+ self.proxyConnector.propertiesEntries.remove(entry);
+ self.proxyConnector.modified(true);
+ }
+ }
+
+ }
+
+ this.addProperty=function(){
+ var mainContent=$("#main-content");
+ var key=mainContent.find("#property-key").val();
+ var value=mainContent.find("#property-value").val();
+ var oldTab = self.proxyConnector.propertiesEntries();
+ oldTab.push(new Entry(key,value));
+ self.proxyConnector.propertiesEntries(oldTab);
+ mainContent.find("#property-key").val("");
+ mainContent.find("#property-value").val("");
+ self.proxyConnector.modified(true);
+ }
+
+ displayGrid=function(){
+ activateProxyConnectorsGridTab();
+ }
+ }
+
+ ProxyConnectorsViewModel=function(){
+ var self=this;
+ this.proxyConnectors=ko.observableArray([]);
+ this.proxyConnectors.subscribe(function(newValue){
+ $.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;
+ });
+ });
+ this.policyInformations=ko.observableArray([]);
+ this.managedRepositories=ko.observableArray([]);
+ this.remoteRepositories=ko.observableArray([]);
+ this.networkProxies=ko.observableArray([]);
+
+ this.bulkSave=function(){
+ return getModifiedProxyConnectors().length>0;
+ }
+
+ getModifiedProxyConnectors=function(){
+ var prx = $.grep(self.proxyConnectors(),
+ function (proxyConnector,i) {
+ return proxyConnector.modified();
+ });
+ return prx;
+ }
+
+ this.updateModifiedProxyConnectors=function(){
+ var modifiedProxyConnectors = getModifiedProxyConnectors();
+
+ openDialogConfirm(function(){
+ for(var i=0;i<modifiedProxyConnectors.length;i++){
+ var viewModel = new ProxyConnectorViewModel(modifiedProxyConnectors[i],true,self,false);
+ viewModel.save();
+ }
+ closeDialogConfirm();
+ },
+ $.i18n.prop('ok'),
+ $.i18n.prop('cancel'),
+ $.i18n.prop('proxy-connectors.bulk.save.confirm.title'),
+ $.i18n.prop('proxy.connector.bulk.save.confirm',modifiedProxyConnectors.length));
+ }
+
+ updateProxyConnector=function(proxyConnector){
+ var viewModel = new ProxyConnectorViewModel(proxyConnector,true,self,false);
+ viewModel.save();
+ }
+
+ editProxyConnector=function(proxyConnector){
+ var proxyConnectorViewModel=new ProxyConnectorViewModel(proxyConnector,true,self);
+ var mainContent = $("#main-content");
+ mainContent.find("#proxy-connectors-edit").html($("#proxy-connector-edit-form-tmpl").tmpl());
+ ko.applyBindings(proxyConnectorViewModel,mainContent.find("#proxy-connectors-edit").get(0));
+ activateProxyConnectorsEditTab();
+ mainContent.find("#proxy-connectors-view-tabs-li-edit a").html($.i18n.prop("edit"));
+ }
+
+ deleteProxyConnector=function(proxyConnector){
+
+ openDialogConfirm(
+ function(){
+ clearUserMessages();
+ removeProxyConnector(proxyConnector,function(){
+ displaySuccessMessage($.i18n.prop('proxyconnector.removed'));
+ self.proxyConnectors.remove(proxyConnector);
+ closeDialogConfirm();
+ })}, $.i18n.prop('ok'), $.i18n.prop('cancel'), $.i18n.prop('proxyconnector.delete.confirm'),
+ $("#proxy-connector-delete-warning-tmpl").tmpl(proxyConnector));
+
+
+ }
+
+
+ getManagedRepository=function(id){
+ return findManagedRepository(id,self.managedRepositories());
+ }
+
+ getRemoteRepository=function(id){
+ var remoteRepository=$.grep(self.remoteRepositories(),
+ function(repo,idx){
+ return repo.id()==id;
+ }
+ );
+ return ($.isArray(remoteRepository) && remoteRepository.length>0) ? remoteRepository[0]:new RemoteRepository();
+ }
+
+ getProxyConnector=function(sourceRepoId,targetRepoId){
+ var proxyConnectors=$.grep(self.proxyConnectors(),
+ function(proxyConnector,idx){
+ return proxyConnector.sourceRepoId()==sourceRepoId
+ && proxyConnector.targetRepoId()==targetRepoId;
+ }
+ );
+ var res = ($.isArray(proxyConnectors) && proxyConnectors.length>0) ? proxyConnectors[0]:new ProxyConnector();
+ return res;
+ }
+ showSettings=function(){
+ $.log("showSettings");
+ $("#body_content" ).find(".popover" ).hide();
+ //$("#main-content").find("[id^='proxy-connectors-grid-remoterepo-settings-edit-']" ).popover("hide");
+ }
+ buildSettings=function(proxyConnector){
+ var tmplHtml = $("#proxy-connectors-remote-settings-popover-tmpl")
+ .tmpl({
+ proxyConnectorsViewModel: self,
+ proxyConnector:ko.toJS(proxyConnector)
+ } ).html();
+
+ var targetImg = $(("#proxy-connectors-grid-remoterepo-settings-edit-")
+ +proxyConnector.sourceRepoId().replace(/\./g,"\\\.")+"-"+proxyConnector.targetRepoId().replace(/\./g,"\\\."));
+ return tmplHtml;
+ }
+
+ this.displaySettings=function(sourceRepoId,targetRepoId,targetContentStartId, targetImgStartId){
+ var proxyConnector=getProxyConnector(sourceRepoId,targetRepoId);
+ showSettings(proxyConnector,targetContentStartId,targetImgStartId);
+ }
+
+ this.findPolicyInformationName=function(id){
+ for(var i=0;i<self.policyInformations().length;i++){
+ if (id==self.policyInformations()[i].id()){
+ return self.policyInformations()[i].name();
+ }
+ }
+ return null;
+ }
+
+ orderChangeAware=function(proxyConnector){
+ return findProxyConnectorsWithSourceId(proxyConnector).length>1;
+ }
+
+ findProxyConnectorsWithSourceId=function(proxyConnector){
+ return $.grep(self.proxyConnectors(),function(curProxyConnector,idx){
+ return curProxyConnector.sourceRepoId()==proxyConnector.sourceRepoId();
+ }
+ );
+ }
+
+ displayOrderEdit=function(proxyConnector){
+ var proxyConnectors=findProxyConnectorsWithSourceId(proxyConnector);
+ $.log("displayOrderEdit:"+proxyConnector.sourceRepoId()+",number:"+proxyConnectors.length);
+
+ var managedRepository = getManagedRepository(proxyConnector.sourceRepoId());
+ var proxyConnectorEditOrderViewModel=new ProxyConnectorEditOrderViewModel(proxyConnectors,self,managedRepository);
+ ko.applyBindings(proxyConnectorEditOrderViewModel,$("#main-content").find("#proxy-connector-edit-order").get(0));
+ activateProxyConnectorsEditOrderTab();
+ }
+
+ this.displayGrid=function(){
+ this.gridViewModel = new ko.simpleGrid.viewModel({
+ data: self.proxyConnectors,
+ pageSize: 5,
+ gridUpdateCallBack: function(){
+ $("#main-content" ).find("#proxyConnectorsTable" ).find("[title]").tooltip();
+ }
+ });
+ var mainContent = $("#main-content");
+
+ ko.applyBindings(this,mainContent.find("#proxy-connectors-view").get(0));
+ var prxGrids=mainContent.find("[id^='proxy-connectors-grid-remoterepo-settings-edit-']");
+ prxGrids.popover();
+ removeSmallSpinnerImg();
+ mainContent.find("#proxy-connectors-view-tabs #proxy-connectors-view-tabs-a-network-proxies-grid").tab('show');
+
+ mainContent.find("#proxy-connectors-view-tabs").on('show', function (e) {
+ $.log("on show:"+$(e.target).attr("href"));
+ if ($(e.target).attr("href")=="#proxy-connectors-edit") {
+ $.log("#proxy-connectors-edit");
+ var proxyConnector=new ProxyConnector();
+ var defaultPolicies=new Array();
+ // populate with defaut policies options
+ for (i=0;i<self.policyInformations().length;i++){
+ defaultPolicies.push(new Entry(self.policyInformations()[i].id(),self.policyInformations()[i].defaultOption));
+ }
+ 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));
+ mainContent.find("#sourceRepoId" ).select2();
+ mainContent.find("#targetRepoId" ).select2();
+ }
+ if ($(e.target).attr("href")=="#proxy-connectors-view") {
+ $("#proxy-connectors-view-tabs-a-network-proxies-grid").html($.i18n.prop("proxy-connectors.grid.tab.title"));
+ mainContent.find("#proxy-connectors-view-tabs-li-edit a").html($.i18n.prop("add"));
+ }
+ if ($(e.target).attr("href")=="#proxy-connectors-edit-order") {
+ activateProxyConnectorsEditOrderTab();
+ }
+
+ });
+ }
+
+ }
+
+ ProxyConnectorEditOrderViewModel=function(proxyConnectors,proxyConnectorsViewModel,managedRepository){
+ var self=this;
+ this.proxyConnectors=ko.observableArray(proxyConnectors);
+ this.proxyConnectorsViewModel=proxyConnectorsViewModel;
+ this.managedRepository=managedRepository;
+ proxyConnectorMoved=function(arg){
+ $.log("proxyConnectorMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
+ // if only 1 move just update two whereas update all with the new order
+ if (arg.targetIndex-arg.sourceIndex==1){
+ self.proxyConnectors()[arg.targetIndex].order(arg.targetIndex+1);
+ self.proxyConnectors()[arg.sourceIndex].order(arg.sourceIndex+1);
+ } else {
+ for (i=0;i<self.proxyConnectors().length;i++){
+ self.proxyConnectors()[i].order(i+1);
+ }
+ }
+ }
+
+ this.findRemoteRepository=function(id){
+ $.log("findRemoteRepository:"+id());
+ for(var i=0;i<self.proxyConnectorsViewModel.remoteRepositories().length;i++){
+ if (self.proxyConnectorsViewModel.remoteRepositories()[i].id()==id()){
+ return self.proxyConnectorsViewModel.remoteRepositories()[i];
+ }
+ }
+ return null;
+ }
+
+ this.updateModifiedProxyConnectors=function(){
+ self.proxyConnectorsViewModel.updateModifiedProxyConnectors();
+ }
+
+ displaySettings=function(sourceRepoId,targetRepoId){
+ $.log("ProxyConnectorEditOrderViewModel#showSettings:"+sourceRepoId+"-"+targetRepoId);
+ self.proxyConnectorsViewModel.displaySettings(sourceRepoId,targetRepoId,
+ "#proxy-connectors-order-remoterepo-settings-content-",
+ "#proxy-connectors-order-remoterepo-settings-edit-");
+ }
+
+ }
+
+ displayProxyConnectors=function(){
+ screenChange();
+ var mainContent = $("#main-content");
+ mainContent.html($("#proxyConnectorsMain").tmpl());
+ mainContent.append(smallSpinnerImg());
+
+ this.proxyConnectorsViewModel = new ProxyConnectorsViewModel();
+ var self=this;
+
+ loadManagedRepositories(function(data) {
+ self.proxyConnectorsViewModel.managedRepositories(mapManagedRepositories(data));
+
+ loadRemoteRepositories(function(data) {
+ self.proxyConnectorsViewModel.remoteRepositories(mapRemoteRepositories(data));
+
+ loadNetworkProxies(function(data) {
+ self.proxyConnectorsViewModel.networkProxies(mapNetworkProxies(data));
+
+ loadAllPolicies( function(data) {
+ self.proxyConnectorsViewModel.policyInformations(mapPolicyInformations(data));
+
+ loadAllProxyConnectors( function(data) {
+ self.proxyConnectorsViewModel.proxyConnectors(mapProxyConnectors(data));
+ self.proxyConnectorsViewModel.displayGrid();
+ });
+
+ });
+
+ });
+
+ });
+
+ });
+
+ }
+
+ loadAllPolicies=function(successCallBackFn,errorCallBackFn){
+ $.ajax("restServices/archivaServices/proxyConnectorService/allPolicies", {
+ type: "GET",
+ dataType: 'json',
+ success: successCallBackFn,
+ error: errorCallBackFn
+ }
+ );
+ }
+
+ loadAllProxyConnectors=function(successCallBackFn,errorCallBackFn){
+ $.ajax("restServices/archivaServices/proxyConnectorService/getProxyConnectors", {
+ type: "GET",
+ dataType: 'json',
+ success: successCallBackFn,
+ error: errorCallBackFn
+ });
+ }
+
+ activateProxyConnectorsGridTab=function(){
+ var mainContent = $("#main-content");
+ mainContent.find("#proxy-connectors-view-tabs-content div[class*='tab-pane']").removeClass("active");
+ mainContent.find("#proxy-connectors-view-tabs li").removeClass("active");
+
+ mainContent.find("#proxy-connectors-view").addClass("active");
+ mainContent.find("#proxy-connectors-view-tabs-li-grid").addClass("active");
+ mainContent.find("#proxy-connectors-view-tabs-li-edit a").html($.i18n.prop("add"));
+
+ }
+
+ activateProxyConnectorsEditTab=function(){
+ var mainContent = $("#main-content");
+
+ mainContent.find("#proxy-connectors-view-tabs-content div[class*='tab-pane']").removeClass("active");
+ mainContent.find("#proxy-connectors-view-tabs li").removeClass("active");
+
+ mainContent.find("#proxy-connectors-edit").addClass("active");
+ mainContent.find("#proxy-connectors-view-tabs-li-edit").addClass("active");
+ }
+
+ activateProxyConnectorsEditOrderTab=function(){
+ var mainContent = $("#main-content");
+
+ mainContent.find("#proxy-connectors-view-tabs-content div[class*='tab-pane']").removeClass("active");
+ mainContent.find("#proxy-connectors-view-tabs li").removeClass("active");
+
+ mainContent.find("#proxy-connector-edit-order").addClass("active");
+ mainContent.find("#proxy-connectors-view-tabs-li-edit-order").addClass("active");
+ }
+
+ mapProxyConnector=function(data){
+ if (data==null){
+ return null;
+ }
+ var policiesEntries = data.policiesEntries == null ? []: $.each(data.policiesEntries,function(item){
+ return new Entry(item.key, item.value);
+ });
+ if (!$.isArray(policiesEntries)){
+ policiesEntries=[];
+ }
+ var propertiesEntries = data.propertiesEntries == null ? []: $.each(data.propertiesEntries,function(item){
+ return new Entry(item.key, item.value);
+ });
+ if (!$.isArray(propertiesEntries)){
+ propertiesEntries=[];
+ }
+ return new ProxyConnector(data.sourceRepoId,data.targetRepoId,data.proxyId,mapStringArray(data.blackListPatterns),
+ mapStringArray(data.whiteListPatterns),policiesEntries,propertiesEntries,
+ data.disabled,data.order);
+ }
+
+ mapProxyConnectors=function(data){
+ var mappedProxyConnectors = $.map(data, function(item) {
+ return mapProxyConnector(item);
+ });
+ return mappedProxyConnectors;
+ }
+
+ mapPolicyInformation=function(data){
+ if (data==null){
+ return null;
+ }
+ var policyInformation = new PolicyInformation(mapStringArray(data.options),data.defaultOption,data.id,data.name);
+ $.log("policyInformation.options:"+policyInformation.options());
+ return policyInformation;
+ }
+
+ mapPolicyInformations=function(data){
+ return $.map(data, function(item) {
+ return mapPolicyInformation(item);
+ });
+ }
+
+ removeProxyConnector=function(proxyConnector,fnSuccessCallback){
+ clearUserMessages();
+ var url="restServices/archivaServices/proxyConnectorService/removeProxyConnector?";
+ url += "sourceRepoId="+encodeURIComponent(proxyConnector.sourceRepoId());
+ url += "&targetRepoId="+encodeURIComponent(proxyConnector.targetRepoId());
+ $.ajax(url,
+ {
+ type: "GET",
+ contentType: 'application/json',
+ success: function(data) {
+ fnSuccessCallback();
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ }
+ }
+ );
+
+ }
+
+});
--- /dev/null
+/*
+ * 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/admin/repository/maven2/repositories",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","knockout","knockout.simpleGrid"],
+function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,ko) {
+
+ // FIXME this must be dynamic if we do a plugin mechanism with dynamic repositories types
+ // FIXME i18n
+
+ ManagedRepositoryType=function(type,label){
+ this.type=type;
+ this.label=label;
+ }
+
+ window.managedRepositoryTypes = [
+ new ManagedRepositoryType("default","Maven 2.x Repository"),
+ new ManagedRepositoryType("legacy", "Maven 1.x Repository")
+ ];
+
+ ManagedRepository=function(id,name,layout,indexDirectory,location,snapshots,releases,blockRedeployments,cronExpression,
+ scanned,daysOlder,retentionCount,deleteReleasedSnapshots,stageRepoNeeded,description,
+ skipPackedIndexCreation,feedsUrl,url){
+
+ var self=this;
+
+ //private String id;
+ this.id=ko.observable(id);
+ this.id.subscribe(function(newValue){self.modified(true)});
+
+ //private String name;
+ this.name=ko.observable(name);
+ this.name.subscribe(function(newValue){self.modified(true)});
+
+ //private String layout = "default";
+ this.layout=ko.observable(layout);
+ this.layout.subscribe(function(newValue){self.modified(true)});
+
+ //private String indexDirectory;
+ this.indexDirectory=ko.observable(indexDirectory);
+ this.indexDirectory.subscribe(function(newValue){self.modified(true)});
+
+ //private String location;
+ this.location=ko.observable(location);
+ this.location.subscribe(function(newValue){self.modified(true)});
+
+ //private String cronExpression = "0 0 * * * ?";
+ this.cronExpression=ko.observable(cronExpression);
+ this.cronExpression.subscribe(function(newValue){self.modified(true)});
+
+ //private ManagedRepository stagingRepository;
+
+ //private int daysOlder = 100;
+ this.daysOlder=ko.observable(daysOlder);
+ this.daysOlder.subscribe(function(newValue){self.modified(true)});
+
+ //private int retentionCount = 2;
+ this.retentionCount=ko.observable(retentionCount);
+ this.retentionCount.subscribe(function(newValue){self.modified(true)});
+
+ //private boolean scanned = true;
+ this.scanned=ko.observable(scanned?scanned:true);
+ this.scanned.subscribe(function(newValue){self.modified(true)});
+
+ //private boolean deleteReleasedSnapshots;
+ this.deleteReleasedSnapshots=ko.observable(deleteReleasedSnapshots);
+ this.deleteReleasedSnapshots.subscribe(function(newValue){self.modified(true)});
+
+ //private boolean stageRepoNeeded;
+ this.stageRepoNeeded=ko.observable(stageRepoNeeded);
+ this.stageRepoNeeded.subscribe(function(newValue){self.modified(true)});
+
+ //private boolean snapshots = false;
+ this.snapshots=ko.observable(snapshots?snapshots:false);
+ this.snapshots.subscribe(function(newValue){self.modified(true)});
+
+ //private boolean releases = true;
+ this.releases=ko.observable(releases?releases:false);
+ this.releases.subscribe(function(newValue){self.modified(true)});
+
+ //private boolean blockRedeployments = false;
+ this.blockRedeployments=ko.observable(blockRedeployments?blockRedeployments:false);
+ this.blockRedeployments.subscribe(function(newValue){self.modified(true)});
+
+ //private String name;
+ this.description=ko.observable(description);
+ this.description.subscribe(function(newValue){self.modified(true)});
+
+ this.skipPackedIndexCreation=ko.observable(skipPackedIndexCreation?skipPackedIndexCreation:false);
+ this.skipPackedIndexCreation.subscribe(function(newValue){self.modified(true)});
+
+ this.feedsUrl=feedsUrl;
+
+ this.url=url;
+
+ this.getTypeLabel=function(){
+ for(var i=0;i<window.managedRepositoryTypes.length;i++){
+ if (window.managedRepositoryTypes[i].type==self.layout()){
+ return window.managedRepositoryTypes[i].label;
+ }
+ }
+ return "no label";
+ }
+
+ this.modified=ko.observable(false);
+ }
+
+ ArchivaRepositoryStatistics=function(scanEndTime,scanStartTime,totalArtifactCount,totalArtifactFileSize,totalFileCount,
+ totalGroupCount,totalProjectCount,newFileCount,duration,managedRepository,lastScanDate){
+ //private Date scanEndTime;
+ this.scanEndTime = ko.observable(scanEndTime);
+
+ //private Date scanStartTime;
+ this.scanStartTime = ko.observable(scanStartTime);
+
+ //private long totalArtifactCount;
+ this.totalArtifactCount = ko.observable(totalArtifactCount);
+
+ //private long totalArtifactFileSize;
+ this.totalArtifactFileSize = ko.observable(totalArtifactFileSize);
+
+ //private long totalFileCount;
+ this.totalFileCount = ko.observable(totalFileCount);
+
+ //private long totalGroupCount;
+ this.totalGroupCount = ko.observable(totalGroupCount);
+
+ //private long totalProjectCount;
+ this.totalProjectCount = ko.observable(totalProjectCount);
+
+ //private long newFileCount;
+ this.newFileCount = ko.observable(newFileCount);
+
+ this.duration = ko.observable(duration);
+
+ this.managedRepository = managedRepository;
+
+ this.lastScanDate=ko.observable(lastScanDate);
+ }
+
+ mapManagedRepositories=function(data,applicationUrl){
+ var mappedManagedRepositories = $.map(data, function(item) {
+ var managedRepository = mapManagedRepository(item);
+ managedRepository.feedsUrl=applicationUrl+"/feeds/"+managedRepository.id();
+ managedRepository.url=applicationUrl+"/repository/"+managedRepository.id()
+ return managedRepository;
+ });
+ return mappedManagedRepositories;
+ }
+ mapManagedRepository=function(data){
+ if (data==null){
+ return null;
+ }
+ return new ManagedRepository(data.id,data.name,data.layout,data.indexDirectory,data.location,data.snapshots
+ ,data.releases,
+ data.blockRedeployments,data.cronExpression,
+ data.scanned,data.daysOlder,data.retentionCount,data.deleteReleasedSnapshots,
+ data.stageRepoNeeded,data.description,data.skipPackedIndexCreation);
+ }
+
+ mapArchivaRepositoryStatistics=function(data){
+ if (data==null){
+ return null;
+ }
+ return new ArchivaRepositoryStatistics(data.scanEndTime,data.scanStartTime,data.totalArtifactCount,data.totalArtifactFileSize,
+ data.totalFileCount,data.totalGroupCount,data.totalProjectCount,data.newFileCount,
+ data.duration,data.managedRepository,data.lastScanDate)
+ }
+
+ ManagedRepositoryViewModel=function(managedRepository, update, managedRepositoriesViewModel){
+ this.managedRepository=managedRepository;
+ this.managedRepositoriesViewModel = managedRepositoriesViewModel;
+ this.update = update;
+
+ var self = this;
+
+ this.availableLayouts = window.managedRepositoryTypes;
+
+ showCronExpressionDoc=function(){
+ //$.log("showCronExpressionDoc") ;
+ }
+
+ this.save=function(){
+ $.log('managedrepo save');
+ var valid = $("#main-content").find("#managed-repository-edit-form").valid();
+ if (valid==false) {
+ return;
+ }
+ $.log("save:"+this.managedRepository.name());
+ clearUserMessages();
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ $("#managed-repository-save-button" ).button('loading');
+ if (this.update){
+ $.ajax("restServices/archivaServices/managedRepositoriesService/updateManagedRepository",
+ {
+ type: "POST",
+ data: ko.toJSON(this.managedRepository),
+ contentType: 'application/json',
+ dataType: 'json',
+ success: function(data) {
+ displaySuccessMessage($.i18n.prop('managedrepository.updated',self.managedRepository.id()));
+ activateManagedRepositoriesGridTab();
+ self.managedRepository.modified(false);
+ },
+ complete: function(){
+ $("#managed-repository-save-button" ).button('reset');
+ removeMediumSpinnerImg(userMessages);
+ }
+ }
+ );
+ } else {
+ var url="restServices/archivaServices/managedRepositoriesService/fileLocationExists";
+ url+="?fileLocation="+encodeURIComponent(self.managedRepository.location());
+ $.ajax(url,
+ {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ if (data){
+ var completeCallbackFn = function(){window.modalConfirmDialog.modal('hide')};
+ openDialogConfirm(
+ function(){addManagedRepository(self.managedRepository,completeCallbackFn)},
+ $.i18n.prop('ok'), $.i18n.prop('cancel'),
+ $.i18n.prop('managedrepository.add.title'),
+ $("#managed-repository-location-warning-tmpl").tmpl(self.managedRepository));
+ }else{
+ addManagedRepository(self.managedRepository);
+ }
+ },
+ complete: function(){
+ $("#managed-repository-save-button" ).button('reset');
+ removeMediumSpinnerImg(userMessages);
+ }
+ });
+ }
+ }
+
+ addManagedRepository=function(managedRepository,completeCallbackFn){
+ var curManagedRepository=managedRepository;
+ var callbackFn = completeCallbackFn;
+ var dataJson=ko.toJSON(managedRepository);
+ $.log("managedRepository.release:"+managedRepository.releases()+",dataJson:"+dataJson);
+ $.ajax("restServices/archivaServices/managedRepositoriesService/addManagedRepository",
+ {
+ type: "POST",
+ contentType: 'application/json',
+ data: dataJson,
+ dataType: 'json',
+ success: function(data) {
+ if (managedRepository.stageRepoNeeded()){
+ $.log("stageRepoNeeded:"+managedRepository.stageRepoNeeded());
+ // reload all to see the new staged repo
+ loadManagedRepositories(function(data){
+ self.managedRepositoriesViewModel.managedRepositories(mapManagedRepositories(data));
+ });
+ } else {
+ curManagedRepository.location(data.location);
+ self.managedRepositoriesViewModel.managedRepositories.push(curManagedRepository);
+ }
+
+ displaySuccessMessage($.i18n.prop('managedrepository.added',curManagedRepository.id()));
+ curManagedRepository.modified(false);
+ activateManagedRepositoriesGridTab();
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete:function(data){
+ if(callbackFn){
+ callbackFn();
+ }
+ }
+ }
+ );
+ }
+
+ displayGrid=function(){
+ activateManagedRepositoriesGridTab();
+ }
+
+ }
+
+ activateManagedRepositoryFormValidation=function(){
+ var validator = $("#main-content" ).find("#managed-repository-edit-form").validate({
+ rules: {
+ daysOlder : {
+ digits: true,
+ min: 1
+ },
+ retentionCount : {
+ digits: true,
+ min: 1,
+ max: 100
+ },
+ cronExpression: {
+ required: true,
+ remote: {
+ url: "restServices/archivaServices/commonServices/validateCronExpression",
+ type: "get"
+ }
+ },
+ id: {
+ required: true,
+ remote: {
+ url: "restServices/archivaUiServices/dataValidatorService/managedRepositoryIdNotExists",
+ type: "get"
+ }
+ }
+ },
+ showErrors: function(validator, errorMap, errorList) {
+ customShowError("#main-content #managed-repository-edit-form",validator,errorMap,errorMap);
+ }
+ });
+ validator.settings.messages["cronExpression"]=$.i18n.prop("cronExpression.notvalid");
+ validator.settings.messages["id"]=$.i18n.prop("id.required.or.alreadyexists");
+ }
+
+ ManagedRepositoriesViewModel=function(){
+ this.managedRepositories=ko.observableArray([]);
+
+ this.gridViewModel = null;
+ var self = this;
+
+ editManagedRepository=function(managedRepository){
+ var mainContent = $("#main-content");
+ var viewModel = new ManagedRepositoryViewModel(managedRepository,true,self);
+ ko.applyBindings(viewModel,mainContent.find("#managed-repository-edit").get(0));
+ activateManagedRepositoryEditTab();
+ mainContent.find("#managed-repository-edit-li a").html($.i18n.prop('edit'));
+ activateManagedRepositoryFormValidation();
+ activatePopoverDoc();
+ }
+
+ this.editManagedRepositoryWithId=function(managedRepositoryId){
+ $.each(self.managedRepositories(), function(index, value) {
+ if(value.id()==managedRepositoryId){
+ editManagedRepository(value);
+ }
+ });
+ }
+
+ scanNow=function(managedRepository){
+ clearUserMessages();
+ openDialogConfirm(
+ function(){
+ $("#dialog-confirm-modal" ).find("#modal-login-footer").append(smallSpinnerImg());
+ var checked = $("#managed-repository-scan-now-all").get(0).checked;
+ var url = "restServices/archivaServices/repositoriesService/scanRepositoryNow?";
+ url += "repositoryId="+encodeURIComponent(managedRepository.id());
+ url += "&fullScan="+(checked==true?"true":"false");
+ $.ajax(url,
+ {
+ type: "GET",
+ beforeSend:function(){
+ displayInfoMessage($.i18n.prop("managedrepository.scan.started",managedRepository.id()));
+ closeDialogConfirm();
+ },
+ success: function(data) {
+ displaySuccessMessage($.i18n.prop("managedrepository.scanned",managedRepository.name()));
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete: function(){
+ removeSmallSpinnerImg();
+ closeDialogConfirm();
+ }
+ }
+ );
+ },
+ $.i18n.prop("ok"),
+ $.i18n.prop("cancel"),
+ $.i18n.prop("managedrepository.scan.now"),
+ $("#managed-repository-scan-now-modal-tmpl").tmpl(managedRepository));
+
+ }
+
+ removeManagedRepository=function(managedRepository){
+ clearUserMessages();
+ openDialogConfirm(
+ function(){
+ var url = "restServices/archivaServices/managedRepositoriesService/deleteManagedRepository?";
+ url += "repositoryId="+encodeURIComponent(managedRepository.id());
+ var checked = $("#managedrepository-deletecontent").get(0).checked;
+ url += "&deleteContent="+(checked==true?"true":"false");
+ var dialogText=$("#dialog-confirm-modal-body-text" );
+ dialogText.html(mediumSpinnerImg());
+ $.ajax(url,
+ {
+ type: "GET",
+ success: function(data) {
+ self.managedRepositories.remove(managedRepository);
+ displaySuccessMessage($.i18n.prop("managedrepository.deleted",managedRepository.name()));
+
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete: function(){
+ removeMediumSpinnerImg(dialogText);
+ closeDialogConfirm();
+ }
+ }
+ );
+
+ },
+ $.i18n.prop("ok"),
+ $.i18n.prop("cancel"),
+ $.i18n.prop("managedrepository.delete.confirm",managedRepository.name()),
+ $("#managed-repository-delete-warning-tmpl").tmpl(managedRepository));
+ }
+
+ updateManagedRepository=function(managedRepository){
+ var managedRepositoryViewModel = new ManagedRepositoryViewModel(managedRepository,true,this);
+ managedRepositoryViewModel.save();
+ }
+
+ this.bulkSave=function(){
+ $.log("bulkSave");
+ return getModifiedManagedRepositories().length>0;
+ }
+
+ getModifiedManagedRepositories=function(){
+ var prx = $.grep(self.managedRepositories(),
+ function (managedRepository,i) {
+ return managedRepository.modified();
+ });
+ return prx;
+ }
+ updateModifiedManagedRepositories=function(){
+ var repos = getModifiedManagedRepositories();
+
+ openDialogConfirm(function(){
+ for (i=0;i<repos.length;i++){
+ updateManagedRepository(repos[i]);
+ }
+ closeDialogConfirm();
+ },
+ $.i18n.prop('ok'),
+ $.i18n.prop('cancel'),
+ $.i18n.prop('managed.repository.bulk.save.confirm.title'),
+ $.i18n.prop('managed.repository.bulk.save.confirm',repos.length));
+ }
+
+ directoriesScan=function(managedRepository){
+ $.log("directoriesScan:"+managedRepository.id());
+ clearUserMessages();
+ var url = "restServices/archivaServices/repositoriesService/scanRepositoryDirectoriesNow/"+managedRepository.id();
+ $.ajax(url,
+ {
+ type: "GET",
+ dataType: 'json',
+ beforeSend:function(){
+ displayInfoMessage($.i18n.prop("managedrepository.scan.directories.started", managedRepository.id()));
+ },
+ success: function(data) {
+ $.log(" scanRepositoryDirectoriesNow finished ");
+ displaySuccessMessage( $.i18n.prop("managedrepository.scan.directories.finished", managedRepository.id()));
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete: function(){
+ removeSmallSpinnerImg();
+ }
+
+ }
+ );
+ }
+
+ showStats=function(managedRepository){
+ if ($(calculatePopoverId(managedRepository)).html()){
+ // we ask stats all the time ? if no uncomment return
+ //return;
+ $("#managedrepository-stats-"+escapeDot(managedRepository.id())).append(smallSpinnerImg());
+ }
+ var curRepo=managedRepository;
+ var url = "restServices/archivaServices/managedRepositoriesService/getManagedRepositoryStatistics/"+managedRepository.id();
+ url+="/"+encodeURIComponent(usedLang());
+ $.ajax(url,
+ {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ if (data==null){
+ return;
+ }
+ var archivaRepositoryStatistics=mapArchivaRepositoryStatistics(data);
+ archivaRepositoryStatistics.managedRepository=curRepo;
+ var mainContent = $("#main-content");
+ mainContent.find("#managedrepository-stats-"+escapeDot(curRepo.id())).append($("#managed-repository-stats-tmpl").tmpl(archivaRepositoryStatistics));
+ mainContent.find("#managedrepository-stats-img-"+escapeDot(curRepo.id())).attr("data-content",$(calculatePopoverId(curRepo)).html());
+ mainContent.find("#managedrepository-stats-img-"+escapeDot(curRepo.id())).popover(
+ {
+ placement: "left",
+ html: true,
+ trigger:'manual'
+ }
+ );
+
+ mainContent.find("#managedrepository-stats-img-"+escapeDot(curRepo.id())).popover('show');
+ removeSmallSpinnerImg();
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete: function(){
+ }
+ }
+ );
+ }
+
+ calculatePopoverId=function(managedRepository){
+ return "#main-content #managedrepository-stats-"+escapeDot(managedRepository.id()) + " #managedrepository-stats-"+escapeDot(managedRepository.id())+"-popover";
+ }
+
+ hideStats=function(managedRepository){
+ $("#body_content" ).find(".popover" ).hide();
+ }
+
+ showPomSnippet=function(managedRepository){
+ var mainContent = $("#main-content");
+ mainContent.find("#managed-repositories-pom-snippet").html(mediumSpinnerImg());
+ mainContent.find('#managed-repositories-pom-snippet').show();
+ var url = "restServices/archivaServices/managedRepositoriesService/getPomSnippet/"+encodeURIComponent(managedRepository.id());
+ $.ajax(url,
+ {
+ type: "GET",
+ dataType: 'text',
+ success: function(data) {
+ $("#managed-repositories-pom-snippet").html($("#pom-snippet-tmpl").tmpl(data));
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete: function(){
+ }
+ }
+ );
+
+ }
+
+ mergeRepo=function(managedRepository){
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ // is there any artifacts to merge ?
+ var artifactsNumberUrl = "restServices/archivaServices/browseService/artifacts/"+encodeURIComponent(managedRepository.id());
+ $.ajax(artifactsNumberUrl,{
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+ var artifacts=mapArtifacts(data);
+ $.log("artifactsNumber for '" + managedRepository.id() + "': " + artifacts.length);
+
+ if (artifacts<1){
+ displayWarningMessage($.i18n.prop("managedrepository.merge.noartifacts", managedRepository.id()));
+ return;
+ }
+
+ $.log("merge repo open dialog");
+ var dialogMergeRepo=$("#dialog-modal-merge-repo");
+ if (window.modalMergeRepoDialog==null) {
+ window.modalMergeRepoDialog = dialogMergeRepo.modal();
+
+ }
+
+ loadManagedRepositories(function(data){
+
+ var managedRepositories = $.map(mapManagedRepositories(data), function(item) {
+ return item.id()==managedRepository.id()?null:item;
+ });
+ $("#dialog-modal-merge-repo-body-text").html($("#merge-repo-dialog-content" )
+ .tmpl({sourceRepoId:managedRepository.id(),repositories:managedRepositories}));
+ window.modalMergeRepoDialog.modal('show');
+ });
+
+ },
+ complete: function(){
+ removeMediumSpinnerImg(userMessages);
+ }
+ }
+ );
+
+ }
+
+
+ }
+
+
+ mergeRepositories=function(sourceRepository,targetRepository){
+ $.log("mergeRepositories:"+sourceRepository+":"+targetRepository);
+
+ var mergeRepoDialogBodyId="dialog-modal-merge-repo-body-text";
+ var mergeRepoDialogBody=$("#"+mergeRepoDialogBodyId);
+ mergeRepoDialogBody.html(mediumSpinnerImg());
+
+ // check conflicts
+ var url = "restServices/archivaServices/mergeRepositoriesService/mergeConflictedArtifacts/"+encodeURIComponent(sourceRepository);
+ url+="/"+encodeURIComponent(targetRepository);
+ $.ajax(url, {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+ var artifacts=mapArtifacts(data);
+ if (artifacts && artifacts.length){
+ // we have conflicts ask to skip or not
+ $.log("conflicts:"+artifacts.length);
+ displayWarningMessage($.i18n.prop("managedrepository.merge.conflicts", artifacts.length),"dialog-modal-merge-repo-body-text");
+ $.tmpl($("#merge-repo-skip-conflicts").html(),
+ { artifacts:artifacts, sourceRepository: sourceRepository, targetRepository:targetRepository })
+ .appendTo( "#dialog-modal-merge-repo-body-text" );
+ $("#dialog-modal-merge-repo-header-title" ).html($.i18n.prop("managedrepository.merge.conflicts.header",sourceRepository,targetRepository));
+ } else {
+ doMerge(sourceRepository,targetRepository,false);
+ }
+ },
+ complete: function(){
+ $.log("complete removeMediumSpinnerImg");
+ removeMediumSpinnerImg("#dialog-modal-merge-repo-body-text");
+ }
+ });
+
+
+
+ }
+
+ doMerge=function(sourceRepository,targetRepository,skipConflicts){
+ $.log("doMerge:"+sourceRepository+" to " + targetRepository + ", skipConflicts: " + skipConflicts);
+ window.modalMergeRepoDialog.modal('hide');
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ var url = "restServices/archivaServices/mergeRepositoriesService/mergeRepositories/"+encodeURIComponent(sourceRepository);
+ url+="/"+encodeURIComponent(targetRepository);
+ url+="/"+skipConflicts;
+ $.ajax(url, {
+ type: "GET",
+ dataType: 'json',
+ success: function(data){
+ displaySuccessMessage($.i18n.prop("managedrepository.merge.success", sourceRepository,targetRepository));
+ },
+ complete: function(){
+ removeMediumSpinnerImg(userMessages);
+ }
+ });
+ }
+
+ activateManagedRepositoriesGridTab=function(){
+ var mainContent = $("#main-content");
+ mainContent.find("#managed-repository-edit-li").removeClass("active");
+ mainContent.find("#managed-repository-edit").removeClass("active");
+
+ mainContent.find("#managed-repositories-view-li").addClass("active");
+ mainContent.find("#managed-repositories-view").addClass("active");
+ mainContent.find("#managed-repository-edit-li a").html($.i18n.prop("add"));
+ }
+
+ activateManagedRepositoryEditTab=function(){
+ var mainContent = $("#main-content");
+ mainContent.find("#managed-repositories-view-li").removeClass("active");
+ mainContent.find("#managed-repositories-view").removeClass("active");
+
+ mainContent.find("#managed-repository-edit-li").addClass("active");
+ mainContent.find("#managed-repository-edit").addClass("active");
+ }
+
+
+ //---------------------------
+ // Remote repositories part
+ //---------------------------
+
+
+
+ RemoteRepository=function(id,name,layout,indexDirectory,url,userName,password,timeout,downloadRemoteIndex,remoteIndexUrl,
+ remoteDownloadNetworkProxyId,cronExpression,remoteDownloadTimeout,downloadRemoteIndexOnStartup,
+ description,extraParametersEntries,extraHeadersEntries){
+
+ var self=this;
+
+ //private String id;
+ this.id=ko.observable(id);
+ this.id.subscribe(function(newValue){self.modified(true)});
+
+ //private String name;
+ this.name=ko.observable(name);
+ this.name.subscribe(function(newValue){self.modified(true)});
+
+ //private String layout = "default";
+ this.layout=ko.observable(layout);
+ this.layout.subscribe(function(newValue){self.modified(true)});
+
+ //private String indexDirectory;
+ this.indexDirectory=ko.observable(indexDirectory);
+ this.indexDirectory.subscribe(function(newValue){self.modified(true)});
+
+ //private String url;
+ this.url=ko.observable(url);
+ this.url.subscribe(function(newValue){self.modified(true)});
+
+ //private String userName;
+ this.userName=ko.observable(userName);
+ this.userName.subscribe(function(newValue){self.modified(true)});
+
+ //private String password;
+ this.password=ko.observable(password);
+ this.password.subscribe(function(newValue){self.modified(true)});
+
+ //private int timeout = 60;
+ this.timeout=ko.observable(timeout);
+ this.timeout.subscribe(function(newValue){self.modified(true)});
+
+ //private boolean downloadRemoteIndex = false;
+ this.downloadRemoteIndex=ko.observable(downloadRemoteIndex?false:downloadRemoteIndex);
+ this.downloadRemoteIndex.subscribe(function(newValue){self.modified(true)});
+
+ //private String remoteIndexUrl = ".index";
+ this.remoteIndexUrl=ko.observable(remoteIndexUrl);
+ this.remoteIndexUrl.subscribe(function(newValue){self.modified(true)});
+
+ //private String remoteDownloadNetworkProxyId;
+ this.remoteDownloadNetworkProxyId=ko.observable(remoteDownloadNetworkProxyId);
+ this.remoteDownloadNetworkProxyId.subscribe(function(newValue){self.modified(true)});
+
+ //private String cronExpression = "0 0 08 ? * SUN";
+ this.cronExpression=ko.observable(cronExpression);
+ this.cronExpression.subscribe(function(newValue){self.modified(true)});
+
+ //private int remoteDownloadTimeout = 300;
+ this.remoteDownloadTimeout=ko.observable(remoteDownloadTimeout);
+ this.remoteDownloadTimeout.subscribe(function(newValue){self.modified(true)});
+
+ //private boolean downloadRemoteIndexOnStartup = false;
+ this.downloadRemoteIndexOnStartup=ko.observable(downloadRemoteIndexOnStartup?false:downloadRemoteIndexOnStartup);
+ this.downloadRemoteIndexOnStartup.subscribe(function(newValue){self.modified(true)});
+
+ this.description=ko.observable(description);
+ this.description.subscribe(function(newValue){self.modified(true)});
+
+ this.getTypeLabel=function(){
+ for(var i=0;i<window.managedRepositoryTypes.length;i++){
+ if (window.managedRepositoryTypes[i].type==self.layout()){
+ return window.managedRepositoryTypes[i].label;
+ }
+ }
+ 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);
+ }
+
+ mapRemoteRepository=function(data){
+ 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,
+ extraParametersEntries,extraHeadersEntries);
+ }
+
+ mapRemoteRepositories=function(data){
+ var mappedRemoteRepositories = $.map(data, function(item) {
+ return mapRemoteRepository(item);
+ });
+ return mappedRemoteRepositories;
+ }
+
+ RemoteRepositoryViewModel=function(remoteRepository, update, remoteRepositoriesViewModel){
+ this.remoteRepository=remoteRepository;
+ this.remoteRepositoriesViewModel = remoteRepositoriesViewModel;
+ this.networkProxies=ko.observableArray([]);
+ this.update = update;
+
+ var self = this;
+
+ this.availableLayouts = window.managedRepositoryTypes;
+
+ this.save=function(){
+ var valid = $("#main-content" ).find("#remote-repository-edit-form").valid();
+ if (valid==false) {
+ return;
+ }
+ clearUserMessages();
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ $("#remote-repository-save-button" ).button('loading');
+ if (update){
+ $.ajax("restServices/archivaServices/remoteRepositoriesService/updateRemoteRepository",
+ {
+ type: "POST",
+ data: ko.toJSON(this.remoteRepository),
+ contentType: 'application/json',
+ dataType: 'json',
+ success: function(data) {
+ displaySuccessMessage($.i18n.prop('remoterepository.updated',self.remoteRepository.id()));
+ activateRemoteRepositoriesGridTab();
+ self.remoteRepository.modified(false);
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete: function(){
+ $("#remote-repository-save-button" ).button('reset');
+ removeMediumSpinnerImg(userMessages);
+ }
+ }
+ );
+ }else {
+ $.ajax("restServices/archivaServices/remoteRepositoriesService/addRemoteRepository",
+ {
+ type: "POST",
+ data: ko.toJSON(this.remoteRepository),
+ contentType: 'application/json',
+ dataType: 'json',
+ success: function(data) {
+ self.remoteRepository.modified(false);
+ self.remoteRepositoriesViewModel.remoteRepositories.push(self.remoteRepository);
+ displaySuccessMessage($.i18n.prop('remoterepository.added'));
+ activateRemoteRepositoriesGridTab();
+ removeMediumSpinnerImg(userMessages);
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ }
+ }
+ );
+ }
+ }
+
+ displayGrid=function(){
+ activateRemoteRepositoriesGridTab();
+ }
+
+ addExtraParameter=function(){
+
+ var mainContent=$("#main-content");
+ mainContent.find("#extra-parameters-error" ).empty();
+ 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();
+ oldTab.push(new Entry(key,value));
+ self.remoteRepository.extraParametersEntries(oldTab);
+ mainContent.find("#extraParameter-key").val("");
+ mainContent.find("#extraParameter-value").val("");
+ self.remoteRepository.modified(true);
+ }
+
+ deleteExtraParameter=function(key){
+ for(var i=0;i<self.remoteRepository.extraParametersEntries().length;i++){
+ var entry=self.remoteRepository.extraParametersEntries()[i];
+ if (entry.key==key){
+ self.remoteRepository.extraParametersEntries.remove(entry);
+ self.remoteRepository.modified(true);
+ }
+ }
+ }
+
+ addExtraHeader=function(){
+
+ var mainContent=$("#main-content");
+ mainContent.find("#extra-headers-error" ).empty();
+ 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(){
+ this.remoteRepositories=ko.observableArray([]);
+ this.applicationUrl=null;
+ this.gridViewModel = null;
+ var self = this;
+
+ editRemoteRepository=function(remoteRepository){
+ $.log("editRemoteRepository");
+ $.ajax("restServices/archivaServices/networkProxyService/getNetworkProxies", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ 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(false);
+ activatePopoverDoc();
+ }
+ })
+
+ }
+
+ removeRemoteRepository=function(remoteRepository){
+ clearUserMessages();
+ openDialogConfirm(
+ function(){
+ var dialogText=$("#dialog-confirm-modal-body-text" );
+ dialogText.html(mediumSpinnerImg());
+ $.ajax("restServices/archivaServices/remoteRepositoriesService/deleteRemoteRepository/"+encodeURIComponent(remoteRepository.id()),
+ {
+ type: "GET",
+ success: function(data) {
+ self.remoteRepositories.remove(remoteRepository);
+ displaySuccessMessage($.i18n.prop('remoterepository.deleted',remoteRepository.id()));
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete:function(){
+ removeMediumSpinnerImg(dialogText);
+ closeDialogConfirm();
+ }
+ }
+ )}, $.i18n.prop('ok'),
+ $.i18n.prop('cancel'),
+ $.i18n.prop('remoterepository.delete.confirm',remoteRepository.id()),
+ $("#remote-repository-delete-modal-tmpl").tmpl(remoteRepository));
+
+ }
+
+ this.bulkSave=function(){
+ return getModifiedRemoteRepositories().length>0;
+ }
+
+ getModifiedRemoteRepositories=function(){
+ var prx = $.grep(self.remoteRepositories(),
+ function (remoteRepository,i) {
+ return remoteRepository.modified();
+ });
+ return prx;
+ }
+
+ updateModifiedRemoteRepositories=function(){
+ var modifiedRemoteRepositories = getModifiedRemoteRepositories();
+
+ openDialogConfirm(function(){
+ for(var i=0;i<modifiedRemoteRepositories.length;i++){
+ updateRemoteRepository(modifiedRemoteRepositories[i]);
+ }
+ closeDialogConfirm();
+ },
+ $.i18n.prop('ok'),
+ $.i18n.prop('cancel'),
+ $.i18n.prop('remoterepositories.bulk.save.confirm.title'),
+ $.i18n.prop('remoterepositories.bulk.save.confirm',modifiedRemoteRepositories.length));
+ }
+
+ updateRemoteRepository=function(remoteRepository){
+ var viewModel = new RemoteRepositoryViewModel(remoteRepository,true,self);
+ viewModel.save();
+ }
+
+ scheduleDownloadRemoteIndex=function(remoteRepository){
+ openDialogConfirm(
+ function(){
+
+ var url = "restServices/archivaServices/repositoriesService/scheduleDownloadRemoteIndex?";
+ url += "repositoryId="+encodeURIComponent(remoteRepository.id());
+
+ var now = $("#remoterepository-scan-now").get(0).checked;
+
+ var full = $("#remoterepository-scan-full").get(0).checked;
+
+ url += "&now="+(now==true?"true":"false");
+ url += "&fullDownload="+(full==true?"true":"false");
+ $.ajax(url,
+ {
+ type: "GET",
+ success: function(data) {
+ clearUserMessages();
+ displaySuccessMessage($.i18n.prop("remoterepository.download.remote.scheduled",remoteRepository.name()));
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete: function(){
+ closeDialogConfirm();
+ }
+ }
+ );
+
+ },
+ $.i18n.prop("ok"),
+ $.i18n.prop("cancel"),
+ $.i18n.prop("remoterepository.download.remote.confirm",remoteRepository.name()),
+ $("#remote-repository-scan-modal-tmpl").tmpl(remoteRepository));
+ }
+ }
+
+ /**
+ *
+ * @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 = 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);
+ }
+ });
+ } 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");
+ }
+
+ activateRemoteRepositoriesGridTab=function(){
+ var mainContent = $("#main-content");
+ mainContent.find("#remote-repository-edit-li").removeClass("active");
+ mainContent.find("#remote-repository-edit").removeClass("active");
+
+ mainContent.find("#remote-repositories-view-li").addClass("active");
+ mainContent.find("#remote-repositories-view").addClass("active");
+ mainContent.find("#remote-repository-edit-li a").html($.i18n.prop("add"));
+ }
+
+ activateRemoteRepositoryEditTab=function(){
+ var mainContent = $("#main-content");
+ mainContent.find("#remote-repositories-view-li").removeClass("active");
+ mainContent.find("#remote-repositories-view").removeClass("active");
+
+ mainContent.find("#remote-repository-edit-li").addClass("active");
+ mainContent.find("#remote-repository-edit").addClass("active");
+ }
+
+ //---------------------------
+ // Screen loading
+ //---------------------------
+
+ /**
+ *
+ * @param successFnManagedRepositories function called with param managedRepositoriesViewModel when managed repositories grid has been displayed
+ * @param successFnRemoteRepositories function called with param remoteRepositoriesViewModel when remote repositories grid has been displayed
+ */
+ displayRepositoriesGrid=function(successFnManagedRepositories,successFnRemoteRepositories){
+ screenChange();
+ var mainContent = $("#main-content");
+ mainContent.html(mediumSpinnerImg());
+ mainContent.html($("#repositoriesMain").tmpl());
+ mainContent.find("#repositories-tabs a:first").tab("show");
+
+ mainContent.find("#managed-repositories-content").append(mediumSpinnerImg());
+ mainContent.find("#remote-repositories-content").append(mediumSpinnerImg());
+
+ var managedRepositoriesViewModel = new ManagedRepositoriesViewModel();
+ var remoteRepositoriesViewModel = new RemoteRepositoriesViewModel();
+
+ $.ajax({
+ url: "restServices/archivaServices/archivaAdministrationService/applicationUrl",
+ type: "GET",
+ dataType: 'text',
+ success: function(applicationUrl){
+ $.log("applicationUrl:"+applicationUrl);
+ loadManagedRepositories(function(data) {
+
+
+ managedRepositoriesViewModel.managedRepositories(
+ mapManagedRepositories(data,applicationUrl?applicationUrl:window.location.toString().substringBeforeLast("/")));
+
+ managedRepositoriesViewModel.gridViewModel = new ko.simpleGrid.viewModel({
+ data: managedRepositoriesViewModel.managedRepositories,
+ columns: [
+ {
+ headerText: $.i18n.prop('identifier'),
+ rowText: "id"
+ },
+ {
+ headerText: $.i18n.prop('name'),
+ rowText: "name"
+ },
+ {
+ headerText: $.i18n.prop('type'),
+ rowText: "getTypeLabel",
+ // FIXME i18n
+ title: "Repository type (default is Maven 2)"
+ }
+ ],
+ pageSize: 5,
+ gridUpdateCallBack: function(){
+ // a bit ugly
+ //$("#main-content" ).find("#managed-repositories-table").find("[title]").tooltip({animation:"false"});
+ }
+ });
+ var mainContent = $("#main-content");
+ ko.applyBindings(managedRepositoriesViewModel,mainContent.find("#managed-repositories-view").get(0));
+ activatePopoverDoc();
+ mainContent.find("#managed-repositories-pills #managed-repositories-view-a").tab('show');
+ removeMediumSpinnerImg(mainContent.find("#managed-repositories-content"));
+ activateManagedRepositoriesGridTab();
+ if(successFnManagedRepositories){
+ successFnManagedRepositories(managedRepositoriesViewModel);
+ }
+ });
+
+ loadRemoteRepositories(function(data) {
+ remoteRepositoriesViewModel.remoteRepositories(mapRemoteRepositories(data));
+ remoteRepositoriesViewModel.gridViewModel = new ko.simpleGrid.viewModel({
+ data: remoteRepositoriesViewModel.remoteRepositories,
+ columns: [
+ {
+ headerText: $.i18n.prop('identifier'),
+ rowText: "id"
+ },
+ {
+ headerText: $.i18n.prop('name'),
+ rowText: "name"
+ },
+ {
+ headerText: $.i18n.prop('url'),
+ rowText: "url"
+ },
+ {
+ headerText: $.i18n.prop('type'),
+ rowText: "getTypeLabel",
+ // FIXME i18n
+ title: "Repository type (default is Maven 2)"
+ }
+ ],
+ pageSize: 5,
+ gridUpdateCallBack: function(){
+ //$("#main-content" ).find("#remote-repositories-table").find("[title]").tooltip();
+ }
+ });
+ var mainContent = $("#main-content");
+ ko.applyBindings(remoteRepositoriesViewModel,mainContent.find("#remote-repositories-view").get(0));
+ mainContent.find("#remote-repositories-pills #remote-repositories-view-a").tab('show')
+ removeMediumSpinnerImg(mainContent.find("#remote-repositories-content"));
+ activatePopoverDoc();
+ if(successFnRemoteRepositories){
+ successFnRemoteRepositories(managedRepositoriesViewModel);
+ }
+ });
+ }
+ }
+ );
+
+
+ mainContent.find("#managed-repositories-pills").on('show', function (e) {
+ var mainContent = $("#main-content");
+ if ($(e.target).attr("href")=="#managed-repository-edit") {
+ var managedRepo=new ManagedRepository();
+ managedRepo.cronExpression("0 0 * * * ?");
+ var viewModel = new ManagedRepositoryViewModel(managedRepo,false,managedRepositoriesViewModel);
+ ko.applyBindings(viewModel,mainContent.find("#managed-repository-edit").get(0));
+ activateManagedRepositoryFormValidation();
+ activatePopoverDoc();
+ }
+ if ($(e.target).attr("href")=="#managed-repositories-view") {
+ mainContent.find("#managed-repository-edit-li a").html($.i18n.prop("add"));
+ }
+
+ });
+
+ mainContent.find("#remote-repositories-pills").on('show', function (e) {
+ if ($(e.target).attr("href")=="#remote-repository-edit") {
+ $.ajax("restServices/archivaServices/networkProxyService/getNetworkProxies", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ var remoteRepo=new RemoteRepository();
+ remoteRepo.cronExpression("0 0 08 ? * SUN");
+ var viewModel = new RemoteRepositoryViewModel(remoteRepo,false,remoteRepositoriesViewModel);
+ viewModel.networkProxies(mapNetworkProxies(data));
+ ko.applyBindings(viewModel,mainContent.find("#remote-repository-edit").get(0));
+ activateRemoteRepositoryFormValidation(true);
+ activatePopoverDoc();
+ }
+ })
+ }
+ if ($(e.target).attr("href")=="#remote-repositories-view") {
+ $("#main-content" ).find("#remote-repository-edit-li" ).find("a").html($.i18n.prop("add"));
+ }
+
+ });
+
+ }
+
+ loadManagedRepositories=function(successCallBackFn,errorCallBackFn){
+ $.ajax("restServices/archivaServices/managedRepositoriesService/getManagedRepositories", {
+ type: "GET",
+ dataType: 'json',
+ success: successCallBackFn,
+ error: errorCallBackFn
+ });
+ }
+
+ loadRemoteRepositories=function(successCallBackFn,errorCallBackFn){
+ $.ajax("restServices/archivaServices/remoteRepositoriesService/getRemoteRepositories", {
+ type: "GET",
+ dataType: 'json',
+ success: successCallBackFn,
+ error: errorCallBackFn
+ });
+ }
+
+ findManagedRepository=function(id,managedRepositories){
+ var managedRepository=$.grep(managedRepositories,
+ function(repo,idx){
+ return repo.id()==id;
+ }
+ );
+ return ($.isArray(managedRepository) && managedRepository.length>0) ? managedRepository[0]:new ManagedRepository();
+ }
+
+});
\ No newline at end of file
--- /dev/null
+/*
+ * 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/admin/repository/maven2/repository-groups",["jquery","i18n","jquery.tmpl","bootstrap","jquery.validate","jquery.ui","knockout"
+ ,"knockout.simpleGrid","knockout.sortable","archiva/admin/repository/maven2/repositories"],
+function(jquery,i18n,jqueryTmpl,bootstrap,jqueryValidate,jqueryUi,ko) {
+
+ RepositoryGroup=function(id,repositories,mergedIndexPath){
+
+ var self=this;
+
+ //private String id;
+ this.id=ko.observable(id);
+ this.id.subscribe(function(newValue){self.modified(true)});
+
+ //private String mergedIndexPath = "/.indexer";
+ this.mergedIndexPath=ko.observable(mergedIndexPath?mergedIndexPath:".indexer");
+ this.mergedIndexPath.subscribe(function(newValue){self.modified(true)});
+
+ // private List<String> repositories;
+ this.repositories=ko.observableArray(repositories);
+ this.repositories.subscribe(function(newValue){self.modified(true)});
+
+ // to store managedRepositories description not sended to server
+ this.managedRepositories=ko.observableArray([]);
+ this.managedRepositories.subscribe(function(newValue){self.modified(true)});
+
+ this.modified=ko.observable(false);
+ }
+
+ RepositoryGroupViewModel=function(repositoryGroup,update,repositoryGroupsViewModel){
+ var self = this;
+ this.repositoryGroup=repositoryGroup;
+ this.update=update;
+ this.repositoryGroupsViewModel=repositoryGroupsViewModel;
+ this.availableRepositories=ko.observableArray([]);
+ this.applicationUrl=null;
+
+ for (var i=0;i<repositoryGroupsViewModel.managedRepositories().length;i++){
+ if ( $.inArray(repositoryGroupsViewModel.managedRepositories()[i].id(),this.repositoryGroup.repositories())<0){
+ this.availableRepositories.push(repositoryGroupsViewModel.managedRepositories()[i]);
+ }
+ }
+
+ repositoryMoved=function(arg){
+ $.log("repositoryMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
+ var repositories=[];
+ for(var i=0;i<self.repositoryGroup.managedRepositories().length;i++){
+ repositories.push(self.repositoryGroup.managedRepositories()[i].id());
+ }
+ self.repositoryGroup.repositories(repositories);
+ self.repositoryGroup.modified(true);
+ var mainContent=$("#main-content");
+ mainContent.find("#repository-groups-edit-available-repositories").find(".icon-plus-sign" ).off("click");
+ mainContent.find("#repository-groups-edit-order-div").find(".icon-minus-sign" ).off("click");
+ self.renderSortableAvailables(self.repositoryGroupsViewModel);
+ self.renderSortableChoosed(self.repositoryGroupsViewModel);
+ }
+
+ this.saveRepositoryGroup=function(repositoryGroup){
+ if (self.update){
+ self.repositoryGroupsViewModel.saveRepositoryGroup(repositoryGroup);
+ } else {
+ self.repositoryGroupsViewModel.addRepositoryGroup(repositoryGroup);
+ }
+ }
+
+ this.removeRepository=function(id){
+ $.log("removeRepository:"+id);
+ }
+
+ this.removeAvailable=function(idVal){
+ for (var i=0;i<self.repositoryGroupsViewModel.managedRepositories().length;i++){
+ if(self.repositoryGroupsViewModel.managedRepositories()[i].id()==idVal){
+ self.availableRepositories.remove(repositoryGroupsViewModel.managedRepositories()[i]);
+ }
+ }
+
+ for(var i= 0;i<self.repositoryGroupsViewModel.managedRepositories().length;i++){
+ if(self.repositoryGroupsViewModel.managedRepositories()[i].id()==idVal){
+ $.log("find repo to add");
+ self.repositoryGroup.repositories.push(idVal);
+ self.repositoryGroup.managedRepositories.push(findManagedRepository(idVal,self.repositoryGroupsViewModel.managedRepositories()));
+ }
+ }
+ $("#main-content").find("#repository-groups-edit-order-div").find("#minus-"+idVal ).on("click",function(){
+ var idVal = $(this).attr("id");
+ idVal=idVal.substringAfterFirst("minus-");
+ self.removeChoosed(idVal);
+ });
+ }
+
+ this.renderSortableAvailables=function(repositoryGroupsViewModel){
+ $("#main-content").find("#repository-groups-edit-available-repositories").find(".icon-plus-sign" ).on("click",function(){
+ var idVal = $(this).attr("id");
+ idVal=idVal.substringAfterFirst("plus-");
+ self.removeAvailable(idVal);
+ });
+ }
+
+ this.removeChoosed=function(idVal){
+ for (var i=0;i<self.repositoryGroupsViewModel.managedRepositories().length;i++){
+ if(self.repositoryGroupsViewModel.managedRepositories()[i].id()==idVal){
+ self.availableRepositories.push(repositoryGroupsViewModel.managedRepositories()[i]);
+ }
+ }
+
+ for(var i= 0;i<self.repositoryGroup.repositories().length;i++){
+ if(self.repositoryGroup.repositories()[i]==idVal){
+ self.repositoryGroup.repositories.remove(self.repositoryGroup.repositories()[i]);
+ self.repositoryGroup.managedRepositories.remove(findManagedRepository(idVal,self.repositoryGroupsViewModel.managedRepositories()));
+ }
+ }
+ $("#main-content").find("#repository-groups-edit-available-repositories").find("#plus-"+idVal ).on("click",function(){
+ var idVal = $(this).attr("id");
+ idVal=idVal.substringAfterFirst("plus-");
+ self.removeAvailable(idVal);
+ });
+ }
+
+ this.renderSortableChoosed=function(repositoryGroupsViewModel){
+ $("#main-content").find("#repository-groups-edit-order-div").find(".icon-minus-sign" ).on("click",function(){
+ var idVal = $(this).attr("id");
+ idVal=idVal.substringAfterFirst("minus-");
+ self.removeChoosed(idVal);
+ });
+ }
+ }
+
+ RepositoryGroupsViewModel=function(){
+ var self=this;
+ this.repositoryGroups=ko.observableArray([]);
+ this.managedRepositories=ko.observableArray([]);
+ this.applicationUrl="";
+
+ this.removeFromList=function(managedRepository){
+ $.log("removeFromList");
+ }
+
+ this.findManagedRepository=function(id){
+ return findManagedRepository(id,self.managedRepositories());
+ }
+ this.deleteRepositoryGroup=function(repositoryGroup){
+ openDialogConfirm(
+ function(){self.removeRepositoryGroup(repositoryGroup);window.modalConfirmDialog.modal('hide')},
+ $.i18n.prop('ok'), $.i18n.prop('cancel'),
+ $.i18n.prop('repository.group.delete.confirm',repositoryGroup.id()),
+ $("#repository-group-delete-warning-tmpl").tmpl(self.repositoryGroup));
+ }
+ this.removeRepositoryGroup=function(repositoryGroup){
+ clearUserMessages();
+ $.ajax("restServices/archivaServices/repositoryGroupService/deleteRepositoryGroup/"+encodeURIComponent(repositoryGroup.id()),
+ {
+ type: "GET",
+ success: function(data) {
+ var message=$.i18n.prop('repository.group.deleted',repositoryGroup.id());
+ displaySuccessMessage(message);
+ self.repositoryGroups.remove(repositoryGroup);
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ }
+ }
+ );
+ }
+
+ this.editRepositoryGroup=function(repositoryGroup){
+
+ var mainContent=$("#main-content");
+ $.ajax({
+ url: "restServices/archivaServices/archivaAdministrationService/applicationUrl",
+ type: "GET",
+ dataType: 'text',
+ success: function(applicationUrl){
+ $.log("editRepositoryGroup:"+repositoryGroup.id()+",repositories:"+repositoryGroup.repositories().length+",managed:"+repositoryGroup.managedRepositories().length);
+ var repositoryGroupViewModel=new RepositoryGroupViewModel(repositoryGroup,true,self);
+ repositoryGroupViewModel.applicationUrl=applicationUrl;
+ activateRepositoryGroupEditTab();
+ ko.applyBindings(repositoryGroupViewModel,mainContent.find("#repository-groups-edit" ).get(0));
+ repositoryGroupViewModel.renderSortableChoosed(self);
+ repositoryGroupViewModel.renderSortableAvailables(self);
+ mainContent.find("#repository-groups-view-tabs-li-edit" ).find("a").html($.i18n.prop("edit"));
+ repositoryGroupValidator();
+ }
+ });
+ }
+
+ this.editRepositoryGroupWithId=function(repositoryGroupId){
+
+ $.each(self.repositoryGroups(), function(index, value) {
+ if(value.id()==repositoryGroupId){
+ self.editRepositoryGroup(value);
+ }
+ });
+ }
+
+ this.saveRepositoryGroup=function(repositoryGroup){
+ if(valid==false){
+ $.log("saveRepositoryGroup, valid:"+valid);
+ return;
+ }
+ clearUserMessages();
+ var userMessages=$("#user-messages");
+ userMessages.html(mediumSpinnerImg());
+ var valid = $("#main-content").find("#repository-group-edit-form" ).valid();
+
+
+ $("#repository-group-save" ).button('loading');
+ $.ajax("restServices/archivaServices/repositoryGroupService/updateRepositoryGroup",
+ {
+ type: "POST",
+ contentType: 'application/json',
+ data:ko.toJSON(repositoryGroup),
+ dataType: 'json',
+ success: function(data) {
+ $.log("update repositoryGroup id:"+repositoryGroup.id());
+ var message=$.i18n.prop('repository.group.updated',repositoryGroup.id());
+ displaySuccessMessage(message);
+ repositoryGroup.modified(false);
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ },
+ complete:function(data){
+ $("#repository-group-save" ).button('reset');
+ removeMediumSpinnerImg(userMessages);
+ }
+ }
+ );
+
+ };
+
+ this.addRepositoryGroup=function(repositoryGroup){
+ clearUserMessages();
+ $.ajax("restServices/archivaServices/repositoryGroupService/addRepositoryGroup",
+ {
+ type: "POST",
+ contentType: 'application/json',
+ data: ko.toJSON(repositoryGroup),
+ dataType: 'json',
+ success: function(data) {
+ $.log("update repositoryGroup id:"+repositoryGroup.id());
+ var message=$.i18n.prop('repository.group.added',repositoryGroup.id());
+ displaySuccessMessage(message);
+ repositoryGroup.modified(false);
+ self.repositoryGroups.push(repositoryGroup);
+ },
+ error: function(data) {
+ var res = $.parseJSON(data.responseText);
+ displayRestError(res);
+ }
+ }
+ );
+
+ }
+
+ getManagedRepository=function(id){
+ $.log("getManagedRepository:"+id);
+ return findManagedRepository(self.managedRepositories());
+ }
+
+ }
+
+ displayRepositoryGroups=function(successFn){
+ screenChange();
+ var mainContent = $("#main-content");
+ mainContent.html(mediumSpinnerImg());
+ this.repositoryGroupsViewModel=new RepositoryGroupsViewModel();
+ var self=this;
+
+ loadManagedRepositories(function(data) {
+
+ $.ajax({
+ url: "restServices/archivaServices/archivaAdministrationService/applicationUrl",
+ type: "GET",
+ dataType: 'text',
+ success: function(applicationUrl){
+
+ self.repositoryGroupsViewModel.managedRepositories(
+ mapManagedRepositories(data,applicationUrl?applicationUrl:window.location.toString().substringBeforeLast("/")));
+ self.repositoryGroupsViewModel.applicationUrl=applicationUrl;
+ $.ajax("restServices/archivaServices/repositoryGroupService/getRepositoriesGroups", {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+ var mappedRepositoryGroups=mapRepositoryGroups(data);
+ for(var i=0;i<mappedRepositoryGroups.length;i++){
+ mappedRepositoryGroups[i]
+ .managedRepositories(self.mapManagedRepositoriesToRepositoryGroup(mappedRepositoryGroups[i]));
+ mappedRepositoryGroups[i].modified(false);
+ $.log("mappedRepositoryGroups.repositories().length:"+mappedRepositoryGroups[i].repositories().length);
+ }
+ mainContent.html($("#repositoryGroupsMain").tmpl());
+ self.repositoryGroupsViewModel.repositoryGroups(mappedRepositoryGroups);
+ $.log("displayRepositoryGroups#applyBindings before");
+ ko.applyBindings(self.repositoryGroupsViewModel,mainContent.find("#repository-groups-view" ).get(0));
+ $.log("displayRepositoryGroups#applyBindings after");
+
+ mainContent.find("#repository-groups-view-tabs").on('show', function (e) {
+ if ($(e.target).attr("href")=="#repository-groups-edit") {
+ var repositoryGroup = new RepositoryGroup();
+ var repositoryGroupViewModel=new RepositoryGroupViewModel(repositoryGroup,false,self.repositoryGroupsViewModel);
+
+ activateRepositoryGroupEditTab();
+ ko.applyBindings(repositoryGroupViewModel,mainContent.find("#repository-groups-edit" ).get(0));
+ repositoryGroupViewModel.renderSortableChoosed(self.repositoryGroupsViewModel);
+ repositoryGroupViewModel.renderSortableAvailables(self.repositoryGroupsViewModel);
+ }
+ if ($(e.target).attr("href")=="#repository-groups-view") {
+ mainContent.find("#repository-groups-view-tabs-li-edit a").html($.i18n.prop("add"));
+ clearUserMessages();
+ }
+
+ });
+
+ if(successFn){
+ successFn(self.repositoryGroupsViewModel);
+ }
+
+ }
+ }
+ );
+
+ }
+ });
+ });
+
+ this.mapManagedRepositoriesToRepositoryGroup=function(repositoryGroup){
+ $.log("mapManagedRepositoriesToRepositoryGroup");
+ var managedRepositories=new Array();
+ if (!repositoryGroup.repositories()) {
+ repositoryGroup.repositories(new Array());
+ return managedRepositories;
+ }
+ for(var i=0;i<repositoryGroup.repositories().length;i++){
+ managedRepositories.push(self.repositoryGroupsViewModel.findManagedRepository(repositoryGroup.repositories()[i]));
+ }
+ $.log("end mapManagedRepositoriesToRepositoryGroup");
+ return managedRepositories;
+ }
+
+ }
+
+
+
+ activateRepositoryGroupsGridTab=function(){
+ var mainContent = $("#main-content");
+ mainContent.find("#repository-groups-view-tabs-content div[class*='tab-pane']").removeClass("active");
+ mainContent.find("#repository-groups-view-tabs li").removeClass("active");
+
+ mainContent.find("#repository-groups-view").addClass("active");
+ mainContent.find("#repository-groups-view-tabs-li-grid").addClass("active");
+ mainContent.find("#repository-groups-view-tabs-li-edit a").html($.i18n.prop("add"));
+
+ }
+
+ activateRepositoryGroupEditTab=function(){
+ $.log("activateRepositoryGroupEditTab");
+ var mainContent = $("#main-content");
+
+ mainContent.find("#repository-groups-view-tabs-content div[class*='tab-pane']").removeClass("active");
+ mainContent.find("#repository-groups-view-tabs li").removeClass("active");
+
+ mainContent.find("#repository-groups-edit").addClass("active");
+ mainContent.find("#repository-groups-view-tabs-li-edit").addClass("active");
+
+
+ }
+
+ repositoryGroupValidator=function(){
+ $.log("validator");
+ var theForm=$("#main-content").find("#repository-group-edit-form");
+ var validator = theForm.validate({
+ rules: {
+ id: {
+ required: true
+ },
+ mergedIndexPath:{
+ required:true
+ }
+ },
+ showErrors: function(validator, errorMap, errorList) {
+ customShowError("#main-content #repository-group-edit-form",validator,errorMap,errorMap);
+ }
+ });
+ return validator;
+ }
+
+ mapRepositoryGroups=function(data){
+ if (data == null){
+ return new Array();
+ }
+ var mappedRepositoryGroups = $.map(data, function(item) {
+ return mapRepositoryGroup(item);
+ });
+ return mappedRepositoryGroups;
+ }
+
+ mapRepositoryGroup=function(data){
+ return new RepositoryGroup(data.id, mapStringArray(data.repositories),data.mergedIndexPath);
+ }
+
+});
"redback.user": "redback/user",
"redback.users": "redback/users",
"redback.templates": "redback/redback-tmpl",
- // "archiva.general-admin":"archiva/general-admin",
+ "archiva.cookie-information":"archiva/cookie-information",
"archiva.templates": "archiva/main-tmpl",
// "archiva.repositories": "archiva/repositories",
// "archiva.network-proxies": "archiva/network-proxies",
});
- CookieInformation=function(path,domain,secure,timeout,rememberMeEnabled){
- //private String path;
- this.path=path;
-
- //private String domain;
- this.domain=domain;
-
- //private String secure;
- this.secure=secure;
-
- //private String timeout;
- this.timeout=timeout;
-
- //private boolean rememberMeEnabled;
- this.rememberMeEnabled=rememberMeEnabled;
- }
-
- mapCookieInformation=function(data){
- if(!data){
- return new CookieInformation();
- }
- return new CookieInformation(data.path,data.domain,data.secure,data.timeout,data.rememberMeEnabled);
- }
+
- requirejs(['jquery','jquery.tmpl','jquery.ui','i18n','sammy','startup','utils','domReady!','archiva.main'/*,'archiva.general-admin'*/], function () {
+ requirejs(['jquery','jquery.tmpl','jquery.ui','i18n','sammy','startup','utils','domReady!','archiva.main','archiva.cookie-information'], function () {
loadi18n(function () {
$.ajax({
url: "restServices/archivaUiServices/runtimeInfoService/archivaRuntimeInfo/"+usedLang(),
--- /dev/null
+/*
+ * Copyright 2013 The Apache Software Foundation.
+ *
+ * Licensed 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.cookie-information",function() {
+CookieInformation=function(path,domain,secure,timeout,rememberMeEnabled){
+ //private String path;
+ this.path=path;
+
+ //private String domain;
+ this.domain=domain;
+
+ //private String secure;
+ this.secure=secure;
+
+ //private String timeout;
+ this.timeout=timeout;
+
+ //private boolean rememberMeEnabled;
+ this.rememberMeEnabled=rememberMeEnabled;
+ }
+
+ mapCookieInformation=function(data){
+ if(!data){
+ return new CookieInformation();
+ }
+ return new CookieInformation(data.path,data.domain,data.secure,data.timeout,data.rememberMeEnabled);
+ }
+
+});
\ No newline at end of file
{ text : $.i18n.prop('menu.artifacts.upload') , id: "menu-find-upload-a", href: "#upload" , redback: "{permissions: ['archiva-upload-repository']}", func: function(){displayUploadArtifact(true)}}
]);
this.administrationMenuItems = ko.observableArray([
- {text: $.i18n.prop('menu.administration'), id: null} ]);
+ {text: $.i18n.prop('menu.administration'), id: null ,order : 1} ]);
var pluginsURL = "restServices/archivaServices/pluginsService/getAdminPlugins";
$.ajax(pluginsURL, {
type: "GET",
dataType: 'text',
+
success: function(data) {
- $.each(data.split("|"), function(key, value) {
+ $.each(data.split("|"), function(key, value) {
require([value], function() {
showMenu(self.administrationMenuItems);
+ // sort menu according to order field
+ //
+ self.administrationMenuItems.sort(function(left, right) {
+ return left.order == right.order ? 0 : (left.order < right.order ? -1 : 1)
+ })
});
});
+
}
+
});
--- /dev/null
+/*
+ RequireJS 2.1.6 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
+ Available via the MIT or new BSD license.
+ see: http://github.com/jrburke/requirejs for details
+*/
+var requirejs,require,define;
+(function(ba){function J(b){return"[object Function]"===N.call(b)}function K(b){return"[object Array]"===N.call(b)}function z(b,c){if(b){var d;for(d=0;d<b.length&&(!b[d]||!c(b[d],d,b));d+=1);}}function O(b,c){if(b){var d;for(d=b.length-1;-1<d&&(!b[d]||!c(b[d],d,b));d-=1);}}function t(b,c){return ha.call(b,c)}function m(b,c){return t(b,c)&&b[c]}function H(b,c){for(var d in b)if(t(b,d)&&c(b[d],d))break}function S(b,c,d,m){c&&H(c,function(c,l){if(d||!t(b,l))m&&"string"!==typeof c?(b[l]||(b[l]={}),S(b[l],
+c,d,m)):b[l]=c});return b}function v(b,c){return function(){return c.apply(b,arguments)}}function ca(b){throw b;}function da(b){if(!b)return b;var c=ba;z(b.split("."),function(b){c=c[b]});return c}function B(b,c,d,m){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=m;d&&(c.originalError=d);return c}function ia(b){function c(a,f,C){var e,n,b,c,d,T,k,g=f&&f.split("/");e=g;var l=j.map,h=l&&l["*"];if(a&&"."===a.charAt(0))if(f){e=m(j.pkgs,f)?g=[f]:g.slice(0,g.length-
+1);f=a=e.concat(a.split("/"));for(e=0;f[e];e+=1)if(n=f[e],"."===n)f.splice(e,1),e-=1;else if(".."===n)if(1===e&&(".."===f[2]||".."===f[0]))break;else 0<e&&(f.splice(e-1,2),e-=2);e=m(j.pkgs,f=a[0]);a=a.join("/");e&&a===f+"/"+e.main&&(a=f)}else 0===a.indexOf("./")&&(a=a.substring(2));if(C&&l&&(g||h)){f=a.split("/");for(e=f.length;0<e;e-=1){b=f.slice(0,e).join("/");if(g)for(n=g.length;0<n;n-=1)if(C=m(l,g.slice(0,n).join("/")))if(C=m(C,b)){c=C;d=e;break}if(c)break;!T&&(h&&m(h,b))&&(T=m(h,b),k=e)}!c&&
+T&&(c=T,d=k);c&&(f.splice(0,d,c),a=f.join("/"))}return a}function d(a){A&&z(document.getElementsByTagName("script"),function(f){if(f.getAttribute("data-requiremodule")===a&&f.getAttribute("data-requirecontext")===k.contextName)return f.parentNode.removeChild(f),!0})}function p(a){var f=m(j.paths,a);if(f&&K(f)&&1<f.length)return d(a),f.shift(),k.require.undef(a),k.require([a]),!0}function g(a){var f,b=a?a.indexOf("!"):-1;-1<b&&(f=a.substring(0,b),a=a.substring(b+1,a.length));return[f,a]}function l(a,
+f,b,e){var n,D,i=null,d=f?f.name:null,l=a,h=!0,j="";a||(h=!1,a="_@r"+(N+=1));a=g(a);i=a[0];a=a[1];i&&(i=c(i,d,e),D=m(r,i));a&&(i?j=D&&D.normalize?D.normalize(a,function(a){return c(a,d,e)}):c(a,d,e):(j=c(a,d,e),a=g(j),i=a[0],j=a[1],b=!0,n=k.nameToUrl(j)));b=i&&!D&&!b?"_unnormalized"+(O+=1):"";return{prefix:i,name:j,parentMap:f,unnormalized:!!b,url:n,originalName:l,isDefine:h,id:(i?i+"!"+j:j)+b}}function s(a){var f=a.id,b=m(q,f);b||(b=q[f]=new k.Module(a));return b}function u(a,f,b){var e=a.id,n=m(q,
+e);if(t(r,e)&&(!n||n.defineEmitComplete))"defined"===f&&b(r[e]);else if(n=s(a),n.error&&"error"===f)b(n.error);else n.on(f,b)}function w(a,f){var b=a.requireModules,e=!1;if(f)f(a);else if(z(b,function(f){if(f=m(q,f))f.error=a,f.events.error&&(e=!0,f.emit("error",a))}),!e)h.onError(a)}function x(){U.length&&(ja.apply(I,[I.length-1,0].concat(U)),U=[])}function y(a){delete q[a];delete W[a]}function G(a,f,b){var e=a.map.id;a.error?a.emit("error",a.error):(f[e]=!0,z(a.depMaps,function(e,c){var d=e.id,
+g=m(q,d);g&&(!a.depMatched[c]&&!b[d])&&(m(f,d)?(a.defineDep(c,r[d]),a.check()):G(g,f,b))}),b[e]=!0)}function E(){var a,f,b,e,n=(b=1E3*j.waitSeconds)&&k.startTime+b<(new Date).getTime(),c=[],i=[],g=!1,l=!0;if(!X){X=!0;H(W,function(b){a=b.map;f=a.id;if(b.enabled&&(a.isDefine||i.push(b),!b.error))if(!b.inited&&n)p(f)?g=e=!0:(c.push(f),d(f));else if(!b.inited&&(b.fetched&&a.isDefine)&&(g=!0,!a.prefix))return l=!1});if(n&&c.length)return b=B("timeout","Load timeout for modules: "+c,null,c),b.contextName=
+k.contextName,w(b);l&&z(i,function(a){G(a,{},{})});if((!n||e)&&g)if((A||ea)&&!Y)Y=setTimeout(function(){Y=0;E()},50);X=!1}}function F(a){t(r,a[0])||s(l(a[0],null,!0)).init(a[1],a[2])}function L(a){var a=a.currentTarget||a.srcElement,b=k.onScriptLoad;a.detachEvent&&!Z?a.detachEvent("onreadystatechange",b):a.removeEventListener("load",b,!1);b=k.onScriptError;(!a.detachEvent||Z)&&a.removeEventListener("error",b,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function M(){var a;for(x();I.length;){a=
+I.shift();if(null===a[0])return w(B("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));F(a)}}var X,$,k,P,Y,j={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},shim:{},config:{}},q={},W={},aa={},I=[],r={},V={},N=1,O=1;P={require:function(a){return a.require?a.require:a.require=k.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?a.exports:a.exports=r[a.map.id]={}},module:function(a){return a.module?a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){var b=
+m(j.pkgs,a.map.id);return(b?m(j.config,a.map.id+"/"+b.main):m(j.config,a.map.id))||{}},exports:r[a.map.id]}}};$=function(a){this.events=m(aa,a.id)||{};this.map=a;this.shim=m(j.shim,a.id);this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};$.prototype={init:function(a,b,c,e){e=e||{};if(!this.inited){this.factory=b;if(c)this.on("error",c);else this.events.error&&(c=v(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=c;this.inited=
+!0;this.ignore=e.ignore;e.enabled||this.enabled?this.enable():this.check()}},defineDep:function(a,b){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=b)},fetch:function(){if(!this.fetched){this.fetched=!0;k.startTime=(new Date).getTime();var a=this.map;if(this.shim)k.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],v(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=
+this.map.url;V[a]||(V[a]=!0,k.load(this.map.id,a))},check:function(){if(this.enabled&&!this.enabling){var a,b,c=this.map.id;b=this.depExports;var e=this.exports,n=this.factory;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(1>this.depCount&&!this.defined){if(J(n)){if(this.events.error&&this.map.isDefine||h.onError!==ca)try{e=k.execCb(c,n,b,e)}catch(d){a=d}else e=k.execCb(c,n,b,e);this.map.isDefine&&((b=this.module)&&void 0!==b.exports&&b.exports!==
+this.exports?e=b.exports:void 0===e&&this.usingExports&&(e=this.exports));if(a)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:null,a.requireType=this.map.isDefine?"define":"require",w(this.error=a)}else e=n;this.exports=e;if(this.map.isDefine&&!this.ignore&&(r[c]=e,h.onResourceLoad))h.onResourceLoad(k,this.map,this.depMaps);y(c);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=
+!0)}}else this.fetch()}},callPlugin:function(){var a=this.map,b=a.id,d=l(a.prefix);this.depMaps.push(d);u(d,"defined",v(this,function(e){var n,d;d=this.map.name;var g=this.map.parentMap?this.map.parentMap.name:null,C=k.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(e.normalize&&(d=e.normalize(d,function(a){return c(a,g,!0)})||""),e=l(a.prefix+"!"+d,this.map.parentMap),u(e,"defined",v(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),
+d=m(q,e.id)){this.depMaps.push(e);if(this.events.error)d.on("error",v(this,function(a){this.emit("error",a)}));d.enable()}}else n=v(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),n.error=v(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];H(q,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&y(a.map.id)});w(a)}),n.fromText=v(this,function(e,c){var d=a.name,g=l(d),i=Q;c&&(e=c);i&&(Q=!1);s(g);t(j.config,b)&&(j.config[d]=j.config[b]);try{h.exec(e)}catch(D){return w(B("fromtexteval",
+"fromText eval for "+b+" failed: "+D,D,[b]))}i&&(Q=!0);this.depMaps.push(g);k.completeLoad(d);C([d],n)}),e.load(a.name,C,n,j)}));k.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){W[this.map.id]=this;this.enabling=this.enabled=!0;z(this.depMaps,v(this,function(a,b){var c,e;if("string"===typeof a){a=l(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=m(P,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;u(a,"defined",v(this,function(a){this.defineDep(b,
+a);this.check()}));this.errback&&u(a,"error",v(this,this.errback))}c=a.id;e=q[c];!t(P,c)&&(e&&!e.enabled)&&k.enable(a,this)}));H(this.pluginMaps,v(this,function(a){var b=m(q,a.id);b&&!b.enabled&&k.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){z(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};k={config:j,contextName:b,registry:q,defined:r,urlFetched:V,defQueue:I,Module:$,makeModuleMap:l,
+nextTick:h.nextTick,onError:w,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=j.pkgs,c=j.shim,e={paths:!0,config:!0,map:!0};H(a,function(a,b){e[b]?"map"===b?(j.map||(j.map={}),S(j[b],a,!0,!0)):S(j[b],a,!0):j[b]=a});a.shim&&(H(a.shim,function(a,b){K(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=k.makeShimExports(a);c[b]=a}),j.shim=c);a.packages&&(z(a.packages,function(a){a="string"===typeof a?{name:a}:a;b[a.name]={name:a.name,
+location:a.location||a.name,main:(a.main||"main").replace(ka,"").replace(fa,"")}}),j.pkgs=b);H(q,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=l(b))});if(a.deps||a.callback)k.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(ba,arguments));return b||a.exports&&da(a.exports)}},makeRequire:function(a,f){function d(e,c,g){var i,j;f.enableBuildCallback&&(c&&J(c))&&(c.__requireJsBuild=!0);if("string"===typeof e){if(J(c))return w(B("requireargs",
+"Invalid require call"),g);if(a&&t(P,e))return P[e](q[a.id]);if(h.get)return h.get(k,e,a,d);i=l(e,a,!1,!0);i=i.id;return!t(r,i)?w(B("notloaded",'Module name "'+i+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):r[i]}M();k.nextTick(function(){M();j=s(l(null,a));j.skipMap=f.skipMap;j.init(e,c,g,{enabled:!0});E()});return d}f=f||{};S(d,{isBrowser:A,toUrl:function(b){var d,f=b.lastIndexOf("."),g=b.split("/")[0];if(-1!==f&&(!("."===g||".."===g)||1<f))d=b.substring(f,b.length),b=
+b.substring(0,f);return k.nameToUrl(c(b,a&&a.id,!0),d,!0)},defined:function(b){return t(r,l(b,a,!1,!0).id)},specified:function(b){b=l(b,a,!1,!0).id;return t(r,b)||t(q,b)}});a||(d.undef=function(b){x();var c=l(b,a,!0),d=m(q,b);delete r[b];delete V[c.url];delete aa[b];d&&(d.events.defined&&(aa[b]=d.events),y(b))});return d},enable:function(a){m(q,a.id)&&s(a).enable()},completeLoad:function(a){var b,c,e=m(j.shim,a)||{},d=e.exports;for(x();I.length;){c=I.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}else c[0]===
+a&&(b=!0);F(c)}c=m(q,a);if(!b&&!t(r,a)&&c&&!c.inited){if(j.enforceDefine&&(!d||!da(d)))return p(a)?void 0:w(B("nodefine","No define call for "+a,null,[a]));F([a,e.deps||[],e.exportsFn])}E()},nameToUrl:function(a,b,c){var d,g,l,i,k,p;if(h.jsExtRegExp.test(a))i=a+(b||"");else{d=j.paths;g=j.pkgs;i=a.split("/");for(k=i.length;0<k;k-=1)if(p=i.slice(0,k).join("/"),l=m(g,p),p=m(d,p)){K(p)&&(p=p[0]);i.splice(0,k,p);break}else if(l){a=a===l.name?l.location+"/"+l.main:l.location;i.splice(0,k,a);break}i=i.join("/");
+i+=b||(/\?/.test(i)||c?"":".js");i=("/"===i.charAt(0)||i.match(/^[\w\+\.\-]+:/)?"":j.baseUrl)+i}return j.urlArgs?i+((-1===i.indexOf("?")?"?":"&")+j.urlArgs):i},load:function(a,b){h.load(k,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if("load"===a.type||la.test((a.currentTarget||a.srcElement).readyState))R=null,a=L(a),k.completeLoad(a.id)},onScriptError:function(a){var b=L(a);if(!p(b.id))return w(B("scripterror","Script error for: "+b.id,a,[b.id]))}};k.require=k.makeRequire();
+return k}var h,x,y,E,L,F,R,M,s,ga,ma=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,na=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,fa=/\.js$/,ka=/^\.\//;x=Object.prototype;var N=x.toString,ha=x.hasOwnProperty,ja=Array.prototype.splice,A=!!("undefined"!==typeof window&&navigator&&window.document),ea=!A&&"undefined"!==typeof importScripts,la=A&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,Z="undefined"!==typeof opera&&"[object Opera]"===opera.toString(),G={},u={},U=[],Q=
+!1;if("undefined"===typeof define){if("undefined"!==typeof requirejs){if(J(requirejs))return;u=requirejs;requirejs=void 0}"undefined"!==typeof require&&!J(require)&&(u=require,require=void 0);h=requirejs=function(b,c,d,p){var g,l="_";!K(b)&&"string"!==typeof b&&(g=b,K(c)?(b=c,c=d,d=p):b=[]);g&&g.context&&(l=g.context);(p=m(G,l))||(p=G[l]=h.s.newContext(l));g&&p.configure(g);return p.require(b,c,d)};h.config=function(b){return h(b)};h.nextTick="undefined"!==typeof setTimeout?function(b){setTimeout(b,
+4)}:function(b){b()};require||(require=h);h.version="2.1.6";h.jsExtRegExp=/^\/|:|\?|\.js$/;h.isBrowser=A;x=h.s={contexts:G,newContext:ia};h({});z(["toUrl","undef","defined","specified"],function(b){h[b]=function(){var c=G._;return c.require[b].apply(c,arguments)}});if(A&&(y=x.head=document.getElementsByTagName("head")[0],E=document.getElementsByTagName("base")[0]))y=x.head=E.parentNode;h.onError=ca;h.load=function(b,c,d){var h=b&&b.config||{},g;if(A)return g=h.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml",
+"html:script"):document.createElement("script"),g.type=h.scriptType||"text/javascript",g.charset="utf-8",g.async=!0,g.setAttribute("data-requirecontext",b.contextName),g.setAttribute("data-requiremodule",c),g.attachEvent&&!(g.attachEvent.toString&&0>g.attachEvent.toString().indexOf("[native code"))&&!Z?(Q=!0,g.attachEvent("onreadystatechange",b.onScriptLoad)):(g.addEventListener("load",b.onScriptLoad,!1),g.addEventListener("error",b.onScriptError,!1)),g.src=d,M=g,E?y.insertBefore(g,E):y.appendChild(g),
+M=null,g;if(ea)try{importScripts(d),b.completeLoad(c)}catch(l){b.onError(B("importscripts","importScripts failed for "+c+" at "+d,l,[c]))}};A&&O(document.getElementsByTagName("script"),function(b){y||(y=b.parentNode);if(L=b.getAttribute("data-main"))return s=L,u.baseUrl||(F=s.split("/"),s=F.pop(),ga=F.length?F.join("/")+"/":"./",u.baseUrl=ga),s=s.replace(fa,""),h.jsExtRegExp.test(s)&&(s=L),u.deps=u.deps?u.deps.concat(s):[s],!0});define=function(b,c,d){var h,g;"string"!==typeof b&&(d=c,c=b,b=null);
+K(c)||(d=c,c=null);!c&&J(d)&&(c=[],d.length&&(d.toString().replace(ma,"").replace(na,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c)));if(Q){if(!(h=M))R&&"interactive"===R.readyState||O(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return R=b}),h=R;h&&(b||(b=h.getAttribute("data-requiremodule")),g=G[h.getAttribute("data-requirecontext")])}(g?g.defQueue:U).push([b,c,d])};define.amd={jQuery:!0};h.exec=function(b){return eval(b)};
+h(u)}})(this);