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 ApplicationsCtrl {
24 constructor($log, $cookies, conf, ngDialog,
25 applicationsService, confirmBoxService, userProfileService, utilsService,$modal) {
26 this.emptyImgForPreview = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
27 let getOnboardingApps = () => {
28 this.isLoadingTable = true;
29 applicationsService.getOnboardingApps()
31 // Use proper back-end URL to load image
32 for (var i = 0; i < appsList.length; i++) {
33 appsList[i].imageLink = '';
34 if (appsList[i].imageUrl){
35 appsList[i].imageLink = conf.api.appThumbnail.replace(':appId', appsList[i].id);
36 appsList[i].imageLink = appsList[i].imageLink+'?' + new Date().getTime();
39 this.appsList = appsList;
41 confirmBoxService.showInformation('There was a problem retrieving the Applications. ' +
42 'Please try again later. Error Status: '+ err.status).then(isConfirmed => {});
43 $log.error('ApplicationsCtrl:openAddNewAppModal: Error: ', err);
45 this.isLoadingTable = false;
50 this.isLoadingTable = false;
52 this.searchString = '';
53 this.appsTableHeaders = [
54 {name: 'Application Name', value: 'name', isSortable: true},
55 {name: 'Active', value: 'isEnabled', isSortable: true},
56 {name: 'Integration Type', value: 'restrictedApp', isSortable: true},
57 {name: 'Guest Access', value: 'isOpen', isSortable: true},
58 {name: 'URL', value: 'url', isSortable: true},
59 {name: 'REST URL', value: 'restUrl', isSortable: true},
60 {name: 'Communication Topic', value: 'uebTopicName', isSortable: true},
61 {name: 'Communication Key', value: 'uebKey', isSortable: true},
62 {name: 'Communication Secret', value: 'uebSecret', isSortable: true},
63 {name: 'Application Namespace', value: 'nameSpace', isSortable: true},
64 {name: 'Central Access Type', value: 'isCentralAuth', isSortable: true}
71 this.openAddNewAppModal = (selectedApp) => {
74 if (!selectedApp.id) {
75 $log.error('App id not found');
82 var modalInstance = $modal.open({
83 templateUrl: 'app/views/applications/application-details-dialog/application-details.modal.html',
84 controller: 'AppDetailsModalCtrl as appDetails',
85 sizeClass: 'modal-large',
93 modalInstance.result.finally(function (){
99 this.deleteApp = application => {
100 $log.debug('ApplicationsCtrl:deleteApp:: ', application.name);
102 confirmBoxService.deleteItem(application.name).then(isConfirmed => {
104 if(!application || !application.id){
105 $log.error('ApplicationsCtrl:deleteApp:: No application or ID... cannot delete');
108 applicationsService.deleteOnboardingApp(application.id).then(() => {
109 this.appsList.splice(this.appsList.indexOf(application), 1);
111 confirmBoxService.showInformation('There was a problem deleting the Application. ' +
112 'Please try again later. Error Status: '+ err.status).then(isConfirmed => {});
113 $log.error('ApplicationsCtrl:deleteApp: Error: ', err);
117 confirmBoxService.showInformation('There was a problem deleting the Application. ' +
118 'Please try again later. Error Status: '+ err.status).then(isConfirmed => {});
119 $log.error('ApplicationsCtrl:deleteApp error:: ', err);
126 ApplicationsCtrl.$inject = ['$log', '$cookies', 'conf', 'ngDialog',
127 'applicationsService', 'confirmBoxService', 'userProfileService', 'utilsService','$modal'];
128 angular.module('ecompApp').controller('ApplicationsCtrl', ApplicationsCtrl);