2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
23 app.controller('GlobalPropertiesCtrl', [
30 'cldsTemplateService',
31 function($scope, $rootScope, $uibModalInstance, cldsModelService, $location,
32 dialogs, cldsTemplateService) {
33 $scope.$watch('name', function(newValue, oldValue) {
37 var el = elementMap["global"];
38 if (el !== undefined) {
39 for (var i = 0; i < el.length; i++) {
40 if (el[i].name === 'deployParameters')
42 // This is a special case, that value is not a string but a JSON
43 $("#" + el[i].name).val(JSON.stringify(el[i].value));
45 $("#" + el[i].name).val(el[i].value);
51 $("#savePropsBtn").attr("disabled", "");
52 $('select[multiple] option').each(function() {
53 var input = $('input[value="' + $(this).val() + '"]');
54 input.prop('disabled', true);
55 input.parent('li').addClass('disabled');
57 $('input[value="multiselect-all"]').prop('disabled', true).parent(
58 'li').addClass('disabled');
59 ($("select:not([multiple])")).multiselect("disable");
62 $scope.retry = function() {
65 $scope.close = function() {
67 $uibModalInstance.close("closed");
69 $scope.convertDeployParametersJsonToString = function() {
70 var index = elementMap["global"].findIndex(function(e) {
71 return (typeof e == "object" && !(e instanceof Array))
72 && "deployParameters" == e["name"];
75 $('#deployParameters').val(JSON.stringify(elementMap["global"][index].value));
79 function noRepeats(form) {
81 for (var i = 0; i < form.length; i++) {
82 if (form[i].hasOwnProperty("name")) {
83 if (form[i].name === 'deployParameters') {
84 // This is a special case, that value MUST not be a string but a JSON
85 select[form[i].name]=JSON.parse(form[i].value);
87 if (select[form[i].name] === undefined)
88 select[form[i].name] = []
89 select[form[i].name].push(form[i].value);
98 if (!(s == "service" && f.value == "")) {
105 $scope.submitForm = function() {
106 saveGlobalProperties(noRepeats($("#saveProps").serializeArray()))
107 $uibModalInstance.close();