Added Widget-Onboarding and dependent Services
[portal.git] / portal-FE-common / src / app / shared / services / applications / applications.service.ts
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2019 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
39 import { Injectable } from '@angular/core';
40 import { HttpClient, HttpParams } from '@angular/common/http';
41 import { environment } from '../../../../environments/environment';
42 import { Observable } from 'rxjs';
43 import * as uuid from 'uuid';
44
45 @Injectable({
46   providedIn: 'root'
47 })
48 export class ApplicationsService {
49
50   api = environment.api;
51   resp: string;
52   headerParams = { 'X-Widgets-Type': 'all' };
53
54   constructor(private http: HttpClient) { }
55
56   getOnboardingApps(): Observable<any> {
57     let getOnboardingAppsURL = this.api.onboardingApps;
58     return this.http.get(getOnboardingAppsURL);
59   };
60
61   getSingleAppInfo(appName): Observable<any> {
62     let getSingleAppInfoURL = this.api.singleAppInfo;
63     return this.http.get(getSingleAppInfoURL);
64   };
65
66   getSingleAppInfoById(appId) {
67     let httpParams = new HttpParams()
68       .set('appParam', appId);
69     return this.http.get(this.api.singleAppInfoById, { params: httpParams, responseType: 'json' })
70   }
71
72   getPersUserApps(): Observable<any> {
73     let getPersUserAppsURL = this.api.persUserApps;
74     return this.http.get(getPersUserAppsURL);
75   };
76
77   getAppsOrderBySortPref(userAppSortTypePref): Observable<any> {
78     let getAppsOrderBySortPrefURL = this.api.userAppsOrderBySortPref;
79     return this.http.get(getAppsOrderBySortPrefURL);
80   }
81
82   checkIfUserIsSuperAdmin(): Observable<any> {
83     let checkIfUserIsSuperAdminURL = this.api.checkIfUserIsSuperAdmin;
84     return this.http.get(checkIfUserIsSuperAdminURL);
85   }
86
87   saveAppsSortTypeManual(appsSortManual: any): Observable<any> {
88     let saveAppsSortTypeManualURL = this.api.saveUserAppsSortingManual;
89     return this.http.put(saveAppsSortTypeManualURL, appsSortManual);
90   }
91
92   saveAppsSortTypePreference(appsSortPreference: any): Observable<any> {
93     let saveAppsSortTypePreferenceURL = this.api.saveUserAppsSortingPreference;
94     return this.http.put(saveAppsSortTypePreferenceURL, appsSortPreference);
95   }
96
97   getUserAppsSortTypePreference(): Observable<any> {
98     let getUserAppsSortTypePreferenceURL = this.api.userAppsSortTypePreference;
99     return this.http.get(getUserAppsSortTypePreferenceURL);
100   }
101
102   saveWidgetsSortManual(widgetsSortManual: any): Observable<any> {
103     let saveWidgetsSortManualURL = this.api.saveUserWidgetsSortManual;
104     return this.http.put(saveWidgetsSortManualURL, widgetsSortManual);
105   }
106
107   delWidgetsSortPref(widgetsData: any): Observable<any> {
108     let delWidgetsSortPrefURL = this.api.updateWidgetsSortPref;
109     return this.http.put(delWidgetsSortPrefURL, widgetsData);
110   }
111
112   getAvailableApps(): Observable<any> {
113     let getAvailableAppsURL = this.api.availableApps;
114     return this.http.get(getAvailableAppsURL);
115   }
116
117   getAdminApps(): Observable<any> {
118     let getAdminAppsURL = this.api.adminApps;
119     return this.http.get(getAdminAppsURL);
120   }
121
122   getLeftMenuItems(): Observable<any> {
123     let getLeftMenuItemsURL = this.api.leftmenuItems;
124     return this.http.get(getLeftMenuItemsURL);
125   }
126
127   getAppsForSuperAdminAndAccountAdmin(): Observable<any> {
128     let getAppsForSuperAdminAndAccountAdminURL = this.api.appsForSuperAdminAndAccountAdmin;
129     return this.http.get(getAppsForSuperAdminAndAccountAdminURL);
130   }
131
132   getAdminAppsSimpler(): Observable<any> {
133     let getAdminAppsSimplerURL = this.api.adminApps;
134     return this.http.get(getAdminAppsSimplerURL);
135   }
136
137   addOnboardingApp(newApp: any): Observable<any> {
138     let addOnboardingAppURL = this.api.onboardingApps;
139     return this.http.post(addOnboardingAppURL, newApp);
140   }
141
142   updateOnboardingApp(appData: any): Observable<any> {
143     let updateOnboardingAppURL = this.api.onboardingApps;
144     return this.http.put(updateOnboardingAppURL, appData);
145   }
146
147   saveUserAppsRoles(UserAppRolesRequest: any): Observable<any> {
148     let saveUserAppsRolesURL = this.api.saveUserAppRoles;
149     return this.http.put(saveUserAppsRolesURL, UserAppRolesRequest);
150   }
151
152   deleteOnboardingApp(appId: any): Observable<any> {
153     let deleteOnboardingAppURL = this.api.onboardingApps + '/' + appId;
154     return this.http.delete(deleteOnboardingAppURL);
155   }
156
157   syncRolesEcompFromExtAuthSystem(appId: any): Observable<any> {
158     let syncRolesEcompFromExtAuthSystemURL = this.api.syncRolesFromExternalAuthSystem;
159     return this.http.post(syncRolesEcompFromExtAuthSystemURL, appId);
160   }
161
162   syncFunctionsFromExternalAuthSystem(appId: any): Observable<any> {
163     let syncFunctionsFromExternalAuthSystemURL = this.api.syncFunctionsFromExternalAuthSystem;
164     return this.http.post(syncFunctionsFromExternalAuthSystemURL, appId);
165   }
166
167   ping(appId): Observable<any> {
168     let pingURL = this.api.ping;
169     return this.http.get(pingURL);
170   }
171
172 }