- 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';
- 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;
- }
-
- sortProducers(sort: Sort){
- const data = this.producersDataSource.data
- data.sort((a: EIProducer, b: EIProducer) => {
- const isAsc = sort.direction === 'asc';
- switch (sort.active) {
- case 'id': return this.compare(a.ei_producer_id, b.ei_producer_id, isAsc);
- case 'types': return this.compare(a.ei_producer_types, b.ei_producer_types, isAsc);
- case 'status': return this.compare(a.status, b.status, isAsc);
- default: return 0;
- }
- });
- this.producersDataSource.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);
- }
-
- 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<boolean> {
- 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 >';
- }
-