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 { GridsterConfig, GridsterItem, DisplayGrid, GridType } from 'angular-gridster2';
40 import { UUID } from 'angular2-uuid';
41 import { CoreService } from '../core/core.service';
42 import { Observable } from 'rxjs';
43 import { IApplicationCatalog } from '../../model/application-catalog.model';
44 import { environment } from 'src/environments/environment';
45 import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
50 export class ApplicationCatalogService {
51 public options: GridsterConfig = {
67 gridType: GridType.ScrollVertical,
70 displayGrid: DisplayGrid.None,
71 itemChangeCallback: this.itemChange,
82 public layout: GridsterItem[] = [];
83 constructor(private api: HttpClient) { }
85 addItem(appData: any): void {
86 this.layout.push(appData);
88 getAppCatalog(): Observable<any> {
89 return this.api.get(environment.api.appCatalog);
91 updateAppCatalog(appData: any): Observable<any> {
92 return this.api.put(environment.api.appCatalog, appData);
94 updateManualAppSort(appData: any): Observable<any> {
95 return this.api.put(environment.api.UpdateUserAppsSortManual, appData);
97 getuserAppRolesCatalog(appName: string): Observable<any> {
98 return this.api.get(environment.api.appCatalogRoles);
100 getAppsFullList(): Observable<any> {
101 return this.api.get(environment.api.appsFullList);
103 getUserAppsSortTypePreference(): Observable<any> {
104 const headers = new HttpHeaders().set('Content-Type','text/plain;charset=utf-8');
105 return this.api.get(environment.api.userAppsSortTypePreference,{headers,responseType:'text'});
107 getAppsOrderBySortPref(appSortPrefData: any): Observable<any> {
108 let httpParam = new HttpParams().set('mparams', appSortPrefData);
109 return this.api.get(environment.api.userAppsOrderBySortPref, {params: httpParam});
111 saveAppsSortTypePreference(userPrefData: any): Observable<any> {
112 return this.api.put(environment.api.saveUserAppsSortingPreference, userPrefData);
114 itemChange(item, itemComponent) {
115 //console.info('itemChanged', item, itemComponent);
118 //console.log("check the layout value "+this.layout.values);
121 checkIfUserIsSuperAdmin(): Observable<any> {
122 let checkIfUserIsSuperAdminURL = environment.api.checkIfUserIsSuperAdmin;
123 return this.api.get(checkIfUserIsSuperAdminURL);
125 clearCatalog(): void {