Rework the UI Menu
authorxg353y <xg353y@intl.att.com>
Thu, 7 Mar 2019 08:41:53 +0000 (09:41 +0100)
committerxg353y <xg353y@intl.att.com>
Fri, 8 Mar 2019 12:03:54 +0000 (13:03 +0100)
Create a menuHandler to handle enable/disable all the menu actions. Also
rework the method to determine the permittedActions based on the current
CL status.

Issue-ID: CLAMP-311
Change-Id: Iecc194eb62a6546d53ad6121c73f9d3946a135a2
Signed-off-by: xg353y <xg353y@intl.att.com>
src/main/resources/META-INF/resources/designer/index.html
src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js
src/main/resources/META-INF/resources/designer/scripts/app.js
src/main/resources/META-INF/resources/designer/scripts/menuHandler.js [new file with mode: 0644]

index 0d87e26..e30d724 100644 (file)
     <!--    dialog box ctl end -->
     <script src="scripts/aOnBoot.js"></script>
     <script src="scripts/propertyController.js"></script>
+    <script src="scripts/menuHandler.js"></script>
         
 </body>
index cdbca2f..c7ffdb3 100644 (file)
@@ -201,32 +201,13 @@ app
                    });
                    return def.promise;
            };
-           this.checkPermittedActionCd = function(permittedActionCd, menuText,
-                                                  actionCd) {
-
-                   if (permittedActionCd.indexOf(actionCd) > -1) {
-                           document.getElementById(menuText).classList.remove('ThisLink');
-                   } else {
-                           document.getElementById(menuText).classList.add('ThisLink');
-                   }
-           };
            this.processActionResponse = function(modelName, pars) {
 
                    // populate control name (prefix and uuid here)
-                   var controlNamePrefix = pars.controlNamePrefix;
-                   var controlNameUuid = pars.controlNameUuid;
-                   deploymentId = pars.deploymentId;
-                   typeID = pars.typeId;
                    var headerText = "Closed Loop Modeler - " + modelName;
-                   if (controlNameUuid != null) {
-                           headerText = headerText + " [" + controlNamePrefix
-                           + controlNameUuid + "]";
-                   }
-                   document.getElementById("modeler_name").textContent = headerText;
-                   document.getElementById("templa_name").textContent = ("Template Used - " + selected_template);
-                   setStatus(pars)
+                   setStatus();
                    disableBPMNAddSVG(pars);
-                   this.enableDisableMenuOptions(pars);
+                   enableDisableMenuOptions();
            };
            this.processRefresh = function(pars) {
 
@@ -237,7 +218,7 @@ app
                    typeID = newPars.typeId;
                    deploymentId = newPars.deploymentId;
                    setStatus(newPars);
-                   this.enableDisableMenuOptions(newPars);
+                   enableDisableMenuOptions();
            }
            function setStatus() {
 
@@ -297,49 +278,13 @@ app
                            checkIfElementType(name)
                    });
            }
-           this.enableDisableMenuOptions = function(pars) {
-
-                   var permittedActionCd = pars.permittedActionCd;
+           enableDisableMenuOptions = function() {
+               //var status = getStatus();
+               var status = "DESIGN";
                    // dropdown options - always true
-                   document.getElementById('Open CL').classList.remove('ThisLink');
-                   if (readMOnly) {
-                           // enable model options
-                           document.getElementById('Properties CL').classList
-                           .remove('ThisLink');
-                           document.getElementById('Close Model').classList
-                           .remove('ThisLink');
-                           // disable models options
-                           document.getElementById('Save CL').classList.add('ThisLink');
-                           document.getElementById('Revert Model Changes').classList
-                           .add('ThisLink');
-                   } else {
-                           // enable menu options
-                           document.getElementById('Save CL').classList.remove('ThisLink');
-                           document.getElementById('Properties CL').classList
-                           .remove('ThisLink');
-                           document.getElementById('Revert Model Changes').classList
-                           .remove('ThisLink');
-                           document.getElementById('Close Model').classList
-                           .remove('ThisLink');
-                           document.getElementById('Validation Test').classList
-                           .remove('ThisLink');
-                           document.getElementById('Refresh Status').classList
-                           .remove('ThisLink');
-                   }
+               enableDefaultMenu();
                    // enable/disable menu options based on permittedActionCd
                    // list
-                   this.checkPermittedActionCd(permittedActionCd, 'Validation Test',
-                   'TEST');
-                   this.checkPermittedActionCd(permittedActionCd, 'Submit', 'SUBMIT');
-                   this.checkPermittedActionCd(permittedActionCd, 'Resubmit',
-                   'RESUBMIT');
-                   this.checkPermittedActionCd(permittedActionCd, 'Update', 'UPDATE');
-                   this.checkPermittedActionCd(permittedActionCd, 'Stop', 'STOP');
-                   this
-                   .checkPermittedActionCd(permittedActionCd, 'Restart', 'RESTART');
-                   this.checkPermittedActionCd(permittedActionCd, 'Delete', 'DELETE');
-                   this.checkPermittedActionCd(permittedActionCd, 'Deploy', 'DEPLOY');
-                   this.checkPermittedActionCd(permittedActionCd, 'UnDeploy',
-                   'UNDEPLOY');
+               enableActionMenu(status);
            }
     } ]);
