Skip to content
Snippets Groups Projects
datasets-result.component.ts 2.1 KiB
Newer Older
  • Learn to ignore specific revisions
  • import { Component, Input, Output, ChangeDetectionStrategy, EventEmitter } from '@angular/core';
    
    import { Attribute, Dataset, Project } from "../../../metamodel/model";
    
    import { DatasetCount } from "../../store/model";
    
    import { sortByDisplay } from "../../../shared/utils";
    
    
    @Component({
        selector: 'app-datasets-result',
        templateUrl: 'datasets-result.component.html',
        changeDetection: ChangeDetectionStrategy.OnPush
    })
    export class DatasetsResultComponent {
        @Input() datasetsCountIsLoaded: boolean;
        @Input() projectList: Project[];
        @Input() datasetList: Dataset[];
        @Input() selectedDatasets: string[];
    
        // TODO: change any type
        @Input() datasetsAttributeList: any;
    
        @Input() datasetsCount: DatasetCount[];
    
        @Output() retrieveMeta: EventEmitter<string> = new EventEmitter();
    
        @Output() retrieveData: EventEmitter<string> = new EventEmitter();
    
        getOrderedDatasetWithResults(): Dataset[] {
            let datasets: Dataset[] = [];
    
            const projectOrderedByName: Project[] = [...this.projectList].sort((a, b) => a.name.localeCompare(b.name));
    
            projectOrderedByName.map(p => {
                this.datasetList.filter(d => d.project_name === p.name)
                    .sort(sortByDisplay)
                    .map(d => {
                        this.datasetsCount.map(c => {
                            if (c.dname === d.name && c.count > 0) {
                                datasets.push(d);
                            }
                        });
                    });
            });
            return datasets;
        }
    
        getCount(dname: string): number {
            return this.datasetsCount.find(c => c.dname === dname).count;
    
    
        // getDatasetAttributeList(dname: string): Attribute[] {
        //
        // }
    
        getData(dname: string, pagination: any): void {
            console.log(dname, pagination);
        }
    
        addSelectedData(d: number | string): void {
            console.log('addSelectedData: ' + d);
        }
    
        deleteSelectedData(d: number | string): void {
            console.log('deleteSelectedData: ' + d);
        }
    
        executeProcess(typeProcess: string): void {
            console.log('executeProcess: ' + typeProcess);
        }