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 { HttpErrorResponse } from '@angular/common/http';
21 import { Component, OnDestroy, OnInit } from '@angular/core';
22 import { MatDialog } from '@angular/material/dialog';
23 import { Subscription } from 'rxjs';
24 import { finalize } from 'rxjs/operators';
25 import { RicInstance } from '../interfaces/dashboard.types';
26 import { E2ManagerService } from '../services/e2-mgr/e2-mgr.service';
27 import { InstanceSelectorService } from '../services/instance-selector/instance-selector.service';
28 import { ConfirmDialogService } from '../services/ui/confirm-dialog.service';
29 import { ErrorDialogService } from '../services/ui/error-dialog.service';
30 import { LoadingDialogService } from '../services/ui/loading-dialog.service';
31 import { NotificationService } from '../services/ui/notification.service';
32 import { UiService } from '../services/ui/ui.service';
33 import { RanControlConnectDialogComponent } from './ran-connection-dialog.component';
34 import { RANControlDataSource } from './ran-control.datasource';
37 selector: 'rd-ran-control',
38 templateUrl: './ran-control.component.html',
39 styleUrls: ['./ran-control.component.scss']
41 export class RanControlComponent implements OnInit, OnDestroy {
45 displayedColumns: string[] = ['nbId', 'nodeType', 'ranName', 'ranIp', 'ranPort', 'connectionStatus'];
46 dataSource: RANControlDataSource;
47 private instanceChange: Subscription;
48 private instanceKey: string;
50 constructor(private e2MgrSvc: E2ManagerService,
51 private errorDialogService: ErrorDialogService,
52 private confirmDialogService: ConfirmDialogService,
53 private notificationService: NotificationService,
54 private loadingDialogService: LoadingDialogService,
55 public instanceSelectorService: InstanceSelectorService,
56 public dialog: MatDialog,
57 public ui: UiService) { }
60 this.dataSource = new RANControlDataSource(this.e2MgrSvc, this.notificationService);
62 this.ui.darkModeState.subscribe((isDark) => {
63 this.darkMode = isDark;
66 this.instanceChange = this.instanceSelectorService.getSelectedInstance().subscribe((instance: RicInstance) => {
68 this.instanceKey = instance.key;
69 this.dataSource.loadTable(instance.key);
75 this.instanceChange.unsubscribe();
78 setupRANConnection() {
80 this.panelClass = 'dark-theme';
84 const dialogRef = this.dialog.open(RanControlConnectDialogComponent, {
85 panelClass: this.panelClass,
88 instanceKey: this.instanceKey
91 dialogRef.afterClosed()
92 .subscribe((result: boolean) => {
94 this.dataSource.loadTable(this.instanceKey);
99 disconnectAllRANConnections() {
100 const aboutError = 'Disconnect all RAN Connections Failed: ';
101 this.confirmDialogService.openConfirmDialog('Are you sure you want to disconnect all RAN connections?')
102 .afterClosed().subscribe((res: boolean) => {
104 this.loadingDialogService.startLoading('Disconnecting');
105 this.e2MgrSvc.nodebPut(this.instanceKey)
107 finalize(() => this.loadingDialogService.stopLoading())
111 this.notificationService.success('Disconnect succeeded!');
112 this.dataSource.loadTable(this.instanceKey);
114 (her: HttpErrorResponse) => {
115 // the error field should have an ErrorTransport object
116 let msg = her.message;
117 if (her.error && her.error.message) {
118 msg = her.error.message;
120 this.errorDialogService.displayError('Disconnect failed: ' + msg);