aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSébastien Determe <sebastien.determe@intl.att.com>2019-03-15 07:28:02 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-15 07:28:02 +0000
commit00c267ab4f48207a0f129235e67a4f2e1d154408 (patch)
tree1943b8873962feae2c4f65e87e71ad3cc9e2bd25 /src
parentf02fc13f2a5b1680fc39740e5e0a429641a5698a (diff)
parentec7f47aacc6c124d8d2e01416e80e2278b427be8 (diff)
Merge "Rework UI"
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopController.java4
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopService.java7
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java23
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/PolicyWindow_properties.html5
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/global_properties.html4
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js3
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/CldsOpenModelCtrl.js2
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/GlobalPropertiesCtrl.js46
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/ImportSchemaCtrl.js12
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js17
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/ToscaModelService.js12
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/importSchemaService.js12
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/menuHandler.js2
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/propertyController.js67
-rw-r--r--src/main/resources/clds/camel/rest/clamp-api-v2.xml8
15 files changed, 132 insertions, 92 deletions
diff --git a/src/main/java/org/onap/clamp/loop/LoopController.java b/src/main/java/org/onap/clamp/loop/LoopController.java
index 2bcce1e37..8b64e9d70 100644
--- a/src/main/java/org/onap/clamp/loop/LoopController.java
+++ b/src/main/java/org/onap/clamp/loop/LoopController.java
@@ -75,6 +75,10 @@ public class LoopController {
return loopService.updateAndSaveGlobalPropertiesJson(loopName, globalProperties);
}
+ public MicroServicePolicy updateMicroservicePolicy(String loopName, MicroServicePolicy newMicroservicePolicy) {
+ return loopService.updateMicroservicePolicy(loopName, newMicroservicePolicy);
+ }
+
public String getSVGRepresentation(String loopName) {
return loopService.getClosedLoopModelSVG(loopName);
diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java
index cf2f4c669..051ab6ed6 100644
--- a/src/main/java/org/onap/clamp/loop/LoopService.java
+++ b/src/main/java/org/onap/clamp/loop/LoopService.java
@@ -86,6 +86,13 @@ public class LoopService {
return loopsRepository.save(loop);
}
+ MicroServicePolicy updateMicroservicePolicy(String loopName, MicroServicePolicy newMicroservicePolicy) {
+ Loop loop = findClosedLoopByName(loopName);
+ MicroServicePolicy newPolicies = microservicePolicyService
+ .getAndUpdateMicroServicePolicy(loop, newMicroservicePolicy);
+ return newPolicies;
+ }
+
private Loop updateOperationalPolicies(Loop loop, List<OperationalPolicy> newOperationalPolicies) {
Set<OperationalPolicy> newPolicies = operationalPolicyService
.updatePolicies(loop, newOperationalPolicies);
diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java b/src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java
index 91794b754..c316f1f5d 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java
@@ -24,11 +24,13 @@
package org.onap.clamp.policy.microservice;
import com.google.common.collect.Sets;
+
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
-import org.onap.clamp.policy.PolicyService;
+
import org.onap.clamp.loop.Loop;
+import org.onap.clamp.policy.PolicyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -45,12 +47,8 @@ public class MicroservicePolicyService implements PolicyService<MicroServicePoli
@Override
@Transactional
- public Set<MicroServicePolicy> updatePolicies(Loop loop,
- List<MicroServicePolicy> newMicroservicePolicies) {
- return newMicroservicePolicies
- .stream()
- .map(policy ->
- getAndUpdateMicroServicePolicy(loop, policy))
+ public Set<MicroServicePolicy> updatePolicies(Loop loop, List<MicroServicePolicy> newMicroservicePolicies) {
+ return newMicroservicePolicies.stream().map(policy -> getAndUpdateMicroServicePolicy(loop, policy))
.collect(Collectors.toSet());
}
@@ -59,13 +57,10 @@ public class MicroservicePolicyService implements PolicyService<MicroServicePoli
return repository.existsById(policyName);
}
- private MicroServicePolicy getAndUpdateMicroServicePolicy(Loop loop, MicroServicePolicy policy) {
- return repository
- .findById(policy.getName())
- .map(p -> updateMicroservicePolicyProperties(p, policy, loop))
- .orElse(new MicroServicePolicy(policy.getName(), policy.getPolicyTosca(),
- policy.getShared(), policy.getJsonRepresentation(),
- Sets.newHashSet(loop)));
+ public MicroServicePolicy getAndUpdateMicroServicePolicy(Loop loop, MicroServicePolicy policy) {
+ return repository.findById(policy.getName()).map(p -> updateMicroservicePolicyProperties(p, policy, loop))
+ .orElse(new MicroServicePolicy(policy.getName(), policy.getPolicyTosca(), policy.getShared(),
+ policy.getJsonRepresentation(), Sets.newHashSet(loop)));
}
private MicroServicePolicy updateMicroservicePolicyProperties(MicroServicePolicy oldPolicy,
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>