Application Onboarding page changes
[portal.git] / ecomp-portal-FE-common / client / app / services / applications / applications.service.js
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
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
12  *
13  *             http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
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
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
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.
33  *
34  * ============LICENSE_END============================================
35  *
36  * 
37  */
38 'use strict';
39
40 (function () {
41     class ApplicationsService {
42         constructor($q, $log, $http, conf, uuid, utilsService) {
43             this.$q = $q;
44             this.$log = $log;
45             this.$http = $http;
46             this.conf = conf;
47             this.uuid = uuid;
48             this.utilsService = utilsService
49         }
50         
51         getSingleAppInfo(appName) {
52             let deferred = this.$q.defer();
53             var _this12 = this;
54             this.$http.get(this.conf.api.singleAppInfo,
55                 {
56                     cache: false,
57                     params:{'appParam':appName},
58                     headers: {
59                         'X-ECOMP-RequestID':this.uuid.generate()
60                     }
61                 })
62                 .then( res => {
63                     // If response comes back as a redirected HTML page which IS NOT a success
64                         // But don't declare an empty list to be an error.
65                     if (res == null || res.data == null || _this12.utilsService.isValidJSON(res.data) == false) {
66                         deferred.reject("ApplicationsService::getSingleAppInfo Failed");
67                     } else {
68                         deferred.resolve(res.data);
69                     }
70                 })
71                 .catch( status => {
72                     deferred.reject(status);
73                 });
74             return deferred.promise;
75         }
76         
77         getSingleAppInfoById(appId) {
78             let deferred = this.$q.defer();
79             var _this14 = this;
80             this.$http.get(this.conf.api.singleAppInfoById,
81                 {
82                     cache: false,
83                     params:{'appParam':appId},
84                     headers: {
85                         'X-ECOMP-RequestID':this.uuid.generate()
86                     }
87                 })
88                 .then( res => {
89                     // If response comes back as a redirected HTML page which IS NOT a success
90                         // But don't declare an empty list to be an error.
91                     if (res == null || res.data == null || _this14.utilsService.isValidJSON(res.data) == false) {
92                         deferred.reject("ApplicationsService::getSingleAppInfoById Failed");
93                     } else {
94                         deferred.resolve(res.data);
95                     }
96                 })
97                 .catch( status => {
98                     deferred.reject(status);
99                 });
100             return deferred.promise;
101         }
102         
103         getPersUserApps() {
104             let deferred = this.$q.defer();
105             var _this0 = this;
106             // this.$log.info('ApplicationsService::getPersUserApps');
107             this.$http.get(this.conf.api.persUserApps,
108                 {
109                     cache: false,
110                     headers: {
111                         'X-ECOMP-RequestID':this.uuid.generate()
112                     }
113                 })
114                 .then( res => {
115                     // If response comes back as a redirected HTML page which IS NOT a success
116                         // But don't declare an empty list to be an error.
117                     if (res == null || res.data == null || _this0.utilsService.isValidJSON(res.data) == false) {
118                         deferred.reject("ApplicationsService::getPersUserApps Failed");
119                     } else {
120                         deferred.resolve(res.data);
121                     }
122                 })
123                 .catch( status => {
124                     deferred.reject(status);
125                 });
126             return deferred.promise;
127         }
128         
129         getAppsOrderBySortPref(userAppSortTypePref) {
130             let deferred = this.$q.defer();
131             var _this1 = this;
132             // this.$log.info('ApplicationsService::getAppsOrderBySortPref');
133             this.$http.get(this.conf.api.userAppsOrderBySortPref,
134                 {
135                     cache: false,
136                     params:{'mparams':userAppSortTypePref},
137                     headers: {
138                         'X-ECOMP-RequestID':this.uuid.generate()
139                     }
140                 })
141                 .then( res => {
142                     // If response comes back as a redirected HTML page which IS NOT a success
143                         // But don't declare an empty list to be an error.
144                     if (res == null || res.data == null || _this1.utilsService.isValidJSON(res.data)== false) {
145                         deferred.reject("ApplicationsService::getAppsOrderBySortPref Failed");
146                     } else {
147                         // this.$log.info('ApplicationsService::getAppsOrderBySortPref Succeeded');
148                         deferred.resolve(res.data);
149                     }
150                 })
151                 .catch( status => {
152                     deferred.reject(status);
153                 });
154
155             return deferred.promise;
156         }
157         checkIfUserIsSuperAdmin() {
158             let deferred = this.$q.defer();
159             var _this0 = this;
160             // this.$log.info('ApplicationsService::getPersUserApps');
161             this.$http.get(this.conf.api.checkIfUserIsSuperAdmin,
162                 {
163                     cache: false,
164                     headers: {
165                         'X-ECOMP-RequestID':this.uuid.generate()
166                     }
167                 })
168                 .then( res => {
169                     // If response comes back as a redirected HTML page which IS NOT a success
170                         // But don't declare an empty list to be an error.
171                     if (res == null || res.data == null) {
172                         deferred.reject("ApplicationsService::checkIfUserIsSuperAdmin Failed");
173                     } else {
174                         deferred.resolve(res.data);
175                     }
176                 })
177                 .catch( status => {
178                     deferred.reject(status);
179                 });
180             return deferred.promise;
181         }
182         saveAppsSortTypeManual(appsSortManual){
183             let deferred = this.$q.defer();
184             if (appsSortManual== undefined
185                                         || appsSortManual == null
186                                         || appsSortManual.length == 0) {
187                 this.$log.error('ApplicationsService::saveAppsSortTypeManual: Apps Sort Manual received empty string!'); 
188                 return deferred.reject('Apps Sort Manual received empty string ');
189             }
190             
191             this.$http({
192                 method: 'PUT',
193                 url: this.conf.api.saveUserAppsSortingManual,
194                 data: appsSortManual,
195                 cache: false,
196                 headers: {
197                     'X-ECOMP-RequestID':this.uuid.generate()
198                 }
199             }).then( res => {
200                     // If response comes back as a redirected HTML page which IS
201                                         // NOT a success
202                         // But don't declare an empty list to be an error.
203                     if (res == null || res.data == null) {
204                         deferred.reject("ApplicationsService::saveAppsSortTypeManual Failed");
205                     } else {
206                         // this.$log.info('ApplicationsService::saveAppsSortTypeManual
207                                                 // Succeeded');
208                         deferred.resolve(res.data);
209                     }
210                 })
211                 .catch( status => {
212                     deferred.reject(status);
213                 });
214             return deferred.promise;
215         }
216             
217         saveAppsSortTypePreference(appsSortPreference){
218             let deferred = this.$q.defer();
219             var _this2 = this;
220             if (appsSortPreference== undefined
221                                         || appsSortPreference == null
222                                         || appsSortPreference.length == 0){
223                 this.$log.error('ApplicationsService::saveAppsSortTypePreference: Apps Sort type Preference received empty string!'); 
224                          return deferred.reject('Apps Sort type Preference received empty string ');
225             }
226             this.$http({
227                 method: 'PUT',
228                 url: this.conf.api.saveUserAppsSortingPreference,
229                 data: appsSortPreference,
230                 cache: false,
231                 headers: {
232                     'X-ECOMP-RequestID':this.uuid.generate()
233                 }
234             }).then( res => {
235                     // If response comes back as a redirected HTML page which IS NOT a success
236                         // But don't declare an empty list to be an error.
237                     if (res == null || res.data == null || _this2.utilsService.isValidJSON(res) == false) {
238                         deferred.reject("ApplicationsService::saveAppsSortTypePreference Failed");
239                     } else {
240                         // this.$log.info('ApplicationsService::saveAppsSortTypePreference Succeeded');
241                         deferred.resolve(res.data);
242                     }
243                 })
244                 .catch( status => {
245                     deferred.reject(status);
246                 });
247             return deferred.promise;
248         }
249         
250         getUserAppsSortTypePreference() {
251                 let deferred = this.$q.defer();
252                 var _this3 = this;
253                 this.$http({
254                         method: "GET",
255                         url: this.conf.api.userAppsSortTypePreference,
256                         cache: false,
257                         headers: {
258                             'X-ECOMP-RequestID':this.uuid.generate()
259                         }
260                     })
261                     .then( res => {
262                         if (res == null || res.data == null || _this3.utilsService.isValidJSON(res) == false) {  
263                                 deferred.reject("ApplicationsService::getSortTypePreference Failed");
264                         } else {
265                             // this.$log.info('ApplicationsService::getUserAppsSortTypePreference Succeeded');
266                             deferred.resolve(res.data);
267                         }
268                     })
269                     .catch( status => {
270                         deferred.reject(status);
271                     });
272                         return deferred.promise;
273         }
274         
275         saveWidgetsSortManual(widgetsSortManual){
276             let deferred = this.$q.defer();
277             var _this4 = this;
278             if (widgetsSortManual== undefined
279                                         || widgetsSortManual == null
280                                         || widgetsSortManual.length == 0){
281                 this.$log.error('ApplicationsService::saveWidgetsSortManual: Widegts Sort type Preference received empty string!'); 
282                          return deferred.reject('Widgets Sort Manual received empty string ');
283             }
284             this.$http({
285                 method: 'PUT',
286                 url: this.conf.api.saveUserWidgetsSortManual,
287                 data: widgetsSortManual,
288                 cache: false,
289                 headers: {
290                     'X-ECOMP-RequestID':this.uuid.generate()
291                 }
292             }).then( res => {
293                     if (res == null || res.data == null || _this4.utilsService.isValidJSON(res) == false) {
294                         deferred.reject("ApplicationsService::saveWidgetsSortManual Failed");
295                     } else {
296                         // this.$log.info('ApplicationsService::saveWidgetsSortManual
297                                                 // Succeeded');
298                         deferred.resolve(res.data);
299                     }
300                 })
301                 .catch( status => {
302                     deferred.reject(status);
303                 });
304             return deferred.promise;
305         }
306         
307         delWidgetsSortPref(widgetsData){
308             let deferred = this.$q.defer();
309             var _this5 = this;
310              
311             if (widgetsData== undefined
312                                         || widgetsData == null
313                                         || widgetsData.length == 0){
314                 this.$log.error('ApplicationsService::delWidgetsSortPref: While deleting, widgets  received empty string!'); 
315                 return deferred.reject('Widgets received empty string ');
316             }
317             
318             this.$http({
319                 method: 'PUT',
320                 url: this.conf.api.updateWidgetsSortPref,
321                 data: widgetsData,
322                 cache: false,
323                 headers: {
324                     'X-ECOMP-RequestID':this.uuid.generate()
325                 }
326             }).then( res => {
327                     if (res == null || res.data == null || _this5.utilsService.isValidJSON(res) == false) {
328                         deferred.reject("ApplicationsService::delWidgetsSortPref Failed");
329                     } else {
330                         // this.$log.info('ApplicationsService::delWidgetsSortPref
331                                                 // Succeeded');
332                         deferred.resolve(res.data);
333                     }
334                 })
335                 .catch( status => {
336                     deferred.reject(status);
337                 });
338             return deferred.promise;
339         }
340         
341         getAvailableApps() {
342             let deferred = this.$q.defer();
343             var _this6 = this;
344             // this.$log.info('ApplicationsService::getAvailableApps');
345             
346             this.$http(
347                 {
348                     method: "GET",
349                     url: this.conf.api.availableApps,
350                     cache: false,
351                     headers: {
352                         'X-ECOMP-RequestID':this.uuid.generate()
353                     }
354                 })
355                 .then( res => {
356                     if (res == null || res.data == null || _this6.utilsService.isValidJSON(res) == false) {
357                         deferred.reject("ApplicationsService::getAvailableApps Failed");
358                     } else {
359                         // this.$log.info('ApplicationsService::getAvailableApps Succeeded');
360                         deferred.resolve(res.data);
361                     }
362                 })
363                 .catch( status => {
364                     deferred.reject(status);
365                 });
366
367             return deferred.promise;
368         }
369
370         getAdminApps(){
371             var _this7 = this;
372             let canceller = this.$q.defer();
373             let isActive = false;
374
375             let cancel = () => {
376                 if(isActive){
377                     this.$log.debug('ApplicationsService::getAdminApps: canceling the request');
378                     canceller.resolve();
379                 }
380             };
381
382             let promise = () => {
383                 isActive = true;
384                 let deferred = this.$q.defer();
385                 // this.$log.info('ApplicationsService::getAdminApps: starting');
386                 this.$http({method: "GET",
387                         url: this.conf.api.adminApps,
388                         cache: false,
389                         timeout: canceller.promise,
390                         headers: {
391                             'X-ECOMP-RequestID':this.uuid.generate()
392                         }
393                     }).then(res => {
394                         isActive = false;
395                         if (res == null || res.data == null || _this7.utilsService.isValidJSON(res) == false) {
396                             deferred.reject("ApplicationsService::adminApps Failed");
397                         } else {
398                             // this.$log.info('ApplicationsService::adminApps Succeeded');
399                             deferred.resolve(res.data);
400                         }
401                     })
402                     .catch(status => {
403                         isActive = false;
404                         deferred.reject(status);
405                     });
406                 return deferred.promise;
407             };
408
409             return {
410                 cancel: cancel,
411                 promise: promise
412             };
413         }
414
415         getLeftMenuItems(){
416             let deferred = this.$q.defer();
417             var _this8 = this;
418             // this.$log.info('ApplicationsService::getAppsForSuperAdminAndAccountAdmin');
419             this.$http({method: "GET",
420                 url: this.conf.api.leftmenuItems,
421                 cache: false,
422                 headers: {
423                     'X-ECOMP-RequestID':this.uuid.generate()
424                 }
425             }).then(res => {
426                     // If response comes back as a redirected HTML page which IS NOT a success
427                         // But don't declare an empty list to be an error.
428                 this.$log.debug('getLeftMenuItems::getAdminApps: canceling the request',res);
429
430                     if (res == null || res.data == null || _this8.utilsService.isValidJSON(res) == false) {
431                         deferred.reject("ApplicationsService::getLeftMenuItems Failed");
432                     } else {
433                         // this.$log.info('ApplicationsService::getAppsForSuperAdminAndAccountAdmin Succeeded');
434                         deferred.resolve(res.data);
435                     }
436                 })
437                 .catch(status => {
438                     deferred.reject(status);
439                 });
440             return deferred.promise;
441         }
442         
443         getAppsForSuperAdminAndAccountAdmin(){
444             let deferred = this.$q.defer();
445             var _this9 = this;
446             // this.$log.info('ApplicationsService::getAppsForSuperAdminAndAccountAdmin');
447             this.$http({method: "GET",
448                 url: this.conf.api.appsForSuperAdminAndAccountAdmin,
449                 cache: false,
450                 headers: {
451                     'X-ECOMP-RequestID':this.uuid.generate()
452                 }
453             }).then(res => {
454                     // If response comes back as a redirected HTML page which IS NOT a success
455                         // But don't declare an empty list to be an error.
456                     if (res == null || res.data == null || _this9.utilsService.isValidJSON(res) == false) {
457                         deferred.reject("ApplicationsService::getAppsForSuperAdminAndAccountAdmin Failed");
458                     } else {
459                         // this.$log.info('ApplicationsService::getAppsForSuperAdminAndAccountAdmin Succeeded');
460                         deferred.resolve(res.data);
461                     }
462                 })
463                 .catch(status => {
464                     deferred.reject(status);
465                 });
466             return deferred.promise;
467         }
468
469         getAdminAppsSimpler(){
470                 let deferred = this.$q.defer();
471                 var _this10 = this;
472             // this.$log.info('ApplicationsService::getAdminAppsSimpler');
473                 this.$http({method: "GET",
474                         url: this.conf.api.adminApps,
475                         cache: false,
476                         headers: {
477                                 'X-ECOMP-RequestID':this.uuid.generate()
478                         }
479                 }).then(res => {
480                         // If response comes back as a redirected HTML page which IS NOT a success
481                         // But don't declare an empty list to be an error.
482                         if (res == null || res.data == null || _this10.utilsService.isValidJSON(res.data) == false) {
483                                 deferred.reject("ApplicationsService::getAdminAppsSimpler Failed");
484                         } else {
485                                 // this.$log.info('ApplicationsService::getAdminAppsSimpler Succeeded');
486                                 deferred.resolve(res.data);
487                         }
488                 })
489                 .catch(status => {
490                         deferred.reject(status);
491                 });
492                 return deferred.promise;
493         }
494
495         getOnboardingApps(){
496             let deferred = this.$q.defer();
497             var _this11 = this;
498             // this.$log.debug('applications-service::getOnboardingApps');
499             this.$http.get(this.conf.api.onboardingApps,
500                 {
501                     cache: false,
502                     headers: {
503                         'X-ECOMP-RequestID':this.uuid.generate()
504                     }
505                 })
506                 .then( res => {
507                     // If response comes back as a redirected HTML page which IS NOT a success
508                         // But don't declare an empty list to be an error.
509                     if (res == null || res.data == null || _this11.utilsService.isValidJSON(res.data) == false) {
510                         deferred.reject("ApplicationsService::getOnboardingApps Failed");
511                     } else {
512                         // this.$log.info('ApplicationsService::getOnboardingApps Succeeded');
513                         deferred.resolve(res.data);
514                     }
515                 })
516                 .catch( status => {
517                     deferred.reject(status);
518                 });
519
520             return deferred.promise;
521         }
522
523         addOnboardingApp(newApp){
524             let deferred = this.$q.defer();
525             // this.$log.debug('applications-service::addOnboardingApp with:', newApp);
526             this.$http({
527                 method: "POST",
528                 url: this.conf.api.onboardingApps,
529                 data: newApp,
530                 cache: false,
531                 headers: {
532                     'X-ECOMP-RequestID':this.uuid.generate()
533                 }
534             }).then( res => {
535                     // If response comes back as a redirected HTML page which IS NOT a success
536                         // But don't declare an empty list to be an error.
537                     if (res == null || res.data == null) {
538                         deferred.reject("ApplicationsService::addOnboardingApp Failed");
539                     } else {
540                         // this.$log.info('ApplicationsService::addOnboardingApp Succeeded');
541                         deferred.resolve(res.data);
542                     }
543                 })
544                 .catch( status => {
545                     deferred.reject(status);
546                 });
547             return deferred.promise;
548         }
549
550         updateOnboardingApp(appData){
551             let deferred = this.$q.defer();
552             // this.$log.info('ApplicationsService::addOnboardingApp');
553             if(!appData.id){
554                 this.$log.error('ApplicationsService::addOnboardingApp: App id not found!');
555                 return deferred.reject('App id not found');
556             }
557
558             this.$http({
559                 method: "PUT",
560                 url: this.conf.api.onboardingApps,
561                 data: appData,
562                 cache: false,
563                 headers: {
564                     'X-ECOMP-RequestID':this.uuid.generate()
565                 }
566             }).then( res => {
567                     // If response comes back as a redirected HTML page which IS NOT a success
568                         // But don't declare an empty list to be an error.
569                     if (res == null || res.data == null) {
570                         deferred.reject("ApplicationsService::updateOnboardingApp Failed");
571                     } else {
572                         // this.$log.info('ApplicationsService::updateOnboardingApp Succeeded');
573                         deferred.resolve(res.data);
574                     }
575                 })
576                 .catch( status => {
577                     deferred.reject(status);
578                 });
579             return deferred.promise;
580         }
581         
582         saveUserAppsRoles(UserAppRolesRequest) {
583                  let deferred = this.$q.defer();
584                  
585                 if (UserAppRolesRequest== undefined
586                                 || UserAppRolesRequest == null
587                                 || UserAppRolesRequest.length == 0){
588                 this.$log.error('ApplicationsService::saveAppsSortTypeManual: Apps Sort Manual received empty string!'); 
589                          return deferred.reject('Apps Sort Manual received empty string ');
590                         }
591                         // var manualAppsJson = angular.toJson(appsSortManual);
592       
593                     // console.log(manual_jsonData);
594                     this.$http({
595                         method: 'PUT',
596                         url: this.conf.api.saveUserAppRoles,
597                         data: UserAppRolesRequest,
598                         cache: false,
599                         headers: {
600                             'X-ECOMP-RequestID':this.uuid.generate()
601                         }
602                     }).then( res => {
603                             // If response comes back as a redirected HTML page which IS
604                                         // NOT a success
605                                 // But don't declare an empty list to be an error.
606                             if (res == null || res.data == null) {
607                                 deferred.reject("ApplicationsService::saveAppsSortTypeManual Failed");
608                             } else {
609                                 // this.$log.info('ApplicationsService::saveAppsSortTypeManual
610                                                 // Succeeded');
611                                 deferred.resolve(res.data);
612                             }
613                         })
614                         .catch( status => {
615                             deferred.reject(status);
616                         });
617                     return deferred.promise;
618
619         }
620          
621
622         deleteOnboardingApp(appId) {
623             let deferred = this.$q.defer();
624             let url = this.conf.api.onboardingApps + '/' + appId;
625             // this.$log.info('applications.service::deleteOnboardingApp' +appId);
626
627             this.$http({
628                 method: "DELETE",
629                 url: url,
630                 cache: false,
631                 data:'',
632                 headers: {
633                     'X-ECOMP-RequestID':this.uuid.generate()
634                 }
635             }).then(res => {
636                     // If response comes back as a redirected HTML page which IS NOT a success
637                         // But don't declare an empty list to be an error.
638                     if (res == null || res.data == null) {
639                         deferred.reject("applications.service::deleteOnboardingApp Failed");
640                     } else {
641                         // this.$log.info('applications.service::deleteOnboardingApp succeeded: ');
642                         deferred.resolve(res.data);
643                     }
644                 })
645                 .catch(errRes => {
646                     deferred.reject(errRes);
647                 });
648             return deferred.promise;
649         }
650         
651         syncRolesEcompFromExtAuthSystem(appId){
652                  let deferred = this.$q.defer();
653                  let url = this.conf.api.syncRolesFromExternalAuthSystem;
654              var _this13 = this; 
655                 this.$http({
656                 method: "POST",
657                 url: url,
658                 cache: false,
659                 data:appId,
660                 headers: {
661                     'X-ECOMP-RequestID':this.uuid.generate()
662                 }
663               }).then( res => {
664                      // If response comes back as a redirected HTML page which IS NOT a success
665                         // But don't declare an empty list to be an error.
666                      if (res == null || res.data == null || _this13.utilsService.isValidJSON(res.data) == false ||  res.data.status == 'ERROR') {
667                          deferred.reject("ApplicationsService::syncRolesEcompFromExtAuthSystem Failed"  + res.data.message);
668                      } else {
669                          deferred.resolve(res);
670                      }
671                  })
672                  .catch( status => {
673                      deferred.reject(status);
674                  });
675              return deferred.promise;
676         }
677         
678         syncFunctionsFromExternalAuthSystem(appId){
679                  let deferred = this.$q.defer();
680                  let url = this.conf.api.syncFunctionsFromExternalAuthSystem;
681                var _this13 = this; 
682                   this.$http({
683                   method: "POST",
684                   url: url,
685                   cache: false,
686                   data:appId,
687                   headers: {
688                       'X-ECOMP-RequestID':this.uuid.generate()
689                   }
690                 }).then( res => {
691                        // If response comes back as a redirected HTML page which IS NOT a success
692                         // But don't declare an empty list to be an error.
693                        if (res == null || res.data == null || _this13.utilsService.isValidJSON(res.data) == false) {
694                            deferred.reject("ApplicationsService::syncFunctionsFromExternalAuthSystem Failed");
695                        } else {
696                            deferred.resolve(res);
697                        }
698                    })
699                    .catch( status => {
700                        deferred.reject(status);
701                    });
702                return deferred.promise;
703           }
704
705         getTopMenuData(selectedApp) {
706             let deferred = this.$q.defer();
707             // this.$log.info('ApplicationsService:getTopMenuData');
708             this.$log.debug('ApplicationsService:getTopMenuData with:', selectedApp);
709         }
710
711         ping(){
712             let deferred = this.$q.defer();
713             // this.$log.info('ApplicationsService::ping: ');
714             this.$http.get(this.conf.api.ping,
715                 {
716                     cache: false,
717                     headers: {
718                         'X-ECOMP-RequestID':this.uuid.generate()
719                     }
720                 })
721                 .success( res => {
722                     // If response comes back as a redirected HTML page which IS NOT a success
723                     if (Object.keys(res).length == 0) {
724                         deferred.reject("ApplicationsService::ping: Failed");
725                     } else {
726                         // this.$log.info('ApplicationsService::ping: Succeeded');
727                         deferred.resolve(res);
728                     }
729                 })
730                 .error( status => {
731                     deferred.reject(status);
732                 });
733
734             return deferred.promise;
735         }
736     }
737     ApplicationsService.$inject = ['$q', '$log', '$http', 'conf','uuid4','utilsService'];
738     angular.module('ecompApp').service('applicationsService', ApplicationsService)
739 })();