diff --git a/src/app/shared/slim-table/slim-table.component.html b/src/app/shared/slim-table/slim-table.component.html index a0657667..ab45d499 100644 --- a/src/app/shared/slim-table/slim-table.component.html +++ b/src/app/shared/slim-table/slim-table.component.html @@ -5,9 +5,23 @@
- + - + diff --git a/src/app/shared/slim-table/slim-table.component.ts b/src/app/shared/slim-table/slim-table.component.ts index 63d218f0..458cf0fd 100644 --- a/src/app/shared/slim-table/slim-table.component.ts +++ b/src/app/shared/slim-table/slim-table.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, Input } from '@angular/core'; -import { PombaseAPIService, TermSubsetDetails, GeneSubsetDetails, APIError } from '../../pombase-api.service'; +import { PombaseAPIService, TermSubsetDetails, GeneSubsetDetails, APIError, TermSubsets } from '../../pombase-api.service'; import { getAppConfig, SlimConfig, getAnnotationTableConfig, AnnotationType } from '../../config'; class SlimSubsetElement { @@ -10,6 +10,8 @@ class SlimSubsetElement { public single_multi_gene_count: number) { } } +type SortableColumnNames = 'name' | 'gene_count'; + @Component({ selector: 'app-slim-table', templateUrl: './slim-table.component.html', @@ -30,16 +32,33 @@ export class SlimTableComponent implements OnInit { nonSlimWithAnnotationName: string; nonSlimWithoutAnnotationName: string; + sortColumnName: SortableColumnNames = 'name'; + cvConfig: AnnotationType; + subsets: TermSubsets; constructor(private pombaseApiService: PombaseAPIService) { } + setSortColumn(col: SortableColumnNames): void { + this.sortColumnName = col; + this.sortRows(); + } + + sortRows() { + if (this.sortColumnName == 'name') { + this.slimSubsetElements.sort((a, b) => a.name.localeCompare(b.name)); + } else { + this.slimSubsetElements.sort((a, b) => b.gene_count - a.gene_count); + } + } + ngOnInit() { this.slimConfig = this.appConfig.slims[this.slimName]; this.cvConfig = getAnnotationTableConfig().getAnnotationType(this.slimConfig.cv_name); this.pombaseApiService.getTermSubsets() .then(subsets => { - this.slimSubset = Object.assign({}, subsets[this.slimName]); + this.subsets = subsets; + this.slimSubset = Object.assign({}, this.subsets[this.slimName]); this.slimSubsetElements = []; for (const termid of Object.keys(this.slimSubset.elements)) { const element = this.slimSubset.elements[termid]; @@ -47,7 +66,7 @@ export class SlimTableComponent implements OnInit { new SlimSubsetElement(termid, element.name, element.gene_count, element.single_locus_gene_count); this.slimSubsetElements.push(slimSubsetElement); } - this.slimSubsetElements.sort((a, b) => a.name.localeCompare(b.name)); + this.sortRows(); }) .catch(error => { this.apiError = error;
Name + + Name + + + Name + + TermGenes + + Genes + + + Genes + + {{slimConfig.external_link_config.description}}