Newer
Older
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ConeSearch } from "../../../shared/cone-search/store/model";
import { Dataset, Project } from 'src/app/metamodel/model';
import { DatasetCount, SearchMultipleQueryParams } from "../../store/model";
@Component({
selector: 'app-overview',
templateUrl: 'overview.component.html'
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
})
export class OverviewComponent {
@Input() set datasetSearchMetaIsLoaded(datasetSearchMetaIsLoaded: boolean) {
if (datasetSearchMetaIsLoaded) {
this.getDatasetCount.emit();
}
}
@Input() coneSearch: ConeSearch;
@Input() projectList: Project[];
@Input() datasetList: Dataset[];
@Input() selectedDatasets: string[];
@Input() queryParams: SearchMultipleQueryParams;
@Input() datasetsCountIsLoaded: boolean;
@Input() datasetsCount: DatasetCount[];
@Output() getDatasetCount: EventEmitter<null> = new EventEmitter();
getTotalObject(): number {
let total: number = 0;
this.datasetsCount
.filter(c => c.count > 0)
.map(c => total += c.count)
return total;
}
getTotalDatasets(): number {
return this.datasetsCount.filter(c => c.count > 0).length;
}
getProjectSortedByName(): Project[] {
return [...this.projectList].sort((a, b) => a.name.localeCompare(b.name));
}
getSelectedDatasetsByProject(projectName: string): Dataset[] {
return this.datasetList
.filter(d => d.project_name === projectName)
.filter(d => this.selectedDatasets.includes(d.name));
}
getCountByDataset(dname: string): number {
return this.datasetsCount.find(c => c.dname === dname).count;
}
}