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 {
23 constructor($log, applicationsService, confirmBoxService, ngDialog,userProfileService,$cookies) {
24 $log.info('ApplicationsCtrl::init: Starting up');
26 this.emptyImgForPreview = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
27 let getOnboardingApps = () => {
28 this.isLoadingTable = true;
29 applicationsService.getOnboardingApps()
31 this.appsList = appsList;
35 this.isLoadingTable = false;
40 this.isLoadingTable = false;
43 this.searchString = '';
44 this.appsTableHeaders = [
45 {name: 'Application Name', value: 'name', isSortable: true},
46 {name: 'Active', value: 'isEnabled', isSortable: true},
47 {name: 'Integration Type', value: 'restrictedApp', isSortable: true},
48 {name: 'Guest Access', value: 'isOpen', isSortable: true},
49 {name: 'URL', value: 'url', isSortable: true},
50 {name: 'REST URL', value: 'restUrl', isSortable: true},
51 {name: 'Communication Topic', value: 'uebTopicName', isSortable: true},
52 {name: 'Communication Key', value: 'uebKey', isSortable: true},
53 {name: 'Communication Secret', value: 'uebSecret', isSortable: true},
60 this.openAddNewAppModal = (selectedApp) => {
63 if (!selectedApp.id) {
64 $log.error('App id not found');
72 templateUrl: 'app/views/applications/application-details-dialog/application-details.modal.html',
73 controller: 'AppDetailsModalCtrl',
74 controllerAs: 'appDetails',
76 }).closePromise.then(needUpdate => {
77 if (needUpdate.value === true) {
78 $log.debug('ApplicationsCtrl:openAddNewAppModal:: updating table data...');
86 this.deleteApp = application => {
87 $log.debug('ApplicationsCtrl:deleteApp:: ', application.name);
89 confirmBoxService.deleteItem(application.name).then(isConfirmed => {
91 if(!application || !application.id){
92 $log.error('ApplicationsCtrl:deleteApp:: No application or ID... cannot delete');
95 applicationsService.deleteOnboardingApp(application.id).then(() => {
96 this.appsList.splice(this.appsList.indexOf(application), 1);
102 $log.error('ApplicationsCtrl:deleteApp error:: ', err);
109 ApplicationsCtrl.$inject = ['$log', 'applicationsService', 'confirmBoxService', 'ngDialog','userProfileService','$cookies'];
110 angular.module('ecompApp').controller('ApplicationsCtrl', ApplicationsCtrl);