summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/webapp
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-09-22 20:04:28 +0300
committerIttay Stern <ittay.stern@att.com>2019-09-23 12:48:51 +0300
commit9a2cd4170c33326dc6a0829675fa4cef231efdd9 (patch)
tree06b2ec4c6d9722e1a1ebf52f60cd632f35f40ebb /vid-app-common/src/main/webapp
parent5a824bbfbe95afd3b1fbaae8c029a8b4c5ad5401 (diff)
Change-management: provide and use scheduler's fields through vm.scheduleWorkflow()
In addition, show error message when no Portal-frame. Use the dumped data to revive ChangeManagementTest tests by capturing the error's payload. Issue-ID: VID-397 Change-Id: I978bf537c43b0e3933e82c761c60cd067ab2cf27 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/main/webapp')
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js46
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js17
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.html18
3 files changed, 60 insertions, 21 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 28b3eea5d..f70d6250e 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
@@ -225,7 +225,7 @@
$uibModalInstance.close();
};
- vm.uploadConfigFile = function (file) {
+ vm.uploadConfigFile = function (file, item) {
var defer = $q.defer();
Upload.upload({
url: "change-management/uploadConfigUpdateFile",
@@ -235,7 +235,7 @@
}]
})
.then(function (configUpdateResponse) {
- vm.getInternalWorkFlowParameter("VNF Config Update", "FILE", "Attach configuration file").value = configUpdateResponse && JSON.parse(configUpdateResponse.data).payload;
+ item.value = configUpdateResponse && JSON.parse(configUpdateResponse.data).payload;
defer.resolve(true);
})
.catch(function (error) {
@@ -443,6 +443,19 @@
}
};
+ vm.collectWorkflowFieldsValues = function () {
+ /**
+ * Transforms items with name and value properties, to associative map, e.g the array
+ * [{name: foo, value: bar}, {name: baz, value: fiz}] will become the object {foo: bar, baz: fiz}
+ */
+ return vm.getAllInternalWorkFlowParameters(
+ vm.changeManagement.workflow
+ ).reduce(function (result, item) {
+ result[item.name] = item.value;
+ return result;
+ }, {});
+ };
+
vm.scheduleWorkflow = function () {
$scope.widgetParameter = ""; // needed by the scheduler?
@@ -456,11 +469,18 @@
}
var data = {
widgetName: 'Portal-Common-Scheduler',
- widgetData: vm.changeManagement,
+ widgetData: Object.assign({}, vm.changeManagement, vm.collectWorkflowFieldsValues()),
widgetParameter: $scope.widgetParameter
};
- window.parent.postMessage(data, VIDCONFIGURATION.SCHEDULER_PORTAL_URL);
+ console.log("vm.scheduleWorkflow data:", data);
+
+ if (window.parent !== window.self) {
+ window.parent.postMessage(data, VIDCONFIGURATION.SCHEDULER_PORTAL_URL);
+ } else {
+ vm.errorMsg = {message: "Portal not found. Cannot send: " + JSON.stringify(data)};
+ throw vm.errorMsg; // prevent popup closure
+ }
};
vm.executeWorkflow = function () {
@@ -856,21 +876,23 @@
return form[itemName].$error.validateAsyncFn;
};
- vm.getIdFor = function (type, id, name) {
- return "internal-workflow-parameter-" + type + "-" + id + "-" + (name ? name.split(' ').join('-').toLowerCase() : "");
+ vm.getIdFor = function (type, item) {
+ return "internal-workflow-parameter-" + type + "-" + item.id + "-" + (item.displayName ? item.displayName.split(' ').join('-').toLowerCase() : "");
};
- vm.getInternalWorkFlowParameters = function (workflow, 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);
+ vm.getAllInternalWorkFlowParameters = function (workflow) {
+ if (workflow && vm.localWorkflowsParameters.has(workflow) && vm.localWorkflowsParameters.get(workflow)) {
+ return vm.localWorkflowsParameters.get(workflow);
}
return [];
};
+ vm.getInternalWorkFlowParameters = function (workflow, type) {
+ return vm.getAllInternalWorkFlowParameters(workflow).filter(parameter => parameter.type === type);
+ };
+
vm.getInternalWorkFlowParameter = function (workflow, type, parameterName) {
- 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]
- }
+ return vm.getInternalWorkFlowParameters(workflow, type).filter(parameter => parameter.displayName === parameterName)[0];
};
vm.getRemoteWorkflowSource = (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 675c1b7c0..e8cba4aa8 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
@@ -318,6 +318,23 @@ describe('Testing workFlows from SO', () => {
});
});
+ test('Verify get internal workflow parameters should return an empty list if type exist but mapped to undefined', () => {
+ // given
+ $featureFlags.isOn = jestMock.fn(() => false);
+ let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}});
+ let getLocalWorkflowsParametersStub = Promise.resolve({"data": undefined});
+
+ $controller.changeManagement.vnfNames = [{name: 'test1'}];
+ $changeManagementService.getWorkflows = () => getWorkflowsStub;
+ $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub;
+ // when
+ return $controller.loadWorkFlows()
+ .then(() => {
+ let internalWorkFlowParameters = $controller.getInternalWorkFlowParameters("VNF Scale Out", "FILE");
+ expect(internalWorkFlowParameters).toEqual([]);
+ });
+ });
+
test('Verify get internal workflow parameters should return a list if such workflow and type exist', () => {
// given
$featureFlags.isOn = jestMock.fn(() => false);
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 f06d88321..40bb92b7e 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
@@ -22,7 +22,7 @@
<div class="modal-header">
<h3 class="modal-title" id="modal-title">New VNF Change</h3>
<span ng-click="vm.close()" class="pull-right modal-close" aria-hidden="true">&times;</span>
- <div ng-if="vm.errorMsg!==''"><font color='red'>{{vm.errorMsg.message}}</font></div>
+ <div ng-if="vm.errorMsg!==''" style="max-height: 150px; overflow: auto;" data-tests-id="error-message"><font color='red'>{{vm.errorMsg.message}}</font></div>
</div>
<form class="form-create" data-tests-id="newChangeManagementForm" name="newChangeManagement"
ng-submit="vm.openModal();vm.close();" novalidate>
@@ -142,16 +142,16 @@
<div class="form-group" ng-if="vm.changeManagement.workflow"
ng-repeat="item in vm.getInternalWorkFlowParameters(vm.changeManagement.workflow, 'FILE')">
- <label class="control-label">{{item.name}}</label>
+ <label class="control-label">{{item.displayName}}</label>
<div class="file-wrapper">
- <input id="{{vm.getIdFor('file',item.id,item.name)}}" ng-change="vm.onChange(item)" class="file-input"
- type="file" ngf-select ng-model="item.value" ngf-validate-async-fn="vm.uploadConfigFile($file)"
+ <input id="{{vm.getIdFor('file',item)}}" ng-change="vm.onChange(item)" class="file-input"
+ type="file" ngf-select ng-model="item.file" ngf-validate-async-fn="vm.uploadConfigFile($file, item)"
ng-attr-name="{{'internal-workflow-parameter-file-name-' + item.id}}"
accept="{{item.acceptableFileType}}" ngf-pattern="{{item.acceptableFileType}}"
ng-required="{{item.required}}"/>
- <label id="{{vm.getIdFor('file',item.id,item.name)}}-label" class="file-input-label">
- {{item.value&&item.value.name||"Select File"}} </label>
- <label ng-attr-for="{{vm.getIdFor('file',item.id,item.name)}}"><span class="icon-browse"></span></label>
+ <label id="{{vm.getIdFor('file',item)}}-label" class="file-input-label">
+ {{item.file&&item.file.name||"Select File"}} </label>
+ <label ng-attr-for="{{vm.getIdFor('file',item)}}"><span class="icon-browse"></span></label>
</div>
<label id="errorLabel" class="icon-alert error"
ng-if="vm.hasPatternError(newChangeManagement, 'internal-workflow-parameter-file-name-' + item.id)">{{item.msgOnPatternError}}</label>
@@ -161,8 +161,8 @@
<div class="form-group" ng-if="vm.changeManagement.workflow"
ng-repeat="item in vm.getInternalWorkFlowParameters(vm.changeManagement.workflow, 'text')">
- <label ng-attr-for="{{vm.getIdFor('text',item.id,item.name)}}" class="control-label">{{item.name}}</label>
- <input ng-model="item.value" type="text" id="{{vm.getIdFor('text',item.id,item.name)}}"
+ <label ng-attr-for="{{vm.getIdFor('text',item)}}" class="control-label">{{item.displayName}}</label>
+ <input ng-model="item.value" type="text" id="{{vm.getIdFor('text',item)}}"
pattern="{{item.pattern}}" ng-required="{{item.required}}">
</div>