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=79b7129a3feb4f804eff65a4d54b07216cac79b9;hpb=1f5664f310dc6a18ecc10dbd2a0705500b2e15c9;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 79b7129..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,114 +17,40 @@ * limitations under the License. * ========================LICENSE_END=================================== */ -import { Component, OnInit } from '@angular/core'; -import { Sort } from '@angular/material/sort'; -import { FormBuilder, FormGroup, AbstractControl } from '@angular/forms'; -import { MatTableDataSource } from '@angular/material/table'; +import { Component, OnInit, ViewChild } from '@angular/core'; -import { EIJob } from '../interfaces/ei.types'; -import { EIJobDataSource } from './ei-job.datasource'; import { UiService } from '../services/ui/ui.service'; +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'] + styleUrls: ['./ei-coordinator.component.scss'], + providers: [ + ProducersListComponent, + JobsListComponent + ] }) export class EICoordinatorComponent implements OnInit { darkMode: boolean; - formGroup: FormGroup; - jobsDataSource: MatTableDataSource = new MatTableDataSource(); + @ViewChild(ProducersListComponent) producersList: ProducersListComponent; + @ViewChild(JobsListComponent) jobComponent: JobsListComponent; - readonly jobsFormControl: AbstractControl; constructor( - private producersList: ProducersListComponent, - private eiJobsDataSource: EIJobDataSource, - 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.loadJobs(); - - this.eiJobsDataSource.eiJobsSubject().subscribe((data) => { - this.jobsDataSource.data = data; - }); - - this.jobsFormControl.valueChanges.subscribe(value => { - const filter = {...value, id: value.id.trim().toLowerCase()} as string; - this.jobsDataSource.filter = filter; - }); - - this.jobsDataSource.filterPredicate = ((data: EIJob, filter) => { - return this.isDataIncluding(data.ei_job_identity, filter.id) - && this.isDataIncluding(data.target_uri, filter.targetUri) - && this.isDataIncluding(data.owner, filter.owner) - && this.isDataIncluding(data.ei_type_identity, filter.typeId); - }) as (data: EIJob, filter: any) => boolean; - this.ui.darkModeState.subscribe((isDark) => { this.darkMode = isDark; }); } - sortJobs(sort: Sort){ - const data = this.jobsDataSource.data - data.sort((a: EIJob, b: EIJob) => { - const isAsc = sort.direction === 'asc'; - switch (sort.active) { - case 'id': return this.compare(a.ei_job_identity, b.ei_job_identity, isAsc); - case 'typeId': return this.compare(a.ei_type_identity, b.ei_type_identity, isAsc); - case 'owner': return this.compare(a.owner, b.owner, isAsc); - case 'targetUri': return this.compare(a.target_uri, b.owner, isAsc); - default: return 0; - } - }); - this.jobsDataSource.data = data; - } - - compare(a: any, b: any, isAsc: boolean) { - return (a < b ? -1 : 1) * (isAsc ? 1 : -1); - } - - stopSort(event: any){ - event.stopPropagation(); - } - - isDataIncluding(data: string, filter: string) : boolean { - return !filter || data.toLowerCase().includes(filter); - } - - getJobTypeId(eiJob: EIJob): string { - if (eiJob.ei_type_identity) { - return eiJob.ei_type_identity; - } - return '< No type >'; - } - - getJobOwner(eiJob: EIJob): string { - if (eiJob.owner) { - return eiJob.owner; - } - return '< No owner >'; - } refreshTables() { - this.eiJobsDataSource.loadJobs(); - this.eiJobsDataSource.eiJobsSubject().subscribe((data) => { - this.jobsDataSource.data = data; - }); - - this.producersList.refresh(); + this.jobComponent.loadJobs(); + this.producersList.loadProducers(); } }