0323529eeb274ea821512e1f9d60a2e264546253
[clamp.git] / src / main / resources / META-INF / resources / designer / scripts / propertyController.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights
6  *                             reserved.
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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  * ===================================================================
21  * 
22  */
23
24 function updateMsProperties(type, newMsProperties) {
25     if (newMsProperties["name"] == type) {
26         for (p in cl_props["microServicePolicies"]) {
27             if (cl_props["microServicePolicies"][p]["name"] == type) {
28                 cl_props["microServicePolicies"][p] = newMsProperties;
29             }
30         }
31     }
32 }
33
34 function updateGlobalProperties(newGlobalProperties) {
35     cl_props["globalPropertiesJson"] = newGlobalProperties;
36 }
37
38 function updateOpPolicyProperties(newOpProperties) {    
39    cl_props["operationalPolicies"] = newOpProperties;
40 }
41
42 function getLoopName() {
43     return cl_props["name"];
44 }
45
46 function getOperationalPolicyProperty() {
47     return JSON.parse(JSON.stringify(cl_props["operationalPolicies"]["0"]["configurationsJson"]));
48 }
49
50 function getOperationalPolicies() {
51     return JSON.parse(JSON.stringify(cl_props["operationalPolicies"]));
52 }
53
54 function getGlobalProperty() {
55     return JSON.parse(JSON.stringify(cl_props["globalPropertiesJson"]));
56 }
57
58 function getDeploymentProperties() {
59     return JSON.parse(JSON.stringify(cl_props["globalPropertiesJson"]["dcaeDeployParameters"]));
60 }
61
62 function getMsJson(type) {
63     var msProperties = cl_props["microServicePolicies"];
64     for (p in msProperties) {
65         if (msProperties[p]["name"] == type) {
66            return JSON.parse(JSON.stringify(msProperties[p]));
67         }
68     }
69     return null;
70 }
71
72 function getMsProperty(type) {
73     var msProperties = cl_props["microServicePolicies"];
74     for (p in msProperties) {
75         if (msProperties[p]["name"] == type) {
76                 if (msProperties[p]["properties"] !== null && msProperties[p]["properties"] !== undefined) {
77                         return JSON.parse(JSON.stringify(msProperties[p]["properties"]));
78                 }
79         }
80     }
81     return null;
82 }
83
84 function getMsUI(type) {
85     var msProperties = cl_props["microServicePolicies"];
86     for (p in msProperties) {
87         if (msProperties[p]["name"] == type) {
88                 return JSON.parse(JSON.stringify(msProperties[p]["jsonRepresentation"]));
89         }
90     }
91     return null;
92 }
93
94 function getResourceDetailsVfProperty() {
95         return cl_props["modelPropertiesJson"]["resourceDetails"]["VF"];
96 }
97
98 function getResourceDetailsVfModuleProperty() {
99         return cl_props["modelPropertiesJson"]["resourceDetails"]["VFModule"];
100 }
101
102 function getLoopLogsArray() {
103         return cl_props.loopLogs;
104 }
105
106 function getComponentStates() {
107         return cl_props.components;
108 }
109
110 module.exports = { getOperationalPolicyProperty,getGlobalProperty,getMsProperty,getMsUI,getResourceDetailsVfProperty,getResourceDetailsVfModuleProperty };