X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fresources%2FMETA-INF%2Fresources%2Fdesigner%2Fscripts%2FCldsModelService.js;h=a75326de161adc98d8da46b922bb0612e0ad6f0f;hb=6b20a432a2d959c6841a1ee8d9db35486a8d1046;hp=90cdc0d78ef44cf9953bffaddf24e57cc3cd249e;hpb=a3ad7dbdf67559f58af24cb5b361c46a91075c7c;p=clamp.git diff --git a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js index 90cdc0d7..a75326de 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js +++ b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js @@ -34,7 +34,7 @@ app //This will open the methods located in the app.js if (undefined == name) { return; - }else if (name.toLowerCase().indexOf("policy") >= 0){ + }else if (name === "OperationalPolicy"){ PolicyWindow(); } else { $rootScope.selectedBoxName = name; @@ -51,10 +51,10 @@ app def.resolve(data); alertService.alertMessage("Action Successful: " + svcAction, 1) // update deploymentID, lastUpdatedStatus - setLastUpdatedStatus(data.lastUpdatedStatus); + setLastComputedState(data.lastComputedState); setDeploymentStatusURL(data.dcaeDeploymentStatusUrl); setDeploymentID(data.dcaeDeploymentId); - setStatus(); + setStatus(data.lastComputedState); enableDisableMenuOptions(); }).error( function(data) { @@ -68,11 +68,9 @@ app var def = $q.defer(); var sets = []; 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; + setStatus(data.lastComputedState); def.resolve(data); }).error(function(data) { def.reject("Open Model not successful"); @@ -103,11 +101,9 @@ app def.resolve(data); alertService.alertMessage("Action Successful: " + svcAction, 1) // update deploymentID, lastUpdatedStatus - setLastUpdatedStatus(data.lastUpdatedStatus); + setLastComputedState(data.lastComputedState); setDeploymentStatusURL(data.dcaeDeploymentStatusUrl); setDeploymentID(data.dcaeDeploymentId); - setStatus(); - enableDisableMenuOptions(); }).error( function(data) { def.resolve(data); @@ -141,24 +137,31 @@ app }; this.processActionResponse = function(modelName) { // populate control name (prefix and uuid here) - var headerText = "Closed Loop Modeler - " + modelName; - setStatus(); + $("#loop_name").text(getLoopName()); manageCLImage(modelName); enableDisableMenuOptions(); }; - this.processRefresh = function() { - setStatus(); + this.refreshStatus = function(modelName) { + var def = $q.defer(); + var sets = []; + var svcUrl = "/restservices/clds/v2/loop/getstatus/" + modelName; + $http.get(svcUrl).success(function(data) { + setStatus(data.lastComputedState); + def.resolve(data); + }).error(function(data) { + def.reject("Refresh Status not successful"); + }); + return def.promise; enableDisableMenuOptions(); } - function setStatus() { - var status = getLastUpdatedStatus(); + function setStatus(status) { // apply color to status var statusColor = 'white'; if (status.trim() === "DESIGN") { statusColor = 'gray' } else if (status.trim() === "DISTRIBUTED") { statusColor = 'blue' - } else if (status.trim() === "ACTIVE") { + } else if (status.trim() === "SUBMITTED") { statusColor = 'green' } else if (status.trim() === "STOPPED") { statusColor = 'red' @@ -185,7 +188,6 @@ app } function manageCLImage(modelName) { getModelImage(modelName).then(function(pars) { - //var svg=' VES TCA Policy '; var svg = pars; if ($("#svgContainer").length > 0) $("#svgContainer").remove(); @@ -203,8 +205,6 @@ app } enableDisableMenuOptions = function() { enableDefaultMenu(); - //var status = getStatus(); - //enableActionMenu(status); enableAllActionMenu(); } getModelImage = function(modelName) {