aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorxg353y <xg353y@intl.att.com>2019-03-15 15:06:25 +0100
committerxg353y <xg353y@intl.att.com>2019-03-15 16:17:53 +0100
commit7fc8fd594dddbd079fcb8419f658e08620eb38c7 (patch)
treead4e98e197943668d305bcc265e46ed61d89b161 /src
parent2e4242e58dbc659e11df212115b9c8827d548167 (diff)
Rework UI
Fix bugs due to the data model change Issue-ID: CLAMP-318 Change-Id: If3750505a5f496caae61c01c2179e058e79eba52 Signed-off-by: xg353y <xg353y@intl.att.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java3
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js2
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/ImportSchemaCtrl.js2
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js11
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/ToscaModelService.js2
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/propertyController.js6
-rw-r--r--src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java2
7 files changed, 14 insertions, 14 deletions
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 c316f1f5d..ee9ba5370 100644
--- a/src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java
+++ b/src/main/java/org/onap/clamp/policy/microservice/MicroservicePolicyService.java
@@ -57,6 +57,7 @@ public class MicroservicePolicyService implements PolicyService<MicroServicePoli
return repository.existsById(policyName);
}
+ @Transactional
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(),
@@ -65,7 +66,7 @@ public class MicroservicePolicyService implements PolicyService<MicroServicePoli
private MicroServicePolicy updateMicroservicePolicyProperties(MicroServicePolicy oldPolicy,
MicroServicePolicy newPolicy, Loop loop) {
- oldPolicy.setJsonRepresentation(newPolicy.getJsonRepresentation());
+ oldPolicy.setProperties(newPolicy.getProperties());
if (oldPolicy.getUsedByLoops().contains(loop)) {
oldPolicy.getUsedByLoops().add(loop);
}
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 097235fa1..972676b61 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js
@@ -38,7 +38,7 @@ app
}else if (name.toLowerCase().indexOf("policy") >= 0){
PolicyWindow();
} else {
- $rootScope.selectedBoxName = name.toLowerCase();
+ $rootScope.selectedBoxName = name;
ToscaModelWindow();
}
}
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 5dae2dc19..e2f1913d0 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/ImportSchemaCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/ImportSchemaCtrl.js
@@ -283,7 +283,7 @@ function($scope, $rootScope, $uibModalInstance, data, svnservice, fileUpload,
};
$scope.submitForm = function(obj) {
- var operationalPolicies = getOperationalPolicies();
+ var operationalPolicies = JSON.parse(JSON.stringify(getOperationalPolicies()));
if (obj !== null) {
operationalPolicies[0]["configurationsJson"] = obj;
}
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 d287f3d78..129c5d984 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
@@ -64,7 +64,7 @@ app.controller('ToscaModelCtrl',
if($rootScope.selectedBoxName) {
var policyType = $rootScope.selectedBoxName.split('_')[0].toLowerCase();
$scope.toscaModelName = policyType.toUpperCase() + " Microservice";
- $scope.jsonByPolicyType(policyType, '', '');
+ $scope.jsonByPolicyType($rootScope.selectedBoxName, '', '');
}
});
@@ -88,12 +88,11 @@ app.controller('ToscaModelCtrl',
$scope.saveToscaProps = function(){
var policyType = $rootScope.selectedBoxName;
var data = $scope.getEditorData();
-
if(data !== null) {
- var msJson = getMsJson(policyType);
- msJson["properties"] = data;
- cldsModelService.saveMsProperties(msJson).then(function(pars) {
- saveMsProperties(policyType, data);
+ var msJson = JSON.parse(JSON.stringify(getMsJson(policyType)));
+ msJson["properties"] = data[0];
+ toscaModelService.saveMsProperties(msJson).then(function(pars) {
+ updateMsProperties(policyType, msJson);
}, function(data) {
});
if($scope.editor) { $scope.editor.destroy(); $scope.editor = null; }
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 222c2c96a..ad864a04c 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelService.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelService.js
@@ -39,7 +39,7 @@ app.service('toscaModelService', ['alertService','$http', '$q', '$rootScope', fu
this.saveMsProperties = function(form) {
var loopName = getLoopName();
var def = $q.defer();
- var svcUrl = "/restservices/clds/v2/loop/updateMicroservicePolicies/" + loopName;
+ var svcUrl = "/restservices/clds/v2/loop/updateMicroservicePolicy/" + loopName;
$http.post(svcUrl, form).success(function(data) {
def.resolve(data);
}).error(function(data) {
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 9b236565d..044b21eca 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/propertyController.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js
@@ -21,11 +21,11 @@
*
*/
-function saveMsProperties(type, form) {
- var newMsProperties = cl_props["microServicePolicies"];
+function updateMsProperties(type, form) {
+ var newMsProperties = cl_props["microServicePolicies"];
for (p in newMsProperties) {
if (newMsProperties[p]["name"] == type) {
- newMsProperties[p]["properties"] = form;
+ cl_props["microServicePolicies"][p] = form;
}
}
}
diff --git a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
index d247344a6..4011a7867 100644
--- a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
+++ b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java
@@ -149,7 +149,7 @@ public class LoopServiceTestItCase {
newJsonRepresentation, null);
//when
- firstMicroServicePolicy.setJsonRepresentation(newJsonRepresentation);
+ firstMicroServicePolicy.setProperties(JsonUtils.GSON.fromJson("{\"name1\":\"value1\"}", JsonObject.class));
Loop actualLoop = loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME,
Lists.newArrayList(firstMicroServicePolicy, secondMicroServicePolicy));