nexus site path corrected
[portal.git] / ecomp-portal-FE / client / app / services / kpi-dashboard / kpi-dashboard.service.js
1 /*-
2  * ================================================================================
3  * eCOMP Portal
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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  * ================================================================================
19  */
20
21 'use strict';
22
23 (function () {
24     class KpiDashboardService {
25         constructor($q, $log, $http, conf, uuid) {
26             this.$q = $q;
27             this.$log = $log;
28             this.$http = $http;
29             this.conf = conf;
30             this.uuid = uuid;
31             this.applicationsHomeUrl = 'kpidash';             
32         }
33
34         kpiApiCall(ApiName) {
35             let deferred = this.$q.defer();
36             this.$log.info('KpiDashboardService::kpiApiCall: '+ApiName);
37             this.$http({
38                     method: 'GET',
39                     url: this.conf.api[ApiName],
40                     cache: false,
41                     headers: {
42                         'X-ECOMP-RequestID':this.uuid.generate()
43                     }
44                 }).then(res => {
45                     this.$log.debug("KpiDashboardService::kpiApiCall: response successfully retrieved");
46                     if (Object.keys(res.data).length == 0) {
47                         deferred.reject("KpiDashboardService::kpiApiCall: "+ ApiName+ " Failed");
48                     } else {                        
49                         deferred.resolve(res);
50                     }
51                 })
52                 .catch(status => {
53                     deferred.reject(status);
54                 });
55             return deferred.promise;
56         }
57
58         getKpiUserStoriesStats(){
59             return this.kpiApiCall("getKpiDashUserStoriesStats");
60         }
61         getKpiUserApiStats(){
62             return this.kpiApiCall("getKpiDashUserApiStats");
63         }
64         getKpiLocStats(){
65             return this.kpiApiCall("getKpiDashLocStats");
66         }
67         getKpiLocStatsCat(){
68             return this.kpiApiCall("getKpiDashLocStatsCat");
69         }
70         getKpiServiceSupported(){
71             return this.kpiApiCall("getKpiDashServiceSupported");
72         }
73         getKpiPublishedDelivered(){
74             return this.kpiApiCall("getKpiDashPublishedDelivered");
75         }
76         getKpiFeedStats(){
77             return this.kpiApiCall("getKpiDashFeedStats");
78         }
79         getKpiUserApis(){
80             return this.kpiApiCall("getKpiDashUserApis");
81         }
82         getKpiGeoMapUrl(){
83             return this.kpiApiCall("getKpiDashGeoMapUrl");
84         }
85         getKpiRCloudAUrl(){
86             return this.kpiApiCall("getKpiDashRCloudAUrl");            
87         }
88         getKpiGeoMapApiUrl(){
89             return this.kpiApiCall("getKpiDashGeoMapApiUrl");
90         }
91
92         getToplevelgTabs1() {
93             var toplevelgTabs1=[{
94                 title : 'eCOMP',
95                 id : 'ECOMP',
96                         url : this.applicationsHomeUrl,
97                 state : 'root.kpidash_ECOMP'
98             }]
99             return toplevelgTabs1;
100         }
101
102         getToplevelgTabs2() {
103             var toplevelgTabs2 = [ {
104                 title : 'A&AI',
105                 id : 'A&AI',
106                 url : this.applicationsHomeUrl,
107                 state : 'root.kpidash_AAI'
108             }, {
109                 title : 'APP-C',
110                 id : 'APP-C',
111                 url : this.applicationsHomeUrl,
112                 state : 'root.kpidash_APPC'
113             }, {
114                 title : 'ASDC',
115                 id : 'ASDC',
116                 url : this.applicationsHomeUrl,
117                 state : 'root.kpidash_ASDC'
118             }, {
119                 title : 'DCAE',
120                 id : 'DCAE',
121                 url : this.applicationsHomeUrl,
122                 state : 'root.kpidash_DCAE'
123             }, {
124                 title : 'OpenECOMP Portal',
125                 id : 'OpenECOMP Portal',
126                 url : this.applicationsHomeUrl,
127                 state : 'root.kpidash_ECOMP_Portal'
128             }, {
129                 title : 'i-Portal',
130                 id : 'i-Portal',
131                 url : this.applicationsHomeUrl,
132                 state : 'root.kpidash_InfrastructurePortal'
133             }, {
134                 title : 'MSO',
135                 id : 'MSO',
136                 url : this.applicationsHomeUrl,
137                 state : 'root.kpidash_MSO'
138             }, {
139                 title : 'Policy',
140                 id : 'Policy',
141                 url : this.applicationsHomeUrl,
142                 state : 'root.kpidash_Policy'
143             }];
144             return toplevelgTabs2;
145         }
146
147         getToplevelgTabs3() {
148             var toplevelgTabs3 = [ {
149                                                 title : 'Closed Loop',
150                                                 id : 'Closedloop',
151                                                 url : this.applicationsHomeUrl,
152                                                 state : 'root.kpidash_Closedloop'
153                                         }, {
154                                                 title : 'eDMaaP',
155                                                 id : 'DMaaP',
156                                                 url : this.applicationsHomeUrl,
157                                                 state : 'root.kpidash_DMaaP'
158                                         } ];
159             return toplevelgTabs3;
160         }
161
162         getGenericTabs(activeTab) {
163             var gTabs = [ {
164                         title : 'KPI',
165                         id : 'KPI',
166                         url : this.applicationsHomeUrl,
167                         state : 'root.kpidash_'+activeTab+'_KPI'
168                     }, {
169                         title : 'User Defined KPI',
170                         id : 'User Defined KPI',
171                         url : this.applicationsHomeUrl,
172                         state : 'root.kpidash_'+activeTab+'_UserDefinedKPI'
173                     }, {
174                         title : 'Metrics',
175                         id : 'Metrics',
176                         url : this.applicationsHomeUrl,
177                         state : 'root.kpidash_'+activeTab+'_Metrics'
178                     } ];
179             return gTabs;        
180         }
181     }
182
183     KpiDashboardService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4'];
184     angular.module('ecompApp').service('KpiDashboardService', KpiDashboardService)
185 })();