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', [
32 function($scope, $rootScope, $uibModalInstance, $http, $q, cldsModelService, $location,
34 $scope.$watch('name', function(newValue, oldValue) {
36 var el = getGlobalProperty();
37 if (el !== undefined) {
39 if (key === 'dcaeDeployParameters')
41 $("#" + key).val(JSON.stringify(el[key]));
43 $("#" + key).val(el[key]);
48 $("#savePropsBtn").attr("disabled", "");
49 $('select[multiple] option').each(function() {
50 var input = $('input[value="' + $(this).val() + '"]');
51 input.prop('disabled', true);
52 input.parent('li').addClass('disabled');
54 $('input[value="multiselect-all"]').prop('disabled', true).parent(
55 'li').addClass('disabled');
56 ($("select:not([multiple])")).multiselect("disable");
59 $scope.retry = function() {
62 $scope.close = function() {
64 $uibModalInstance.close("closed");
68 function noRepeats(form) {
71 for (var i = 0; i < form.length; i++) {
72 if (form[i].hasOwnProperty("name")) {
73 if (form[i].name === 'dcaeDeployParameters') {
74 // This is a special case, that value MUST not be a string but a JSON
75 select[form[i].name]=JSON.parse(form[i].value);
77 if (select[form[i].name] === undefined)
78 select[form[i].name] = []
79 select[form[i].name].push(form[i].value);
88 if (!(s == "service" && f.value == "")) {
95 $scope.submitForm = function() {
96 var form = noRepeats($("#saveProps").serializeArray());
98 for( var i = 0; i < form.length; ++i ) {
99 var name = form[i].name;
100 var value = form[i].value;
106 $scope.saveGlobalProperties(JSON.stringify(obj)).then(function(pars) {
107 updateGlobalProperties(obj);
110 $uibModalInstance.close();
112 $scope.saveGlobalProperties = function(form) {
113 var modelName = getLoopName();
114 var def = $q.defer();
115 var svcUrl = "/restservices/clds/v2/loop/updateGlobalProperties/" + modelName;
116 $http.post(svcUrl, form).success(function(data) {
118 }).error(function(data) {
119 def.reject("Save Model not successful");