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) {
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);
37 this.appsList = appsList;
39 confirmBoxService.showInformation('There was a problem retrieving the Applications. ' +
40 'Please try again later. Error Status: '+ err.status).then(isConfirmed => {});
41 $log.error('ApplicationsCtrl:openAddNewAppModal: Error: ', err);
43 this.isLoadingTable = false;
48 this.isLoadingTable = false;
50 this.searchString = '';
51 this.appsTableHeaders = [
52 {name: 'Application Name', value: 'name', isSortable: true},
53 {name: 'Active', value: 'isEnabled', isSortable: true},
54 {name: 'Integration Type', value: 'restrictedApp', isSortable: true},
55 {name: 'Guest Access', value: 'isOpen', isSortable: true},
56 {name: 'URL', value: 'url', isSortable: true},
57 {name: 'REST URL', value: 'restUrl', isSortable: true},
58 {name: 'Communication Topic', value: 'uebTopicName', isSortable: true},
59 {name: 'Communication Key', value: 'uebKey', isSortable: true},
60 {name: 'Communication Secret', value: 'uebSecret', isSortable: true},
67 this.openAddNewAppModal = (selectedApp) => {
70 if (!selectedApp.id) {
71 $log.error('App id not found');
79 templateUrl: 'app/views/applications/application-details-dialog/application-details.modal.html',
80 controller: 'AppDetailsModalCtrl',
81 controllerAs: 'appDetails',
83 }).closePromise.then(needUpdate => {
84 if (needUpdate.value === true) {
85 $log.debug('ApplicationsCtrl:openAddNewAppModal: updating table data...');
93 this.deleteApp = application => {
94 $log.debug('ApplicationsCtrl:deleteApp:: ', application.name);
96 confirmBoxService.deleteItem(application.name).then(isConfirmed => {
98 if(!application || !application.id){
99 $log.error('ApplicationsCtrl:deleteApp:: No application or ID... cannot delete');
102 applicationsService.deleteOnboardingApp(application.id).then(() => {
103 this.appsList.splice(this.appsList.indexOf(application), 1);
105 confirmBoxService.showInformation('There was a problem deleting the Application. ' +
106 'Please try again later. Error Status: '+ err.status).then(isConfirmed => {});
107 $log.error('ApplicationsCtrl:deleteApp: Error: ', err);
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);
120 ApplicationsCtrl.$inject = ['$log', '$cookies', 'conf', 'ngDialog',
121 'applicationsService', 'confirmBoxService', 'userProfileService', 'utilsService'];
122 angular.module('ecompApp').controller('ApplicationsCtrl', ApplicationsCtrl);