-/*-\r
- * ============LICENSE_START=======================================================\r
- * VID\r
- * ================================================================================\r
- * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-"use strict";\r
-\r
-var creationDialogController = function (COMPONENT, FIELD, PARAMETER, $scope, $http, $timeout, $log,\r
- CreationService, UtilityService, DataService, VIDCONFIGURATION, $location, $uibModal, featureFlags) {\r
-\r
- $scope.isDialogVisible = false;\r
- $scope.isServiceError = false;\r
- $scope.summaryControl = {};\r
- $scope.userProvidedControl = {};\r
-\r
-\r
- var callbackFunction = undefined;\r
- var componentId = undefined;\r
-\r
- $scope.showReportWindow = function() {\r
-\r
- let errorMsg;\r
-\r
- if($scope.error !== undefined && $scope.error != null) {\r
- errorMsg = $scope.error;\r
- } else {\r
- errorMsg = "";\r
- }\r
-\r
- const modalWindow = $uibModal.open({\r
- templateUrl: 'app/vid/scripts/modals/report-modal/report-modal.html',\r
- controller: 'reportModalController',\r
- controllerAs: 'vm',\r
- resolve: {\r
- errorMsg: function () {\r
- return errorMsg;\r
- }\r
- }\r
- });\r
-\r
- $scope.isDialogVisible = false;\r
- $scope.popup.isVisible = false;\r
- };\r
-\r
- $scope.isShowErrorReport = function() {\r
- return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_CREATE_ERROR_REPORTS);\r
- };\r
-\r
- $scope.shouldShowOldPopup = function () {\r
- return !DataService.getShouldIncludeInAsyncInstantiationFlow();\r
- };\r
-\r
- function receiveMessage(event) {\r
- if (event.data == 'closeIframe') {\r
- window.removeEventListener("message", receiveMessage, false);\r
-\r
- $scope.cancel();\r
- }\r
- else if (event.data.eventId == 'submitIframe') {\r
- {\r
- $location.path('/servicePlanning').search({serviceModelId: event.data.data.serviceModelId});\r
- }\r
- }\r
- $scope.$apply();\r
- }\r
-\r
- $scope.$on(COMPONENT.CREATE_COMPONENT, function (event, request) {\r
- $scope.isSpinnerVisible = true;\r
- $scope.isErrorVisible = false;\r
- $scope.isDataVisible = false;\r
- $scope.isConfirmEnabled = false;\r
- $scope.isDialogVisible = true;\r
- $scope.popup.isVisible = true;\r
-\r
-\r
- if (!$scope.shouldShowOldPopup()) {\r
- $scope.url = COMPONENT.SERVICE_POPUP_IFRAME_URL + request.modelNameVersionId + "&isCreate=true&r=" + Math.random();\r
- window.addEventListener("message", receiveMessage, false);\r
-\r
- }\r
- else {\r
- callbackFunction = request.callbackFunction;\r
- componentId = request.componentId;\r
- CreationService.initializeComponent(request.componentId);\r
-\r
- CreationService.setHttpErrorHandler(function (response) {\r
- $scope.isServiceError = true;\r
- showError(FIELD.ERROR.SYSTEM_FAILURE, UtilityService\r
- .getHttpErrorMessage(response));\r
- });\r
-\r
- $scope.componentName = CreationService.getComponentDisplayName();\r
-\r
- CreationService.getParameters(handleGetParametersResponse);\r
- }\r
-\r
- });\r
-\r
- var handleGetParametersResponse = function (parameters) {\r
- $scope.summaryControl.setList(parameters.summaryList);\r
- $scope.userProvidedControl.setList(parameters.userProvidedList);\r
-\r
- $scope.isSpinnerVisible = false;\r
- $scope.isDataVisible = true;\r
- $scope.isConfirmEnabled = true;\r
- };\r
-\r
- var validateInstanceName = function (iname) {\r
- var patt1 = /^([a-z])+([0-9a-z\-_\.]*)$/i;\r
-\r
- if (iname == null) {\r
- return false;\r
- }\r
- if (!iname.match(patt1)) {\r
- return false;\r
- }\r
- return true;\r
- };\r
- var validateMap = function (mname) {\r
- var patt1 = /^{(\s*\w+\s*:\s*\w+\s*)(\s*,\s*\w+\s*:\s*\w+\s*)*}$/im;\r
- if (mname == null) {\r
- return true;\r
- }\r
- if (!mname.match(patt1)) {\r
- return false;\r
- }\r
- return true;\r
- };\r
-\r
- var validateList = function (lname) {\r
- var patt1 = /^\[(\s*\w+\s*)(\s*,\s*\w+\s*)*\]$/i;\r
- if (lname == null) {\r
- return true;\r
- }\r
- if (!lname.match(patt1)) {\r
- return false;\r
- }\r
- return true;\r
- };\r
-\r
- $scope.userParameterChanged = function (id) {\r
- CreationService.updateUserParameterList(id, $scope.userProvidedControl);\r
- };\r
-\r
- $scope.confirm = function () {\r
-\r
- var requiredFields = $scope.userProvidedControl.getRequiredFields();\r
- if (requiredFields !== "") {\r
- showError(FIELD.ERROR.MISSING_DATA, requiredFields);\r
- return;\r
- }\r
-\r
- var isUploadAvailable = false;\r
- var uploadIndex = 0;\r
- var paramList = $scope.userProvidedControl.getList();\r
- var isAnyError = false;\r
- for (var i = 0; i < paramList.length; i++) {\r
- if (paramList[i].id === FIELD.ID.SUPPLEMENTORY_DATA_FILE) {\r
- isUploadAvailable = true;\r
- uploadIndex = i;\r
- }\r
- if (paramList[i].id === FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE && paramList[i].value && document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE).value == '') {\r
- isAnyError = true;\r
- }\r
- }\r
-\r
- if (isUploadAvailable && isAnyError) {\r
- showError(FIELD.ERROR.MISSING_DATA, FIELD.ERROR.MISSING_FILE);\r
-\r
- } else if (isUploadAvailable && document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE).value != '') {\r
- var errorMsg = "";\r
- var fileInput = document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE);\r
- var file = fileInput.files[0];\r
- var reader = new FileReader();\r
- reader.onload = function (e) {\r
- try {\r
- paramList[uploadIndex].value = JSON.parse(reader.result);\r
- FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value'] = paramList[uploadIndex].value;\r
-\r
- var instanceName = "";\r
-\r
- if (DataService.getALaCarte()) {\r
- if (paramList != null) {\r
- for (var i = 0; i < paramList.length; i++) {\r
- if (paramList[i].id === FIELD.ID.INSTANCE_NAME) {\r
- instanceName = paramList[i].value;\r
- break;\r
- }\r
- }\r
- }\r
- var isValid = validateInstanceName(instanceName);\r
- if (isValid) {\r
- $scope.isErrorVisible = false;\r
- } else {\r
- showError(FIELD.ERROR.INVALID_INSTANCE_NAME + instanceName,\r
- FIELD.ERROR.INSTANCE_NAME_VALIDATE);\r
- return;\r
- }\r
- }\r
- var arbitraryParametersList = DataService.getArbitraryParameters();\r
- var p = null;\r
- if (UtilityService.hasContents(arbitraryParametersList)) {\r
- for (var i = 0; i < arbitraryParametersList.length; i++) {\r
- p = arbitraryParametersList[i];\r
- if (p.type === PARAMETER.MAP) {\r
- //validate a map: { <entry_key_1>: <entry_value_1>, ... , <entry_key_n>: <entry_value_n> }\r
- // need to find the value in paramList\r
- for (var j = 0; j < paramList.length; j++) {\r
- if (paramList[j].id === p.id) {\r
- p.value = paramList[j].value;\r
- var isValid = validateMap(p.value);\r
- if (isValid) {\r
- $scope.isErrorVisible = false;\r
- break;\r
- }\r
- else {\r
- showError(FIELD.ERROR.INVALID_MAP + p.id,\r
- FIELD.ERROR.MAP_VALIDATE);\r
- return;\r
- }\r
- }\r
- }\r
- } else if (p.type === PARAMETER.LIST) {\r
- //validate a list: { value or a list of comma separated values }\r
- // need to find the value in paramList\r
- for (var j = 0; j < paramList.length; j++) {\r
- if (paramList[j].id === p.id) {\r
- p.value = paramList[j].value;\r
- var isValid = validateList(p.value);\r
- if (isValid) {\r
- $scope.isErrorVisible = false;\r
- break;\r
- }\r
- else {\r
- showError(FIELD.ERROR.INVALID_LIST + p.id,\r
- FIELD.ERROR.LIST_VALIDATE);\r
- return;\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- var requestDetails = CreationService\r
- .getMsoRequestDetails($scope.userProvidedControl.getList());\r
-\r
- $scope.isDialogVisible = false;\r
-\r
- $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, {\r
- url: CreationService.getMsoUrl(),\r
- requestDetails: requestDetails,\r
- componentId: componentId,\r
- callbackFunction: function (response) {\r
- if (response.isSuccessful) {\r
- $scope.popup.isVisible = false;\r
- runCallback(response);\r
- } else {\r
- $scope.isDialogVisible = false;\r
- $scope.popup.isVisible = false;\r
- }\r
- }\r
- });\r
-\r
- } catch (e) {\r
- errorMsg = errorMsg + FIELD.ERROR.INVALID_DATA_FORMAT;\r
- }\r
- if (errorMsg !== "") {\r
- showError(FIELD.ERROR.SYSTEM_FAILURE, errorMsg);\r
-\r
- }\r
- };\r
- reader.readAsText(file);\r
- } else {\r
-\r
- var paramList = $scope.userProvidedControl.getList();\r
- var instanceName = "";\r
-\r
- if (DataService.getALaCarte()) {\r
- if (paramList != null) {\r
- for (var i = 0; i < paramList.length; i++) {\r
- if (paramList[i].id === FIELD.ID.INSTANCE_NAME) {\r
- instanceName = paramList[i].value;\r
- break;\r
- }\r
- }\r
- }\r
- var isValid = validateInstanceName(instanceName);\r
- if (isValid) {\r
- $scope.isErrorVisible = false;\r
- } else {\r
- showError(FIELD.ERROR.INVALID_INSTANCE_NAME + instanceName,\r
- FIELD.ERROR.INSTANCE_NAME_VALIDATE);\r
- return;\r
- }\r
- }\r
- var arbitraryParametersList = DataService.getArbitraryParameters();\r
- var p = null;\r
- if (UtilityService.hasContents(arbitraryParametersList)) {\r
- for (var i = 0; i < arbitraryParametersList.length; i++) {\r
- p = arbitraryParametersList[i];\r
- if (p.type === PARAMETER.MAP) {\r
- //validate a map: { <entry_key_1>: <entry_value_1>, ... , <entry_key_n>: <entry_value_n> }\r
- // need to find the value in paramList\r
- for (var j = 0; j < paramList.length; j++) {\r
- if (paramList[j].id === p.id) {\r
- p.value = paramList[j].value;\r
- var isValid = validateMap(p.value);\r
- if (isValid) {\r
- $scope.isErrorVisible = false;\r
- break;\r
- }\r
- else {\r
- showError(FIELD.ERROR.INVALID_MAP + p.id,\r
- FIELD.ERROR.MAP_VALIDATE);\r
- return;\r
- }\r
- }\r
- }\r
- } else if (p.type === PARAMETER.LIST) {\r
- //validate a list: { value or a list of comma separated values }\r
- // need to find the value in paramList\r
- for (var j = 0; j < paramList.length; j++) {\r
- if (paramList[j].id === p.id) {\r
- p.value = paramList[j].value;\r
- var isValid = validateList(p.value);\r
- if (isValid) {\r
- $scope.isErrorVisible = false;\r
- break;\r
- }\r
- else {\r
- showError(FIELD.ERROR.INVALID_LIST + p.id,\r
- FIELD.ERROR.LIST_VALIDATE);\r
- return;\r
- }\r
- }\r
- }\r
- }\r
- }\r
- }\r
- var requestDetails = CreationService\r
- .getMsoRequestDetails($scope.userProvidedControl.getList());\r
-\r
- $scope.isDialogVisible = false;\r
-\r
- $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, {\r
- url: CreationService.getMsoUrl(),\r
- requestDetails: requestDetails,\r
- componentId: componentId,\r
- callbackFunction: function (response) {\r
- if (response.isSuccessful) {\r
- $scope.popup.isVisible = false;\r
- runCallback(response);\r
- } else {\r
- $scope.isDialogVisible = false;\r
- $scope.popup.isVisible = false;\r
- }\r
- }\r
- });\r
- }\r
- };\r
-\r
- $scope.cancel = function () {\r
- $scope.isDialogVisible = false;\r
- $scope.popup.isVisible = false;\r
- runCallback(false);\r
- };\r
-\r
-\r
- var runCallback = function (response) {\r
- if (angular.isFunction(callbackFunction)) {\r
- callbackFunction({\r
- isSuccessful: response.isSuccessful,\r
- control: $scope.userProvidedControl.getList(),\r
- instanceId: response.instanceId\r
- });\r
- }\r
- };\r
-\r
- var showError = function (summary, details) {\r
- var message = summary;\r
- if (UtilityService.hasContents(details)) {\r
- message += " (" + details + ")";\r
- }\r
- $scope.isSpinnerVisible = false;\r
- $scope.isErrorVisible = true;\r
- $scope.error = message;\r
- }\r
-\r
-};\r
-\r
-appDS2.controller("creationDialogController", ["COMPONENT", "FIELD", "PARAMETER", "$scope", "$http",\r
- "$timeout", "$log", "CreationService", "UtilityService", "DataService", "VIDCONFIGURATION", "$location",\r
- "$uibModal", "featureFlags",\r
- creationDialogController]);\r
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+"use strict";
+
+var creationDialogController = function (COMPONENT, FIELD, PARAMETER, $scope, $http, $timeout, $log,
+ CreationService, UtilityService, DataService, VIDCONFIGURATION, $location, $uibModal, featureFlags) {
+
+ $scope.isDialogVisible = false;
+ $scope.isServiceError = false;
+ $scope.summaryControl = {};
+ $scope.userProvidedControl = {};
+
+
+ var callbackFunction = undefined;
+ var componentId = undefined;
+
+ $scope.showReportWindow = function() {
+
+ let errorMsg;
+
+ if($scope.error !== undefined && $scope.error != null) {
+ errorMsg = $scope.error;
+ } else {
+ errorMsg = "";
+ }
+
+ const modalWindow = $uibModal.open({
+ templateUrl: 'app/vid/scripts/modals/report-modal/report-modal.html',
+ controller: 'reportModalController',
+ controllerAs: 'vm',
+ resolve: {
+ errorMsg: function () {
+ return errorMsg;
+ }
+ }
+ });
+
+ $scope.isDialogVisible = false;
+ $scope.popup.isVisible = false;
+ };
+
+ $scope.isShowErrorReport = function() {
+ return featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_CREATE_ERROR_REPORTS);
+ };
+
+ $scope.shouldShowOldPopup = function () {
+ return !DataService.getShouldIncludeInAsyncInstantiationFlow();
+ };
+
+ function receiveMessage(event) {
+ if (event.data == 'closeIframe') {
+ window.removeEventListener("message", receiveMessage, false);
+
+ $scope.cancel();
+ }
+ else if (event.data.eventId == 'submitIframe') {
+ {
+ $location.path('/servicePlanning').search({serviceModelId: event.data.data.serviceModelId});
+ }
+ } else if (event.data.eventId == 'showPreviousInstantiations') {
+ {
+ $location.path('/instantiationStatus').search({filterText: event.data.data.serviceModelId});
+ }
+ }
+ $scope.$apply();
+ }
+
+ $scope.$on(COMPONENT.CREATE_COMPONENT, function (event, request) {
+ $scope.isSpinnerVisible = true;
+ $scope.isErrorVisible = false;
+ $scope.isDataVisible = false;
+ $scope.isConfirmEnabled = false;
+ $scope.isDialogVisible = true;
+ $scope.popup.isVisible = true;
+
+
+ if (!$scope.shouldShowOldPopup()) {
+ $scope.url = COMPONENT.SERVICE_POPUP_IFRAME_URL + request.modelNameVersionId + "&isCreate=true&r=" + Math.random();
+ window.addEventListener("message", receiveMessage, false);
+
+ }
+ else {
+ callbackFunction = request.callbackFunction;
+ componentId = request.componentId;
+ CreationService.initializeComponent(request.componentId);
+
+ CreationService.setHttpErrorHandler(function (response) {
+ $scope.isServiceError = true;
+ showError(FIELD.ERROR.SYSTEM_FAILURE, UtilityService
+ .getHttpErrorMessage(response));
+ });
+
+ $scope.componentName = CreationService.getComponentDisplayName();
+
+ CreationService.getParameters(handleGetParametersResponse);
+ }
+
+ });
+
+ var handleGetParametersResponse = function (parameters) {
+ $scope.summaryControl.setList(parameters.summaryList);
+ $scope.userProvidedControl.setList(parameters.userProvidedList);
+
+ $scope.isSpinnerVisible = false;
+ $scope.isDataVisible = true;
+ $scope.isConfirmEnabled = true;
+ };
+
+ var validateInstanceName = function (iname) {
+ var patt1 = /^([a-z])+([0-9a-z\-_\.]*)$/i;
+
+ if (iname == null) {
+ return false;
+ }
+ if (!iname.match(patt1)) {
+ return false;
+ }
+ return true;
+ };
+ var validateMap = function (mname) {
+ var patt1 = /^{(\s*\w+\s*:\s*\w+\s*)(\s*,\s*\w+\s*:\s*\w+\s*)*}$/im;
+ if (mname == null) {
+ return true;
+ }
+ if (!mname.match(patt1)) {
+ return false;
+ }
+ return true;
+ };
+
+ var validateList = function (lname) {
+ var patt1 = /^\[(\s*\w+\s*)(\s*,\s*\w+\s*)*\]$/i;
+ if (lname == null) {
+ return true;
+ }
+ if (!lname.match(patt1)) {
+ return false;
+ }
+ return true;
+ };
+
+ $scope.userParameterChanged = function (id) {
+ CreationService.updateUserParameterList(id, $scope.userProvidedControl);
+ };
+
+ $scope.confirm = function () {
+
+ var requiredFields = $scope.userProvidedControl.getRequiredFields();
+ if (requiredFields !== "") {
+ showError(FIELD.ERROR.MISSING_DATA, requiredFields);
+ return;
+ }
+
+ var isUploadAvailable = false;
+ var uploadIndex = 0;
+ var paramList = $scope.userProvidedControl.getList();
+ var isAnyError = false;
+ for (var i = 0; i < paramList.length; i++) {
+ if (paramList[i].id === FIELD.ID.SUPPLEMENTORY_DATA_FILE) {
+ isUploadAvailable = true;
+ uploadIndex = i;
+ }
+ if (paramList[i].id === FIELD.ID.UPLOAD_SUPPLEMENTORY_DATA_FILE && paramList[i].value && document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE).value == '') {
+ isAnyError = true;
+ }
+ }
+
+ if (isUploadAvailable && isAnyError) {
+ showError(FIELD.ERROR.MISSING_DATA, FIELD.ERROR.MISSING_FILE);
+
+ } else if (isUploadAvailable && document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE).value != '') {
+ var errorMsg = "";
+ var fileInput = document.getElementById(FIELD.ID.SUPPLEMENTORY_DATA_FILE);
+ var file = fileInput.files[0];
+ var reader = new FileReader();
+ reader.onload = function (e) {
+ try {
+ paramList[uploadIndex].value = JSON.parse(reader.result);
+ FIELD.PARAMETER.SUPPLEMENTORY_DATA_FILE['value'] = paramList[uploadIndex].value;
+
+ var instanceName = "";
+
+ if (DataService.getALaCarte()) {
+ if (paramList != null) {
+ for (var i = 0; i < paramList.length; i++) {
+ if (paramList[i].id === FIELD.ID.INSTANCE_NAME) {
+ instanceName = paramList[i].value;
+ break;
+ }
+ }
+ }
+ var isValid = validateInstanceName(instanceName);
+ if (isValid) {
+ $scope.isErrorVisible = false;
+ } else {
+ showError(FIELD.ERROR.INVALID_INSTANCE_NAME + instanceName,
+ FIELD.ERROR.INSTANCE_NAME_VALIDATE);
+ return;
+ }
+ }
+ var arbitraryParametersList = DataService.getArbitraryParameters();
+ var p = null;
+ if (UtilityService.hasContents(arbitraryParametersList)) {
+ for (var i = 0; i < arbitraryParametersList.length; i++) {
+ p = arbitraryParametersList[i];
+ if (p.type === PARAMETER.MAP) {
+ //validate a map: { <entry_key_1>: <entry_value_1>, ... , <entry_key_n>: <entry_value_n> }
+ // need to find the value in paramList
+ for (var j = 0; j < paramList.length; j++) {
+ if (paramList[j].id === p.id) {
+ p.value = paramList[j].value;
+ var isValid = validateMap(p.value);
+ if (isValid) {
+ $scope.isErrorVisible = false;
+ break;
+ }
+ else {
+ showError(FIELD.ERROR.INVALID_MAP + p.id,
+ FIELD.ERROR.MAP_VALIDATE);
+ return;
+ }
+ }
+ }
+ } else if (p.type === PARAMETER.LIST) {
+ //validate a list: { value or a list of comma separated values }
+ // need to find the value in paramList
+ for (var j = 0; j < paramList.length; j++) {
+ if (paramList[j].id === p.id) {
+ p.value = paramList[j].value;
+ var isValid = validateList(p.value);
+ if (isValid) {
+ $scope.isErrorVisible = false;
+ break;
+ }
+ else {
+ showError(FIELD.ERROR.INVALID_LIST + p.id,
+ FIELD.ERROR.LIST_VALIDATE);
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+ var requestDetails = CreationService
+ .getMsoRequestDetails($scope.userProvidedControl.getList());
+
+ $scope.isDialogVisible = false;
+
+ $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, {
+ url: CreationService.getMsoUrl(),
+ requestDetails: requestDetails,
+ componentId: componentId,
+ callbackFunction: function (response) {
+ if (response.isSuccessful) {
+ $scope.popup.isVisible = false;
+ runCallback(response);
+ } else {
+ $scope.isDialogVisible = false;
+ $scope.popup.isVisible = false;
+ }
+ }
+ });
+
+ } catch (e) {
+ errorMsg = errorMsg + FIELD.ERROR.INVALID_DATA_FORMAT;
+ }
+ if (errorMsg !== "") {
+ showError(FIELD.ERROR.SYSTEM_FAILURE, errorMsg);
+
+ }
+ };
+ reader.readAsText(file);
+ } else {
+
+ var paramList = $scope.userProvidedControl.getList();
+ var instanceName = "";
+
+ if (DataService.getALaCarte()) {
+ if (paramList != null) {
+ for (var i = 0; i < paramList.length; i++) {
+ if (paramList[i].id === FIELD.ID.INSTANCE_NAME) {
+ instanceName = paramList[i].value;
+ break;
+ }
+ }
+ }
+ var isValid = validateInstanceName(instanceName);
+ if (isValid) {
+ $scope.isErrorVisible = false;
+ } else {
+ showError(FIELD.ERROR.INVALID_INSTANCE_NAME + instanceName,
+ FIELD.ERROR.INSTANCE_NAME_VALIDATE);
+ return;
+ }
+ }
+ var arbitraryParametersList = DataService.getArbitraryParameters();
+ var p = null;
+ if (UtilityService.hasContents(arbitraryParametersList)) {
+ for (var i = 0; i < arbitraryParametersList.length; i++) {
+ p = arbitraryParametersList[i];
+ if (p.type === PARAMETER.MAP) {
+ //validate a map: { <entry_key_1>: <entry_value_1>, ... , <entry_key_n>: <entry_value_n> }
+ // need to find the value in paramList
+ for (var j = 0; j < paramList.length; j++) {
+ if (paramList[j].id === p.id) {
+ p.value = paramList[j].value;
+ var isValid = validateMap(p.value);
+ if (isValid) {
+ $scope.isErrorVisible = false;
+ break;
+ }
+ else {
+ showError(FIELD.ERROR.INVALID_MAP + p.id,
+ FIELD.ERROR.MAP_VALIDATE);
+ return;
+ }
+ }
+ }
+ } else if (p.type === PARAMETER.LIST) {
+ //validate a list: { value or a list of comma separated values }
+ // need to find the value in paramList
+ for (var j = 0; j < paramList.length; j++) {
+ if (paramList[j].id === p.id) {
+ p.value = paramList[j].value;
+ var isValid = validateList(p.value);
+ if (isValid) {
+ $scope.isErrorVisible = false;
+ break;
+ }
+ else {
+ showError(FIELD.ERROR.INVALID_LIST + p.id,
+ FIELD.ERROR.LIST_VALIDATE);
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+ var requestDetails = CreationService
+ .getMsoRequestDetails($scope.userProvidedControl.getList());
+
+ $scope.isDialogVisible = false;
+
+ $scope.$broadcast(COMPONENT.MSO_CREATE_REQ, {
+ url: CreationService.getMsoUrl(),
+ requestDetails: requestDetails,
+ componentId: componentId,
+ callbackFunction: function (response) {
+ if (response.isSuccessful) {
+ $scope.popup.isVisible = false;
+ runCallback(response);
+ } else {
+ $scope.isDialogVisible = false;
+ $scope.popup.isVisible = false;
+ }
+ }
+ });
+ }
+ };
+
+ $scope.cancel = function () {
+ $scope.isDialogVisible = false;
+ $scope.popup.isVisible = false;
+ runCallback(false);
+ };
+
+
+ var runCallback = function (response) {
+ if (angular.isFunction(callbackFunction)) {
+ callbackFunction({
+ isSuccessful: response.isSuccessful,
+ control: $scope.userProvidedControl.getList(),
+ instanceId: response.instanceId
+ });
+ }
+ };
+
+ var showError = function (summary, details) {
+ var message = summary;
+ if (UtilityService.hasContents(details)) {
+ message += " (" + details + ")";
+ }
+ $scope.isSpinnerVisible = false;
+ $scope.isErrorVisible = true;
+ $scope.error = message;
+ }
+
+};
+
+appDS2.controller("creationDialogController", ["COMPONENT", "FIELD", "PARAMETER", "$scope", "$http",
+ "$timeout", "$log", "CreationService", "UtilityService", "DataService", "VIDCONFIGURATION", "$location",
+ "$uibModal", "featureFlags",
+ creationDialogController]);