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 { ApplicationCatalogService } from '../../shared/services/application-catalog/application-catalog.service';
41 import { IApplicationCatalog } from '../../shared/model/application-catalog.model';
42 import { IWidgetCatalog } from '../../shared/model/widget-catalog.model';
43 import { environment } from 'src/environments/environment';
44 import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
45 import { CatalogModalComponent } from '../catalog-modal/catalog-modal.component';
46 import { ExternalRequestAccessService } from 'src/app/shared/services/external-request-access-service/external-request-access.service';
47 import { UsersService } from 'src/app/shared/services/users/users.service';
48 import { AddTabFunctionService } from 'src/app/shared/services/tab/add-tab-function.service';
51 selector: 'app-dashboard-application-catalog',
52 templateUrl: './dashboard-application-catalog.component.html',
53 styleUrls: ['./dashboard-application-catalog.component.scss']
55 export class DashboardApplicationCatalogComponent implements OnInit {
57 widgetCatalogData: IWidgetCatalog[];
58 appCatalogData: IApplicationCatalog[];
59 resultAccessValue: string;
63 selectedSortType: any;
64 sortOptions: Array<any>;
66 get options(): GridsterConfig {
67 return this.applicationCatalogService.options;
68 } get layout(): GridsterItem[] {
69 return this.applicationCatalogService.layout;
70 } constructor(private applicationCatalogService: ApplicationCatalogService, private externalRequestAccessService: ExternalRequestAccessService, private userService: UsersService,private addTabFuntionService: AddTabFunctionService) {
92 this.selectedSortType = {};
96 this.applicationCatalogService.clearCatalog();
97 //this.selectedSortType = this.sortOptions[0];
98 this.getUserAppsSortTypePreference();
100 // //this.getUserAppsSortTypePreference();
101 //this.getAppCatalogService('N');
104 getUserAppsSortTypePreference() {
105 this.applicationCatalogService.getUserAppsSortTypePreference().subscribe(data => {
106 //console.log("getUserAppsSortTypePreference data"+data);
108 var resJson: any = {};
109 resJson.value = data;
110 if (resJson.value === "N" || resJson.value === "") {
113 } else if (resJson.value === "L") {
116 } else if (resJson.value === "F") {
124 this.selectedSortType = this.sortOptions[resJson.index];
125 //console.log(this.selectedSortType);
126 this.getAppCatalogService(data);
129 console.log('getUserAppsSortTypePreference Error Object' + error.message);
134 sortTypeChanged(userAppSortTypePref: string) {
135 //console.log("check whether get into the method");
136 if (!userAppSortTypePref) {
137 this.selectedSortType = this.sortOptions[0];
140 this.sortOptions.forEach(obj => {
141 if (obj.value == userAppSortTypePref) {
142 this.selectedSortType = obj;
148 this.getAppCatalogService(userAppSortTypePref);
149 this.saveAppsSortTypePreference(this.selectedSortType);
153 getAppCatalogService(userAppSortTypePref: string) {
154 //console.log("getAppCatalogServices called");
155 this.applicationCatalogService.getAppsOrderBySortPref(userAppSortTypePref).subscribe(data => {
156 //console.log("Response data" + data);
157 this.appCatalogData = data;
159 this.applicationCatalogService.layout = [];
160 for (let entry of data) {
161 //console.log("Check the URL" + environment.api.appThumbnail);
167 subHeaderText: entry.notes,
168 imageLink: environment.api.appThumbnail.replace(':appId', <string><any>entry.id),
169 restrictedApp: entry.restrictedApp,
170 select: entry.select,
171 access: entry.access,
172 pending: entry.pending,
177 this.applicationCatalogService.addItem(appCatalog);
181 console.log('getAppCatalogServices Error Object' + error);
185 saveAppsSortTypePreference(selectedSortType: any) {
186 this.applicationCatalogService.saveAppsSortTypePreference(selectedSortType).subscribe();
190 openAddRoleModal(item: any) {
191 //console.log("OpenModal check" + item.id+" "+item.url);
192 if (item.restrictedApp) {
193 // Link-based apps open in their own browser tab
194 window.open(item.url, '_blank');
202 this.addTabFuntionService.filter(tabContent);