Fix the loop log issue
[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     var newMsProperties = JSON.parse(JSON.stringify(cl_props["microServicePolicies"]));
26     for (p in newMsProperties) {
27         if (newMsProperties[p]["name"] == type) {
28                 cl_props["microServicePolicies"][p] = newMsProperties;
29         }
30     }
31 }
32
33 function updateGlobalProperties(newGlobalProperties) {
34     cl_props["globalPropertiesJson"] = newGlobalProperties;
35 }
36
37 function updateOpPolicyProperties(newOpProperties) {    
38    cl_props["operationalPolicies"] = newOpProperties;
39 }
40
41 function getLoopName() {
42     return cl_props["name"];
43 }
44
45 function getOperationalPolicyProperty() {
46     return JSON.parse(JSON.stringify(cl_props["operationalPolicies"]["0"]["configurationsJson"]));
47 }
48
49 function getOperationalPolicies() {
50     return JSON.parse(JSON.stringify(cl_props["operationalPolicies"]));
51 }
52
53 function getGlobalProperty() {
54     return JSON.parse(JSON.stringify(cl_props["globalPropertiesJson"]));
55 }
56
57 function getDeploymentProperties() {
58     return JSON.parse(JSON.stringify(cl_props["globalPropertiesJson"]["dcaeDeployParameters"]));
59 }
60
61 function getMsJson(type) {
62     var msProperties = cl_props["microServicePolicies"];
63     for (p in msProperties) {
64         if (msProperties[p]["name"] == type) {
65            return JSON.parse(JSON.stringify(msProperties[p]));
66         }
67     }
68     return null;
69 }
70
71 function getMsProperty(type) {
72     var msProperties = cl_props["microServicePolicies"];
73     for (p in msProperties) {
74         if (msProperties[p]["name"] == type) {
75                 if (msProperties[p]["properties"] !== null && msProperties[p]["properties"] !== undefined) {
76                         return JSON.parse(JSON.stringify(msProperties[p]["properties"]));
77                 }
78         }
79     }
80     return null;
81 }
82
83 function getMsUI(type) {
84     var msProperties = cl_props["microServicePolicies"];
85     for (p in msProperties) {
86         if (msProperties[p]["name"] == type) {
87                 return JSON.parse(JSON.stringify(msProperties[p]["jsonRepresentation"]));
88         }
89     }
90     return null;
91 }
92
93 function getLastUpdatedStatus() {
94     return cl_props["lastComputedState"];
95 }
96
97 function setLastComputedState(status) {
98     cl_props["lastComputedState"] =  status;
99 }
100
101 function getDeploymentID() {
102     return cl_props["dcaeDeploymentId"];
103 }
104
105 function setDeploymentID(deploymentId) {
106     cl_props["dcaeDeploymentId"] = deploymentId;
107 }
108
109 function getDeploymentStatusURL() {
110     return cl_props["dcaeDeploymentStatusUrl"];
111 }
112
113 function setDeploymentStatusURL(deploymentStatusURL) {
114     cl_props["dcaeDeploymentStatusUrl"] = deploymentStatusURL;
115 }
116
117 function getResourceDetailsVfProperty() {
118         return cl_props["modelPropertiesJson"]["resourceDetails"]["VF"];
119 }
120
121 function getResourceDetailsVfModuleProperty() {
122         return cl_props["modelPropertiesJson"]["resourceDetails"]["VFModule"];
123 }
124
125 function getLoopLogsArray() {
126         return cl_props.loopLogs;
127 }
128
129 module.exports = { getOperationalPolicyProperty,getGlobalProperty,getMsProperty,getMsUI,getLastUpdatedStatus,getDeploymentID,getDeploymentStatusURL,getResourceDetailsVfProperty,getResourceDetailsVfModuleProperty };