diff options
Diffstat (limited to 'vid-app-common/src/main/webapp')
5 files changed, 72 insertions, 9 deletions
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js index 8ee2d062c..dff51ee2b 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js @@ -116,6 +116,7 @@ appDS2 CHANGE_MANAGEMENT_OPERATION_NO_SCHEDULER: "change-management/workflow/@vnfName", GET_WORKFLOW: "change-management/get_vnf_workflow_relation", GET_SO_WORKFLOWS: "workflows-management/workflows", + GET_SO_WORKFLOW_PARAMETER: "workflows-management/workflow-parameters/@workflowID", GET_MSO_WORKFLOWS: "change-management/mso", GET_SCHEDULER_CHANGE_MANAGEMENTS: "change-management/scheduler", CANCEL_SCHEDULE_REQUEST: "change-management/scheduler/schedules", diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js index 11f5cd6e5..c85f0fc55 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js @@ -43,6 +43,7 @@ var init = function () { vm.changeManagement = {}; + vm.changeManagement.workflowParameters = new Map(); loadServicesCatalog(); fetchAttUid().then(registerVNFNamesWatcher); @@ -619,11 +620,13 @@ vm.loadWorkFlows = function () { // Should be corrected when VID-397 will be closed. At the moment there is a need // to merge local and remote workflows not to broke current functionality. - return vm.loadLocalWorkFlows() - .then(vm.loadRemoteWorkFlows) - .then(function () { - vm.workflows = vm.localWorkflows.concat(vm.remoteWorkflows.map(item => item.name)); - }); + return vm.loadLocalWorkFlows() + .then(vm.loadRemoteWorkFlows) + .then(function () { + vm.workflows = vm.localWorkflows.concat(vm.remoteWorkflows.map(item => item.name)); + }).then(function () { + vm.loadRemoteWorkFlowsParameters(); + }); }; vm.loadLocalWorkFlows = function () { @@ -645,6 +648,30 @@ }); }; + vm.loadRemoteWorkFlowsParameters = function () { + vm.remoteWorkflowsParameters = new Map(); + vm.remoteWorkflows.forEach(function(workflow) { + vm.loadRemoteWorkFlowParameters(workflow); + }); + }; + + vm.loadRemoteWorkFlowParameters = function (workflow) { + changeManagementService.getSOWorkflowParameter(workflow.id) + .then(function (response) { + vm.remoteWorkflowsParameters.set(workflow.name, response.data.parameterDefinitions); + }) + .catch(function (error) { + $log.error(error); + }); + }; + + vm.getRemoteWorkFlowParameters = function (workflow) { + if (workflow && vm.remoteWorkflowsParameters.has(workflow)) { + return vm.remoteWorkflowsParameters.get(workflow) + } + return []; + }; + //Must be $scope because we bind to the onchange of the html (cannot attached to vm variable). $scope.selectFileForVNFName = function (fileInput) { if (fileInput && fileInput.id) { @@ -669,11 +696,11 @@ vm.isConfigUpdate = function () { return vm.changeManagement.workflow === COMPONENT.WORKFLOWS.vnfConfigUpdate; - } + }; vm.isScaleOut = function () { return vm.changeManagement.workflow === COMPONENT.WORKFLOWS.vnfScaleOut; - } + }; vm.shouldShowVnfInPlaceFields = function () { return vm.changeManagement.workflow === COMPONENT.WORKFLOWS.vnfInPlace; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js index c4b940641..7f21ddaf5 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js @@ -50,7 +50,7 @@ describe('Testing workFlows from SO', () => { // when return $controller.loadRemoteWorkFlows() .then(() => { - remoteWorkflows = $controller.remoteWorkflows.map(item => item.name) + remoteWorkflows = $controller.remoteWorkflows.map(item => item.name); expect(remoteWorkflows).toContain('workflow 1'); expect(remoteWorkflows).toContain('workflow 2'); } @@ -61,10 +61,12 @@ describe('Testing workFlows from SO', () => { // given let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}}); let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 1"}, {"id": "2", "name": "workflow 2"}]}); + let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": []}}); $controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}]; $changeManagementService.getWorkflows = () => getWorkflowsStub; $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub; + $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub; // when return $controller.loadWorkFlows().then(() => { expect($controller.workflows).toContain('workflow 0'); @@ -73,6 +75,29 @@ describe('Testing workFlows from SO', () => { }); }); + test('Verify load workflows will call load workflows parameters from SO', () => { + // given + let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}}); + let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 0"}]}); + let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": [ + {"id": 1, "name": "parameter 1", "required": true, "type": "STRING", "pattern": "[0-9]*"}, + {"id": 2, "name": "parameter 2", "required": true, "type": "STRING", "pattern": ".*"}, + {"id": 3, "name": "parameter 3", "required": false, "type": "STRING", "pattern": "[0-9]*"}]}}); + + $controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}]; + $changeManagementService.getWorkflows = () => getWorkflowsStub; + $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub; + $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub; + // when + return $controller.loadWorkFlows() + .then(() => { + expect($controller.remoteWorkflowsParameters).toEqual(new Map([["workflow 0", + [{"id": 1, "name": "parameter 1", "pattern": "[0-9]*", "required": true, "type": "STRING"}, + {"id": 2, "name": "parameter 2", "pattern": ".*", "required": true, "type": "STRING"}, + {"id": 3, "name": "parameter 3", "pattern": "[0-9]*", "required": false, "type": "STRING"}]]])); + }); + }); + test('Verify broken SO workflows wont change content of local workflows', () => { // given let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}}); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html index 21f9c5d3f..f83a267dc 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html @@ -86,7 +86,10 @@ <label class="control-label">New software version</label> <input class="form-control" ng-model="vm.changeManagement.newSoftwareVersion" name="newSoftwareVersion" type="text" id="new-software-version" pattern="{{vm.softwareVersionRegex}}" required> </div> - + </div> + <div class="form-group" ng-if="vm.changeManagement.workflow" ng-repeat="item in vm.getRemoteWorkFlowParameters(vm.changeManagement.workflow)"> + <label for="so-workflow-parameter-{{item.id}}" class="control-label">{{item.name}}</label> + <input class="form-control" ng-model="item.value" type="text" id="so-workflow-parameter-{{item.id}}" pattern="{{item.pattern}}" ng-required="{{item.required}}"> </div> </div> diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js index 699868477..38b85f973 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js @@ -30,6 +30,13 @@ }); }; + this.getSOWorkflowParameter = function (workflowID){ + return $http.get(COMPONENT.GET_SO_WORKFLOW_PARAMETER.replace('@workflowID', workflowID)) + .success(function (response) { + return {data: response.parameterDefinitions} + }); + }; + this.getMSOChangeManagements = function() { var deferred = $q.defer(); |