index 100dda3..1794cb7 100644 (file)
@@ -269,12 +269,8 @@ function($scope, $rootScope, $timeout, dialogs) {
                            } else if (name == "Save CL") {
                                    $rootScope.isNewClosed = false;
                                    $scope.cldsPerformAction("SAVE");
-                           } else if (name == "Validation Test") {
-                                   $scope.cldsPerformAction("TEST");
                            } else if (name == "Submit") {
                                    $scope.cldsConfirmPerformAction("SUBMIT");
-                           } else if (name == "Resubmit") {
-                                   $scope.cldsConfirmPerformAction("RESUBMIT");
                            } else if (name == "Update") {
                                    $scope.cldsConfirmPerformAction("UPDATE");
                            } else if (name == "Delete") {
@@ -319,17 +315,12 @@ function($scope, $rootScope, $timeout, dialogs) {
                    name : "Close Model"
                } ],
                "Manage" : [ {
-                   link : "/cldsTestActivate",
-                   name : "Validation Test"
-               }, {
                    link : "/cldsSubmit",
                    name : "Submit"
                }, {
-                   link : "/cldsResubmit",
-                   name : "Resubmit"
-               }, {
-                   link : "/cldsUpdate",
-                   name : "Update"
+               // disabled for Dublin since Policy doesn't support updating in this release
+                   //   link : "/cldsUpdate",
+               //    name : "Update"
                }, {
                    link : "/cldsStop",
                    name : "Stop"
diff --git a/src/main/resources/META-INF/resources/designer/scripts/menuHandler.js b/src/main/resources/META-INF/resources/designer/scripts/menuHandler.js
new file mode 100644 (file)
index 0000000..43c9275
--- /dev/null
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ * 
+ */
+
+
+function enableActionMenu(status) {
+       var actionMap = '{"DESIGN": ["Submit","Delete"],"RUNNING": ["Stop","UnDeploy"],"SUBMITTED": ["Submit","Delete","Deploy"],"DEPLOYED": ["UnDeploy","Stop"],"UNDEPLOY": ["Deploy","Submit","Restart","Delete"],"STOPPED":["UnDeploy","Restart"]}';
+       var actionMapJson = JSON.parse(actionMap);
+       var actionArr = actionMapJson[status];
+       disableAllActionMenu();
+       if (actionArr != null && actionArr.length > 0) {
+               for (var i=0; i < actionArr.length; i++) {
+                   document.getElementById(actionArr[i]).classList
+                   .remove('ThisLink');
+               }
+       }
+}
+
+function disableAllActionMenu() {
+       var allActions = ["Submit","Stop","Restart","Delete","Deploy","UnDeploy"];
+       for (var i=0; i < allActions.length; i++) {
+           document.getElementById(allActions[i]).classList
+           .add('ThisLink');
+       }
+}
+
+function enableAllActionMenu() {
+       var allActions = ["Submit","Stop","Restart","Delete","Deploy","UnDeploy"];
+       for (var i=0; i < allActions.length; i++) {
+           document.getElementById(allActions[i]).classList
+           .remove('ThisLink');
+       }
+}
+
+function enableDefaultMenu() {
+        document.getElementById('Open CL').classList.remove('ThisLink');
+        document.getElementById('Wiki').classList.remove('ThisLink');
+        document.getElementById('Contact Us').classList.remove('ThisLink');
+           if (readMOnly) {
+                   // enable model options
+                   document.getElementById('Properties CL').classList
+                   .remove('ThisLink');
+                   document.getElementById('Close Model').classList
+                   .remove('ThisLink');
+                   // disable models options
+                   document.getElementById('Save CL').classList.add('ThisLink');
+                   document.getElementById('Revert Model Changes').classList
+                   .add('ThisLink');
+           } else {
+                   // enable menu options
+                   document.getElementById('Save CL').classList.remove('ThisLink');
+                   document.getElementById('Properties CL').classList
+                   .remove('ThisLink');
+                   document.getElementById('Revert Model Changes').classList
+                   .remove('ThisLink');
+                   document.getElementById('Close Model').classList
+                   .remove('ThisLink');
+                   document.getElementById('Refresh Status').classList
+                   .remove('ThisLink');
+           }
+}
+