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=9698f55ae728b15b0026e53791a854443d31d665;hb=923a26d056fd5b613aa1342fff7d7f0f74d9267e;hp=b8230181eba67fab73d1e7d7bdd3c2163ede82fa;hpb=ad70d4114bbfc5dbf20fd1a8151095d89610c759;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 b823018..9698f55 100644 --- a/webapp-frontend/src/app/ei-coordinator/ei-coordinator.component.ts +++ b/webapp-frontend/src/app/ei-coordinator/ei-coordinator.component.ts @@ -19,44 +19,27 @@ */ import { Component, OnInit } from '@angular/core'; import { Sort } from '@angular/material/sort'; -import { animate, state, style, transition, trigger } from '@angular/animations'; import { FormBuilder, FormGroup, AbstractControl } from '@angular/forms'; -import { MatTableDataSource, MatTable } from '@angular/material/table'; - -import { BehaviorSubject, Observable } from 'rxjs'; +import { MatTableDataSource } from '@angular/material/table'; 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 { Observable } from 'rxjs/Observable'; @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)')) - ]), - ], + styleUrls: ['./ei-coordinator.component.scss'] }) export class EICoordinatorComponent implements OnInit { - eiJobInfo = new Map(); darkMode: boolean; searchString: string; formGroup: FormGroup; - jobsDataSource: MatTableDataSource; - producersDataSource: MatTableDataSource; + jobsDataSource: MatTableDataSource = new MatTableDataSource(); + producersDataSource: MatTableDataSource= new MatTableDataSource(); readonly jobsFormControl: AbstractControl; readonly producersFormControl: AbstractControl; @@ -84,8 +67,13 @@ export class EICoordinatorComponent implements OnInit { ngOnInit() { this.eiJobsDataSource.loadJobs(); this.eiProducersDataSource.loadProducers(); - this.jobsDataSource = new MatTableDataSource(this.eiJobsDataSource.eiJobs()); - this.producersDataSource = new MatTableDataSource(this.eiProducersDataSource.eiProducers()); + + this.eiJobsDataSource.eiJobsSubject().subscribe((data) => { + this.jobsDataSource.data = data; + }); + this.eiProducersDataSource.eiProducersSubject().subscribe((data) => { + this.producersDataSource.data = data; + }); this.jobsFormControl.valueChanges.subscribe(value => { const filter = {...value, id: value.id.trim().toLowerCase()} as string; @@ -98,16 +86,16 @@ export class EICoordinatorComponent implements OnInit { this.jobsDataSource.filterPredicate = ((data: EIJob, filter) => { return this.isDataIncluding(data.ei_job_identity, filter.id) - && this.isDataIncluding(data.target_uri, filter.target_uri) + && this.isDataIncluding(data.target_uri, filter.targetUri) && this.isDataIncluding(data.owner, filter.owner) && this.isDataIncluding(data.ei_type_identity, filter.typeId); - }) as (EIJob, string) => boolean; + }) as (data: EIJob, filter: any) => boolean; this.producersDataSource.filterPredicate = ((data, filter) => { return this.isDataIncluding(data.ei_producer_id, filter.ei_producer_id) && this.isDataIncluding(data.ei_producer_types.join(','), filter.ei_producer_types) && this.isDataIncluding(data.status, filter.status); - }) as (EIProducer, string) => boolean; + }) as (data: EIProducer, filter: any) => boolean; this.ui.darkModeState.subscribe((isDark) => { this.darkMode = isDark; @@ -115,7 +103,6 @@ export class EICoordinatorComponent implements OnInit { } sortJobs(sort: Sort){ - console.log('Jobs new sort: ', sort); const data = this.jobsDataSource.data data.sort((a: EIJob, b: EIJob) => { const isAsc = sort.direction === 'asc'; @@ -156,59 +143,28 @@ export class EICoordinatorComponent implements OnInit { 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 { + getJobTypeId(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; + getJobOwner(eiJob: EIJob): string { + if (eiJob.owner) { + return eiJob.owner; } - return '< No target URI >'; - } - - isInstancesShown(eiJob: EIJob): boolean { - return this.getEIJobInfo(eiJob).isExpanded.getValue(); - } - - getExpandedObserver(eiJob: EIJob): Observable { - return this.getEIJobInfo(eiJob).isExpanded.asObservable(); + return '< No owner >'; } - getEIProducerId(eiProducer: EIProducer): string { - if (eiProducer.ei_producer_id) { - return eiProducer.ei_producer_id; - } - return '< No id>'; - } - - getEIProducerTypes(eiProducer: EIProducer): string[] { + getProducerTypes(eiProducer: EIProducer): string[] { if (eiProducer.ei_producer_types) { return eiProducer.ei_producer_types; } return ['< No types >']; } - getEIProducerStatus(eiProducer: EIProducer): string { + getProducerStatus(eiProducer: EIProducer): string { if (eiProducer.status) { return eiProducer.status; } @@ -217,8 +173,13 @@ export class EICoordinatorComponent implements OnInit { refreshTables() { this.eiJobsDataSource.loadJobs(); - this.jobsDataSource.data = this.eiJobsDataSource.eiJobs(); this.eiProducersDataSource.loadProducers(); - this.producersDataSource.data = this.eiProducersDataSource.eiProducers(); + + this.eiJobsDataSource.eiJobsSubject().subscribe((data) => { + this.jobsDataSource.data = data; + }); + this.eiProducersDataSource.eiProducersSubject().subscribe((data) => { + this.producersDataSource.data = data; + }); } }