Draft of React test
[clamp.git] / src / main / resources / META-INF / resources / designer / scripts / menuHandler.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
25 function enableActionMenu(status) {
26         var actionMap = '{"DESIGN": ["Submit","Delete"],"RUNNING": ["Stop","UnDeploy"],"SUBMITTED": ["Submit","Delete","Deploy"],"DEPLOYED": ["UnDeploy","Stop"],"UNDEPLOY": ["Deploy","Submit","Restart","Delete"],"STOPPED":["UnDeploy","Restart"]}';
27         var actionMapJson = JSON.parse(actionMap);
28         var actionArr = actionMapJson[status];
29         disableAllActionMenu();
30         if (actionArr != null && actionArr.length > 0) {
31                 for (var i=0; i < actionArr.length; i++) {
32                     document.getElementById(actionArr[i]).classList
33                     .remove('ThisLink');
34                 }
35         }
36 }
37
38 function disableAllActionMenu() {
39         var allActions = ["Submit","Stop","Restart","Delete","Deploy","UnDeploy"];
40         for (var i=0; i < allActions.length; i++) {
41             document.getElementById(allActions[i]).classList
42             .add('ThisLink');
43         }
44 }
45
46 function enableAllActionMenu() {
47         var allActions = ["Submit","Stop","Restart","Delete","Deploy","UnDeploy"];
48         for (var i=0; i < allActions.length; i++) {
49             document.getElementById(allActions[i]).classList
50             .remove('ThisLink');
51         }
52 }
53
54 function enableDefaultMenu() {
55          document.getElementById('Open CL').classList.remove('ThisLink');
56          document.getElementById('Wiki').classList.remove('ThisLink');
57          document.getElementById('Contact Us').classList.remove('ThisLink');
58             if (readMOnly) {
59                     // enable model options
60                     document.getElementById('Properties CL').classList
61                     .remove('ThisLink');
62                     document.getElementById('Close Model').classList
63                     .remove('ThisLink');
64             } else {
65                     document.getElementById('Properties CL').classList
66                     .remove('ThisLink');
67                     document.getElementById('Close Model').classList
68                     .remove('ThisLink');
69                     document.getElementById('Refresh Status').classList
70                     .remove('ThisLink');
71             }
72 }
73