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 { RANControlDataSource } from './ran-control.datasource';
36 selector: 'rd-ran-control',
37 templateUrl: './ran-control.component.html',
38 styleUrls: ['./ran-control.component.scss']
40 export class RanControlComponent implements OnInit, OnDestroy {
44 displayedColumns: string[] = ['nbId', 'nodeType', 'ranName', 'ranIp', 'ranPort', 'connectionStatus'];
45 dataSource: RANControlDataSource;
46 private instanceChange: Subscription;
47 private instanceKey: string;
49 constructor(private e2MgrSvc: E2ManagerService,
50 private errorDialogService: ErrorDialogService,
51 private confirmDialogService: ConfirmDialogService,
52 private notificationService: NotificationService,
53 private loadingDialogService: LoadingDialogService,
54 public instanceSelectorService: InstanceSelectorService,
55 public dialog: MatDialog,
56 public ui: UiService) { }
59 this.dataSource = new RANControlDataSource(this.e2MgrSvc, this.notificationService);
61 this.ui.darkModeState.subscribe((isDark) => {
62 this.darkMode = isDark;
65 this.instanceChange = this.instanceSelectorService.getSelectedInstance().subscribe((instance: RicInstance) => {
67 this.instanceKey = instance.key;
68 this.dataSource.loadTable(instance.key);
74 this.instanceChange.unsubscribe();
77 disconnectAllRANConnections() {
78 const aboutError = 'Disconnect all RAN Connections Failed: ';
79 this.confirmDialogService.openConfirmDialog('Are you sure you want to disconnect all RAN connections?')
80 .afterClosed().subscribe((res: boolean) => {
82 this.loadingDialogService.startLoading('Disconnecting');
83 this.e2MgrSvc.nodebPut(this.instanceKey)
85 finalize(() => this.loadingDialogService.stopLoading())
89 this.notificationService.success('Disconnect succeeded!');
90 this.dataSource.loadTable(this.instanceKey);
92 (her: HttpErrorResponse) => {
93 // the error field should have an ErrorTransport object
94 let msg = her.message;
95 if (her.error && her.error.message) {
96 msg = her.error.message;
98 this.errorDialogService.displayError('Disconnect failed: ' + msg);