2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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 * ===================================================================
33 function($scope, $rootScope, $uibModalInstance, data, dialogs, cldsModelService) {
34 function validate_and_set_deploy_parameters() {
35 var inputList = document.getElementsByClassName("deployFormId");
36 var jsonParameters = "{";
37 $.each(inputList, function(key) {
38 if (jsonParameters !== "{") {
39 jsonParameters = jsonParameters + ",";
41 jsonParameters = jsonParameters + '"' + inputList[key].id + '":'
42 + '"' + inputList[key].value + '"'
44 jsonParameters = jsonParameters + "}";
46 // Try to validate the json
47 set_deploy_parameters(JSON.parse(jsonParameters));
49 console.error("Couldn't parse deploy parameters json");
52 function set_deploy_parameters(parameters) {
53 if (!'global' in elementMap) {
54 elementMap["global"] = [];
56 var index = elementMap["global"].findIndex(function(e) {
57 return (typeof e == "object" && !(e instanceof Array))
58 && "deployParameters" == e["name"];
61 elementMap["global"].push({
62 "name" : "deployParameters",
66 elementMap["global"][index]["value"] = parameters;
69 $scope.load_deploy_parameters = function() {
70 var index = elementMap["global"].findIndex(function(e) {
71 return (typeof e == "object" && !(e instanceof Array))
72 && "deployParameters" == e["name"];
75 $('#deployPropertiesDiv').append($('<br/>'));
76 $.each(elementMap["global"][index].value, function(key) {
77 var propertyValue = elementMap["global"][index].value[key];
78 $('#deployPropertiesDiv').append(
79 $('<label class="control-label">' + key + ' </label>'));
80 $('#deployPropertiesDiv').append(
82 '<input style="width: 100%; clear: both;" class="deployFormId" id="'
83 + key + '"></input>').val(propertyValue).html(propertyValue));
84 $('#deployPropertiesDiv').append($('<br/>'));
88 $scope.deploy = function() {
89 validate_and_set_deploy_parameters();
90 $uibModalInstance.close();
92 $scope.close = function() {
93 $uibModalInstance.dismiss();