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============================================
38 import { Injectable } from '@angular/core';
39 import { IWidgetCatalog } from '../../model/widget-catalog.model';
40 import { Observable, from } from 'rxjs';
41 import { GridsterConfig, GridsterItem, CompactType, DisplayGrid, GridType } from 'angular-gridster2';
42 import { environment } from 'src/environments/environment';
43 import { HttpClient, HttpHeaders } from '@angular/common/http';
50 export class WidgetCatalogService {
51 public options: GridsterConfig = {
67 gridType: GridType.ScrollVertical,
70 displayGrid: DisplayGrid.None,
81 public layout: GridsterItem[] = [];
82 constructor(private api: HttpClient) { }
83 addItem(widgetData: any): void {
84 this.layout.push(widgetData);
86 widgetCatalogData: IWidgetCatalog[] = [{
88 widgetName: 'TestData1',
89 widgetStatus: 'TestStatus1',
90 imageLink: 'week_1.png',
95 widgetName: 'TestData1',
96 widgetStatus: 'TestStatus1',
97 imageLink: 'week_1.png',
102 widgetName: 'TestData1',
103 widgetStatus: 'TestStatus1',
104 imageLink: 'week_1.png',
109 widgetName: 'TestData1',
110 widgetStatus: 'TestStatus1',
111 imageLink: 'week_1.png',
116 widgetName: 'TestData1',
117 widgetStatus: 'TestStatus1',
118 imageLink: 'week_1.png',
123 widgetName: 'TestData1',
124 widgetStatus: 'TestStatus1',
125 imageLink: 'week_1.png',
130 widgetName: 'TestData1',
131 widgetStatus: 'TestStatus1',
132 imageLink: 'week_1.png',
137 widgetName: 'TestData1',
138 widgetStatus: 'TestStatus1',
139 imageLink: 'week_1.png',
144 public getWidgetCatalog(): any {
145 const widgetCatalogObservable = new Observable(observer => {
147 observer.next(this.widgetCatalogData);
151 return widgetCatalogObservable;
153 getUserWidgets(loginName: string): Observable<any> {
154 return this.api.get(environment.api.widgetCommon + '/widgetCatalog' + '/' + loginName);
156 getManagedWidgets(): Observable<any> {
157 return this.api.get(environment.api.widgetCommon + '/widgetCatalog');
159 getUploadFlag(): Observable<any> {
160 return this.api.get(environment.api.widgetCommon + '/uploadFlag');
162 // createWidget(newWidget: any, widgetNameparam: string): Observable<any> {
163 // return this.api.post(environment.api.widgetCommon + '/widgetCatalog', newWidget, widgetNameparam);
166 // updateWidgetWithFile(newWidget: any, widgetNameparam: string, widgetIdParam: string): Observable<any> {
167 // return this.api.post(environment.api.widgetCommon + '/widgetCatalog/' + widgetIdParam, newWidget, widgetNameparam);
170 updateWidget(newWidget: any, widgetIdParam: string): Observable<any> {
171 return this.api.put(environment.api.widgetCommon + '/widgetCatalog/' + widgetIdParam, newWidget);
173 updateWidgetCatalog(appData: any): Observable<any> {
174 const headers = new HttpHeaders().set('X-Widgets-Type','all');
175 return this.api.put(environment.api.widgetCatalogSelection, appData,{headers});