X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fsignal%2Fsignal.component.ts;h=9e08f6f07380476e0e7fec11c7402ccb198e757d;hb=refs%2Fchanges%2F68%2F168%2F9;hp=5a9b9252ed7350a2261d0845edbbda121b04dd33;hpb=2239b1d982aafe5e7dce4dbbec5100f3e3191249;p=portal%2Fric-dashboard.git diff --git a/webapp-frontend/src/app/signal/signal.component.ts b/webapp-frontend/src/app/signal/signal.component.ts index 5a9b9252..9e08f6f0 100644 --- a/webapp-frontend/src/app/signal/signal.component.ts +++ b/webapp-frontend/src/app/signal/signal.component.ts @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,16 +17,11 @@ * limitations under the License. * ========================LICENSE_END=================================== */ -import { Component, OnInit, Inject } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { LocalDataSource } from 'ng2-smart-table'; -import { Router } from '@angular/router'; -import { MatDialog, MatDialogConfig, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; -import { MatFormFieldModule } from '@angular/material'; -import { MatRadioModule } from '@angular/material/radio'; -import { FormGroup, FormControl, FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms'; -import { HttpClient } from '@angular/common/http'; -import { Observable } from 'rxjs/Rx'; -import { SignalService } from '../services/signal/signal.service'; +import { MatDialog} from '@angular/material/dialog'; +import { AppRANConnectDialogComponent } from './signal.component.ranconnect-dialog'; +import { E2ManagerService } from '../services/e2-mgr/e2-mgr.service'; import { E2SetupRequest } from '../interfaces/e2-mgr.types'; @Component({ @@ -35,7 +30,7 @@ import { E2SetupRequest } from '../interfaces/e2-mgr.types'; styleUrls: ['signal.component.css'] }) -export class SignalComponent { +export class SignalComponent implements OnInit { settings = { hideSubHeader: true, actions: { @@ -75,85 +70,20 @@ export class SignalComponent { source: LocalDataSource = new LocalDataSource(); - constructor(private service: SignalService, public dialog: MatDialog, private http: HttpClient) { - this.service.getAll().subscribe((val: any[]) => this.source.load(val)); + constructor(private service: E2ManagerService, public dialog: MatDialog) { } + + ngOnInit() { + this.service.getAll().subscribe((val: E2SetupRequest[]) => this.source.load(val)); } openRanConnectDialog() { - const dialogRef = this.dialog.open(AppRANConnectDialog, { + const dialogRef = this.dialog.open(AppRANConnectDialogComponent, { width: '450px', - data: { } - }) + data: {} + }); dialogRef.afterClosed().subscribe(result => { this.service.getAll().subscribe((val: any[]) => this.source.load(val)); }); } -}// class SignalComponent - -@Component({ - selector: 'app-signal-ranconnect-dialog', - templateUrl: 'signal.component.ranconnect-dialog.html', - styleUrls: ['signal.component.css'] -}) - -export class AppRANConnectDialog implements OnInit { - - public ranDialogForm: FormGroup; - - constructor( - public dialogRef: MatDialogRef, - private service: SignalService, - @Inject(MAT_DIALOG_DATA) public data: E2SetupRequest) { - } - - ngOnInit() { - const namePattern = /^([A-Z]){4}([0-9]){6}$/; - const ipPattern = /((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))/; - const portPattern = /^([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$/; - this.ranDialogForm = new FormGroup({ - ranType: new FormControl('endc'), - ranName: new FormControl('', [Validators.required, Validators.pattern(namePattern)]), - ranIp: new FormControl('', [Validators.required, Validators.pattern(ipPattern)]), - ranPort: new FormControl('', [Validators.required, Validators.pattern(portPattern)]) - }); - } - - onCancel() { - this.dialogRef.close(); - } - - public setupConnection = (ranFormValue) => { - if (this.ranDialogForm.valid) { - this.executeSetupConnection(ranFormValue); - } - } - - private executeSetupConnection = (ranFormValue) => { - let setupRequest: E2SetupRequest = { - ranName: ranFormValue.ranName, - ranIp: ranFormValue.ranIp, - ranPort: ranFormValue.ranPort - } - if (ranFormValue.ranType === 'endc') { - this.service.endcSetup(setupRequest).subscribe((val: any[]) => {}); - } - else { - this.service.x2Setup(setupRequest).subscribe((val: any[]) => {}); - } - this.dialogRef.close(); - } - - public hasError(controlName: string, errorName: string) { - if (this.ranDialogForm.controls[controlName].hasError(errorName)) - return true; - return false; - } - - public validateControl(controlName: string) { - if (this.ranDialogForm.controls[controlName].invalid && this.ranDialogForm.controls[controlName].touched) - return true; - return false; - } - -} // class AppRANConnectDialog +} // class SignalComponent