2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
40 class ApplicationsCtrl {
42 constructor($log, $cookies, conf, ngDialog,
43 applicationsService, confirmBoxService, userProfileService, utilsService,$modal) {
44 this.emptyImgForPreview = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
45 let getOnboardingApps = () => {
46 this.isLoadingTable = true;
47 applicationsService.getOnboardingApps()
49 // Use proper back-end URL to load image
50 for (var i = 0; i < appsList.length; i++) {
51 appsList[i].imageLink = '';
52 if (appsList[i].imageUrl){
53 appsList[i].imageLink = conf.api.appThumbnail.replace(':appId', appsList[i].id);
54 appsList[i].imageLink = appsList[i].imageLink+'?' + new Date().getTime();
57 this.appsList = appsList;
59 confirmBoxService.showInformation('There was a problem retrieving the Applications. ' +
60 'Please try again later. Error Status: '+ err.status).then(isConfirmed => {});
61 $log.error('ApplicationsCtrl:openAddNewAppModal: Error: ', err);
63 this.isLoadingTable = false;
68 this.isLoadingTable = false;
70 this.searchString = '';
71 this.appsTableHeaders = [
72 {name: 'Application Name', value: 'name', isSortable: true},
73 {name: 'Active', value: 'isEnabled', isSortable: true},
74 {name: 'Integration Type', value: 'restrictedApp', isSortable: true},
75 {name: 'Guest Access', value: 'isOpen', isSortable: true},
76 {name: 'URL', value: 'url', isSortable: true},
77 {name: 'REST URL', value: 'restUrl', isSortable: true},
78 {name: 'Communication Topic', value: 'uebTopicName', isSortable: true},
79 {name: 'Communication Key', value: 'uebKey', isSortable: true},
80 {name: 'Communication Secret', value: 'uebSecret', isSortable: true},
81 {name: 'Application Namespace', value: 'nameSpace', isSortable: true},
82 {name: 'Central Access Type', value: 'isCentralAuth', isSortable: true}
89 this.openAddNewAppModal = (selectedApp) => {
92 if (!selectedApp.id) {
93 $log.error('App id not found');
100 var modalInstance = $modal.open({
101 templateUrl: 'app/views/applications/application-details-dialog/application-details.modal.html',
102 controller: 'AppDetailsModalCtrl as appDetails',
103 sizeClass: 'modal-large',
104 windowClass:"modal-docked",
112 modalInstance.result.finally(function (){
118 this.deleteApp = application => {
119 $log.debug('ApplicationsCtrl:deleteApp:: ', application.name);
121 confirmBoxService.deleteItem(application.name).then(isConfirmed => {
123 if(!application || !application.id){
124 $log.error('ApplicationsCtrl:deleteApp:: No application or ID... cannot delete');
127 applicationsService.deleteOnboardingApp(application.id).then(() => {
128 this.appsList.splice(this.appsList.indexOf(application), 1);
130 confirmBoxService.showInformation('There was a problem deleting the Application. ' +
131 'Please try again later. Error Status: '+ err.status).then(isConfirmed => {});
132 $log.error('ApplicationsCtrl:deleteApp: Error: ', err);
136 confirmBoxService.showInformation('There was a problem deleting the Application. ' +
137 'Please try again later. Error Status: '+ err.status).then(isConfirmed => {});
138 $log.error('ApplicationsCtrl:deleteApp error:: ', err);
145 ApplicationsCtrl.$inject = ['$log', '$cookies', 'conf', 'ngDialog',
146 'applicationsService', 'confirmBoxService', 'userProfileService', 'utilsService','$modal'];
147 angular.module('ecompApp').controller('ApplicationsCtrl', ApplicationsCtrl);