Introduced dynamic workflow properties in VID FE
[vid.git] / vid-app-common / src / main / webapp / app / vid / scripts / modals / new-change-management / new-change-management.controller.js
index 11f5cd6..c85f0fc 100644 (file)
@@ -43,6 +43,7 @@
 
         var init = function () {
             vm.changeManagement = {};
+            vm.changeManagement.workflowParameters = new Map();
 
             loadServicesCatalog();
             fetchAttUid().then(registerVNFNamesWatcher);
         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 () {
           });
         };
 
+        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) {
 
         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;