2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 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=========================================================
24 appDS2.controller("changeManagementController", ["$uibModal", "changeManagementService", "_", "$log", "SchedulerService", "$filter", "VIDCONFIGURATION", changeManagementController]);
26 function changeManagementController($uibModal, changeManagementService, _, $log, SchedulerService, $filter, VIDCONFIGURATION) {
29 vm.lastTimeUpdated = "";
30 vm.hasScheduler = !!VIDCONFIGURATION.SCHEDULER_PORTAL_URL;
33 vm.init = function() {
34 vm.lastTimeUpdated = $filter('date')(new Date(), "MM/dd/yyyy | HH:mm:ss");
35 loadMSOChangeManagements();
36 loadSchedulerChangeManagements();
39 var fuseMsoAndSchedulerTaks = function() {
40 if (vm.changeManagements && vm.pendingChangeManagements) {
41 var requestIdToVnfName = {};
42 vm.pendingChangeManagements.forEach(function(schedulerItem) {
43 if (schedulerItem.msoRequestId && schedulerItem.vnfName) {
44 requestIdToVnfName[schedulerItem.msoRequestId] = schedulerItem.vnfName;
47 $log.debug("requestIdToVnfName", requestIdToVnfName);
49 vm.changeManagements = vm.changeManagements.map(function(msoItem) {
50 msoItem['vnfNameFromScheduler'] = requestIdToVnfName[msoItem.requestId];
56 var loadMSOChangeManagements = function() {
57 changeManagementService.getMSOChangeManagements()
58 .then(function(response) {
59 vm.changeManagements = response.data;
62 fuseMsoAndSchedulerTaks();
64 .catch(function (error) {
69 var loadSchedulerChangeManagements = function() {
70 changeManagementService.getSchedulerChangeManagements()
71 .then(function(response) {
72 vm.pendingChangeManagements = response.data;
73 _.forEach(vm.pendingChangeManagements, function(changeManagement) {
74 var callbackData = _.filter(changeManagement.scheduleRequest.domainData, {name: "WorkflowName"});
78 parsedModel = callbackData[0].value;
80 $log.error(exception);
83 changeManagement.workflow = parsedModel;
88 fuseMsoAndSchedulerTaks();
90 .catch(function(error) {
95 vm.createNewChange = function() {
96 vm.closeCurrentModalIfOpen();
97 var modalInstance = $uibModal.open({
98 templateUrl: 'app/vid/scripts/modals/new-change-management/new-change-management.html',
99 controller: 'newChangeManagementModalController',
104 vm.currModal = modalInstance;
106 modalInstance.result.then(function (result) {
107 console.log("This is the result of the new change management modal.", result);
111 vm.searchChanges = function() {
112 console.log("function for searching changes: " + vm.searchChangesTerm);
116 vm.openManualTasksPopup = function($event, jobInfo, templateUrl, message) {
118 vm.closeCurrentModalIfOpen();
120 var modalInstance = $uibModal.open({
121 templateUrl: templateUrl,
122 controller: 'changeManagementManualTasksController',
126 appendTo: angular.element($event.currentTarget).parent(),
128 jobInfo: function () {
134 modalInstance.result.then(function (result) {
135 console.log(message, result);
138 vm.currModal = modalInstance;
141 vm.openFailedModal = function($event, jobInfo) {
142 vm.openManualTasksPopup($event, jobInfo,
143 'app/vid/scripts/modals/failed-change-management/failed-change-management.html',
144 "This is the result of the failed change management modal.");
147 vm.openInProgressModal = function($event, jobInfo) {
148 vm.openManualTasksPopup($event, jobInfo,
149 'app/vid/scripts/modals/in-progress-modal-management/in-progress-change-management.html',
150 "This is the result of the in progress change management modal.");
153 vm.openAlertModal = function($event, jobInfo) {
154 vm.openManualTasksPopup($event, jobInfo,
155 'app/vid/scripts/modals/alert-change-management/alert-change-management.html',
156 "This is the result of the alert change management modal.");
159 vm.openBasicAlertModal = function(jobInfo) {
160 vm.closeCurrentModalIfOpen();
161 var modalInstance = $uibModal.open({
162 templateUrl: 'app/vid/scripts/modals/alert-modal/alert-modal.html',
163 controller: 'alertModalController',
167 appendTo: angular.element(".jobs-table").eq(0),
169 jobInfo: function () {
174 vm.currModal = modalInstance;
176 modalInstance.result.then(function (result) {
177 console.log("This is the result of the alert change management modal.", result);
180 vm.openPendingModal = function($event, changeManagement) {
182 vm.closeCurrentModalIfOpen();
184 var modalInstance = $uibModal.open({
185 templateUrl: 'app/vid/scripts/modals/cancel-pending-workflow/cancel-pending-workflow.html',
186 controller: 'cancelPendingWorkflowController',
190 appendTo: angular.element($event.currentTarget).parent(),
192 changeManagement: function () {
193 return changeManagement;
198 vm.currModal = modalInstance;
200 modalInstance.result.then(function (result) {
203 SchedulerService.cancelScheduleRequest(changeManagement.scheduleRequest.scheduleId,
209 message: "Cancel workflow "+changeManagement.scheduleRequest.scheduleName+" succeeded."};
210 vm.openBasicAlertModal(jobInfo);
218 message: "Cancel workflow "+changeManagement.scheduleRequest.scheduleName+" failed due to an unexpected error."};
219 vm.openBasicAlertModal(jobInfo);
225 vm.isChangeManagementDeleted = function(changeManagement) {
226 return changeManagement.scheduleRequest.status!=='Deleted'
229 vm.closeCurrentModalIfOpen = function() {
230 if (vm.currModal != null) {
231 vm.currModal.close();