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 * ================================================================================
23 constructor($log, $scope, $stateParams, filterFilter, getAccessService, userProfileService, ExternalRequestAccessService, applicationsService, ngDialog) {
24 // $log.debug('GetAccessCtrl: appService param is: ' + applicationsService.goGetAccessAppName);
25 var resultAccessValue = null;
27 $scope.openAppRoleModal = (itemData) => {
28 if(resultAccessValue){
33 orgUserId: $scope.orgUserId,
34 firstName: $scope.firstName,
35 lastName: $scope.lastName,
36 headerText: itemData.app_name,
40 templateUrl: 'app/views/catalog/request-access-catalog-dialogs/request-access-catalog.modal.html',
41 controller: 'ExternalRequestAccessCtrl',
42 controllerAs: 'userInfo',
48 $scope.$watch('access.searchString', function (searchKey) {
49 var search = searchKey;
50 this.totalPage = filterFilter($scope.access.appTable, search);
51 var resultLen = this.totalPage.length;
52 $scope.access.totalPage = Math.ceil(resultLen/$scope.access.viewPerPage);
53 $scope.access.currentPage = 1;
56 userProfileService.getUserProfile().then(
58 $scope.orgUserId = profile.orgUserId;
59 $scope.firstName = profile.firstName;
60 $scope.lastName = profile.lastName;
63 this.updateAppsList = () => {
64 ExternalRequestAccessService.getExternalRequestAccessServiceInfo().then(
66 resultAccessValue = property.accessValue;
68 $log.error('GetAccessCtrl: failed getExternalRequestAccessServiceInfo: ' + JSON.Stringify(err));
70 getAccessService.getListOfApp().then(res=> {
72 // $log.info('GetAccessCtrl::updateAppsList: getting res');
73 var result = (typeof(res.data) != "undefined" && res.data!=null)?res.data:null;
74 // $log.info('GetAccessCtrl::updateAppsList: result',result);
75 // $log.info('GetAccessCtrl::updateAppsList: done');
77 // $log.info('GetAccessCtrl::updateAppsList source: ', source);
78 for(var i=0;i<source.length; i++){
79 var dataArr = source[i];
80 var checkEcompFuncAvail = 'Ecomp Function Not Available' ;
81 var reqStatus = 'Pending';
82 dataArr.ecompFunction = (dataArr.ecompFunction === null) ? checkEcompFuncAvail : dataArr.ecompFunction;
83 dataArr.reqType = (dataArr.reqType === 'P') ? reqStatus : dataArr.reqType;
85 ecomp_function: dataArr.ecompFunction,
86 app_name:dataArr.appName,
87 role_name:dataArr.roleName,
88 current_role:dataArr.roleActive,
89 request_type:dataArr.reqType
91 tableData.push(dataTemp);
93 this.appTable=tableData;
95 var len = tableData.length;
96 this.totalPage = Math.ceil(len/this.viewPerPage);
98 if( $stateParams.appName != null)
99 this.searchString = $stateParams.appName;
101 this.searchString = applicationsService.goGetAccessAppName;
102 // the parameter has been used; clear the value.
103 applicationsService.goGetAccessAppName = '';
105 $log.error('GetAccessCtrl:error:: ', err);
107 this.isLoadingTable = false;
111 this.updateTable = (num) => {
112 this.startIndex=this.viewPerPage*(num-1);
113 this.currentPage = num;
116 // $log.info('GetAccessCtrl:: initializing...');
117 this.searchString = '';
118 this.getAccessTableHeaders = ['ECOMP Function', 'Application Name', 'Role Name', 'Current Role', 'Request Status'];
120 this.updateAppsList();
123 this.currentPage = 1;
129 GetAccessCtrl.$inject = ['$log', '$scope', '$stateParams', 'filterFilter', 'getAccessService', 'userProfileService', 'ExternalRequestAccessService','applicationsService', 'ngDialog'];
130 angular.module('ecompApp').controller('GetAccessCtrl', GetAccessCtrl);