diff options
author | xg353y <xg353y@intl.att.com> | 2019-03-14 16:27:49 +0100 |
---|---|---|
committer | sebdet <sebastien.determe@intl.att.com> | 2019-03-14 18:06:29 +0100 |
commit | ec7f47aacc6c124d8d2e01416e80e2278b427be8 (patch) | |
tree | f94a2ae5817095bfbadcac1c752696e97c4a2da4 /src/main/resources | |
parent | 4549fd92024cdadf3277d7cc364f33109ca22b59 (diff) |
Rework UI
Rework UI to cooperate with the new data model
Issue-ID: CLAMP-318
Change-Id: I1266c350e7604d29ff86da7c7584c74ad1f8715a
Signed-off-by: xg353y <xg353y@intl.att.com>
Diffstat (limited to 'src/main/resources')
12 files changed, 112 insertions, 78 deletions
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html index 0da015358..6255698d8 100644 --- a/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html +++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html @@ -562,8 +562,8 @@ label { } console.log("save properties; add tableVal to policies: "+ tableVal); }); - - saveOpPolicyProperties(finalSaveList); + var scope = angular.element(document.getElementById('formSpan')).scope(); + scope.submitForm(finalSaveList); $("#close_button").click(); }) @@ -803,7 +803,6 @@ label { $("#pid").val(0); - setASDCFields(); initTargetResourceId(); //load metrics dropdown if (elementMap["global"]) { 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 e7b4f383e..4531ef3a4 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 @@ -51,8 +51,8 @@ Deploy Parameters</label> <div class="col-sm-8"> - <textarea class="form-control" id="deployParameters" - name="deployParameters" rows="3"> + <textarea class="form-control" id="dcaeDeployParameters" + name="dcaeDeployParameters" rows="3"> </textarea> </div> 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 5848f5432..097235fa1 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js +++ b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js @@ -269,10 +269,7 @@ app $("#svgContainer svg").attr('height', '100%'); $("#svgContainer").click( function(event) { - console.log("svgContainer:" + $("#svgContainer svg")); var name = $($($($(event.target).parent()).parent()).parent()).attr("data-element-id") - lastElementSelected = $($(event.target).parent()).attr( - "data-element-id") checkIfElementType(name) }); }, function(data) { 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 0e3fce971..2d76dc3ec 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js @@ -42,7 +42,7 @@ function($scope, $rootScope, $modalInstance, $window, $uibModalInstance, cldsMod cldsModelService.getSavedModel().then(function(pars) { $scope.modelNamel = [] for (var i = 0; i < pars.length; i++) { - $scope.modelNamel.push(pars[i].value); + $scope.modelNamel.push(pars[i]); } setTimeout(function() { setMultiSelect(); 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 e9ff49961..f34267a2f 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js @@ -24,22 +24,23 @@ app.controller('GlobalPropertiesCtrl', [ '$scope', '$rootScope', '$uibModalInstance', +'$http', +'$q', 'cldsModelService', '$location', 'dialogs', -function($scope, $rootScope, $uibModalInstance, cldsModelService, $location, +function($scope, $rootScope, $uibModalInstance, $http, $q, cldsModelService, $location, dialogs) { $scope.$watch('name', function(newValue, oldValue) { var el = getGlobalProperty(); if (el !== undefined) { - for (var i = 0; i < el.length; i++) { - if (el[i].name === 'deployParameters') + for (var key in el) { + if (key === 'dcaeDeployParameters') { - // This is a special case, that value is not a string but a JSON - $("#" + el[i].name).val(JSON.stringify(el[i].value)); + $("#" + key).val(JSON.stringify(el[key])); } else { - $("#" + el[i].name).val(el[i].value); + $("#" + key).val(el[key]); } } } @@ -64,11 +65,13 @@ function($scope, $rootScope, $uibModalInstance, cldsModelService, $location, $uibModalInstance.close("closed"); }; + function noRepeats(form) { + var select = {}; for (var i = 0; i < form.length; i++) { if (form[i].hasOwnProperty("name")) { - if (form[i].name === 'deployParameters') { + if (form[i].name === 'dcaeDeployParameters') { // This is a special case, that value MUST not be a string but a JSON select[form[i].name]=JSON.parse(form[i].value); } else { @@ -91,8 +94,31 @@ function($scope, $rootScope, $uibModalInstance, cldsModelService, $location, } $scope.submitForm = function() { - saveGlobalProperties(noRepeats($("#saveProps").serializeArray())) + var form = noRepeats($("#saveProps").serializeArray()); + var obj = {}; + for( var i = 0; i < form.length; ++i ) { + var name = form[i].name; + var value = form[i].value; + if( name ) { + obj[ name ] = value; + } + } + + $scope.saveGlobalProperties(JSON.stringify(obj)).then(function(pars) { + updateGlobalProperties(obj); + }, function(data) { + }); $uibModalInstance.close(); - } - + }; + $scope.saveGlobalProperties = function(form) { + var modelName = getLoopName(); + var def = $q.defer(); + var svcUrl = "/restservices/clds/v2/loop/updateGlobalProperties/" + modelName; + $http.post(svcUrl, form).success(function(data) { + def.resolve(data); + }).error(function(data) { + def.reject("Save Model not successful"); + }); + return def.promise; + }; } ]); diff --git a/src/main/resources/META-INF/resources/designer/scripts/ImportSchemaCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/ImportSchemaCtrl.js index 7fb0f4468..5dae2dc19 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/ImportSchemaCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/ImportSchemaCtrl.js @@ -281,4 +281,16 @@ function($scope, $rootScope, $uibModalInstance, data, svnservice, fileUpload, // $scope.name = 'You did not enter in your name!'; }); }; + + $scope.submitForm = function(obj) { + var operationalPolicies = getOperationalPolicies(); + if (obj !== null) { + operationalPolicies[0]["configurationsJson"] = obj; + } + svnservice.saveOpPolicyProperties(operationalPolicies).then(function(pars) { + updateOpPolicyProperties(operationalPolicies); + }, function(data) { + }); + }; + } ]);
\ No newline at end of file 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 09a1d0caa..d287f3d78 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js @@ -86,14 +86,19 @@ app.controller('ToscaModelCtrl', } $scope.saveToscaProps = function(){ - var policyType = $rootScope.selectedBoxName.split('_')[0].toLowerCase(); - var data = $scope.getEditorData(); + var policyType = $rootScope.selectedBoxName; + var data = $scope.getEditorData(); if(data !== null) { - saveMsProperties(policyType,data); - if($scope.editor) { $scope.editor.destroy(); $scope.editor = null; } - $modalInstance.close('closed'); - } + var msJson = getMsJson(policyType); + msJson["properties"] = data; + cldsModelService.saveMsProperties(msJson).then(function(pars) { + saveMsProperties(policyType, data); + }, function(data) { + }); + if($scope.editor) { $scope.editor.destroy(); $scope.editor = null; } + $modalInstance.close('closed'); + } } $scope.displayErrorMessage = function(errors){ diff --git a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelService.js b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelService.js index c99a4556b..222c2c96a 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelService.js +++ b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelService.js @@ -35,4 +35,16 @@ app.service('toscaModelService', ['alertService','$http', '$q', '$rootScope', fu return response.data; }); }; + + this.saveMsProperties = function(form) { + var loopName = getLoopName(); + var def = $q.defer(); + var svcUrl = "/restservices/clds/v2/loop/updateMicroservicePolicies/" + loopName; + $http.post(svcUrl, form).success(function(data) { + def.resolve(data); + }).error(function(data) { + def.reject("Save Model not successful"); + }); + return def.promise; + }; }]); diff --git a/src/main/resources/META-INF/resources/designer/scripts/importSchemaService.js b/src/main/resources/META-INF/resources/designer/scripts/importSchemaService.js index 8c23f1ffb..c355d7523 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/importSchemaService.js +++ b/src/main/resources/META-INF/resources/designer/scripts/importSchemaService.js @@ -46,4 +46,16 @@ app.service('svnservice', ['$http', '$q', function ($http, $q) { return def.promise; }; + + this.saveOpPolicyProperties = function(form) { + var modelName = getLoopName(); + var def = $q.defer(); + var svcUrl = "/restservices/clds/v2/loop/updateOperationalPolicies/" + modelName; + $http.post(svcUrl, form).success(function(data) { + def.resolve(data); + }).error(function(data) { + def.reject("Save Operational Policy not successful"); + }); + return def.promise; + }; }]);
\ No newline at end of file diff --git a/src/main/resources/META-INF/resources/designer/scripts/menuHandler.js b/src/main/resources/META-INF/resources/designer/scripts/menuHandler.js index 1509d3e1a..d03918444 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/menuHandler.js +++ b/src/main/resources/META-INF/resources/designer/scripts/menuHandler.js @@ -64,8 +64,6 @@ function enableDefaultMenu() { } else { 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 diff --git a/src/main/resources/META-INF/resources/designer/scripts/propertyController.js b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js index c3f1aaf13..9b236565d 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/propertyController.js +++ b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js @@ -28,69 +28,42 @@ function saveMsProperties(type, form) { newMsProperties[p]["properties"] = form; } } - - var def = $q.defer(); - var sets = []; - var svcUrl = "/restservices/clds/v2/loop/updateMicroservicePolicies/" + modelName; - var svcRequest = { - loopName : modelName, - newMicroservicePolicies : newMsProperties - }; - $http.post(svcUrl, svcRequest).success(function(data) { - def.resolve(data); - }).error(function(data) { - def.reject("Save Model not successful"); - }); - cl_props["microServicePolicies"] = newMsProperties; - return def.promise; } -function saveGlobalProperties(form) { - var def = $q.defer(); - var sets = []; - var svcUrl = "/restservices/clds/v2/loop/globalProperties/" + modelName; - var svcRequest = { - loopName : modelName, - newGlobalPolicies : form - }; - $http.post(svcUrl, svcRequest).success(function(data) { - def.resolve(data); - }).error(function(data) { - def.reject("Save Model not successful"); - }); +function updateGlobalProperties(form) { cl_props["globalPropertiesJson"] = form; - return def.promise; } -function saveOpPolicyProperties(form) { - var newOpProperties = cl_props["operationalPolicies"]; - newOpProperties["0"]["configurationsJson"]= form; - - var def = $q.defer(); - var sets = []; - var svcUrl = "/restservices/clds/v2/loop/updateOperationalPolicies/" + modelName; - var svcRequest = { - loopName : modelName, - newGlobalPolicies : newOpProperties - }; - $http.post(svcUrl, svcRequest).success(function(data) { - def.resolve(data); - }).error(function(data) { - def.reject("Save Model not successful"); - }); - +function updateOpPolicyProperties(form) { cl_props["operationalPolicies"] = newOpProperties; - return def.promise; +} + +function getLoopName() { + return cl_props["name"]; } function getOperationalPolicyProperty() { return cl_props["operationalPolicies"]["0"]["configurationsJson"]; } +function getOperationalPolicies() { + return cl_props["operationalPolicies"]; +} + function getGlobalProperty() { return cl_props["globalPropertiesJson"]; } +function getMsJson(type) { + var msProperties = cl_props["microServicePolicies"]; + for (p in msProperties) { + if (msProperties[p]["name"] == type) { + return msProperties[p]; + } + } + return null; +} + function getMsProperty(type) { var msProperties = cl_props["microServicePolicies"]; for (p in msProperties) { diff --git a/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/src/main/resources/clds/camel/rest/clamp-api-v2.xml index 6b6ec458a..d4872ef45 100644 --- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml +++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml @@ -43,14 +43,14 @@ <to uri="bean:org.onap.clamp.loop.LoopController?method=updateOperationalPolicies(${header.loopName},${body})" /> </route> </post> - <post uri="/v2/loop/updateMicroservicePolicies/{loopName}" - type="com.google.gson.JsonArray" + <post uri="/v2/loop/updateMicroservicePolicy/{loopName}" + type="org.onap.clamp.policy.microservice.MicroServicePolicy" consumes="application/json" - outType="org.onap.clamp.loop.Loop" + outType="org.onap.clamp.policy.microservice.MicroServicePolicy" produces="application/json"> <route> <to uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" /> - <to uri="bean:org.onap.clamp.loop.LoopController?method=updateMicroservicePolicies(${header.loopName},${body})" /> + <to uri="bean:org.onap.clamp.loop.LoopController?method=updateMicroservicePolicy(${header.loopName},${body})" /> </route> </post> </rest> |