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 { Component, OnInit } from '@angular/core';
39 import { GridsterConfig, GridsterItem } from 'angular-gridster2';
40 import { WidgetCatalogService } from '../../shared/services/widget-catalog/widget-catalog.service';
41 import { IWidgetCatalog } from '../../shared/model/widget-catalog.model';
42 import { Observable } from 'rxjs';
43 import { inflateRaw } from 'zlib';
44 import { UsersService } from 'src/app/shared/services/users/users.service';
47 selector: 'app-dashboard-widget-catalog',
48 templateUrl: './dashboard-widget-catalog.component.html',
49 styleUrls: ['./dashboard-widget-catalog.component.scss']
51 export class DashboardWidgetCatalogComponent implements OnInit {
54 widgetCatalogData: IWidgetCatalog[];
55 isCommonError: boolean = false;
56 isApiRunning: boolean = true;
60 get options(): GridsterConfig {
61 return this.widgetCatalogService.options;
62 } get layout(): GridsterItem[] {
63 return this.widgetCatalogService.layout;
64 } constructor(private widgetCatalogService: WidgetCatalogService, private userService: UsersService) {
69 const widgetCatalogObservable = this.widgetCatalogService.getWidgetCatalog();
70 this.widgetCatalogService.layout = [];
71 this.getUserWidgets(this.userName);
75 getUserWidgets(loginName: string) {
76 const widgetCatalogUserObservable = this.userService.getUserProfile();
77 widgetCatalogUserObservable.subscribe((userProfile: any) => {
78 //console.log('UserProfile is ' + userProfile);
80 const widgetCatalogObservable = this.widgetCatalogService.getUserWidgets(userProfile.orgUserId);
81 widgetCatalogObservable.subscribe(data => {
82 //console.log("What is coming from backend" + JSON.parse(data));
83 this.widgetCatalogData = data;
84 console.log(this.widgetCatalogData);
85 if(this.widgetCatalogData != null){
86 for (let entry of this.widgetCatalogData) {
87 if (entry[1] == 'Events' || entry[1] == 'News' || entry[1] == 'Resources') {
88 if(entry[4] === 'S' || entry[4] === null)
94 //select: (entry[4] === 'S' || entry[4] === null) ? true : false
96 this.widgetCatalogService.addItem(appCatalog);
107 getUserProfile(): Observable<any> {
108 const widgetCatalogObservable = this.userService.getUserProfile();
109 return widgetCatalogObservable;
112 storeSelection(widgetCatalogData: any) {
113 console.log("Store selection called " + widgetCatalogData.select);
114 if (widgetCatalogData && widgetCatalogData.select) {
116 widgetId: widgetCatalogData.id,
117 select: widgetCatalogData.select,
120 this.widgetCatalogService.updateWidgetCatalog(appData).subscribe(data => {
121 //console.log("Update App sort data" + data);
123 console.log('updateWidgetCatalog error' + error);