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