From 2f56e98490cd3f7f3a688685e38ee6178c19648c Mon Sep 17 00:00:00 2001 From: xg353y Date: Fri, 8 Mar 2019 13:00:06 +0100 Subject: Rework the UI Rework the UI, fixing some bugs, update the method to get the CL image, rework the URL used to communicate with backend, remove the save CL/update/validationTest/resubmit menu. Issue-ID: CLAMP-312, CLAMP-318 Change-Id: I3e167a5432b99f851382e36c1b56189c18e43476 Signed-off-by: xg353y --- .../partials/portfolios/global_properties.html | 59 --------------- .../portfolios/tosca_model_properties.html | 5 +- .../resources/designer/scripts/CldsModelService.js | 88 +++++++++++++--------- .../designer/scripts/CldsOpenModelCtrl.js | 4 +- .../designer/scripts/GlobalPropertiesCtrl.js | 2 - .../resources/designer/scripts/ToscaModelCtrl.js | 4 + .../META-INF/resources/designer/scripts/aOnBoot.js | 38 ---------- .../META-INF/resources/designer/scripts/app.js | 11 +-- .../designer/scripts/propertyController.js | 59 +++++++++++++-- 9 files changed, 111 insertions(+), 159 deletions(-) (limited to 'src/main/resources') diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/global_properties.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/global_properties.html index febdb6b61..e7b4f383e 100644 --- a/src/main/resources/META-INF/resources/designer/partials/portfolios/global_properties.html +++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/global_properties.html @@ -46,31 +46,6 @@ / Cancel
- -
- - -
- - -
-
- -
- - -
- - -
-
@@ -99,38 +74,4 @@ class="btn btn-primary">Cancel
- - -
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/tosca_model_properties.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/tosca_model_properties.html index ca627b354..271def436 100644 --- a/src/main/resources/META-INF/resources/designer/partials/portfolios/tosca_model_properties.html +++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/tosca_model_properties.html @@ -62,8 +62,9 @@ - - + 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 c7ffdb3f4..8a6981cb8 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js +++ b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js @@ -104,10 +104,12 @@ app 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); + //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) { @@ -119,7 +121,8 @@ app var def = $q.defer(); var sets = []; - var svcUrl = "/restservices/clds/v1/clds/model-names"; + //var svcUrl = "/restservices/clds/v1/clds/model-names"; + var svcUrl = "/restservices/clds/v2/loop/getAllNames"; $http.get(svcUrl).success(function(data) { def.resolve(data); @@ -201,12 +204,12 @@ app }); return def.promise; }; - this.processActionResponse = function(modelName, pars) { + this.processActionResponse = function(modelName) { // populate control name (prefix and uuid here) var headerText = "Closed Loop Modeler - " + modelName; setStatus(); - disableBPMNAddSVG(pars); + manageCLImage(modelName); enableDisableMenuOptions(); }; this.processRefresh = function(pars) { @@ -217,7 +220,7 @@ app } typeID = newPars.typeId; deploymentId = newPars.deploymentId; - setStatus(newPars); + setStatus(); enableDisableMenuOptions(); } function setStatus() { @@ -254,37 +257,48 @@ app 'Status: ' + statusMsg + ''); } - function disableBPMNAddSVG(pars) { - - var svg = pars.imageText.substring(pars.imageText.indexOf(" 0) - $("#svgContainer").remove(); - $("#js-canvas").append( - "" + svg + ""); - /* 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) - }); + function manageCLImage(modelName) { + getModelImage(modelName).then(function(pars) { + //var svg=' VesCollector third_app first_app second_app Policy '; + var svg = pars; + if ($("#svgContainer").length > 0) + $("#svgContainer").remove(); + $("#js-canvas").append( + "" + svg + ""); + /* 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("svgContainer:" + $("#svgContainer svg")); + // 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) + }); + }, function(data) { + }); } enableDisableMenuOptions = function() { - //var status = getStatus(); - var status = "DESIGN"; - // dropdown options - always true - enableDefaultMenu(); - // enable/disable menu options based on permittedActionCd - // list - enableActionMenu(status); + 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; + }; } ]); diff --git a/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js index 825dd57d0..a1625a936 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js @@ -52,11 +52,9 @@ function($scope, $rootScope, $modalInstance, $window, $uibModalInstance, cldsMod $scope.paramsRetry = function() { // $("#paramsWarn").hide(); $("#ridinSpinners").css("display", "") - loadSharedPropertyByService(currentValue, true, callBack); $("#ridinSpinners").css("display", "none") }; $scope.paramsCancel = function() { - loadSharedPropertyByServiceProperties(callBack); $("#paramsWarnrefresh").hide(); }; function completeClose() { @@ -145,7 +143,7 @@ function($scope, $rootScope, $modalInstance, $window, $uibModalInstance, cldsMod cldsModelService.getModel(modelName).then(function(pars) { // deserialize model properties selected_model = modelName; - cldsModelService.processActionResponse(modelName, pars); + cldsModelService.processActionResponse(modelName); // set model bpmn and open diagram $rootScope.isPalette = true; }, function(data) { diff --git a/src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js index ffe17371c..2ac959b45 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js @@ -32,8 +32,6 @@ function($scope, $rootScope, $uibModalInstance, cldsModelService, $location, dialogs, cldsTemplateService) { $scope.$watch('name', function(newValue, oldValue) { - setASDCFields() - var el = getGlobalProperty(); if (el !== undefined) { for (var i = 0; i < el.length; i++) { diff --git a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js index c4f02acfe..09a1d0caa 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js @@ -30,6 +30,10 @@ app.controller('ToscaModelCtrl', $('#editor').empty(); var toscaModel = getMsUI(selectedPolicy); + if (toscaModel == null) { + $modalInstance.close('closed'); + return; + } var editorData = getMsProperty(selectedPolicy); JSONEditor.defaults.options.theme = 'bootstrap3'; diff --git a/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js b/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js index 6b5234805..347d74720 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js +++ b/src/main/resources/META-INF/resources/designer/scripts/aOnBoot.js @@ -71,44 +71,6 @@ function setMultiSelect() { }); } - - -function setASDCFields() { - try { - var location_values = defaults_props['global']['location']; - if (location_values) { - for (key in location_values) { - if ($("#location").length > 0) { - $("#location").append("