From bc753dfd1a7eeccecd34763674653d319b822f2b Mon Sep 17 00:00:00 2001 From: xg353y Date: Thu, 9 May 2019 11:41:30 +0200 Subject: Fix the loop log issue Fix the issue where loop log doesn't refresh in UI on time; update the Refresh Status menu to point to the correct url Issue-ID: CLAMP-360 Change-Id: I65064e8f3fe16beea4cb397f66d8e871db17f77d Signed-off-by: xg353y --- .../resources/designer/scripts/CldsModelService.js | 31 ++++++++++++---------- .../META-INF/resources/designer/scripts/app.js | 15 +++++++---- .../designer/scripts/propertyController.js | 2 +- .../resources/clds/camel/rest/clamp-api-v2.xml | 6 +++-- 4 files changed, 32 insertions(+), 22 deletions(-) (limited to 'src/main') 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 38cdc9388..a75326de1 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js +++ b/src/main/resources/META-INF/resources/designer/scripts/CldsModelService.js @@ -51,10 +51,10 @@ app def.resolve(data); alertService.alertMessage("Action Successful: " + svcAction, 1) // update deploymentID, lastUpdatedStatus - setLastUpdatedStatus(data.lastUpdatedStatus); + setLastComputedState(data.lastComputedState); setDeploymentStatusURL(data.dcaeDeploymentStatusUrl); setDeploymentID(data.dcaeDeploymentId); - setStatus(); + setStatus(data.lastComputedState); enableDisableMenuOptions(); }).error( function(data) { @@ -70,6 +70,7 @@ app var svcUrl = "/restservices/clds/v2/loop/" + modelName; $http.get(svcUrl).success(function(data) { cl_props = data; + setStatus(data.lastComputedState); def.resolve(data); }).error(function(data) { def.reject("Open Model not successful"); @@ -100,11 +101,9 @@ app def.resolve(data); alertService.alertMessage("Action Successful: " + svcAction, 1) // update deploymentID, lastUpdatedStatus - setLastUpdatedStatus(data.lastUpdatedStatus); + setLastComputedState(data.lastComputedState); setDeploymentStatusURL(data.dcaeDeploymentStatusUrl); setDeploymentID(data.dcaeDeploymentId); - setStatus(); - enableDisableMenuOptions(); }).error( function(data) { def.resolve(data); @@ -139,23 +138,30 @@ app this.processActionResponse = function(modelName) { // populate control name (prefix and uuid here) $("#loop_name").text(getLoopName()); - setStatus(); manageCLImage(modelName); enableDisableMenuOptions(); }; - this.processRefresh = function() { - setStatus(); + this.refreshStatus = function(modelName) { + var def = $q.defer(); + var sets = []; + var svcUrl = "/restservices/clds/v2/loop/getstatus/" + modelName; + $http.get(svcUrl).success(function(data) { + setStatus(data.lastComputedState); + def.resolve(data); + }).error(function(data) { + def.reject("Refresh Status not successful"); + }); + return def.promise; enableDisableMenuOptions(); } - function setStatus() { - var status = getLastUpdatedStatus(); + function setStatus(status) { // apply color to status var statusColor = 'white'; if (status.trim() === "DESIGN") { statusColor = 'gray' } else if (status.trim() === "DISTRIBUTED") { statusColor = 'blue' - } else if (status.trim() === "ACTIVE") { + } else if (status.trim() === "SUBMITTED") { statusColor = 'green' } else if (status.trim() === "STOPPED") { statusColor = 'red' @@ -180,7 +186,6 @@ app 'Status: ' + statusMsg + ''); } - function manageCLImage(modelName) { getModelImage(modelName).then(function(pars) { var svg = pars; @@ -200,8 +205,6 @@ app } enableDisableMenuOptions = function() { enableDefaultMenu(); - //var status = getStatus(); - //enableActionMenu(status); enableAllActionMenu(); } getModelImage = function(modelName) { 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 323cffc1e..5597bd992 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/app.js +++ b/src/main/resources/META-INF/resources/designer/scripts/app.js @@ -505,17 +505,18 @@ function($scope, $rootScope, $timeout, dialogs) { cldsModelService.processAction(uiAction, modelName).then(function(pars) { console.log("cldsPerformAction: pars=" + pars); - $rootScope.refreshLoopLog(); + cldsModelService.getModel(modelName).then(function(pars) { + $rootScope.refreshLoopLog(); + }, function(data) { + }); }, function(data) { - }); }; $scope.refreshStatus = function() { var modelName = selected_model; console.log("refreStatus modelName=" + modelName); - cldsModelService.getModel(modelName).then(function(pars) { + cldsModelService.refreshStatus(modelName).then(function(pars) { console.log("refreStatus: pars=" + pars); - cldsModelService.processRefresh(); }, function(data) { }); @@ -566,9 +567,13 @@ function($scope, $rootScope, $timeout, dialogs) { + selected_model); cldsModelService.toggleDeploy(uiAction, selected_model).then( function(pars) { + cldsModelService.getModel(selected_model).then(function(pars) { + $rootScope.refreshLoopLog(); + }, function(data) { + }); }, function(data) { - }); + } $scope.ToscaModelWindow = function (tosca_model) { 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 ee602b993..994e4a765 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/propertyController.js +++ b/src/main/resources/META-INF/resources/designer/scripts/propertyController.js @@ -94,7 +94,7 @@ function getLastUpdatedStatus() { return cl_props["lastComputedState"]; } -function setLastUpdatedStatus(status) { +function setLastComputedState(status) { cl_props["lastComputedState"] = status; } 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 4d3c6b389..0d6d3cb2f 100644 --- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml +++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml @@ -605,8 +605,6 @@ message="Get Status request successfully executed. The new state is: ${body}" /> - @@ -622,6 +620,10 @@ + + + -- cgit 1.2.3-korg