2 * ========================LICENSE_START=================================
5 * Copyright (C) 2019 AT&T Intellectual Property
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ========================LICENSE_END===================================
20 import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
21 import { MatDialog } from '@angular/material/dialog';
22 import { MatSort } from '@angular/material/sort';
23 import { Subscription } from 'rxjs';
24 import { XMXapp } from '../interfaces/app-mgr.types';
25 import { RicInstance } from '../interfaces/dashboard.types';
26 import { AppMgrService } from '../services/app-mgr/app-mgr.service';
27 import { InstanceSelectorService } from '../services/instance-selector/instance-selector.service';
28 import { ConfirmDialogService } from '../services/ui/confirm-dialog.service';
29 import { LoadingDialogService } from '../services/ui/loading-dialog.service';
30 import { NotificationService } from '../services/ui/notification.service';
31 import { UiService } from '../services/ui/ui.service';
32 import { DeployDialogComponent } from '../ui/deploy-dialog/deploy-dialog.component';
33 import { AppConfigurationComponent } from './../app-configuration/app-configuration.component';
34 import { OnboardComponent } from './../onboard/onboard.component';
35 import { CatalogDataSource } from './catalog.datasource';
38 selector: 'rd-app-catalog',
39 templateUrl: './catalog.component.html',
40 styleUrls: ['./catalog.component.scss'],
42 export class CatalogComponent implements OnInit, OnDestroy {
46 displayedColumns: string[] = ['name', 'version', 'action'];
47 dataSource: CatalogDataSource;
48 private instanceChange: Subscription;
49 private instanceKey: string;
51 @ViewChild(MatSort, { static: true }) sort: MatSort;
54 private appMgrService: AppMgrService,
55 private confirmDialogService: ConfirmDialogService,
56 private dialog: MatDialog,
57 private loadingDialogService: LoadingDialogService,
58 private notificationService: NotificationService,
59 public instanceSelectorService: InstanceSelectorService,
60 public ui: UiService) { }
63 this.dataSource = new CatalogDataSource(this.appMgrService, this.sort, this.notificationService);
64 this.ui.darkModeState.subscribe((isDark) => {
65 this.darkMode = isDark;
68 this.instanceChange = this.instanceSelectorService.getSelectedInstance().subscribe((instance: RicInstance) => {
70 this.instanceKey = instance.key;
71 this.dataSource.loadTable(instance.key);
77 this.instanceChange.unsubscribe();
80 onConfigureApp(xapp: XMXapp): void {
82 this.panelClass = 'dark-theme';
86 const dialogRef = this.dialog.open(AppConfigurationComponent, {
87 panelClass: this.panelClass,
95 instanceKey: this.instanceKey
101 onDeployApp(app: XMXapp): void {
103 this.panelClass = 'dark-theme';
105 this.panelClass = '';
107 const dialogRef = this.dialog.open(DeployDialogComponent, {
108 panelClass: this.panelClass,
116 instanceKey: this.instanceKey
124 this.panelClass = 'dark-theme';
126 this.panelClass = '';
128 const dialogRef = this.dialog.open(OnboardComponent, {
129 panelClass: this.panelClass,
136 instanceKey: this.instanceKey