X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=inline;f=webapp-frontend%2Fsrc%2Fapp%2Frd.component.ts;h=31bd76466ea9af34015737f8d16e6c04fa0c9cee;hb=refs%2Fchanges%2F72%2F2272%2F8;hp=16a18495001fbb8e18ef68ef05890f97b827f3d4;hpb=43e79e4a410e1cf377d344cae2c9a7a6e4806fe9;p=portal%2Fric-dashboard.git diff --git a/webapp-frontend/src/app/rd.component.ts b/webapp-frontend/src/app/rd.component.ts index 16a18495..31bd7646 100644 --- a/webapp-frontend/src/app/rd.component.ts +++ b/webapp-frontend/src/app/rd.component.ts @@ -18,10 +18,10 @@ * ========================LICENSE_END=================================== */ import { Component, OnInit } from '@angular/core'; -import { finalize } from 'rxjs/operators'; +import { Subscription } from 'rxjs'; import { RicInstance } from './interfaces/dashboard.types'; import { InstanceSelectorService } from './services/instance-selector/instance-selector.service'; -import { LoadingDialogService } from './services/ui/loading-dialog.service'; +import { InstanceSelectorDialogService } from './services/ui/instance-selector-dialog.service'; import { UiService } from './services/ui/ui.service'; @Component({ @@ -32,40 +32,40 @@ import { UiService } from './services/ui/ui.service'; export class RdComponent implements OnInit { showMenu = false; darkModeActive: boolean; - private instanceArray: RicInstance[]; - private selectedInstanceKey: string; + + private selectedInstanceName: string = 'Select RIC instance'; + private instanceChange: Subscription; constructor( public ui: UiService, - private instanceSelectorService: InstanceSelectorService, - private loadingDialogService: LoadingDialogService) { + private instanceSelectorDialogService: InstanceSelectorDialogService, + private instanceSelectorService: InstanceSelectorService) { } ngOnInit() { this.ui.darkModeState.subscribe((value) => { this.darkModeActive = value; }); - this.loadingDialogService.startLoading('Loading RIC instances'); - this.instanceSelectorService.getInstanceArray() - .pipe( - finalize(() => this.loadingDialogService.stopLoading()) - ) - .subscribe((instanceArray: RicInstance[]) => { - this.instanceArray = instanceArray; - this.selectedInstanceKey = instanceArray[0].key; - }) + + this.instanceChange = this.instanceSelectorService.getSelectedInstance().subscribe((instance: RicInstance) => { + if (instance.name) { + this.selectedInstanceName = instance.name; + } else { + this.openInstanceSelectorDialog() + } + }); } - toggleMenu() { - this.showMenu = !this.showMenu; + ngOnDestroy() { + this.instanceChange.unsubscribe(); } modeToggleSwitch() { this.ui.darkModeState.next(!this.darkModeActive); } - changeInstance(selectedInstancekey: string) { - this.instanceSelectorService.updateSelectedInstance(selectedInstancekey); + openInstanceSelectorDialog() { + this.instanceSelectorDialogService.openInstanceSelectorDialog(); } }