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);
104 if(entry.applicationType != "3"){
110 mlAppName: entry.mlAppName,
111 imageLink: environment.api.appThumbnail.replace(':appId', <string><any>entry.id),
112 applicationType: entry.applicationType,
113 select: entry.select,
114 access: entry.access,
115 pending: entry.pending,
116 mlproperty: this.resultAccessValue
118 this.applicationCatalogService.addItem(appCatalog);
122 console.log('getAppCatalogServices Error Object' + error);
126 storeSelection(appCatalogData: any) {
127 //console.log("Store selection called " + appCatalogData.name);
128 var pendingFlag: boolean = false;
129 if (appCatalogData.access)
132 pendingFlag = appCatalogData.pending;
135 appId: appCatalogData.id,
136 select: appCatalogData.select,
139 this.applicationCatalogService.updateManualAppSort(appData).subscribe(data => {
140 //console.log("Update App sort data" + data);
142 console.log('Update App sort error' + error);
145 this.applicationCatalogService.updateAppCatalog(appData).subscribe(data => {
146 //console.log("Update App Catalog data" + data);
148 console.log('Update App Catalog error' + error);
151 openAddRoleModal(item: any) {
152 //console.log("OpenModal check" + item.id);
153 if ((item.applicationType == "1") && (item.mlproperty)) {
154 this.modal.open(CatalogModalComponent);
158 getExternalAccess() {
159 //console.log("getExternalAccess service called");
160 this.externalRequestAccessService.getExternalRequestAccessServiceInfo().subscribe(data => {
161 //console.log("Response data" + data);
163 this.resultAccessValue = data.accessValue;
165 console.log('getExternalAccess Error object' + error);
170 const userProfileObservable = this.userService.getUserProfile();
171 userProfileObservable.subscribe((userProfile: any) => {
172 //console.log('UserProfile is ' + userProfile);
174 this.orgUserId = userProfile.orgUserId;
175 this.firstName = userProfile.firstName;
176 this.lastName = userProfile.lastName;