summaryrefslogtreecommitdiffstats
path: root/src/main/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/resources')
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html2
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js136
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js83
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js2
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js2
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/app.js37
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/propertyController.js34
7 files changed, 112 insertions, 184 deletions
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html
index 3fc1b0301..7b1b6c23b 100644
--- a/src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html
+++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/deploy_parameters.html
@@ -29,6 +29,8 @@
<div class="modal-body" style="display:block">
<div style="height: 100%;clear: both;" id="deployPropertiesDiv" name="deployPropertiesDiv" ng-init="load_deploy_parameters()" >
Deployment parameters.
+ <form id="deployForm" class="form-horizontal">
+ </form>
</div>
</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 972676b61..3dc4d003e 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js
@@ -24,84 +24,47 @@ app
.service(
'cldsModelService',
[
- 'alertService',
- '$http',
- '$q',
- '$rootScope',
- function(alertService, $http, $q, $rootScope) {
-
- function checkIfElementType(name) {
-
- //This will open the methods located in the app.js
- if (undefined == name) {
- return;
- }else if (name.toLowerCase().indexOf("policy") >= 0){
- PolicyWindow();
- } else {
- $rootScope.selectedBoxName = name;
- ToscaModelWindow();
- }
- }
- function handleQueryToBackend(def, svcAction, svcUrl, svcPayload) {
-
- $http.put(svcUrl, svcPayload).success(
- function(data) {
-
- def.resolve(data);
- if (typeof data.statusCodeValue === 'undefined'
- || data.statusCodeValue === 200) {
- alertService.alertMessage(
- "Action Successful: " + svcAction, 1)
- } else {
- if (typeof data.body !== 'undefined') {
- alertService.alertMessage("Action Failure: "
- + svcAction + ", " + data.body.errorMessageForUi, 2);
- } else {
- alertService.alertMessage("Action Failure: "
- + svcAction, 2);
- }
- def.reject(svcAction + " not successful");
- }
- }).error(
- function(data) {
-
- def.resolve(data);
- if (typeof data.body !== 'undefined') {
- alertService.alertMessage("Action Failure: " + svcAction
- + ", " + data.body.errorMessageForUi, 2);
- } else {
- alertService
- .alertMessage("Action Failure: " + svcAction, 2);
- }
- def.reject(svcAction + " not successful");
- });
- }
- this.toggleDeploy = function(uiAction, modelName, controlNamePrefixIn,
- bpmnTextIn, propTextIn, svgXmlIn,
- templateName, typeID, controlNameUuid,
- modelEventService, deploymentId) {
-
- var def = $q.defer();
- var sets = [];
- var action = uiAction.toLowerCase();
- var deployUrl = "/restservices/clds/v1/clds/" + action + "/"
- + modelName;
- var requestData = {
- name : modelName,
- controlNamePrefix : controlNamePrefixIn,
- bpmnText : bpmnTextIn,
- propText : propTextIn,
- imageText : svgXmlIn,
- templateName : templateName,
- typeId : typeID,
- controlNameUuid : controlNameUuid,
- event : modelEventService,
- deploymentId : deploymentId
- };
- handleQueryToBackend(def, action, deployUrl, requestData);
- return def.promise;
- };
- this.getModel = function(modelName) {
+ 'alertService',
+ '$http',
+ '$q',
+ '$rootScope',
+ function(alertService, $http, $q, $rootScope) {
+
+ function checkIfElementType(name) {
+ //This will open the methods located in the app.js
+ if (undefined == name) {
+ return;
+ }else if (name.toLowerCase().indexOf("policy") >= 0){
+ PolicyWindow();
+ } else {
+ $rootScope.selectedBoxName = name;
+ ToscaModelWindow();
+ }
+ }
+ this.toggleDeploy = function(uiAction, modelName) {
+ var svcAction = uiAction.toLowerCase();
+ var deployUrl = "/restservices/clds/v2/loop/" + svcAction + "Loop/" + modelName;
+ var def = $q.defer();
+ var sets = [];
+ $http.put(deployUrl).success(
+ function(data) {
+ def.resolve(data);
+ alertService.alertMessage("Action Successful: " + svcAction, 1)
+ // update deploymentID, lastUpdatedStatus
+ setLastUpdatedStatus(data.lastUpdatedStatus);
+ setDeploymentStatusURL(data.dcaeDeploymentStatusUrl);
+ setDeploymentID(data.dcaeDeploymentId);
+ setStatus();
+ enableDisableMenuOptions();
+ }).error(
+ function(data) {
+ def.resolve(data);
+ alertService.alertMessage("Action Failure: " + svcAction, 2);
+ def.reject(svcAction + " not successful");
+ });
+ return def.promise;
+ }
+ this.getModel = function(modelName) {
var def = $q.defer();
var sets = [];
var svcUrl = "/restservices/clds/v2/loop/" + modelName;
@@ -112,7 +75,6 @@ app
cl_props = data;
def.resolve(data);
}).error(function(data) {
-
def.reject("Open Model not successful");
});
return def.promise;
@@ -145,7 +107,6 @@ app
propText : propTextIn
};
$http.put(svcUrl, svcRequest).success(function(data) {
-
def.resolve(data);
}).error(function(data) {
@@ -205,27 +166,18 @@ app
return def.promise;
};
this.processActionResponse = function(modelName) {
-
- // populate control name (prefix and uuid here)
+ // populate control name (prefix and uuid here)
var headerText = "Closed Loop Modeler - " + modelName;
setStatus();
manageCLImage(modelName);
enableDisableMenuOptions();
};
- this.processRefresh = function(pars) {
-
- var newPars = pars;
- if (typeof pars.body !== 'undefined') {
- newPars = pars.body;
- }
- typeID = newPars.typeId;
- deploymentId = newPars.deploymentId;
+ this.processRefresh = function() {
setStatus();
enableDisableMenuOptions();
}
function setStatus() {
-
- var status = getStatus();
+ var status = getLastUpdatedStatus();
// apply color to status
var statusColor = 'white';
if (status.trim() === "DESIGN") {
diff --git a/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js
index 3faf9f631..138d80202 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/DeploymentCtrl.js
@@ -27,62 +27,40 @@ app
'$scope',
'$rootScope',
'$uibModalInstance',
+'$http',
+'$q',
'data',
'dialogs',
'cldsModelService',
-function($scope, $rootScope, $uibModalInstance, data, dialogs, cldsModelService) {
+function($scope, $rootScope, $uibModalInstance, $http, $q, data, dialogs, cldsModelService) {
function validate_and_set_deploy_parameters() {
- var inputList = document.getElementsByClassName("deployFormId");
- var jsonParameters = "{";
- $.each(inputList, function(key) {
- if (jsonParameters !== "{") {
- jsonParameters = jsonParameters + ",";
+ var form = $("#deployForm")[0];
+ 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;
+ }
}
- jsonParameters = jsonParameters + '"' + inputList[key].id + '":'
- + '"' + inputList[key].value + '"'
- });
- jsonParameters = jsonParameters + "}";
- try {
- // Try to validate the json
- set_deploy_parameters(JSON.parse(jsonParameters));
- } catch (e) {
- console.error("Couldn't parse deploy parameters json");
- }
- }
- function set_deploy_parameters(parameters) {
- if (!'global' in elementMap) {
- elementMap["global"] = [];
- }
- var index = elementMap["global"].findIndex(function(e) {
- return (typeof e == "object" && !(e instanceof Array))
- && "deployParameters" == e["name"];
- });
- if (index == -1) {
- elementMap["global"].push({
- "name" : "deployParameters",
- "value" : parameters
+
+ var el = getGlobalProperty();
+ el["dcaeDeployParameters"] = obj;
+ $scope.saveGlobalProperties(JSON.stringify(el)).then(function(pars) {
+ updateGlobalProperties(el);
+ }, function(data) {
});
- } else {
- elementMap["global"][index]["value"] = parameters;
- }
}
+
$scope.load_deploy_parameters = function() {
- var index = elementMap["global"].findIndex(function(e) {
- return (typeof e == "object" && !(e instanceof Array))
- && "deployParameters" == e["name"];
- });
- if (index != -1) {
- $('#deployPropertiesDiv').append($('<br/>'));
- $.each(elementMap["global"][index].value, function(key) {
- var propertyValue = elementMap["global"][index].value[key];
- $('#deployPropertiesDiv').append(
- $('<label class="control-label">' + key + ' </label>'));
- $('#deployPropertiesDiv').append(
- $(
- '<input style="width: 100%; clear: both;" class="deployFormId" id="'
+ var el = getDeploymentProperties();
+ for (var key in el) {
+ var propertyValue = el[key];
+ $('#deployForm').append(
+ $('<label for="' + key + '" class="control-label">' + key + ' </label>'));
+ $('#deployForm').append(
+ $('<input style="width: 100%; clear: both;" class="form-control" name="'
+ key + '"></input>').val(propertyValue).html(propertyValue));
- $('#deployPropertiesDiv').append($('<br/>'));
- });
}
}
$scope.deploy = function() {
@@ -92,4 +70,15 @@ function($scope, $rootScope, $uibModalInstance, data, dialogs, cldsModelService)
$scope.close = function() {
$uibModalInstance.dismiss();
};
+ $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 Global properties not successful");
+ });
+ return def.promise;
+ };
} ]);
diff --git a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js
index 655775461..8e0319c1f 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js
@@ -54,7 +54,7 @@ function($scope, $rootScope, $uibModalInstance, data, operationalPolicyService,
};
$scope.submitForm = function(obj) {
- var operationalPolicies = JSON.parse(JSON.stringify(getOperationalPolicies()));
+ var operationalPolicies = 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 1901d95e6..2ef866c8b 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/ToscaModelCtrl.js
@@ -89,7 +89,7 @@ app.controller('ToscaModelCtrl',
var policyType = $rootScope.selectedBoxName;
var data = $scope.getEditorData();
if(data !== null) {
- var msJson = JSON.parse(JSON.stringify(getMsJson(policyType)));
+ var msJson = getMsJson(policyType);
msJson["properties"] = data[0];
toscaModelService.saveMsProperties(msJson).then(function(pars) {
updateMsProperties(policyType, msJson);
diff --git a/src/main/resources/META-INF/resources/designer/scripts/app.js b/src/main/resources/META-INF/resources/designer/scripts/app.js
index b0b34533a..1b77bf82d 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/app.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/app.js
@@ -580,9 +580,8 @@ function($scope, $rootScope, $timeout, dialogs) {
var svgXml = $("#svgContainer").html();
console.log("refreStatus modelName=" + modelName);
cldsModelService.getModel(modelName).then(function(pars) {
-
console.log("refreStatus: pars=" + pars);
- cldsModelService.processRefresh(pars);
+ cldsModelService.processRefresh();
}, function(data) {
});
@@ -629,40 +628,10 @@ function($scope, $rootScope, $timeout, dialogs) {
});
};
function cldsToggleDeploy(uiAction) {
-
- var modelName = selected_model;
- var controlNamePrefix = "ClosedLoop-";
- var bpmnText = modelXML;
- // serialize model properties
- var propText = JSON.stringify(elementMap);
- var templateName = selected_template;
- var svgXml = $("#svgContainer").html();
console.log("cldsPerformAction: " + uiAction + " modelName="
- + modelName);
- console.log("cldsPerformAction: " + uiAction
- + " controlNamePrefix=" + controlNamePrefix);
- console.log("cldsPerformAction: " + uiAction + " bpmnText="
- + bpmnText);
- console.log("cldsPerformAction: " + uiAction + " propText="
- + propText);
- console.log("cldsPerformAction: " + uiAction
- + " modelEventService=" + modelEventService);
- console.log("cldsPerformAction: " + uiAction + " typeID=" + typeID);
- console.log("cldsPerformAction: " + uiAction + " deploymentId="
- + deploymentId);
- cldsModelService.toggleDeploy(uiAction, modelName,
- controlNamePrefix, bpmnText, propText, svgXml, templateName,
- typeID, controlNameUuid, modelEventService, deploymentId).then(
+ + selected_model);
+ cldsModelService.toggleDeploy(uiAction, selected_model).then(
function(pars) {
-
- var cldsObject = pars.body;
- typeID = cldsObject.typeId;
- controlNameUuid = cldsObject.controlNameUuid;
- selected_template = cldsObject.templateName;
- modelEventService = cldsObject.event;
- actionStateCd = cldsObject.event.actionStateCd;
- deploymentId = cldsObject.deploymentId;
- cldsModelService.processActionResponse(modelName, cldsObject);
}, 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 f1ab1e195..2b32f4d26 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/propertyController.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js
@@ -22,7 +22,7 @@
*/
function updateMsProperties(type, newMsProperties) {
- var newMsProperties = cl_props["microServicePolicies"];
+ var newMsProperties = JSON.parse(JSON.stringify(cl_props["microServicePolicies"]));
for (p in newMsProperties) {
if (newMsProperties[p]["name"] == type) {
cl_props["microServicePolicies"][p] = newMsProperties;
@@ -43,22 +43,26 @@ function getLoopName() {
}
function getOperationalPolicyProperty() {
- return cl_props["operationalPolicies"]["0"]["configurationsJson"];
+ return JSON.parse(JSON.stringify(cl_props["operationalPolicies"]["0"]["configurationsJson"]));
}
function getOperationalPolicies() {
- return cl_props["operationalPolicies"];
+ return JSON.parse(JSON.stringify(cl_props["operationalPolicies"]));
}
function getGlobalProperty() {
- return cl_props["globalPropertiesJson"];
+ return JSON.parse(JSON.stringify(cl_props["globalPropertiesJson"]));
+}
+
+function getDeploymentProperties() {
+ return JSON.parse(JSON.stringify(cl_props["globalPropertiesJson"]["dcaeDeployParameters"]));
}
function getMsJson(type) {
var msProperties = cl_props["microServicePolicies"];
for (p in msProperties) {
if (msProperties[p]["name"] == type) {
- return msProperties[p];
+ return JSON.parse(JSON.stringify(msProperties[p]));
}
}
return null;
@@ -68,7 +72,7 @@ function getMsProperty(type) {
var msProperties = cl_props["microServicePolicies"];
for (p in msProperties) {
if (msProperties[p]["name"] == type) {
- return msProperties[p]["properties"];
+ return JSON.parse(JSON.stringify(msProperties[p]["properties"]));
}
}
return null;
@@ -78,21 +82,33 @@ function getMsUI(type) {
var msProperties = cl_props["microServicePolicies"];
for (p in msProperties) {
if (msProperties[p]["name"] == type) {
- return msProperties[p]["jsonRepresentation"];
+ return JSON.parse(JSON.stringify(msProperties[p]["jsonRepresentation"]));
}
}
return null;
}
-function getStatus() {
+function getLastUpdatedStatus() {
return cl_props["lastComputedState"];
}
+function setLastUpdatedStatus(status) {
+ cl_props["lastComputedState"] = status;
+}
+
function getDeploymentID() {
return cl_props["dcaeDeploymentId"];
}
+function setDeploymentID(deploymentId) {
+ cl_props["dcaeDeploymentId"] = deploymentId;
+}
+
function getDeploymentStatusURL() {
return cl_props["dcaeDeploymentStatusUrl"];
}
-module.exports = { getOperationalPolicyProperty,getGlobalProperty,getMsProperty,getMsUI,getStatus,getDeploymentID,getDeploymentStatusURL }; \ No newline at end of file
+
+function setDeploymentStatusURL(deploymentStatusURL) {
+ cl_props["dcaeDeploymentStatusUrl"] = deploymentStatusURL;
+}
+module.exports = { getOperationalPolicyProperty,getGlobalProperty,getMsProperty,getMsUI,getLastUpdatedStatus,getDeploymentID,getDeploymentStatusURL }; \ No newline at end of file