2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
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 * ================================================================================
22 class PortalAdminsCtrl {
23 constructor($log, portalAdminsService, ngDialog, confirmBoxService, $modal) {
25 let updateTableData = () => {
26 this.isLoadingTable = true;
27 portalAdminsService.getPortalAdmins().then(result=> {
28 $log.debug('PortalAdminsCtrl::updateTableData: result: ' + JSON.stringify(result));
29 if (!result || !result.length) {
30 $log.info('PortalAdminsCtrl::updateTableData: no Portal Admins err handling');
31 this.portalAdminsTableData = [];
34 this.portalAdminsTableData = result;
36 $log.error('PortalAdminsCtrl::updateTableData error :',err);
37 confirmBoxService.showInformation('There was a problem retrieving the portal admins. ' +
38 'Please try again later. Error: ' + err.status).then(isConfirmed => {});
41 this.isLoadingTable = false;
46 $log.info('portalAdminsService.getPortalAdmins::initializing...');
47 this.isLoadingTable = false;
49 /*Table general configuration params*/
50 this.searchString= '';
52 this.portalAdminsTableHeaders = ['First Name', 'Last Name', 'User ID', 'Delete'];
53 this.portalAdminsTableData = [];
59 this.removePortalAdmin = pAdmin => {
60 $log.debug('PortalAdminsCtrl::removePortalAdmin: pAdmin = ' + JSON.stringify(pAdmin));
61 confirmBoxService.deleteItem(pAdmin.firstName + ' ' + pAdmin.lastName )
62 .then(isConfirmed => {
64 if(!pAdmin || !pAdmin.userId){
65 $log.error('PortalAdminsCtrl::removePortalAdmin No portal admin or ID... cannot delete');
68 portalAdminsService.removePortalAdmin(pAdmin.userId,pAdmin.loginId).then(() => {
69 $log.info("PortalAdminsCtrl::removePortalAdmin removed admin");
72 $log.error('PortalAdminsCtrl::removePortalAdmin.deleteItem error: '+ err);
73 confirmBoxService.showInformation('There was a problem deleting this portal admins. ' +
74 'Please try again later. Error: ' + err.status).then(isConfirmed => {});
78 $log.error('PortalAdminsCtrl::removePortalAdmin.deleteItem error: '+ err);
82 this.openAddNewPortalAdminModal = (user) => {
88 orgUserId: user.orgUserId,
89 firstName: user.firstName,
90 lastName: user.lastName
95 var modalInstance = $modal.open({
96 templateUrl: 'app/views/portal-admin/new-portal-admin/new-portal-admin.modal.html',
97 controller: 'NewPortalAdminModalCtrl as newPortalAdmin',
98 sizeClass: 'modal-medium',
102 modalInstance.result.finally(function () {
103 $log.debug('PortalAdminsCtrl::openAddNewPortalAdminModal: updating Portal Admin table data...');
110 PortalAdminsCtrl.$inject = ['$log', 'portalAdminsService', 'ngDialog', 'confirmBoxService', '$modal'];
111 angular.module('ecompApp').controller('PortalAdminsCtrl', PortalAdminsCtrl);