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';
50 selector: 'app-application-catalog',
51 templateUrl: './application-catalog.component.html',
52 styleUrls: ['./application-catalog.component.scss']
54 export class ApplicationCatalogComponent implements OnInit {
55 widgetCatalogData: IWidgetCatalog[];
56 appCatalogData: IApplicationCatalog[];
57 resultAccessValue: string;
62 isUserSuperAdmin: boolean;
64 get options(): GridsterConfig {
65 return this.applicationCatalogService.options;
66 } get layout(): GridsterItem[] {
67 return this.applicationCatalogService.layout;
68 } constructor(private applicationCatalogService: ApplicationCatalogService, private externalRequestAccessService: ExternalRequestAccessService, private userService: UsersService, private modal: NgbModal) { }
71 this.applicationCatalogService.clearCatalog();
72 this.radioValue = 'All';
73 this.callAppCatalogExecutor();
76 callAppCatalogExecutor() {
77 //Check whether Admin is Super Admin
78 this.checkAdminIsSuperAdmin();
80 this.getExternalAccess();
82 //Call user profile service
83 this.getUserProfile();
85 //Call Application Catalog services
86 this.getAppCatalogService();
89 checkAdminIsSuperAdmin() {
90 this.applicationCatalogService.checkIfUserIsSuperAdmin().subscribe(data => {
91 this.isUserSuperAdmin = data;
93 console.log('checkAdminIsSuperAdmin Error Object' + error);
97 getAppCatalogService() {
98 //console.log("getAppCatalogServices called");
99 this.applicationCatalogService.getAppCatalog().subscribe(data => {
100 //console.log("Response data" + data);
101 this.appCatalogData = data;
102 for (let entry of this.appCatalogData) {
103 //console.log("Check the URL" + environment.api.appThumbnail);
109 mlAppName: entry.mlAppName,
110 imageLink: environment.api.appThumbnail.replace(':appId', <string><any>entry.id),
111 restricted: entry.restricted,
112 select: entry.select,
113 access: entry.access,
114 pending: entry.pending,
115 mlproperty: this.resultAccessValue
117 this.applicationCatalogService.addItem(appCatalog);
120 console.log('getAppCatalogServices Error Object' + error);
124 storeSelection(appCatalogData: any) {
125 //console.log("Store selection called " + appCatalogData.name);
126 var pendingFlag: boolean = false;
127 if (appCatalogData.access)
130 pendingFlag = appCatalogData.pending;
133 appId: appCatalogData.id,
134 select: appCatalogData.select,
137 this.applicationCatalogService.updateManualAppSort(appData).subscribe(data => {
138 //console.log("Update App sort data" + data);
140 console.log('Update App sort error' + error);
143 this.applicationCatalogService.updateAppCatalog(appData).subscribe(data => {
144 //console.log("Update App Catalog data" + data);
146 console.log('Update App Catalog error' + error);
149 openAddRoleModal(item: any) {
150 //console.log("OpenModal check" + item.id);
151 if ((!item.restricted) && (item.mlproperty)) {
152 this.modal.open(CatalogModalComponent);
156 getExternalAccess() {
157 //console.log("getExternalAccess service called");
158 this.externalRequestAccessService.getExternalRequestAccessServiceInfo().subscribe(data => {
159 //console.log("Response data" + data);
161 this.resultAccessValue = data.accessValue;
163 console.log('getExternalAccess Error object' + error);
168 const userProfileObservable = this.userService.getUserProfile();
169 userProfileObservable.subscribe((userProfile: any) => {
170 //console.log('UserProfile is ' + userProfile);
172 this.orgUserId = userProfile.orgUserId;
173 this.firstName = userProfile.firstName;
174 this.lastName = userProfile.lastName;