X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fei-coordinator%2Fei-coordinator.component.ts;h=1bb082c64075724abbf1c95d3d78414130f5a376;hb=042a087cf3eea5e6f941ee9add6e1c50cb106e91;hp=8532fccdb3e1c09f5e0ae7687ef7a0733f424ff7;hpb=7083fe17ce58e2ef8719b78164f41a459a40f5ef;p=portal%2Fnonrtric-controlpanel.git diff --git a/webapp-frontend/src/app/ei-coordinator/ei-coordinator.component.ts b/webapp-frontend/src/app/ei-coordinator/ei-coordinator.component.ts index 8532fcc..1bb082c 100644 --- a/webapp-frontend/src/app/ei-coordinator/ei-coordinator.component.ts +++ b/webapp-frontend/src/app/ei-coordinator/ei-coordinator.component.ts @@ -17,162 +17,40 @@ * limitations under the License. * ========================LICENSE_END=================================== */ -import { Component, OnInit} from '@angular/core'; -import { animate, state, style, transition, trigger } from '@angular/animations'; -import { FormBuilder, FormGroup, AbstractControl } from '@angular/forms'; -import { MatTableDataSource } from '@angular/material'; +import { Component, OnInit, ViewChild } from '@angular/core'; -import { defer, BehaviorSubject, Observable } from 'rxjs'; -import { map, withLatestFrom, startWith } from 'rxjs/operators'; - -import { EIJob, EIProducer } from '../interfaces/ei.types'; -import { EIJobDataSource } from './ei-job.datasource'; -import { EIProducerDataSource } from './ei-producer.datasource'; import { UiService } from '../services/ui/ui.service'; - -class EIJobInfo { - constructor(public eiJob: EIJob) { } - - isExpanded: BehaviorSubject = new BehaviorSubject(false); -} +import { JobsListComponent } from './jobs-list/jobs-list.component'; +import { ProducersListComponent } from './producers-list/producers-list.component'; @Component({ selector: 'nrcp-ei-coordinator', templateUrl: './ei-coordinator.component.html', styleUrls: ['./ei-coordinator.component.scss'], - animations: [ - trigger('detailExpand', [ - state('collapsed, void', style({ height: '0px', minHeight: '0', display: 'none' })), - state('expanded', style({ height: '*' })), - transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')), - transition('expanded <=> void', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')) - ]), - ], + providers: [ + ProducersListComponent, + JobsListComponent + ] }) export class EICoordinatorComponent implements OnInit { - producers$: Observable; - filteredProducers$: Observable; - - eiJobInfo = new Map(); darkMode: boolean; - searchString: string; - formGroup: FormGroup; - jobsDataSource: MatTableDataSource; + @ViewChild(ProducersListComponent) producersList: ProducersListComponent; + @ViewChild(JobsListComponent) jobComponent: JobsListComponent; - readonly jobsFormControl: AbstractControl; constructor( - private eiJobsDataSource: EIJobDataSource, - private eiProducersDataSource: EIProducerDataSource, - private ui: UiService, - private formBuilder: FormBuilder) { - - this.formGroup = formBuilder.group({ filter: [""] }); - this.jobsFormControl = formBuilder.group({ - id: '', - typeId: '', - owner: '', - targetUri:'', - }) + private ui: UiService) { } ngOnInit() { - this.eiJobsDataSource.getJobs(); - this.jobsDataSource = new MatTableDataSource(this.eiJobsDataSource.eiJobsSubject.value); - - this.jobsFormControl.valueChanges.subscribe(value => { - const filter = {...value, id: value.id.trim().toLowerCase()} as string; - this.jobsDataSource.filter = filter; - }); - - this.jobsDataSource.filterPredicate = ((data, filter) => { - return this.isDataIncluding(data.ei_job_identity, filter.id) - && this.isDataIncluding(data.target_uri, filter.target_uri) - && this.isDataIncluding(data.owner, filter.owner) - && this.isDataIncluding(data.ei_type_identity, filter.typeId); - }) as (EIJob, string) => boolean; - - this.producers$= this.eiProducersDataSource.loadProducers(); - this.filteredProducers$ = defer(() => this.formGroup.get("filter") - .valueChanges.pipe( - startWith(""), - withLatestFrom(this.producers$), - map(([val, producers]) => - !val ? producers : producers.filter((x) => - x.ei_producer_id.toLowerCase().includes(val)))) - ); - this.ui.darkModeState.subscribe((isDark) => { this.darkMode = isDark; }); } - isDataIncluding(data: string, filter: string) : boolean { - return !filter || data.toLowerCase().includes(filter); - } - - getEIJobInfo(eiJob: EIJob): EIJobInfo { - let info: EIJobInfo = this.eiJobInfo.get(eiJob.ei_job_data); - if (!info) { - info = new EIJobInfo(eiJob); - this.eiJobInfo.set(eiJob.ei_job_data, info); - } - return info; - } - - getDisplayName(eiJob: EIJob): string { - if (eiJob.ei_job_identity) { - return eiJob.ei_job_identity; - } - return '< No id >'; - } - - getEITypeId(eiJob: EIJob): string { - if (eiJob.ei_type_identity) { - return eiJob.ei_type_identity; - } - return '< No type >'; - } - - getTargetUri(eiJob: EIJob): string { - if (eiJob.target_uri) { - return eiJob.target_uri; - } - return '< No target URI >'; - } - - isInstancesShown(eiJob: EIJob): boolean { - return this.getEIJobInfo(eiJob).isExpanded.getValue(); - } - - getExpandedObserver(eiJob: EIJob): Observable { - return this.getEIJobInfo(eiJob).isExpanded.asObservable(); - } - - getEIProducerId(eiProducer: EIProducer): string { - if (eiProducer.ei_producer_id) { - return eiProducer.ei_producer_id; - } - return '< No id>'; - } - - getEIProducerTypes(eiProducer: EIProducer): string[] { - if (eiProducer.ei_producer_types) { - return eiProducer.ei_producer_types; - } - return ['< No types >']; - } - - getEIProducerStatus(eiProducer: EIProducer): string { - if (eiProducer.status) { - return eiProducer.status; - } - return '< No status >'; - } - refreshTables() { - this.eiJobsDataSource.getJobs(); - this.eiProducersDataSource.loadProducers(); + this.jobComponent.loadJobs(); + this.producersList.loadProducers(); } }