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 { CoreService } from '../core/core.service';
43 import { environment } from 'src/environments/environment';
44 import { HttpClient, HttpHeaders } from '@angular/common/http';
51 export class WidgetCatalogService {
52 public options: GridsterConfig = {
68 gridType: GridType.ScrollVertical,
71 displayGrid: DisplayGrid.None,
82 public layout: GridsterItem[] = [];
83 constructor(private api: HttpClient) { }
84 addItem(widgetData: any): void {
85 this.layout.push(widgetData);
87 widgetCatalogData: IWidgetCatalog[] = [{
89 widgetName: 'TestData1',
90 widgetStatus: 'TestStatus1',
91 imageLink: 'week_1.png',
96 widgetName: 'TestData1',
97 widgetStatus: 'TestStatus1',
98 imageLink: 'week_1.png',
103 widgetName: 'TestData1',
104 widgetStatus: 'TestStatus1',
105 imageLink: 'week_1.png',
110 widgetName: 'TestData1',
111 widgetStatus: 'TestStatus1',
112 imageLink: 'week_1.png',
117 widgetName: 'TestData1',
118 widgetStatus: 'TestStatus1',
119 imageLink: 'week_1.png',
124 widgetName: 'TestData1',
125 widgetStatus: 'TestStatus1',
126 imageLink: 'week_1.png',
131 widgetName: 'TestData1',
132 widgetStatus: 'TestStatus1',
133 imageLink: 'week_1.png',
138 widgetName: 'TestData1',
139 widgetStatus: 'TestStatus1',
140 imageLink: 'week_1.png',
145 public getWidgetCatalog(): any {
146 const widgetCatalogObservable = new Observable(observer => {
148 observer.next(this.widgetCatalogData);
152 return widgetCatalogObservable;
154 getUserWidgets(loginName: string): Observable<any> {
155 return this.api.get(environment.api.widgetCommon + '/widgetCatalog' + '/' + loginName);
157 getManagedWidgets(): Observable<any> {
158 return this.api.get(environment.api.widgetCommon + '/widgetCatalog');
160 getUploadFlag(): Observable<any> {
161 return this.api.get(environment.api.widgetCommon + '/uploadFlag');
163 // createWidget(newWidget: any, widgetNameparam: string): Observable<any> {
164 // return this.api.post(environment.api.widgetCommon + '/widgetCatalog', newWidget, widgetNameparam);
167 // updateWidgetWithFile(newWidget: any, widgetNameparam: string, widgetIdParam: string): Observable<any> {
168 // return this.api.post(environment.api.widgetCommon + '/widgetCatalog/' + widgetIdParam, newWidget, widgetNameparam);
171 updateWidget(newWidget: any, widgetIdParam: string): Observable<any> {
172 return this.api.put(environment.api.widgetCommon + '/widgetCatalog/' + widgetIdParam, newWidget);
174 updateWidgetCatalog(appData: any): Observable<any> {
175 const headers = new HttpHeaders().set('X-Widgets-Type','all');
176 return this.api.put(environment.api.widgetCatalogSelection, appData,{headers});