2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
23 var statusDialogController = function(COMPONENT, FIELD, $scope, $http, $timeout, $log, MsoService, StatusService, DataService, PropertyService, UtilityService) {
\r
25 $scope.isDialogVisible = false;
\r
26 $scope.summaryControl = {};
\r
27 $scope.detailsControl = {};
\r
28 $scope.userProvidedControl = {};
\r
30 var callbackFunction = undefined;
\r
31 var componentId = undefined;
\r
33 $scope.$on("ComponentStatus", function(event, request) {
\r
36 $scope.isSpinnerVisible = true;
\r
37 $scope.isErrorVisible = false;
\r
38 $scope.isSuccessVisible = false;
\r
39 $scope.isSubmitEnabled = false;
\r
40 $scope.isDataVisible = false;
\r
41 $scope.isDialogVisible = true;
\r
42 $scope.popup.isVisible = true;
\r
43 $scope.isCancelEnabled = true;
\r
44 $scope.success = "";
\r
47 $scope.vnfid = undefined;
\r
48 $scope.targetProvStatus = undefined;
\r
50 callbackFunction = request.callbackFunction;
\r
51 componentId = request.componentId;
\r
53 StatusService.initializeComponent(request.componentId);
\r
55 /*StatusService.setHttpErrorHandler(function(response) {
\r
56 showError("System failure", UtilityService
\r
57 .getHttpErrorMessage(response));
\r
60 $scope.componentName = StatusService.getComponentDisplayName();
\r
62 $scope.summaryControl.setList(StatusService.getSummaryList());
\r
64 $scope.detailsControl.setList(StatusService.getVNFStatusList());
\r
66 StatusService.getParameters(handleGetParametersResponse);
\r
68 //UtilityService.setHttpErrorHandler(function(response) {
\r
69 // showError("System failure", UtilityService
\r
70 // .getHttpErrorMessage(response));
\r
76 var handleGetParametersResponse = function(parameters, dontshow) {
\r
77 $scope.summaryControl.setList(parameters.summaryList);
\r
78 $scope.userProvidedControl.setList(parameters.userProvidedList);
\r
80 $scope.isSpinnerVisible = false;
\r
82 $scope.isDataVisible = false;
\r
84 $scope.isDataVisible = true;
\r
85 $scope.isSubmitEnabled = true;
\r
88 $scope.userParameterChanged = function(id) {
\r
89 StatusService.updateUserParameterList(id, $scope.userProvidedControl);
\r
92 /*$scope.submit = function() {
\r
94 var requiredFields = $scope.userProvidedControl.getRequiredFields();
\r
95 if (requiredFields === "") {
\r
96 $scope.isErrorVisible = false;
\r
98 showError("Missing data", requiredFields);
\r
101 var paramList = $scope.userProvidedControl.getList();
\r
102 var targetprovstatus = "";
\r
104 if ( paramList != null ) {
\r
105 for (var i = 0; i < paramList.length; i++) {
\r
106 if (paramList[i].id === FIELD.ID.VNF_TARGETPROVSTATUS) {
\r
107 targetprovstatus = paramList[i].value;
\r
113 $scope.vnfid = DataService.getVnfInstanceId();
\r
114 $scope.targetProvStatus = StatusService.getTargetProvParameterText(targetprovstatus);
\r
116 $scope.setVnfProvStatus($scope.vnfid, $scope.targetProvStatus);
\r
118 // $scope.isDialogVisible = false;
\r
120 // $scope.popup.isVisible = false;
\r
124 $scope.init = function() {
\r
126 StatusService.updateVnfProvStatus = "";
\r
127 var msecs = PropertyService.retrieveMsoMaxPollingIntervalMsec();
\r
128 PropertyService.setMsoMaxPollingIntervalMsec(msecs);
\r
130 var polls = PropertyService.retrieveMsoMaxPolls();
\r
131 PropertyService.setMsoMaxPolls(polls);
\r
133 PropertyService.setServerResponseTimeoutMsec(30000);
\r
135 $scope.isSpinnerVisible = true;
\r
139 $scope.success = "";
\r
140 $scope.pollAttempts = 0;
\r
142 $scope.isSubmitEnabled = false;
\r
143 $scope.isCancelEnabled = false;
\r
149 $scope.handleInitialResponse = function(response) {
\r
151 $scope.isCancelEnabled = true;
\r
153 if (response.data.status < 200 || response.data.status > 202) {
\r
154 showError(FIELD.ERROR.AAI_ERROR, "");
\r
159 DataService.setUpdatedVNFProvStatus($scope.targetProvStatus);
\r
160 $scope.detailsControl.setList(StatusService.getVNFStatusList());
\r
161 showSuccess(FIELD.STATUS.SUCCESS_VNF_PROV_STATUS, $scope.targetProvStatus);
\r
164 $scope.status = FIELD.STATUS.DONE;
\r
165 $scope.isSpinnerVisible = false;
\r
166 // DataService.setServiceInstanceToCustomer($scope.serviceInstanceToCustomer);
\r
168 $scope.showContentError(error);
\r
172 /* $scope.setVnfProvStatus = function(vnfId, targetProvStatus) {
\r
176 .debug("AaiService:setVnfProvStatus: vnf-id: "
\r
177 + vnfId + " Target Prov_Status: " + targetProvStatus);
\r
178 var url = "aai_vnf_update/"
\r
179 + vnfId + "/" + targetProvStatus + "?r=" + Math.random();
\r
183 timeout : PropertyService
\r
184 .getServerResponseTimeoutMsec()
\r
185 }).then(function(response) {
\r
187 $scope.handleInitialResponse(response);
\r
189 (UtilityService.runHttpErrorHandler);
\r
194 $scope.cancel = function() {
\r
195 $scope.isDialogVisible = false;
\r
196 $scope.popup.isVisible = false;
\r
197 runCallback(false);
\r
200 var runCallback = function(response) {
\r
201 if (angular.isFunction(callbackFunction)) {
\r
203 isSuccessful : response.isSuccessful,
\r
204 control : $scope.userProvidedControl.getList(),
\r
205 instanceId : response.instanceId
\r
210 var showSuccess = function(summary, details) {
\r
211 var message = summary;
\r
212 if (UtilityService.hasContents(details)) {
\r
213 message += " (" + details + ")";
\r
215 $scope.isSpinnerVisible = false;
\r
216 $scope.isSuccessVisible = true;
\r
217 $scope.success = message;
\r
220 var showError = function(summary, details) {
\r
221 var message = summary;
\r
222 if (UtilityService.hasContents(details)) {
\r
223 message += " (" + details + ")";
\r
225 $scope.isSpinnerVisible = false;
\r
226 $scope.isErrorVisible = true;
\r
227 $scope.error = message;
\r
231 appDS2.controller("statusDialogController", [ "COMPONENT", "FIELD", "$scope", "$http", "$timeout",
\r
232 "$log", "MsoService", "StatusService", "DataService", "PropertyService", "UtilityService",
\r
233 statusDialogController ]);
\r