diff options
author | Ittay Stern <ittay.stern@att.com> | 2019-04-11 12:01:41 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-04-11 12:01:42 +0000 |
commit | 61ef90b0912bdd6a7cf7169d46c4c2aa7156742f (patch) | |
tree | 63bf88d27a8be262222f225921e866eacbecefb4 /vid-app-common/src/main/webapp | |
parent | 526efd6589d8e22f46bd0ec8e5ed41cbb3970ca7 (diff) | |
parent | 24c4f394f7f8c8399e4fdc583e82df89489f64d5 (diff) |
Merge "modify local workflow parameters to much native ones"
Diffstat (limited to 'vid-app-common/src/main/webapp')
3 files changed, 44 insertions, 37 deletions
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 246834cdd..c6a5b31af 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 @@ -243,9 +243,9 @@ } }else if(workflowType=="VNF In Place Software Update"){ var payloadObj = { - 'existing_software_version':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'Existing software version').value, - 'new_software_version':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'New software version').value, - 'operations_timeout':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'Operations timeout').value + 'existing_software_version':vm.getInternalWorkFlowParameter(workflowType, 'text', 'Existing software version').value, + 'new_software_version':vm.getInternalWorkFlowParameter(workflowType, 'text', 'New software version').value, + 'operations_timeout':vm.getInternalWorkFlowParameter(workflowType, 'text', 'Operations timeout').value }; requestParametersData = { payload: JSON.stringify(payloadObj) @@ -274,9 +274,9 @@ }else if(workflowType=="VNF In Place Software Update"){ var payloadObj = { - 'existing_software_version':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'Existing software version').value, - 'new_software_version':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'New software version').value, - 'operations_timeout':vm.getInternalWorkFlowParameter(workflowType, 'STRING', 'Operations timeout').value + 'existing_software_version':vm.getInternalWorkFlowParameter(workflowType, 'text', 'Existing software version').value, + 'new_software_version':vm.getInternalWorkFlowParameter(workflowType, 'text', 'New software version').value, + 'operations_timeout':vm.getInternalWorkFlowParameter(workflowType, 'text', 'Operations timeout').value }; requestParametersData = { payload: JSON.stringify(payloadObj) @@ -305,7 +305,7 @@ requestInfo: requestInfoData, relatedInstanceList: [], requestParameters:requestParametersData, - configurationParameters: JSON.parse(vm.getInternalWorkFlowParameter("VNF Scale Out", "STRING", "Configuration Parameters").value) + configurationParameters: JSON.parse(vm.getInternalWorkFlowParameter("VNF Scale Out", "text", "Configuration Parameters").value) }; requestInfoData.instanceName = vnf.name + "_" + (moduleToScale.currentCount + 1); }else{ @@ -428,10 +428,16 @@ }; vm.executeWorkflow = function () { - if (vm.localWorkflows && vm.localWorkflows.length > 0) { + if ( vm.localWorkflows && vm.localWorkflows.length > 0 ) { vm.triggerLocalWorkflow(); } else { - vm.triggerRemoteWorkflow(); + let source = vm.getRemoteWorkflowSource(vm.changeManagement.workflow); + if( source === "NATIVE"){ + vm.localWorkflowsParameters = vm.remoteWorkflowsParameters; + vm.triggerLocalWorkflow(); + }else { + vm.triggerRemoteWorkflow(); + } } }; @@ -726,12 +732,7 @@ vm.loadLocalWorkFlowParameters = function (workflow) { changeManagementService.getLocalWorkflowParameter(workflow) .then(function (response) { - let fileParameters = response.data.parameterDefinitions.filter(item => item.type === 'FILE'); - let textParameters = response.data.parameterDefinitions.filter(item => item.type === 'STRING'); - let parameters = new Map(); - parameters.set('FILE', fileParameters); - parameters.set('STRING', textParameters); - vm.localWorkflowsParameters.set(workflow, parameters); + vm.localWorkflowsParameters.set(workflow, response.data.parameterDefinitions); }) .catch(function (error) { $log.error(error); @@ -762,6 +763,8 @@ workflowParams.pattern = validation.allowableChars; } } + workflowParams.type = param.inputType; + parameters.push(workflowParams); } ); @@ -787,18 +790,22 @@ }; vm.getInternalWorkFlowParameters = function (workflow, type) { - if (workflow && vm.localWorkflowsParameters.has(workflow) && vm.localWorkflowsParameters.get(workflow).has(type)) { - return vm.localWorkflowsParameters.get(workflow).get(type) + if (workflow && vm.localWorkflowsParameters.has(workflow) && vm.localWorkflowsParameters.get(workflow).filter(parameter => parameter.type==type) != []) { + return vm.localWorkflowsParameters.get(workflow).filter(parameter => parameter.type==type) } return []; }; vm.getInternalWorkFlowParameter = function (workflow, type, parameterName) { - if (workflow && vm.localWorkflowsParameters.has(workflow) && vm.localWorkflowsParameters.get(workflow).has(type)) { - return vm.localWorkflowsParameters.get(workflow).get(type).filter(parameter => parameter.name === parameterName)[0] + if (workflow && vm.localWorkflowsParameters.has(workflow) && vm.localWorkflowsParameters.get(workflow).filter(parameter => parameter.type==type) != []) { + return vm.localWorkflowsParameters.get(workflow).filter(parameter => parameter.type==type).filter(parameter => parameter.name === parameterName)[0] } }; + vm.getRemoteWorkflowSource = (workflow) => { + return vm.getCachedWorkflowDetails(workflow)[0].source; + }; + vm.getCachedWorkflowDetails = function (workflow) { return vm.remoteWorkflows.filter( function (remoteWorkflow) { return remoteWorkflow.name === workflow; 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 5989ffdd6..afc643993 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 @@ -33,6 +33,7 @@ describe('Testing workFlows from SO', () => { beforeEach(inject(function (_$controller_) { $notNeeded = jestMock.fn(); + // mock ChangeManagementService $changeManagementService = jestMock.fn(); $changeManagementService.getAllSDCServices = jestMock.fn(() => Promise.resolve([])); @@ -92,7 +93,7 @@ describe('Testing workFlows from SO', () => { "id": 1, "name": "Configuration Parameters", "required": true, - "type": "STRING", + "type": "text", "pattern": ".*", "msgOnPatternError": null, "msgOnContentError": null, @@ -168,7 +169,8 @@ describe('Testing workFlows from SO', () => { "id": "new_software_version", "soFieldName": "new_software_version", "maxLength": '500', - "pattern": '.*' + "pattern": '.*', + "type": "text" }]] ])); }); @@ -181,9 +183,9 @@ describe('Testing workFlows from SO', () => { let getLocalWorkflowsParametersStub = Promise.resolve({"data": {}}); 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]*"}]}}); + {"id": 1, "name": "parameter 1", "required": true, "type": "text", "pattern": "[0-9]*"}, + {"id": 2, "name": "parameter 2", "required": true, "type": "text", "pattern": ".*"}, + {"id": 3, "name": "parameter 3", "required": false, "type": "text", "pattern": "[0-9]*"}]}}); $controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}]; $changeManagementService.getWorkflows = () => getWorkflowsStub; @@ -208,7 +210,7 @@ describe('Testing workFlows from SO', () => { "id": 1, "name": "Configuration Parameters", "required": true, - "type": "STRING", + "type": "text", "pattern": ".*", "msgOnPatternError": null, "msgOnContentError": null, @@ -223,9 +225,7 @@ describe('Testing workFlows from SO', () => { // when let result = new Map(); - const scaleOutResult = new Map(); - scaleOutResult.set("FILE", []); - scaleOutResult.set("STRING", [ + const scaleOutResult = [ { "acceptableFileType": null, "id": 1, @@ -234,9 +234,9 @@ describe('Testing workFlows from SO', () => { "name": "Configuration Parameters", "pattern": ".*", "required": true, - "type": "STRING", + "type": "text", } - ]); + ]; result.set("VNF Scale Out", scaleOutResult); return $controller.loadWorkFlows() @@ -268,7 +268,7 @@ describe('Testing workFlows from SO', () => { "id": 1, "name": "Configuration Parameters", "required": true, - "type": "STRING", + "type": "text", "pattern": ".*", "msgOnPatternError": null, "msgOnContentError": null, @@ -283,7 +283,7 @@ describe('Testing workFlows from SO', () => { // when return $controller.loadWorkFlows() .then(() => { - let internalWorkFlowParameters = $controller.getInternalWorkFlowParameters("NON-EXISTENT WF", "STRING"); + let internalWorkFlowParameters = $controller.getInternalWorkFlowParameters("NON-EXISTENT WF", "text"); expect(internalWorkFlowParameters).toEqual([]); }); }); @@ -298,7 +298,7 @@ describe('Testing workFlows from SO', () => { "id": 1, "name": "Configuration Parameters", "required": true, - "type": "STRING", + "type": "text", "pattern": ".*", "msgOnPatternError": null, "msgOnContentError": null, @@ -328,7 +328,7 @@ describe('Testing workFlows from SO', () => { "id": 1, "name": "Configuration Parameters", "required": true, - "type": "STRING", + "type": "text", "pattern": ".*", "msgOnPatternError": null, "msgOnContentError": null, @@ -348,12 +348,12 @@ describe('Testing workFlows from SO', () => { "name": "Configuration Parameters", "pattern": ".*", "required": true, - "type": "STRING", + "type": "text", }]; // when return $controller.loadWorkFlows() .then(() => { - let internalWorkFlowParameters = $controller.getInternalWorkFlowParameters("VNF Scale Out", "STRING"); + let internalWorkFlowParameters = $controller.getInternalWorkFlowParameters("VNF Scale Out", "text"); expect(internalWorkFlowParameters).toEqual(result); }); }); 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 a5a6d1610..1c91ba5e9 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 @@ -90,7 +90,7 @@ <label id="errorContentLabel" class="icon-alert error" ng-if="item.value.$error.validateAsyncFn">{{item.msgOnContentError}}</label> </div> - <div class="form-group" ng-if="vm.changeManagement.workflow" ng-repeat="item in vm.getInternalWorkFlowParameters(vm.changeManagement.workflow, 'STRING')"> + <div class="form-group" ng-if="vm.changeManagement.workflow" ng-repeat="item in vm.getInternalWorkFlowParameters(vm.changeManagement.workflow, 'text')"> <label for="internal-workflow-parameter-text-{{item.id}}" class="control-label">{{item.name}}</label> <input ng-model="item.value" type="text" id="internal-workflow-parameter-text-{{item.id}}" pattern="{{item.pattern}}" ng-required="{{item.required}}"> </div> |