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, OnInit } from '@angular/core';
22 import { MatDialog } from '@angular/material/dialog';
23 import { finalize } from 'rxjs/operators';
24 import { E2ManagerService } from '../services/e2-mgr/e2-mgr.service';
25 import { ConfirmDialogService } from '../services/ui/confirm-dialog.service';
26 import { ErrorDialogService } from '../services/ui/error-dialog.service';
27 import { LoadingDialogService } from '../services/ui/loading-dialog.service';
28 import { NotificationService } from '../services/ui/notification.service';
29 import { RanControlConnectDialogComponent } from './ran-connection-dialog.component';
30 import { RANControlDataSource } from './ran-control.datasource';
31 import { UiService } from '../services/ui/ui.service';
34 selector: 'rd-ran-control',
35 templateUrl: './ran-control.component.html',
36 styleUrls: ['./ran-control.component.scss']
38 export class RanControlComponent implements OnInit {
41 panelClass: string = "";
42 displayedColumns: string[] = ['nbId', 'nodeType', 'ranName', 'ranIp', 'ranPort', 'connectionStatus'];
43 dataSource: RANControlDataSource;
45 constructor(private e2MgrSvc: E2ManagerService,
46 private errorDialogService: ErrorDialogService,
47 private confirmDialogService: ConfirmDialogService,
48 private notificationService: NotificationService,
49 private loadingDialogService: LoadingDialogService,
50 public dialog: MatDialog,
51 public ui: UiService) { }
54 this.dataSource = new RANControlDataSource(this.e2MgrSvc, this.notificationService);
55 this.dataSource.loadTable();
56 this.ui.darkModeState.subscribe((isDark) => {
57 this.darkMode = isDark;
61 setupRANConnection() {
63 this.panelClass = "dark-theme";
67 const dialogRef = this.dialog.open(RanControlConnectDialogComponent, {
68 panelClass: this.panelClass,
71 dialogRef.afterClosed()
72 .subscribe((result: boolean) => {
74 this.dataSource.loadTable();
79 disconnectAllRANConnections() {
80 const aboutError = 'Disconnect all RAN Connections Failed: ';
81 this.confirmDialogService.openConfirmDialog('Are you sure you want to disconnect all RAN connections?')
82 .afterClosed().subscribe( (res: boolean) => {
84 this.loadingDialogService.startLoading("Disconnecting");
85 this.e2MgrSvc.nodebPut()
87 finalize(() => this.loadingDialogService.stopLoading())
91 this.notificationService.success('Disconnect succeeded!');
92 this.dataSource.loadTable();
94 (her: HttpErrorResponse) => {
95 // the error field should have an ErrorTransport object
96 let msg = her.message;
97 if (her.error && her.error.message) {
98 msg = her.error.message;
100 this.errorDialogService.displayError('Disconnect failed: ' + msg);