Rework the submit operation
[clamp.git] / src / main / resources / META-INF / resources / designer / scripts / CldsModelService.js
index 0e44aec..90cdc0d 100644 (file)
@@ -24,118 +24,65 @@ app
 .service(
 'cldsModelService',
 [
-    'alertService',
-    '$http',
-    '$q',
-    '$rootScope',
-    function(alertService, $http, $q, $rootScope) {
-
-           function checkIfElementType(name, isSimple) {
-
-        //This will open the methods located in the app.js
-                 if (isSimple){
-                         if (undefined == name) {
-                                 return;
-                         }else if (name.toLowerCase().indexOf("policy") >= 0){
-                                         PolicyWindow();
-                         } else {
-                                 $rootScope.selectedBoxName = name.toLowerCase();
-                                 ToscaModelWindow();
-                         }
-                 } else {
-                         if (undefined == name) {
-                                 return;
-                         }
-                       mapping = {
-                               'tca' : TCAWindow,
-                               'policy' : PolicyWindow,
-                               'vescollector' : VesCollectorWindow,
-                               'holmes' : HolmesWindow,
-                           };
-                           key = name.split('_')[0].toLowerCase()
-                           if (key in mapping) {
-                                   mapping[key]();
-                           }
-                 };
-           }
-           function handleQueryToBackend(def, svcAction, svcUrl, svcPayload) {
-
-                   $http.put(svcUrl, svcPayload).success(
-                   function(data) {
-
-                           def.resolve(data);
-                           if (typeof data.statusCodeValue === 'undefined'
-                           || data.statusCodeValue === 200) {
-                                   alertService.alertMessage(
-                                   "Action Successful: " + svcAction, 1)
-                           } else {
-                                   if (typeof data.body !== 'undefined') {
-                                           alertService.alertMessage("Action Failure: "
-                                           + svcAction + ", " + data.body.errorMessageForUi, 2);
-                                   } else {
-                                           alertService.alertMessage("Action Failure: "
-                                           + svcAction, 2);
-                                   }
-                                   def.reject(svcAction + " not successful");
-                           }
-                   }).error(
-                   function(data) {
-
-                           def.resolve(data);
-                           if (typeof data.body !== 'undefined') {
-                                   alertService.alertMessage("Action Failure: " + svcAction
-                                   + ", " + data.body.errorMessageForUi, 2);
-                           } else {
-                                   alertService
-                                   .alertMessage("Action Failure: " + svcAction, 2);
-                           }
-                           def.reject(svcAction + " not successful");
-                   });
-           }
-           this.toggleDeploy = function(uiAction, modelName, controlNamePrefixIn,
-                                        bpmnTextIn, propTextIn, svgXmlIn,
-                                        templateName, typeID, controlNameUuid,
-                                        modelEventService, deploymentId) {
-
+       'alertService',
+       '$http',
+       '$q',
+       '$rootScope',
+       function(alertService, $http, $q, $rootScope) {
+
+               function checkIfElementType(name) {
+               //This will open the methods located in the app.js
+                       if (undefined == name) {
+                               return;
+                       }else if (name.toLowerCase().indexOf("policy") >= 0){
+                               PolicyWindow();
+                       } else {
+                               $rootScope.selectedBoxName = name;
+                               ToscaModelWindow();
+                       }
+               }
+               this.toggleDeploy = function(uiAction, modelName) {
+                       var svcAction = uiAction.toLowerCase();
+                       var deployUrl = "/restservices/clds/v2/loop/" + svcAction + "Loop/" + modelName;
+                       var def = $q.defer();
+                       var sets = [];
+                       $http.put(deployUrl).success(
+                               function(data) {
+                                       def.resolve(data);
+                                       alertService.alertMessage("Action Successful: " + svcAction, 1)
+                                       // update deploymentID, lastUpdatedStatus
+                                       setLastUpdatedStatus(data.lastUpdatedStatus);
+                                       setDeploymentStatusURL(data.dcaeDeploymentStatusUrl);
+                                       setDeploymentID(data.dcaeDeploymentId);
+                                       setStatus();
+                                       enableDisableMenuOptions();
+                       }).error(
+                               function(data) {
+                                       def.resolve(data);
+                                       alertService.alertMessage("Action Failure: " + svcAction, 2);
+                                       def.reject(svcAction + " not successful");
+                       });
+                       return def.promise;
+               }
+               this.getModel = function(modelName) {
                    var def = $q.defer();
                    var sets = [];
-                   var action = uiAction.toLowerCase();
-                   var deployUrl = "/restservices/clds/v1/clds/" + action + "/"
-                   + modelName;
-                   var requestData = {
-                       name : modelName,
-                       controlNamePrefix : controlNamePrefixIn,
-                       bpmnText : bpmnTextIn,
-                       propText : propTextIn,
-                       imageText : svgXmlIn,
-                       templateName : templateName,
-                       typeId : typeID,
-                       controlNameUuid : controlNameUuid,
-                       event : modelEventService,
-                       deploymentId : deploymentId
-                   };
-                   handleQueryToBackend(def, action, deployUrl, requestData);
-                   return def.promise;
-           };
-           this.getModel = function(modelName) {
-
-                   var def = $q.defer();
-                   var sets = [];
-                   var svcUrl = "/restservices/clds/v1/clds/model/" + modelName;
+                   var svcUrl = "/restservices/clds/v2/loop/" + modelName;
+                   //var svcUrl = "/restservices/clds/v1/clds/model/" + modelName;
                    $http.get(svcUrl).success(function(data) {
-
+                       //var clModel = '{"name": "ClosedLoopTest","lastComputedState":"DESIGN","svgRepresentation": "representation","globalPropertiesJson": [{"name":"service","value":["4cc5b45a-1f63-4194-8100-cd8e14248c92"]},{"name":"vf","value":["07e266fc-49ab-4cd7-8378-ca4676f1b9ec"]},{"name":"actionSet","value":["vnfRecipe"]},{"name":"location","value":["DC1"]},{"name":"deployParameters","value":{"location_id":"","service_id":"","policy_id":"AUTO_GENERATED_POLICY_ID_AT_SUBMIT"}}], "blueprint": "yaml","lastComputedState": "DESIGN","operationalPolicies": [ {"name": "OpPolicyTest", "configurationsJson": { "policy1": [{"name": "pname","value": "policy1"},{"name": "pid","value": "0"},{"name": "timeout","value": "345"},{"policyConfigurations": [[{"name": "recipe","value": ["restart"]},{"name": "maxRetries","value": ["3"]},{"name": "retryTimeLimit","value": ["180"]},{"name": "_id","value": ["6TtHGPq"]},{"name": "parentPolicy","value": [""]},{"name": "actor","value": ["APPC"]},{"name": "recipeInput","value": [""]},{"name": "recipeLevel","value": ["VM"]},{"name": "targetResourceId","value": ["07e266fc-49ab-4cd7-8378-ca4676f1b9ec"]},{"name": "targetResourceIdOther","value": [""]},{"name": "enableGuardPolicy","value": ["on"]},{"name": "guardPolicyType","value": ["GUARD_YAML"]},{"name": "guardTargets","value": [".*"]},{"name": "minGuard","value": ["1"]},{"name": "maxGuard","value": ["1"]},{"name": "limitGuard","value": ["1"]},{"name": "timeUnitsGuard","value": ["minute"]},{"name": "timeWindowGuard","value": ["10"]},{"name": "guardActiveStart","value": ["00:00:01-05:00"]},{"name": "guardActiveEnd","value": ["00:00:00-05:00"]}]]}]} }],"microServicePolicies": [{"name": "tca","properties": "", "shared": true,"policyTosca": "tosca","jsonRepresentation": {"schema":{"title":"DCAE TCA Config","type":"object","required":["name","eventName"],"properties":{"name":{"propertyOrder":101,"title":"Name","type":"string","default":"New_Set"},"eventName":{"propertyOrder":102,"title":"EventName","type":"string","enum":["event1","event2"]},"clSchemaType":{"propertyOrder":103,"title":"Control Loop Schema Type","type":"string","enum":["","type1","type2"]},"threshold":{"propertyOrder":104,"title":"Threshold","format":"tabs","type":"array","items":{"type":"object","title":"Threshold","required":["metric","operator"],"properties":{"metric":{"propertyOrder":1001,"title":"Metric","type":"string","enum":["metric1","metric2"]},"operator":{"propertyOrder":1003,"default":">","title":"Operator","type":"string","enum":[">","<","=","<=",">="]}, "clEventStatus":{"propertyOrder":1004,"title":"Closed Loop Event Status","type":"string","enum":["","ONSET","ABATED"]}}}}}}}}],"loopLogs": [{ } ] }';
+                       //cl_props = JSON.parse(clModel);
+                       cl_props = data;
                            def.resolve(data);
                    }).error(function(data) {
-
                            def.reject("Open Model not successful");
                    });
                    return def.promise;
            };
            this.getSavedModel = function() {
-
                    var def = $q.defer();
                    var sets = [];
-                   var svcUrl = "/restservices/clds/v1/clds/model-names";
+                   var svcUrl = "/restservices/clds/v2/loop/getAllNames";
                    $http.get(svcUrl).success(function(data) {
 
                            def.resolve(data);
@@ -145,54 +92,29 @@ app
                    });
                    return def.promise;
            };
-           this.setModel = function(modelName, controlNamePrefixIn, bpmnTextIn,
-                                    propTextIn) {
-
-                   var def = $q.defer();
-                   var sets = [];
-                   var svcUrl = "/restservices/clds/v1/clds/model/" + modelName;
-                   var svcRequest = {
-                       name : modelName,
-                       controlNamePrefix : controlNamePrefixIn,
-                       bpmnText : bpmnTextIn,
-                       propText : propTextIn
-                   };
-                   $http.put(svcUrl, svcRequest).success(function(data) {
-
-                           def.resolve(data);
-                   }).error(function(data) {
-
-                           def.reject("Save Model not successful");
-                   });
-                   return def.promise;
-           };
-           this.processAction = function(uiAction, modelName, controlNamePrefixIn,
-                                         bpmnTextIn, propTextIn, svgXmlIn,
-                                         templateName, typeID, deploymentId) {
-
+           this.processAction = function(uiAction, modelName) {
                    var def = $q.defer();
                    var sets = [];
-                   // console.log(svgXmlIn);
-                   var svcUrl = "/restservices/clds/v1/clds/";
                    var svcAction = uiAction.toLowerCase();
-                   if (svcAction == "save" || svcAction == "refresh") {
-                           svcUrl = svcUrl + "model/" + modelName;
-                   } else if (svcAction == "test") {
-                           svcUrl = svcUrl + "action/submit/" + modelName + "?test=true";
-                   } else {
-                           svcUrl = svcUrl + "action/" + svcAction + "/" + modelName;
-                   }
-                   var svcRequest = {
-                       name : modelName,
-                       controlNamePrefix : controlNamePrefixIn,
-                       bpmnText : bpmnTextIn,
-                       propText : propTextIn,
-                       imageText : svgXmlIn,
-                       templateName : templateName,
-                       typeId : typeID,
-                       deploymentId : deploymentId
-                   };
-                   handleQueryToBackend(def, svcAction, svcUrl, svcRequest);
+                   var svcUrl = "/restservices/clds/v2/loop/" + svcAction + "/" + modelName;
+
+                       $http.put(svcUrl).success(
+                               function(data) {
+                                       def.resolve(data);
+                                       alertService.alertMessage("Action Successful: " + svcAction, 1)
+                                       // update deploymentID, lastUpdatedStatus
+                                       setLastUpdatedStatus(data.lastUpdatedStatus);
+                                       setDeploymentStatusURL(data.dcaeDeploymentStatusUrl);
+                                       setDeploymentID(data.dcaeDeploymentId);
+                                       setStatus();
+                                       enableDisableMenuOptions();
+                       }).error(
+                               function(data) {
+                                       def.resolve(data);
+                                       alertService.alertMessage("Action Failure: " + svcAction, 2);
+                                       def.reject(svcAction + " not successful");
+                       });
+                   
                    return def.promise;
            };
            this.manageAction = function(modelName, typeId, typeName) {
@@ -217,51 +139,19 @@ 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, simple) {
-
-                   // populate control name (prefix and uuid here)
-                   var controlNamePrefix = pars.controlNamePrefix;
-                   var controlNameUuid = pars.controlNameUuid;
-                   deploymentId = pars.deploymentId;
-                   var modelEventService = pars.modelEventService;
-                   typeID = pars.typeId;
+           this.processActionResponse = function(modelName) {
+               // populate control name (prefix and uuid here)
                    var headerText = "Closed Loop Modeler - " + modelName;
-                   if (controlNameUuid != null) {
-                           var actionCd = pars.event.actionCd;
-                           var actionStateCd = pars.event.actionStateCd;
-                           headerText = headerText + " [" + controlNamePrefix
-                           + controlNameUuid + "]";
-                   }
-                   document.getElementById("modeler_name").textContent = headerText;
-                   document.getElementById("templa_name").textContent = ("Template Used - " + selected_template);
-                   setStatus(pars)
-                   disableBPMNAddSVG(pars, simple);
-                   this.enableDisableMenuOptions(pars);
+                   setStatus();
+                   manageCLImage(modelName);
+                   enableDisableMenuOptions();
            };
-           this.processRefresh = function(pars) {
-
-                   var newPars = pars;
-                   if (typeof pars.body !== 'undefined') {
-                           newPars = pars.body;
-                   }
-                   typeID = newPars.typeId;
-                   deploymentId = newPars.deploymentId;
-                   setStatus(newPars);
-                   this.enableDisableMenuOptions(newPars);
-                   elementMap = JSON.parse(newPars.propText);
+           this.processRefresh = function() {
+                   setStatus();
+                   enableDisableMenuOptions();
            }
-           function setStatus(pars) {
-
-                   var status = pars.status;
+           function setStatus() {
+                   var status = getLastUpdatedStatus();
                    // apply color to status
                    var statusColor = 'white';
                    if (status.trim() === "DESIGN") {
@@ -293,73 +183,39 @@ app
                    '<span id="status_clds" style="position: absolute;  left: 61%;top: 151px; font-size:20px;">Status: '
                    + statusMsg + '</span>');
            }
-           function disableBPMNAddSVG(pars, simple) {
-
-                   var svg = pars.imageText.substring(pars.imageText.indexOf("<svg"))
-                   if ($("#svgContainer").length > 0)
-                           $("#svgContainer").remove();
-                   $("#js-canvas").append(
-                   "<span id=\"svgContainer\">" + svg + "</span>");
-                   /* added code for height width viewBox */
-                   $("#svgContainer svg").removeAttr("height");
-                   $("#svgContainer svg").removeAttr('viewBox');
-                   $("#svgContainer svg").removeAttr('width');
-                   $("#svgContainer svg").attr('width', '100%');
-                   $("#svgContainer svg").attr('height', '100%');
-                   $("#svgContainer").click(
-                   function(event) {
-
-                           // console.log($(event.target).parent().html())
-                           // console.log($($(event.target).parent()).attr("data-element-id"))
-                           var name = $($(event.target).parent()).attr("data-element-id")
-                           lastElementSelected = $($(event.target).parent()).attr(
-                           "data-element-id")
-                           checkIfElementType(name, simple)
-                   });
+           function manageCLImage(modelName) {
+               getModelImage(modelName).then(function(pars) {
+                       //var svg='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/2000/svg"> <defs> <marker viewBox="0 0 20 20" markerWidth="10" markerHeight="10" orient="auto" refX="11" refY="10" id="markerSjdype4kmnw"> <path d="M 1 5 L 11 10 L 1 15 Z" style="stroke-width: 1; stroke-linecap: round; stroke-dasharray: 10000, 1;" fill="#000000" /> </marker> <marker viewBox="0 0 20 20" markerWidth="20" markerHeight="20" orient="auto" refX="6" refY="6" id="markerSjdype4kmny"> <circle cx="6" cy="6" r="3.5" style="stroke-width: 1; stroke-linecap: round; stroke-dasharray: 10000, 1;" fill="#ffffff" stroke="#000000" /> </marker> <marker viewBox="0 0 20 20" markerWidth="20" markerHeight="20" orient="auto" refX="8.5" refY="5" id="markerSjdype4kmo0"> <path d="m 1 5 l 0 -3 l 7 3 l -7 3 z" style="stroke-width: 1; stroke-linecap: butt; stroke-dasharray: 10000, 1;" fill="#ffffff" stroke="#000000" /> </marker> <marker viewBox="0 0 20 20" markerWidth="10" markerHeight="10" orient="auto" refX="11" refY="10" id="markerSjdype4kmo2"> <path d="M 1 5 L 11 10 L 1 15" style="stroke-width: 1; stroke-linecap: round; stroke-dasharray: 10000, 1;" fill="#ffffff" stroke="#000000" /> </marker> <marker viewBox="0 0 20 20" markerWidth="10" markerHeight="10" orient="auto" refX="-1" refY="10" id="markerSjdype4kmo4"> <path d="M 0 10 L 8 6 L 16 10 L 8 14 Z" style="stroke-width: 1; stroke-linecap: round; stroke-dasharray: 10000, 1;" fill="#ffffff" stroke="#000000" /> </marker> <marker viewBox="0 0 20 20" markerWidth="10" markerHeight="10" orient="auto" refX="-5" refY="10" id="markerSjdype4kmo6"> <path d="M 1 4 L 5 16" style="stroke-width: 1; stroke-linecap: round; stroke-dasharray: 10000, 1;" fill="#000000" stroke="#000000" /> </marker> </defs><g fill-opacity="1" color-rendering="auto" color-interpolation="auto" text-rendering="auto" stroke="black" stroke-linecap="square" stroke-miterlimit="10" shape-rendering="auto" stroke-opacity="1" fill="black" stroke-dasharray="none" font-weight="normal" stroke-width="1" font-family="&apos;Dialog&apos;" font-style="normal" data-element-id="start-circle" stroke-linejoin="miter" font-size="12px" image-rendering="auto" stroke-dashoffset="0"><!--Generated by the Batik Graphics2D SVG Generator--> <defs id="genericDefs"/> <g> <g shape-rendering="geometricPrecision" text-rendering="optimizeQuality" stroke-width="2"> <circle fill="none" r="17" cx="34" cy="41"/> </g> </g> </g> <g fill-opacity="1" color-rendering="auto" color-interpolation="auto" text-rendering="auto" stroke="black" stroke-linecap="square" stroke-miterlimit="10" shape-rendering="auto" stroke-opacity="1" fill="black" stroke-dasharray="none" font-weight="normal" stroke-width="1" font-family="&apos;Dialog&apos;" font-style="normal" data-element-id="Arrow_d0b22360-770d-4b05-b81c-cf148b121341" stroke-linejoin="miter" font-size="12px" image-rendering="auto" stroke-dashoffset="0"><!--Generated by the Batik Graphics2D SVG Generator--> <defs id="genericDefs"/> <g> <g shape-rendering="geometricPrecision" text-rendering="optimizeQuality" stroke-width="2"> <line y2="41" fill="none" x1="51" x2="170" y1="41"/> <polygon fill="none" points=" 166 38 166 44 172 41"/>             <polygon points=" 166 38 166 44 172 41" stroke="none"/> </g> </g> </g> <g fill-opacity="1" color-rendering="auto" color-interpolation="auto" text-rendering="auto" stroke="black" stroke-linecap="square" stroke-miterlimit="10" shape-rendering="auto" stroke-opacity="1" fill="black" stroke-dasharray="none" font-weight="normal" stroke-width="1" font-family="&apos;Dialog&apos;" font-style="normal" data-element-id="VES" stroke-linejoin="miter" font-size="12px" image-rendering="auto" stroke-dashoffset="0"><!--Generated by the Batik Graphics2D SVG Generator--> <defs id="genericDefs"/> <g> <g shape-rendering="geometricPrecision" text-rendering="optimizeQuality" stroke-width="2"> <rect fill="none" x="174" width="123" y="1" height="82"/> </g> <g fill-opacity="0" fill="rgb(0,0,0)" text-rendering="optimizeQuality" shape-rendering="geometricPrecision" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="2"> <rect x="174" width="123" y="1" height="82" stroke="none"/> </g> <g font-family="sans-serif" shape-rendering="geometricPrecision" text-rendering="optimizeQuality"> <text x="223" xml:space="preserve" y="42" stroke="none">VES</text> <line y2="83" fill="none" stroke-width="2" x1="194" x2="194" y1="1"/> </g> </g> </g> <g fill-opacity="1" color-rendering="auto" color-interpolation="auto" text-rendering="auto" stroke="black" stroke-linecap="square" stroke-miterlimit="10" shape-rendering="auto" stroke-opacity="1" fill="black" stroke-dasharray="none" font-weight="normal" stroke-width="1" font-family="&apos;Dialog&apos;" font-style="normal" data-element-id="Arrow_d4351927-d77a-4e04-82d1-cd8f2b008137" stroke-linejoin="miter" font-size="12px" image-rendering="auto" stroke-dashoffset="0"><!--Generated by the Batik Graphics2D SVG Generator--> <defs id="genericDefs"/> <g> <g text-rendering="optimizeQuality" stroke-width="2" shape-rendering="geometricPrecision" font-family="sans-serif"> <line y2="41" fill="none" x1="297" x2="416" y1="41"/> <polygon fill="none" points=" 412 38 412 44 418 41"/> <polygon points=" 412 38 412 44 418 41" stroke="none"/> </g> </g> </g>    <g fill-opacity="1" color-rendering="auto" color-interpolation="auto" text-rendering="auto" stroke="black" stroke-linecap="square" stroke-miterlimit="10" shape-rendering="auto" stroke-opacity="1" fill="black" stroke-dasharray="none" font-weight="normal" stroke-width="1" font-family="&apos;Dialog&apos;" font-style="normal" data-element-id="TCA" stroke-linejoin="miter" font-size="12px" image-rendering="auto" stroke-dashoffset="0"><!--Generated by the Batik Graphics2D SVG Generator--> <defs id="genericDefs"/> <g> <g text-rendering="optimizeQuality" stroke-width="2" shape-rendering="geometricPrecision" font-family="sans-serif"> <rect fill="none" x="420" width="123" y="1" height="82"/> </g> <g fill-opacity="0" fill="rgb(0,0,0)" text-rendering="optimizeQuality" font-family="sans-serif" shape-rendering="geometricPrecision" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="2"> <rect x="420" width="123" y="1" height="82" stroke="none"/> </g> <g font-family="sans-serif" shape-rendering="geometricPrecision" text-rendering="optimizeQuality"> <text x="470" xml:space="preserve" y="42" stroke="none">TCA</text> <line y2="62" fill="none" stroke-width="2" x1="420" x2="543" y1="62"/> </g> </g> </g>   <g fill-opacity="1" color-rendering="auto" color-interpolation="auto" text-rendering="auto" stroke="black" stroke-linecap="square" stroke-miterlimit="10" shape-rendering="auto" stroke-opacity="1" fill="black" stroke-dasharray="none" font-weight="normal" stroke-width="1" font-family="&apos;Dialog&apos;" font-style="normal" data-element-id="Arrow_5ae2966f-f971-4c3b-8237-efa551beb531" stroke-linejoin="miter" font-size="12px" image-rendering="auto" stroke-dashoffset="0"><!--Generated by the Batik Graphics2D SVG Generator--> <defs id="genericDefs"/> <g> <g text-rendering="optimizeQuality" stroke-width="2" shape-rendering="geometricPrecision" font-family="sans-serif"> <line y2="41" fill="none" x1="543" x2="662" y1="41"/> <polygon fill="none" points=" 658 38 658 44 664 41"/> <polygon points=" 658 38 658 44 664 41" stroke="none"/> </g> </g> </g> <g fill-opacity="1" color-rendering="auto" color-interpolation="auto" text-rendering="auto" stroke="black" stroke-linecap="square" stroke-miterlimit="10" shape-rendering="auto" stroke-opacity="1" fill="black" stroke-dasharray="none" font-weight="normal" stroke-width="1" font-family="&apos;Dialog&apos;" font-style="normal" data-element-id="Policy" stroke-linejoin="miter" font-size="12px" image-rendering="auto" stroke-dashoffset="0"><!--Generated by the Batik Graphics2D SVG Generator--> <defs id="genericDefs"/> <g> <g text-rendering="optimizeQuality" stroke-width="2" shape-rendering="geometricPrecision" font-family="sans-serif"> <rect fill="none" x="666" width="123" y="1" height="82"/> </g> <g fill-opacity="0" fill="rgb(0,0,0)" text-rendering="optimizeQuality" font-family="sans-serif" shape-rendering="geometricPrecision" stroke="rgb(0,0,0)" stroke-opacity="0" stroke-width="2"> <rect x="666" width="123" y="1" height="82" stroke="none"/> </g> <g font-family="sans-serif" shape-rendering="geometricPrecision" text-rendering="optimizeQuality"> <text x="710" xml:space="preserve" y="42" stroke="none">Policy</text> <line y2="1" fill="none" stroke-width="2" x1="666" x2="727" y1="42"/> </g> </g> </g> <g fill-opacity="1" color-rendering="auto" color-interpolation="auto" text-rendering="auto" stroke="black" stroke-linecap="square" stroke-miterlimit="10" shape-rendering="auto" stroke-opacity="1" fill="black" stroke-dasharray="none" font-weight="normal" stroke-width="1" font-family="&apos;Dialog&apos;" font-style="normal" data-element-id="Arrow_ed5ccaed-6d8c-44e9-8245-85f66523cb44" stroke-linejoin="miter" font-size="12px" image-rendering="auto" stroke-dashoffset="0"><!--Generated by the Batik Graphics2D SVG Generator--> <defs id="genericDefs"/> <g> <g text-rendering="optimizeQuality" stroke-width="2" shape-rendering="geometricPrecision" font-family="sans-serif"> <line y2="41" fill="none" x1="789" x2="908" y1="41"/> <polygon fill="none" points=" 904 38 904 44 910 41"/> <polygon points=" 904 38 904 44 910 41" stroke="none"/> </g> </g> </g> <g fill-opacity="1" color-rendering="auto" color-interpolation="auto" text-rendering="auto" stroke="black" stroke-linecap="square" stroke-miterlimit="10" shape-rendering="auto" stroke-opacity="1" fill="black" stroke-dasharray="none" font-weight="normal" stroke-width="1" font-family="&apos;Dialog&apos;" font-style="normal" data-element-id="circle_stop" stroke-linejoin="miter" font-size="12px" image-rendering="auto" stroke-dashoffset="0"><!--Generated by the Batik Graphics2D SVG Generator--> <defs id="genericDefs"/> <g> <g text-rendering="optimizeQuality" stroke-width="4" shape-rendering="geometricPrecision" font-family="sans-serif"> <circle fill="none" r="17" cx="929" cy="41"/> </g> </g> </g> </svg>';
+                       var svg = pars;
+                           if ($("#svgContainer").length > 0)
+                                   $("#svgContainer").remove();
+                           $("#js-canvas").append(
+                           "<span id=\"svgContainer\">" + svg + "</span>");
+                           $("#svgContainer svg").attr('width', '100%');
+                           $("#svgContainer svg").attr('height', '100%');
+                           $("#svgContainer").click(
+                           function(event) {
+                                   var name = $($($($(event.target).parent()).parent()).parent()).attr("data-element-id")
+                                   checkIfElementType(name)
+                           });
+                       }, function(data) {
+                       });
            }
-           this.enableDisableMenuOptions = function(pars) {
-
-                   var permittedActionCd = pars.permittedActionCd;
-                   // 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');
-                   }
-                   // 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');
+           enableDisableMenuOptions = function() {
+                   enableDefaultMenu();
+                   //var status = getStatus();
+               //enableActionMenu(status);
+               enableAllActionMenu();
            }
+           getModelImage = function(modelName) {
+                   var def = $q.defer();
+                   var sets = [];
+                   var svcUrl = "/restservices/clds/v2/loop/svgRepresentation/" + modelName;
+                   $http.get(svcUrl).success(function(data) {
+                           def.resolve(data);
+                   }).error(function(data) {
+                           def.reject("Not able to get the model image");
+                   });
+                   return def.promise;
+           };
     } ]);