2 * ========================LICENSE_START=================================
5 * Copyright (C) 2019 AT&T Intellectual Property and Nokia
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';
33 selector: 'rd-ran-control',
34 templateUrl: './ran-control.component.html',
35 styleUrls: ['./ran-control.component.scss']
37 export class RanControlComponent implements OnInit {
38 displayedColumns: string[] = ['nbId', 'nodeType', 'ranName', 'ranIp', 'ranPort', 'connectionStatus'];
39 dataSource: RANControlDataSource;
41 constructor(private e2MgrSvc: E2ManagerService,
42 private errorDialogService: ErrorDialogService,
43 private confirmDialogService: ConfirmDialogService,
44 private notificationService: NotificationService,
45 private loadingDialogService: LoadingDialogService,
46 public dialog: MatDialog) { }
49 this.dataSource = new RANControlDataSource(this.e2MgrSvc, this.notificationService);
50 this.dataSource.loadTable();
53 setupRANConnection() {
54 const dialogRef = this.dialog.open(RanControlConnectDialogComponent, {
57 dialogRef.afterClosed().subscribe( (result: boolean) => {
59 this.dataSource.loadTable();
64 disconnectAllRANConnections() {
65 const aboutError = 'Disconnect all RAN Connections Failed: ';
66 this.confirmDialogService.openConfirmDialog('Are you sure you want to disconnect all RAN connections?')
67 .afterClosed().subscribe( (res: boolean) => {
69 this.loadingDialogService.startLoading("Disconnecting");
70 this.e2MgrSvc.nodebPut()
72 finalize(() => this.loadingDialogService.stopLoading())
76 this.notificationService.success('Disconnect succeeded!');
77 this.dataSource.loadTable();
79 (her: HttpErrorResponse) => {
80 // the error field should have an ErrorTransport object
81 let msg = her.message;
82 if (her.error && her.error.message) {
83 msg = her.error.message;
85 this.errorDialogService.displayError('Disconnect failed: ' + msg);