2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2019 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============================================
39 import { Injectable } from '@angular/core';
40 import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
41 import { environment } from '../../../../environments/environment';
42 import { Observable } from 'rxjs';
43 import * as uuid from 'uuid';
48 export class WidgetOnboardingService {
50 api = environment.api;
53 headerParams = {'X-Widgets-Type': 'all', 'X-ECOMP-RequestID': uuid.v4() };
55 constructor(private http: HttpClient) { }
57 getManagedWidgets(): Observable<any>{
58 let getManagedWidgetsURL = this.api.widgetCommon + '/widgetCatalog';
59 return this.http.get(getManagedWidgetsURL , { withCredentials: true } );
62 deleteWidget(widgetId: any): Observable<any> {
63 let deleteWidgetURL = this.api.widgetCommon + '/widgetCatalog' + '/' + widgetId;
64 return this.http.delete(deleteWidgetURL , { withCredentials: true } );
67 downloadWidgetFile(widgetId: any): Observable<any> {
68 let downloadWidgetURL = this.api.widgetCommon + '/download/' + widgetId;
69 let httpParam = new HttpParams()
70 .append('requestType', 'downloadWidgetFile');
71 return this.http.get(downloadWidgetURL,{params: httpParam, responseType: "arraybuffer"});
74 getUploadFlag(): Observable<any> {
75 let getUploadFlagURL = this.api.widgetCommon + '/uploadFlag';
76 return this.http.get(getUploadFlagURL , { withCredentials: true } );
79 updateWidgetWithFile(formData: any, widgetId: any, newWidget: any): Observable<any>{
80 let updateWidgetWithFileURL = this.api.widgetCommon + '/widgetCatalog/' + widgetId;
81 let httpParam = new HttpParams()
82 .append('newWidget', JSON.stringify(newWidget))
83 .append('requestType', 'fileUpload');
84 return this.http.post(updateWidgetWithFileURL, formData, {params: httpParam, withCredentials: true})
87 updateWidget(widgetId: any, widgetData: any): Observable<any> {
88 let updateWidgetURL = this.api.widgetCommon + '/widgetCatalog' + '/' + widgetId;
89 return this.http.put(updateWidgetURL, widgetData, { withCredentials: true });
92 createWidget(newWidget: any, formData: any): Observable<any> {
93 let httpParam = new HttpParams()
94 .append('newWidget', JSON.stringify(newWidget))
95 .append('requestType', 'fileUpload');
96 let createWidgetURL = this.api.widgetCommon + '/widgetCatalog';
97 return this.http.post(createWidgetURL, formData, {params: httpParam, withCredentials: true})
100 populateAvailableApps(): Observable<any> {
101 let populateAvailableAppsURL = this.api.appsForSuperAdminAndAccountAdmin;
102 return this.http.get(populateAvailableAppsURL, { withCredentials: true })