2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
23 var deletionDialogController = function($scope, $http, $timeout, $log,
24 DeletionService, UtilityService) {
26 $scope.isDialogVisible = false;
27 $scope.summaryControl = {};
28 $scope.userProvidedControl = {};
30 var callbackFunction = undefined;
32 $scope.$on("deleteComponent", function(event, request) {
34 $scope.isDataVisible = false;
35 $scope.isSpinnerVisible = false;
36 $scope.isErrorVisible = false;
37 $scope.isDialogVisible = true;
38 $scope.popup.isVisible = true;
39 $scope.isConfirmEnabled = false;
41 callbackFunction = request.callbackFunction;
43 DeletionService.initializeComponent(request.componentId);
45 $scope.componentName = DeletionService.getComponentDisplayName();
47 $scope.summaryControl.setList(DeletionService.getSummaryList());
49 DeletionService.getParameters(handleGetParametersResponse);
53 var handleGetParametersResponse = function(parameters, dontshow) {
54 $scope.summaryControl.setList(parameters.summaryList);
55 $scope.userProvidedControl.setList(parameters.userProvidedList);
57 $scope.isSpinnerVisible = false;
59 $scope.isDataVisible = false;
61 $scope.isDataVisible = true;
62 $scope.isConfirmEnabled = true;
65 $scope.userParameterChanged = function(id) {
66 DeletionService.updateUserParameterList(id, $scope.userProvidedControl);
69 $scope.confirm = function() {
71 var requiredFields = $scope.userProvidedControl.getRequiredFields();
72 if (requiredFields === "") {
73 $scope.isErrorVisible = false;
75 showError("Missing data", requiredFields);
80 var requestDetails = DeletionService.getMsoRequestDetails($scope.userProvidedControl.getList());
82 $scope.isDialogVisible = false;
84 $scope.$broadcast("deleteInstance", {
85 url : DeletionService.getMsoUrl(),
86 requestDetails : requestDetails,
87 callbackFunction : function(isSuccessful) {
89 $scope.popup.isVisible = false;
92 $scope.isDialogVisible = true;
99 $scope.cancel = function() {
100 $scope.isDialogVisible = false;
101 $scope.popup.isVisible = false;
105 var runCallback = function(isSuccessful) {
106 if (angular.isFunction(callbackFunction)) {
108 isSuccessful : isSuccessful
115 .controller("deletionDialogController", [ "$scope", "$http",
116 "$timeout", "$log", "DeletionService", "UtilityService",
117 deletionDialogController ]);