aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/webapp/app/vid/scripts/controller/statusDialogController.js
diff options
context:
space:
mode:
authorjimmydot <jf2512@att.com>2017-05-07 14:58:24 -0400
committerjimmydot <jf2512@att.com>2017-05-07 14:58:24 -0400
commit3982f4f67314ec37fd9b22ae54049958af777c1b (patch)
tree72111b7c13ee7529cce1ea4c8d83c89fdd164450 /vid-app-common/src/main/webapp/app/vid/scripts/controller/statusDialogController.js
parent00e0d25933699f9e39c3f0b86c983165a1e3e330 (diff)
[VID-6] Initial rebase push
Change-Id: I9077be9663754d9b22f77c6a7b3109b361b39346 Signed-off-by: jimmydot <jf2512@att.com>
Diffstat (limited to 'vid-app-common/src/main/webapp/app/vid/scripts/controller/statusDialogController.js')
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/statusDialogController.js233
1 files changed, 233 insertions, 0 deletions
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/statusDialogController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/statusDialogController.js
new file mode 100755
index 000000000..de1566678
--- /dev/null
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/statusDialogController.js
@@ -0,0 +1,233 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * VID
+ * ================================================================================
+ * Copyright (C) 2017 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 statusDialogController = function(COMPONENT, FIELD, $scope, $http, $timeout, $log, MsoService, StatusService, DataService, PropertyService, UtilityService) {
+
+ $scope.isDialogVisible = false;
+ $scope.summaryControl = {};
+ $scope.detailsControl = {};
+ $scope.userProvidedControl = {};
+
+ var callbackFunction = undefined;
+ var componentId = undefined;
+
+ $scope.$on("ComponentStatus", function(event, request) {
+
+ $scope.log = "";
+ $scope.isSpinnerVisible = true;
+ $scope.isErrorVisible = false;
+ $scope.isSuccessVisible = false;
+ $scope.isSubmitEnabled = false;
+ $scope.isDataVisible = false;
+ $scope.isDialogVisible = true;
+ $scope.popup.isVisible = true;
+ $scope.isCancelEnabled = true;
+ $scope.success = "";
+ $scope.error = "";
+
+ $scope.vnfid = undefined;
+ $scope.targetProvStatus = undefined;
+
+ callbackFunction = request.callbackFunction;
+ componentId = request.componentId;
+
+ StatusService.initializeComponent(request.componentId);
+
+ /*StatusService.setHttpErrorHandler(function(response) {
+ showError("System failure", UtilityService
+ .getHttpErrorMessage(response));
+ });*/
+
+ $scope.componentName = StatusService.getComponentDisplayName();
+
+ $scope.summaryControl.setList(StatusService.getSummaryList());
+
+ $scope.detailsControl.setList(StatusService.getVNFStatusList());
+
+ StatusService.getParameters(handleGetParametersResponse);
+
+ //UtilityService.setHttpErrorHandler(function(response) {
+ // showError("System failure", UtilityService
+ // .getHttpErrorMessage(response));
+ //});
+
+
+ });
+
+ var handleGetParametersResponse = function(parameters, dontshow) {
+ $scope.summaryControl.setList(parameters.summaryList);
+ $scope.userProvidedControl.setList(parameters.userProvidedList);
+
+ $scope.isSpinnerVisible = false;
+ if (dontshow)
+ $scope.isDataVisible = false;
+ else
+ $scope.isDataVisible = true;
+ $scope.isSubmitEnabled = true;
+ };
+
+ $scope.userParameterChanged = function(id) {
+ StatusService.updateUserParameterList(id, $scope.userProvidedControl);
+ }
+
+ /*$scope.submit = function() {
+
+ var requiredFields = $scope.userProvidedControl.getRequiredFields();
+ if (requiredFields === "") {
+ $scope.isErrorVisible = false;
+ } else {
+ showError("Missing data", requiredFields);
+ return;
+ }
+ var paramList = $scope.userProvidedControl.getList();
+ var targetprovstatus = "";
+
+ if ( paramList != null ) {
+ for (var i = 0; i < paramList.length; i++) {
+ if (paramList[i].id === FIELD.ID.VNF_TARGETPROVSTATUS) {
+ targetprovstatus = paramList[i].value;
+ break;
+ }
+ }
+ }
+
+ $scope.vnfid = DataService.getVnfInstanceId();
+ $scope.targetProvStatus = StatusService.getTargetProvParameterText(targetprovstatus);
+
+ $scope.setVnfProvStatus($scope.vnfid, $scope.targetProvStatus);
+
+ // $scope.isDialogVisible = false;
+
+ // $scope.popup.isVisible = false;
+
+ }*/
+
+ $scope.init = function() {
+
+ StatusService.updateVnfProvStatus = "";
+ var msecs = PropertyService.retrieveMsoMaxPollingIntervalMsec();
+ PropertyService.setMsoMaxPollingIntervalMsec(msecs);
+
+ var polls = PropertyService.retrieveMsoMaxPolls();
+ PropertyService.setMsoMaxPolls(polls);
+
+ PropertyService.setServerResponseTimeoutMsec(10000)
+
+ $scope.isSpinnerVisible = true;
+
+
+ $scope.error = "";
+ $scope.success = "";
+ $scope.pollAttempts = 0;
+ $scope.log = "";
+ $scope.isSubmitEnabled = false;
+ $scope.isCancelEnabled = false;
+
+ }
+
+
+
+ $scope.handleInitialResponse = function(response) {
+ try {
+ $scope.isCancelEnabled = true;
+
+ if (response.data.status < 200 || response.data.status > 202) {
+ showError(FIELD.ERROR.AAI_ERROR, "");
+ return;
+ }
+ else
+ {
+ DataService.setUpdatedVNFProvStatus($scope.targetProvStatus);
+ $scope.detailsControl.setList(StatusService.getVNFStatusList());
+ showSuccess(FIELD.STATUS.SUCCESS_VNF_PROV_STATUS, $scope.targetProvStatus);
+
+ }
+ $scope.status = FIELD.STATUS.DONE;
+ $scope.isSpinnerVisible = false;
+// DataService.setServiceInstanceToCustomer($scope.serviceInstanceToCustomer);
+ } catch (error) {
+ $scope.showContentError(error);
+ }
+ }
+
+ /* $scope.setVnfProvStatus = function(vnfId, targetProvStatus) {
+
+ $scope.init();
+ $log
+ .debug("AaiService:setVnfProvStatus: vnf-id: "
+ + vnfId + " Target Prov_Status: " + targetProvStatus);
+ var url = "aai_vnf_update/"
+ + vnfId + "/" + targetProvStatus + "?r=" + Math.random();
+
+ $http.get(url,
+ {
+ timeout : PropertyService
+ .getServerResponseTimeoutMsec()
+ }).then(function(response) {
+
+ $scope.handleInitialResponse(response);
+ })["catch"]
+ (UtilityService.runHttpErrorHandler);
+
+ };*/
+
+
+ $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 showSuccess = function(summary, details) {
+ var message = summary;
+ if (UtilityService.hasContents(details)) {
+ message += " (" + details + ")";
+ }
+ $scope.isSpinnerVisible = false;
+ $scope.isSuccessVisible = true;
+ $scope.success = message;
+ }
+
+ 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("statusDialogController", [ "COMPONENT", "FIELD", "$scope", "$http", "$timeout",
+ "$log", "MsoService", "StatusService", "DataService", "PropertyService", "UtilityService",
+ statusDialogController ]);