From f39c67b1c213d0318441cba16762dd3373eb58bb Mon Sep 17 00:00:00 2001 From: tsheils Date: Fri, 26 Jan 2024 10:20:33 -0500 Subject: [PATCH 1/2] fix structure viewer injection token --- apps/ramp-client/src/app/app.config.ts | 2 ++ apps/ramp-client/src/app/app.routes.ts | 5 +++-- .../analytes-from-pathways.component.ts | 6 ++--- .../chemical-enrichment.component.spec.ts | 22 ++----------------- .../chemical-enrichment.component.ts | 17 ++------------ .../classes-from-metabolites.component.ts | 4 ++-- .../common-reaction-analytes.component.ts | 6 ++--- .../metabolites-from-ontologies.component.ts | 2 +- .../ontologies-from-metabolites.component.ts | 6 ++--- .../pathway-enrichment.component.ts | 4 ---- .../pathways-from-analytes.component.ts | 6 ++--- .../properties-from-metabolites.component.ts | 10 ++++----- libs/shared/ramp/full-banner/.eslintrc.json | 4 ++-- .../src/lib/page-core/page-core.component.ts | 20 ++++++++++++++--- .../ncats-datatable/models/data-property.ts | 2 +- .../ncats-datatable.component.html | 6 +++++ .../ncats-datatable.component.ts | 5 ++--- .../structure-viewer.component.ts | 11 +++++++--- .../src/lib/+state/ramp-store/ramp.effects.ts | 4 ---- .../src/lib/+state/ramp-store/ramp.reducer.ts | 1 - .../ramp-store/src/lib/+state/ramp.service.ts | 2 -- 21 files changed, 65 insertions(+), 80 deletions(-) diff --git a/apps/ramp-client/src/app/app.config.ts b/apps/ramp-client/src/app/app.config.ts index 7ab4560..d59cb13 100644 --- a/apps/ramp-client/src/app/app.config.ts +++ b/apps/ramp-client/src/app/app.config.ts @@ -19,6 +19,7 @@ import { import { provideEffects } from '@ngrx/effects'; import { provideState, provideStore, Store } from '@ngrx/store'; import { provideStoreDevtools } from '@ngrx/store-devtools'; +import { STRUCTURE_VIEWER_COMPONENT, StructureViewerComponent } from "@ramp/shared/ui/ncats-structure-viewer"; import { LoadRampActions, RampService, @@ -57,6 +58,7 @@ export const appConfig: ApplicationConfig = { deps: [], multi: true, }, + { provide: STRUCTURE_VIEWER_COMPONENT, useClass: StructureViewerComponent }, provideRouter( routes, withViewTransitions(), diff --git a/apps/ramp-client/src/app/app.routes.ts b/apps/ramp-client/src/app/app.routes.ts index 86aea03..4f49085 100644 --- a/apps/ramp-client/src/app/app.routes.ts +++ b/apps/ramp-client/src/app/app.routes.ts @@ -1,5 +1,6 @@ +import { InjectionToken } from "@angular/core"; import { Routes } from '@angular/router'; -import { StructureViewerComponent } from '@ramp/shared/ui/ncats-structure-viewer'; +import { STRUCTURE_VIEWER_COMPONENT, StructureViewerComponent } from "@ramp/shared/ui/ncats-structure-viewer"; import rFunctions from '../assets/data/rFunctions.json'; import { environment } from '../environments/environment'; @@ -113,7 +114,7 @@ export const routes: Routes = [ pathMatch: 'full', runGuardsAndResolvers: 'paramsOrQueryParamsChange', providers: [ - { provide: StructureViewerComponent, useValue: StructureViewerComponent }, + { provide: STRUCTURE_VIEWER_COMPONENT, useValue: StructureViewerComponent }, ], loadComponent: () => import('@ramp/features/ramp/properties-from-metabolites').then( diff --git a/libs/features/ramp/analytes-from-pathways/src/lib/analytes-from-pathways/analytes-from-pathways.component.ts b/libs/features/ramp/analytes-from-pathways/src/lib/analytes-from-pathways/analytes-from-pathways.component.ts index 998b8ed..d936b89 100644 --- a/libs/features/ramp/analytes-from-pathways/src/lib/analytes-from-pathways/analytes-from-pathways.component.ts +++ b/libs/features/ramp/analytes-from-pathways/src/lib/analytes-from-pathways/analytes-from-pathways.component.ts @@ -129,10 +129,10 @@ export class AnalytesFromPathwaysComponent } } - private _mapData(data: any): void { + /*private _mapData(data: any): void { this.dataAsDataProperty = data.map((analyte: Analyte) => { const newObj: { [key: string]: DataProperty } = {}; - Object.entries(analyte).map((value: any, index: any) => { + Object.entries(analyte).map((value: any) => { newObj[value[0]] = new DataProperty({ name: value[0], label: value[0], @@ -141,5 +141,5 @@ export class AnalytesFromPathwaysComponent }); return newObj; }); - } + }*/ } diff --git a/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.spec.ts b/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.spec.ts index c47094f..05e2864 100644 --- a/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.spec.ts +++ b/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.spec.ts @@ -1,8 +1,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { FlexLayoutModule } from '@angular/flex-layout'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { ReactiveFormsModule } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; import { MatDialogModule } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; @@ -17,14 +16,7 @@ import { ActivatedRoute } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { EffectsModule } from '@ngrx/effects'; import { StoreModule } from '@ngrx/store'; -import { SharedRampInputRowModule } from '@ramp/shared/ramp/input-row'; -import { SharedRampPageCoreModule } from '@ramp/shared/ramp/page-core'; -import { SharedRampQueryPageModule } from '@ramp/shared/ramp/query-page'; -import { SharedUiDescriptionPanelModule } from '@ramp/shared/ui/description-panel'; -import { SharedUiFeedbackPanelModule } from '@ramp/shared/ui/feedback-panel'; -import { SharedUiLoadingSpinnerModule } from '@ramp/shared/ui/loading-spinner'; -import { SharedUiObjectTreeModule } from '@ramp/shared/ui/object-tree'; -import { RampFacade, StoresRampStoreModule } from '@ramp/stores/ramp-store'; + import { ChemicalEnrichmentComponent } from './chemical-enrichment.component'; @@ -38,18 +30,9 @@ describe('ChemicalEnrichmentComponent', () => { imports: [ BrowserAnimationsModule, RouterTestingModule, - StoresRampStoreModule, HttpClientTestingModule, - SharedRampQueryPageModule, - SharedRampPageCoreModule, - SharedRampInputRowModule, - SharedUiLoadingSpinnerModule, - SharedUiObjectTreeModule, - SharedUiDescriptionPanelModule, - FlexLayoutModule, MatTabsModule, MatFormFieldModule, - SharedUiFeedbackPanelModule, MatButtonModule, MatTooltipModule, MatIconModule, @@ -71,7 +54,6 @@ describe('ChemicalEnrichmentComponent', () => { EffectsModule.forRoot([]), ], providers: [ - RampFacade, { provide: ActivatedRoute, useValue: { diff --git a/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.ts b/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.ts index f53d874..47d8c6d 100644 --- a/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.ts +++ b/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.ts @@ -193,21 +193,8 @@ export class ChemicalEnrichmentComponent select(RampSelectors.getChemicalEnrichment), takeUntilDestroyed(this.destroyRef), map((res: RampChemicalEnrichmentResponse | undefined) => { - console.log(res); if (res && res.enriched_chemical_class_list) { - this.dataAsDataProperty = res.enriched_chemical_class_list.map( - (enrichment: ChemicalEnrichment) => { - const newObj: { [key: string]: DataProperty } = {}; - Object.entries(enrichment).map((value: any) => { - newObj[value[0]] = new DataProperty({ - name: value[0], - label: value[0], - value: value[1], - }); - }); - return newObj; - }, - ); + this._mapData(res.enriched_chemical_class_list) this.enrichmentLoading = false; // if (res.openModal) { @@ -333,7 +320,7 @@ export class ChemicalEnrichmentComponent private _mapClasses(data: any): void { this.classesAsDataProperty = data.map((obj: Classes) => { const newObj: { [key: string]: DataProperty } = {}; - Object.entries(obj).map((value: any, index: any) => { + Object.entries(obj).map((value: string[]) => { newObj[value[0]] = new DataProperty({ name: value[0], label: value[0], diff --git a/libs/features/ramp/classes-from-metabolites/src/lib/classes-from-metabolites/classes-from-metabolites.component.ts b/libs/features/ramp/classes-from-metabolites/src/lib/classes-from-metabolites/classes-from-metabolites.component.ts index bac0b7c..c2e5c4a 100644 --- a/libs/features/ramp/classes-from-metabolites/src/lib/classes-from-metabolites/classes-from-metabolites.component.ts +++ b/libs/features/ramp/classes-from-metabolites/src/lib/classes-from-metabolites/classes-from-metabolites.component.ts @@ -197,7 +197,7 @@ export class ClassesFromMetabolitesComponent } } - private _mapData(data: any): void { + /*private _mapData(data: any): void { this.dataAsDataProperty = data.map((obj: Classes) => { const newObj: { [key: string]: DataProperty } = {}; Object.entries(obj).map((value: any) => { @@ -209,7 +209,7 @@ export class ClassesFromMetabolitesComponent }); return newObj; }); - } + }*/ onFileSelected(event: any) { this.file = event.target.files[0]; diff --git a/libs/features/ramp/common-reaction-analytes/src/lib/common-reaction-analytes/common-reaction-analytes.component.ts b/libs/features/ramp/common-reaction-analytes/src/lib/common-reaction-analytes/common-reaction-analytes.component.ts index 7e16660..75fecdf 100644 --- a/libs/features/ramp/common-reaction-analytes/src/lib/common-reaction-analytes/common-reaction-analytes.component.ts +++ b/libs/features/ramp/common-reaction-analytes/src/lib/common-reaction-analytes/common-reaction-analytes.component.ts @@ -123,10 +123,10 @@ export class CommonReactionAnalytesComponent } } - private _mapData(data: any): void { + /*private _mapData(data: any): void { this.dataAsDataProperty = data.map((reaction: Reaction) => { const newObj: { [key: string]: DataProperty } = {}; - Object.entries(reaction).map((value: any, index: any) => { + Object.entries(reaction).map((value: any) => { newObj[value[0]] = new DataProperty({ name: value[0], label: value[0], @@ -135,5 +135,5 @@ export class CommonReactionAnalytesComponent }); return newObj; }); - } + }*/ } diff --git a/libs/features/ramp/metabolites-from-ontologies/src/lib/metabolites-from-ontologies/metabolites-from-ontologies.component.ts b/libs/features/ramp/metabolites-from-ontologies/src/lib/metabolites-from-ontologies/metabolites-from-ontologies.component.ts index 93249a1..bcc2854 100644 --- a/libs/features/ramp/metabolites-from-ontologies/src/lib/metabolites-from-ontologies/metabolites-from-ontologies.component.ts +++ b/libs/features/ramp/metabolites-from-ontologies/src/lib/metabolites-from-ontologies/metabolites-from-ontologies.component.ts @@ -147,7 +147,7 @@ export class MetabolitesFromOntologiesComponent if (res && res.data) { this.dataAsDataProperty = res.data.map((metabolite: Metabolite) => { const newObj: { [key: string]: DataProperty } = {}; - Object.entries(metabolite).map((value: any, index: any) => { + Object.entries(metabolite).map((value: any) => { newObj[value[0]] = new DataProperty({ name: value[0], label: value[0], diff --git a/libs/features/ramp/ontologies-from-metabolites/src/lib/ontologies-from-metabolites/ontologies-from-metabolites.component.ts b/libs/features/ramp/ontologies-from-metabolites/src/lib/ontologies-from-metabolites/ontologies-from-metabolites.component.ts index 65a2f10..7b33cc5 100644 --- a/libs/features/ramp/ontologies-from-metabolites/src/lib/ontologies-from-metabolites/ontologies-from-metabolites.component.ts +++ b/libs/features/ramp/ontologies-from-metabolites/src/lib/ontologies-from-metabolites/ontologies-from-metabolites.component.ts @@ -125,10 +125,10 @@ export class OntologiesFromMetabolitesComponent } } - private _mapData(data: any): void { + /*private _mapData(data: any): void { this.dataAsDataProperty = data.map((obj: Ontology) => { const newObj: { [key: string]: DataProperty } = {}; - Object.entries(obj).map((value: any, index: any) => { + Object.entries(obj).map((value: any) => { newObj[value[0]] = new DataProperty({ name: value[0], label: value[0], @@ -137,5 +137,5 @@ export class OntologiesFromMetabolitesComponent }); return newObj; }); - } + }*/ } diff --git a/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.ts b/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.ts index 7d82eea..99b619c 100644 --- a/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.ts +++ b/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.ts @@ -333,7 +333,6 @@ export class PathwayEnrichmentComponent } | undefined, ) => { - console.log(res); if (res && res.data) { if (res.data.length) { this.dataAsDataProperty = this._mapPathwaysData(res.data); @@ -379,7 +378,6 @@ export class PathwayEnrichmentComponent this.query = res.query; } if (res && res.dataframe) { - console.log(res.dataframe); this.enrichedDataframe = res.dataframe; if (this.enrichedDataframe.analyte_type) { this.selectedEnrichmentColumns = @@ -420,7 +418,6 @@ export class PathwayEnrichmentComponent select(RampSelectors.getPathways), takeUntilDestroyed(this.destroyRef), map((res: RampResponse | undefined) => { - console.log(res); if (res && res.data) { this.pathwayDataAsDataProperty = this._mapPathwaysData(res.data); this.matches = Array.from( @@ -464,7 +461,6 @@ export class PathwayEnrichmentComponent fetchEnrichment(event: string[]): void { this.inputList = event.map((item) => item.toLocaleLowerCase()); - console.log(this.inputList); this.store.dispatch( PathwayEnrichmentsActions.fetchPathwaysFromAnalytes({ analytes: event }), ); diff --git a/libs/features/ramp/pathways-from-analytes/src/lib/pathways-from-analytes/pathways-from-analytes.component.ts b/libs/features/ramp/pathways-from-analytes/src/lib/pathways-from-analytes/pathways-from-analytes.component.ts index 900224b..4923eab 100644 --- a/libs/features/ramp/pathways-from-analytes/src/lib/pathways-from-analytes/pathways-from-analytes.component.ts +++ b/libs/features/ramp/pathways-from-analytes/src/lib/pathways-from-analytes/pathways-from-analytes.component.ts @@ -120,10 +120,10 @@ export class PathwaysFromAnalytesComponent } } - private _mapData(data: any): void { + /*private _mapData(data: any): void { this.dataAsDataProperty = data.map((analyte: Pathway) => { const newObj: { [key: string]: DataProperty } = {}; - Object.entries(analyte).map((value: any, index: any) => { + Object.entries(analyte).map((value: any) => { newObj[value[0]] = new DataProperty({ name: value[0], label: value[0], @@ -132,5 +132,5 @@ export class PathwaysFromAnalytesComponent }); return newObj; }); - } + }*/ } diff --git a/libs/features/ramp/properties-from-metabolites/src/lib/properties-from-metabolites/properties-from-metabolites.component.ts b/libs/features/ramp/properties-from-metabolites/src/lib/properties-from-metabolites/properties-from-metabolites.component.ts index 80b6c1c..c6f110c 100644 --- a/libs/features/ramp/properties-from-metabolites/src/lib/properties-from-metabolites/properties-from-metabolites.component.ts +++ b/libs/features/ramp/properties-from-metabolites/src/lib/properties-from-metabolites/properties-from-metabolites.component.ts @@ -9,7 +9,7 @@ import { QueryPageComponent } from '@ramp/shared/ramp/query-page'; import { DescriptionComponent } from '@ramp/shared/ui/description-panel'; import { FeedbackPanelComponent } from '@ramp/shared/ui/feedback-panel'; import { DataProperty } from '@ramp/shared/ui/ncats-datatable'; -import { StructureViewerComponent } from '@ramp/shared/ui/ncats-structure-viewer'; +import { STRUCTURE_VIEWER_COMPONENT } from "@ramp/shared/ui/ncats-structure-viewer"; import { PropertiesFromMetaboliteActions, RampSelectors, @@ -49,7 +49,7 @@ export class PropertiesFromMetabolitesComponent new DataProperty({ label: 'Metabolite', field: 'imageUrl', - customComponent: StructureViewerComponent, + customComponent: STRUCTURE_VIEWER_COMPONENT, }), /* new DataProperty({ label: "Smiles", @@ -91,7 +91,7 @@ export class PropertiesFromMetabolitesComponent takeUntilDestroyed(this.destroyRef), map((res: RampResponse | undefined) => { if (res && res.data) { - this._mapData(res.data); + this._mapPropertyData(res.data); this.matches = Array.from( new Set( res.data.map((prop) => prop.chem_source_id.toLocaleLowerCase()), @@ -140,10 +140,10 @@ export class PropertiesFromMetabolitesComponent } } - private _mapData(data: any): void { + private _mapPropertyData(data: Properties[]): void { this.dataAsDataProperty = data.map((obj: Properties) => { const newObj: { [key: string]: DataProperty } = {}; - Object.entries(obj).map((value: any, index: any) => { + Object.entries(obj).map((value: string[]) => { newObj[value[0]] = new DataProperty({ name: value[0], label: value[0], diff --git a/libs/shared/ramp/full-banner/.eslintrc.json b/libs/shared/ramp/full-banner/.eslintrc.json index f0fce09..eb78159 100644 --- a/libs/shared/ramp/full-banner/.eslintrc.json +++ b/libs/shared/ramp/full-banner/.eslintrc.json @@ -13,7 +13,7 @@ "error", { "type": "attribute", - "prefix": "lib", + "prefix": "ramp", "style": "camelCase" } ], @@ -21,7 +21,7 @@ "error", { "type": "element", - "prefix": "lib", + "prefix": "ramp", "style": "kebab-case" } ] diff --git a/libs/shared/ramp/page-core/src/lib/page-core/page-core.component.ts b/libs/shared/ramp/page-core/src/lib/page-core/page-core.component.ts index 548543d..f55f38b 100644 --- a/libs/shared/ramp/page-core/src/lib/page-core/page-core.component.ts +++ b/libs/shared/ramp/page-core/src/lib/page-core/page-core.component.ts @@ -11,10 +11,10 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { select, Store } from '@ngrx/store'; import { FisherResult, - FishersDataframe, + FishersDataframe, Ontology, RampDataGeneric, - RampQuery, -} from '@ramp/models/ramp-models'; + RampQuery +} from "@ramp/models/ramp-models"; import { DataProperty } from '@ramp/shared/ui/ncats-datatable'; import { RampSelectors } from '@ramp/stores/ramp-store'; import { map } from 'rxjs'; @@ -122,4 +122,18 @@ export class PageCoreComponent { this.supportedIdTypes?.includes(type.analyteType), ); } + + protected _mapData(data: T[]): void { + this.dataAsDataProperty = data.map((obj: T) => { + const newObj: { [key: string]: DataProperty } = {}; + Object.entries(obj).map((value: string[]) => { + newObj[value[0]] = new DataProperty({ + name: value[0], + label: value[0], + value: value[1], + }); + }); + return newObj; + }); + } } diff --git a/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/models/data-property.ts b/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/models/data-property.ts index 03f1e75..2aafdad 100644 --- a/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/models/data-property.ts +++ b/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/models/data-property.ts @@ -68,7 +68,7 @@ export class DataProperty { /** * token for a custom component */ - customComponent?: InjectionToken; + customComponent?: InjectionToken; /** * pass a query params object for a routerLink diff --git a/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.html b/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.html index 8db5daf..5194be5 100644 --- a/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.html +++ b/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.html @@ -59,6 +59,12 @@ [style.max-width]="field.width" > @if (checkCustomComponent(field)) { +
+
} @else { @if (row[field.field] && isArray(row[field.field])) {
diff --git a/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.ts b/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.ts index 7d2fc26..7316144 100644 --- a/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.ts +++ b/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.ts @@ -66,7 +66,7 @@ const _sortingDataAccessor = ( @Component({ selector: 'ncats-frontend-library-ncats-datatable', templateUrl: './ncats-datatable.component.html', - styleUrls: ['./ncats-datatable.component.scss'], + styleUrl: './ncats-datatable.component.scss', changeDetection: ChangeDetectionStrategy.OnPush, animations: [ trigger('detailExpand', [ @@ -89,7 +89,7 @@ const _sortingDataAccessor = ( NgClass, MatCheckboxModule, PropertyDisplayComponent, - PortalModule, + PortalModule ], }) @@ -144,7 +144,6 @@ export class NcatsDatatableComponent */ @Input() set fieldsConfig(value: DataProperty[]) { - console.log(value); this._fieldsConfig.next(value); } diff --git a/libs/shared/ui/ncats-structure-viewer/src/lib/structure-viewer/structure-viewer.component.ts b/libs/shared/ui/ncats-structure-viewer/src/lib/structure-viewer/structure-viewer.component.ts index 3f50a57..54d3581 100644 --- a/libs/shared/ui/ncats-structure-viewer/src/lib/structure-viewer/structure-viewer.component.ts +++ b/libs/shared/ui/ncats-structure-viewer/src/lib/structure-viewer/structure-viewer.component.ts @@ -1,16 +1,21 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, - Component, + Component, InjectionToken, Input, OnInit, - ViewEncapsulation, -} from '@angular/core'; + ViewEncapsulation +} from "@angular/core"; import { DataProperty } from '@ramp/shared/ui/ncats-datatable'; import { BehaviorSubject } from 'rxjs'; import { takeWhile } from 'rxjs/operators'; import { NgClass } from '@angular/common'; + +export const STRUCTURE_VIEWER_COMPONENT = new InjectionToken( + 'StructureViewerComponent' +); + @Component({ selector: 'ramp-structure-viewer', templateUrl: './structure-viewer.component.html', diff --git a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.ts b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.ts index 647242a..6c3629e 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.ts @@ -344,7 +344,6 @@ export const fetchPathwayAnalysis = createEffect( .pipe( map( (ret: RampPathwayEnrichmentResponse) => { - console.log(ret); return PathwayEnrichmentsActions.fetchEnrichmentFromPathwaysSuccess( ret, ); @@ -428,7 +427,6 @@ export const fetchPathwayCluster = createEffect( ), concatLatestFrom((action) => store.select(getFilteredFishersDataframe)), mergeMap(([action, dataframe]) => { - console.log(dataframe); if (dataframe) { return rampService .getClusterdData( @@ -537,7 +535,6 @@ export const filterEnrichedChemicalClasses = createEffect( ), concatLatestFrom((action) => store.select(getChemicalEnrichment)), mergeMap(([action, dataframe]) => { - console.log(dataframe); if (dataframe) { return rampService .filterMetaboliteEnrichment( @@ -548,7 +545,6 @@ export const filterEnrichedChemicalClasses = createEffect( .pipe( map( (ret: RampChemicalEnrichmentResponse) => { - console.log(ret); return MetaboliteEnrichmentsActions.filterEnrichmentFromMetabolitesSuccess( { data: ret }, ); diff --git a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.reducer.ts b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.reducer.ts index 8cabadd..e555577 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.reducer.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.reducer.ts @@ -228,7 +228,6 @@ export const rampReducer = createReducer( MetaboliteEnrichmentsActions.filterEnrichmentFromMetabolitesSuccess, MetaboliteEnrichmentsActions.fetchEnrichmentFromMetabolitesSuccess, (state, { data }) => { - console.log(data); return { ...state, loading: false, diff --git a/libs/stores/ramp-store/src/lib/+state/ramp.service.ts b/libs/stores/ramp-store/src/lib/+state/ramp.service.ts index 9f612b6..ff77232 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp.service.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp.service.ts @@ -389,7 +389,6 @@ export class RampService { ) // ,{responseType: 'text'}) .pipe( map((response: RampChemicalEnrichmentAPIResponse) => { - console.log(response); const retList: ChemicalEnrichment[] = []; const responseClone = response.data; // delete responseClone.result_type; @@ -412,7 +411,6 @@ export class RampService { pval_type?: string, pval_cutoff?: number, ) { - console.log(dataframe); return this.http .post(`${this.url}filter-fisher-test-results`, { fishers_results: dataframe.data, From 3ba2e3bf9080cddbaaae3dbe8c9c0673e5a4333c Mon Sep 17 00:00:00 2001 From: tsheils Date: Tue, 30 Jan 2024 22:11:26 -0500 Subject: [PATCH 2/2] all linting psses --- .github/workflows/build.yml | 2 +- .travis.yml | 2 +- apps/ramp-client/src/app/app.routes.ts | 1 - .../analytes-from-pathways.component.ts | 14 -- .../chemical-enrichment.component.html | 2 +- .../chemical-enrichment.component.ts | 21 +- .../classes-from-metabolites.component.ts | 29 +-- .../common-reaction-analytes.component.ts | 14 -- .../metabolites-from-ontologies.component.ts | 32 +-- .../ontologies-from-metabolites.component.ts | 13 -- .../pathway-enrichment.component.html | 2 +- .../pathway-enrichment.component.ts | 49 ++--- .../pathways-from-analytes.component.ts | 14 -- .../properties-from-metabolites.component.ts | 2 +- .../src/lib/about/about.component.ts | 8 +- libs/models/ramp-models/src/lib/_utils.ts | 2 +- libs/models/ramp-models/src/lib/classes.ts | 59 ++--- libs/models/ramp-models/src/lib/metabolite.ts | 19 +- libs/models/ramp-models/src/lib/ontology.ts | 42 ++-- libs/models/ramp-models/src/lib/pathway.ts | 2 +- libs/models/ramp-models/src/lib/properties.ts | 2 +- libs/models/ramp-models/src/lib/reaction.ts | 24 +-- .../ramp-models/src/lib/source-version.ts | 12 +- .../data-download-button.component.ts | 10 +- .../src/lib/page-core/page-core.component.ts | 63 +++--- .../complete-dialog.component.spec.ts | 2 - .../complete-dialog.component.ts | 6 +- .../filter-panel/filter-panel.component.ts | 71 +++---- .../ui/highlight/src/lib/highlight.pipe.ts | 5 +- libs/shared/ui/ncats-datatable/.eslintrc.json | 4 +- .../ncats-datatable/models/data-property.ts | 9 +- .../ncats-datatable.component.html | 3 +- .../ncats-datatable.component.ts | 164 +++++++------- .../structure-viewer.component.ts | 3 +- libs/shared/ui/object-tree/.eslintrc.json | 36 ---- libs/shared/ui/object-tree/README.md | 7 - libs/shared/ui/object-tree/jest.config.ts | 23 -- libs/shared/ui/object-tree/project.json | 27 --- libs/shared/ui/object-tree/src/index.ts | 1 - .../object-tree/object-tree.component.html | 145 ------------- .../object-tree/object-tree.component.scss | 43 ---- .../object-tree/object-tree.component.spec.ts | 34 --- .../lib/object-tree/object-tree.component.ts | 201 ------------------ libs/shared/ui/object-tree/src/test-setup.ts | 1 - libs/shared/ui/object-tree/tsconfig.json | 25 --- libs/shared/ui/object-tree/tsconfig.lib.json | 17 -- libs/shared/ui/object-tree/tsconfig.spec.json | 11 - .../upset-chart/src/lib/upset-data.ts | 12 +- .../src/lib/upset/upset.component.ts | 171 ++++++++------- .../src/lib/+state/ramp-store/ramp.actions.ts | 80 +++---- .../+state/ramp-store/ramp.effects.spec.ts | 11 +- .../src/lib/+state/ramp-store/ramp.effects.ts | 70 +++--- .../src/lib/+state/ramp-store/ramp.reducer.ts | 10 +- .../+state/ramp-store/ramp.selectors.spec.ts | 2 +- .../lib/+state/ramp-store/ramp.selectors.ts | 7 - .../ramp-store/src/lib/+state/ramp.service.ts | 145 ++++++------- tsconfig.base.json | 4 +- 57 files changed, 539 insertions(+), 1251 deletions(-) delete mode 100644 libs/shared/ui/object-tree/.eslintrc.json delete mode 100644 libs/shared/ui/object-tree/README.md delete mode 100644 libs/shared/ui/object-tree/jest.config.ts delete mode 100644 libs/shared/ui/object-tree/project.json delete mode 100644 libs/shared/ui/object-tree/src/index.ts delete mode 100644 libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.html delete mode 100644 libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.scss delete mode 100644 libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.spec.ts delete mode 100644 libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.ts delete mode 100644 libs/shared/ui/object-tree/src/test-setup.ts delete mode 100644 libs/shared/ui/object-tree/tsconfig.json delete mode 100644 libs/shared/ui/object-tree/tsconfig.lib.json delete mode 100644 libs/shared/ui/object-tree/tsconfig.spec.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1b2fa80..6fc98f3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,5 +28,5 @@ jobs: - run: npm i -g @angular/cli - run: npm i -g nx - run: npm i - - run: ng lint + - run: nx run ramp:lint - run: ng run-many --all --target=test -- --no-watch --no-progress --browsers=ChromeHeadlessCI diff --git a/.travis.yml b/.travis.yml index 107e6cd..a6719e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,5 +14,5 @@ install: - npm install script: - - ng lint + - nx run ramp:lint - ng run-many --all --target=test -- --no-watch --no-progress --browsers=ChromeHeadlessCI diff --git a/apps/ramp-client/src/app/app.routes.ts b/apps/ramp-client/src/app/app.routes.ts index 4f49085..c84bcf5 100644 --- a/apps/ramp-client/src/app/app.routes.ts +++ b/apps/ramp-client/src/app/app.routes.ts @@ -1,4 +1,3 @@ -import { InjectionToken } from "@angular/core"; import { Routes } from '@angular/router'; import { STRUCTURE_VIEWER_COMPONENT, StructureViewerComponent } from "@ramp/shared/ui/ncats-structure-viewer"; import rFunctions from '../assets/data/rFunctions.json'; diff --git a/libs/features/ramp/analytes-from-pathways/src/lib/analytes-from-pathways/analytes-from-pathways.component.ts b/libs/features/ramp/analytes-from-pathways/src/lib/analytes-from-pathways/analytes-from-pathways.component.ts index d936b89..eb03d2b 100644 --- a/libs/features/ramp/analytes-from-pathways/src/lib/analytes-from-pathways/analytes-from-pathways.component.ts +++ b/libs/features/ramp/analytes-from-pathways/src/lib/analytes-from-pathways/analytes-from-pathways.component.ts @@ -128,18 +128,4 @@ export class AnalytesFromPathwaysComponent ); } } - - /*private _mapData(data: any): void { - this.dataAsDataProperty = data.map((analyte: Analyte) => { - const newObj: { [key: string]: DataProperty } = {}; - Object.entries(analyte).map((value: any) => { - newObj[value[0]] = new DataProperty({ - name: value[0], - label: value[0], - value: value[1], - }); - }); - return newObj; - }); - }*/ } diff --git a/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.html b/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.html index 7f09719..4ba373e 100644 --- a/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.html +++ b/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.html @@ -36,7 +36,7 @@

type="file" class="file-input" accept="text/tab-separated-values, .txt" - (change)="onFileSelected($event)" + (change)="_onFileSelected($event)" #fileUpload />
diff --git a/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.ts b/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.ts index 47d8c6d..71da133 100644 --- a/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.ts +++ b/libs/features/ramp/chemical-enrichment/src/lib/chemical-enrichment/chemical-enrichment.component.ts @@ -12,7 +12,6 @@ import { MatDialog, MatDialogRef } from '@angular/material/dialog'; import { MatTabGroup, MatTabsModule } from '@angular/material/tabs'; import { select } from '@ngrx/store'; import { - ChemicalEnrichment, Classes, RampChemicalEnrichmentResponse, RampResponse, @@ -174,9 +173,6 @@ export class ChemicalEnrichmentComponent enrichmentLoading = false; classesAsDataProperty: { [key: string]: DataProperty }[] = []; - fileName = ''; - file?: File; - // enrichmentdataframe: FishersDataframe; constructor( private ref: ChangeDetectorRef, @@ -193,10 +189,9 @@ export class ChemicalEnrichmentComponent select(RampSelectors.getChemicalEnrichment), takeUntilDestroyed(this.destroyRef), map((res: RampChemicalEnrichmentResponse | undefined) => { + this.dialog.closeAll(); if (res && res.enriched_chemical_class_list) { this._mapData(res.enriched_chemical_class_list) - this.enrichmentLoading = false; - // if (res.openModal) { const ref: MatDialogRef = this.dialog.open( CompleteDialogComponent, @@ -211,10 +206,12 @@ export class ChemicalEnrichmentComponent ref.afterClosed().subscribe((res) => { if (res) { this.resultsTabs.selectedIndex = res; + this.enrichmentLoading = false; this.ref.markForCheck(); } }); // } + this.enrichmentLoading = false; this.ref.markForCheck(); } /*if (res && res.dataframe) { @@ -317,12 +314,12 @@ export class ChemicalEnrichmentComponent ); } - private _mapClasses(data: any): void { + private _mapClasses(data: Classes[]): void { this.classesAsDataProperty = data.map((obj: Classes) => { const newObj: { [key: string]: DataProperty } = {}; Object.entries(obj).map((value: string[]) => { newObj[value[0]] = new DataProperty({ - name: value[0], + //name: value[0], label: value[0], value: value[1], }); @@ -331,14 +328,6 @@ export class ChemicalEnrichmentComponent }); } - onFileSelected(event: any) { - this.file = event.target.files[0]; - if (this.file) { - this.fileName = this.file.name; - this.ref.markForCheck(); - } - } - cancelUpload() { this.fileName = ''; this.fileUpload.nativeElement.value = ''; diff --git a/libs/features/ramp/classes-from-metabolites/src/lib/classes-from-metabolites/classes-from-metabolites.component.ts b/libs/features/ramp/classes-from-metabolites/src/lib/classes-from-metabolites/classes-from-metabolites.component.ts index c2e5c4a..9b165f9 100644 --- a/libs/features/ramp/classes-from-metabolites/src/lib/classes-from-metabolites/classes-from-metabolites.component.ts +++ b/libs/features/ramp/classes-from-metabolites/src/lib/classes-from-metabolites/classes-from-metabolites.component.ts @@ -91,8 +91,7 @@ export class ClassesFromMetabolitesComponent customComponent: TREE_VIEWER_COMPONENT, }),*/ ]; - fileName = ''; - file?: File; + biospecimenCtrl: UntypedFormControl = new UntypedFormControl(); biospecimens: string[] = [ 'Blood', @@ -118,7 +117,7 @@ export class ClassesFromMetabolitesComponent takeUntilDestroyed(this.destroyRef), map((res: RampResponse | undefined) => { if (res && res.data) { - const classGroup: Map = new Map(); + /* const classGroup: Map = new Map(); res.data.forEach((chclass) => { const classObj = classGroup.get(chclass.treePath); if (classObj) { @@ -133,7 +132,7 @@ export class ClassesFromMetabolitesComponent }; classGroup.set(chclass.treePath, temp); } - }); + });*/ this._mapData(res.data); this.matches = Array.from( new Set( @@ -197,28 +196,6 @@ export class ClassesFromMetabolitesComponent } } - /*private _mapData(data: any): void { - this.dataAsDataProperty = data.map((obj: Classes) => { - const newObj: { [key: string]: DataProperty } = {}; - Object.entries(obj).map((value: any) => { - newObj[value[0]] = new DataProperty({ - name: value[0], - label: value[0], - value: value[1], - }); - }); - return newObj; - }); - }*/ - - onFileSelected(event: any) { - this.file = event.target.files[0]; - if (this.file) { - this.fileName = this.file.name; - this.ref.markForCheck(); - } - } - cancelUpload() { this.fileName = ''; this.file = undefined; diff --git a/libs/features/ramp/common-reaction-analytes/src/lib/common-reaction-analytes/common-reaction-analytes.component.ts b/libs/features/ramp/common-reaction-analytes/src/lib/common-reaction-analytes/common-reaction-analytes.component.ts index 75fecdf..5e22dbf 100644 --- a/libs/features/ramp/common-reaction-analytes/src/lib/common-reaction-analytes/common-reaction-analytes.component.ts +++ b/libs/features/ramp/common-reaction-analytes/src/lib/common-reaction-analytes/common-reaction-analytes.component.ts @@ -122,18 +122,4 @@ export class CommonReactionAnalytesComponent ); } } - - /*private _mapData(data: any): void { - this.dataAsDataProperty = data.map((reaction: Reaction) => { - const newObj: { [key: string]: DataProperty } = {}; - Object.entries(reaction).map((value: any) => { - newObj[value[0]] = new DataProperty({ - name: value[0], - label: value[0], - value: value[1], - }); - }); - return newObj; - }); - }*/ } diff --git a/libs/features/ramp/metabolites-from-ontologies/src/lib/metabolites-from-ontologies/metabolites-from-ontologies.component.ts b/libs/features/ramp/metabolites-from-ontologies/src/lib/metabolites-from-ontologies/metabolites-from-ontologies.component.ts index bcc2854..d34960f 100644 --- a/libs/features/ramp/metabolites-from-ontologies/src/lib/metabolites-from-ontologies/metabolites-from-ontologies.component.ts +++ b/libs/features/ramp/metabolites-from-ontologies/src/lib/metabolites-from-ontologies/metabolites-from-ontologies.component.ts @@ -1,3 +1,4 @@ +import { SelectionChange } from "@angular/cdk/collections"; import { TitleCasePipe } from '@angular/common'; import { ChangeDetectorRef, @@ -61,7 +62,7 @@ export class MetabolitesFromOntologiesComponent extends PageCoreComponent implements OnInit { - @ViewChildren('filterPanel') filterPanels!: QueryList; + @ViewChildren('filterPanel') filterPanels!: QueryList>; @ViewChild('metaTabs') metaTabs!: ElementRef; tabIndex = 0; @@ -69,7 +70,7 @@ export class MetabolitesFromOntologiesComponent metaboliteColumns: DataProperty[] = [ new DataProperty({ label: 'Ontology', - field: 'ontology', + field: 'ontologyTerm', sortable: true, }), new DataProperty({ @@ -79,7 +80,7 @@ export class MetabolitesFromOntologiesComponent }), new DataProperty({ label: 'Metabolite', - field: 'metabolites', + field: 'metNames', sortable: true, }), new DataProperty({ @@ -90,7 +91,7 @@ export class MetabolitesFromOntologiesComponent ]; ontologies!: OntologyList[]; allOntologies!: OntologyList[]; - selectedOntologies: any[] = []; + selectedOntologies: Ontology[] = []; globalFilter?: string; disableSearch = false; loading = false; @@ -129,7 +130,7 @@ export class MetabolitesFromOntologiesComponent .pipe( select(RampSelectors.getontologiesList), takeUntilDestroyed(this.destroyRef), - map((res: any) => { + map((res: OntologyList[] | undefined) => { if (res && res.length) { this.ontologies = res; this.allOntologies = res; @@ -147,9 +148,9 @@ export class MetabolitesFromOntologiesComponent if (res && res.data) { this.dataAsDataProperty = res.data.map((metabolite: Metabolite) => { const newObj: { [key: string]: DataProperty } = {}; - Object.entries(metabolite).map((value: any) => { + Object.entries(metabolite).map((value: string[]) => { newObj[value[0]] = new DataProperty({ - name: value[0], + //name: value[0], label: value[0], value: value[1], }); @@ -171,17 +172,20 @@ export class MetabolitesFromOntologiesComponent .subscribe(); } - setValues(values: any) { + setValues(values: SelectionChange) { if (values.added) { this.selectedOntologies = Array.from( - new Set(this.selectedOntologies.concat(values.added)), + new Set(this.selectedOntologies.concat(values.added as Ontology[])), ); } if (values.removed) { values.removed.forEach( - (val: { value: any }) => + (val: unknown) => (this.selectedOntologies = this.selectedOntologies.filter( - (ont) => ont.value !== val.value, + (ont: Ontology) => { + const tempVal: Ontology = val as Ontology; + return ont.value !== tempVal.value + } )), ); } @@ -197,7 +201,7 @@ export class MetabolitesFromOntologiesComponent fetchMetabolites(): void { this.loading = true; this.tabIndex = 0; - const ontologiesList = this.selectedOntologies.map((ont) => ont.value); + const ontologiesList: string[] = this.selectedOntologies.map((ont:Ontology) => ont.value); this.store.dispatch( MetaboliteFromOntologyActions.fetchMetabolitesFromOntologies({ ontologies: ontologiesList, @@ -206,8 +210,8 @@ export class MetabolitesFromOntologiesComponent } fetchMetabolitesFile(): void { - const ontologiesList = this.selectedOntologies.map((ont) => ont.value); - if (ontologiesList.length) { + const ontologiesList: string[] = this.selectedOntologies.map((ont:Ontology) => ont.value); + if (ontologiesList && ontologiesList.length) { this.store.dispatch( MetaboliteFromOntologyActions.fetchMetabolitesFromOntologiesFile({ ontologies: ontologiesList, diff --git a/libs/features/ramp/ontologies-from-metabolites/src/lib/ontologies-from-metabolites/ontologies-from-metabolites.component.ts b/libs/features/ramp/ontologies-from-metabolites/src/lib/ontologies-from-metabolites/ontologies-from-metabolites.component.ts index 7b33cc5..5ce4a2f 100644 --- a/libs/features/ramp/ontologies-from-metabolites/src/lib/ontologies-from-metabolites/ontologies-from-metabolites.component.ts +++ b/libs/features/ramp/ontologies-from-metabolites/src/lib/ontologies-from-metabolites/ontologies-from-metabolites.component.ts @@ -125,17 +125,4 @@ export class OntologiesFromMetabolitesComponent } } - /*private _mapData(data: any): void { - this.dataAsDataProperty = data.map((obj: Ontology) => { - const newObj: { [key: string]: DataProperty } = {}; - Object.entries(obj).map((value: any) => { - newObj[value[0]] = new DataProperty({ - name: value[0], - label: value[0], - value: value[1], - }); - }); - return newObj; - }); - }*/ } diff --git a/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.html b/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.html index 9b47913..d50df49 100644 --- a/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.html +++ b/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.html @@ -36,7 +36,7 @@

type="file" class="file-input" accept="text/tab-separated-values, .txt" - (change)="onFileSelected($event)" + (change)="_onFileSelected($event)" #fileUpload />
diff --git a/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.ts b/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.ts index 99b619c..86a49e7 100644 --- a/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.ts +++ b/libs/features/ramp/pathway-enrichment/src/lib/pathway-enrichment/pathway-enrichment.component.ts @@ -98,8 +98,7 @@ export class PathwayEnrichmentComponent pathwaysLoading = false; enrichmentLoading = false; imageLoading = false; - fileName = ''; - file?: File; + enrichmentColumns: { [key: string]: DataProperty[]; } = { @@ -302,7 +301,7 @@ export class PathwayEnrichmentComponent allDataAsDataProperty!: { [key: string]: DataProperty }[]; pathwayDataAsDataProperty!: { [key: string]: DataProperty }[]; image!: SafeHtml; - enrichedDataframe!: FishersDataframe; + enrichedDataframe!: unknown[] | FishersDataframe; tooBig = false; analyteType = ''; @@ -337,19 +336,6 @@ export class PathwayEnrichmentComponent if (res.data.length) { this.dataAsDataProperty = this._mapPathwaysData(res.data); - /* res.data.map( - (enrichment: FisherResult) => { - const newObj: { [key: string]: DataProperty } = {}; - Object.entries(enrichment).map((value:string[]) => { - newObj[value[0]] = new DataProperty({ - name: value[0], - label: value[0], - value: value[1], - }); - }); - return newObj; - }, - );*/ this.enrichmentLoading = false; this.allDataAsDataProperty = this.dataAsDataProperty; this.imageLoading = false; @@ -379,7 +365,7 @@ export class PathwayEnrichmentComponent } if (res && res.dataframe) { this.enrichedDataframe = res.dataframe; - if (this.enrichedDataframe.analyte_type) { + if (this.enrichedDataframe instanceof FishersDataframe && this.enrichedDataframe.analyte_type) { this.selectedEnrichmentColumns = this.enrichmentColumns[ this.enrichedDataframe.analyte_type[0] @@ -530,8 +516,14 @@ export class PathwayEnrichmentComponent } fetchEnrichedPathwaysFile(): void { - this._downloadFile( - this._toTSV(this.enrichedDataframe), + let data: unknown[]; + if (this.enrichedDataframe instanceof FishersDataframe && this.enrichedDataframe.fishresults) { + data = this.enrichedDataframe.fishresults as unknown[] + } else { + data = this.enrichedDataframe as unknown[] + } + this._downloadFile( + this._toTSV(data), 'fetchEnrichedPathwaysFromAnalytes-download.tsv', ); } @@ -546,17 +538,6 @@ export class PathwayEnrichmentComponent ); } - onFileSelected(event: Event) { - const target = event.target as HTMLInputElement; - if (target && target?.files?.length) { - this.file = target?.files[0]; - if (this.file) { - this.fileName = this.file.name; - this.ref.markForCheck(); - } - } - } - cancelUpload() { this.fileName = ''; this.fileUpload.nativeElement.value = ''; @@ -569,11 +550,11 @@ export class PathwayEnrichmentComponent ): { [key: string]: DataProperty }[] { return data.map((fieldObj: FisherResult | Pathway) => { const newObj: { [key: string]: DataProperty } = {}; - Object.entries(fieldObj).map((value: unknown[]) => { + Object.entries(fieldObj).map((value: string[]) => { newObj[value[0]] = new DataProperty({ - name: value[0], - label: value[0], - value: value[1], + // name: value[0], + label: value[0], + value: value[1], }); }); return newObj; diff --git a/libs/features/ramp/pathways-from-analytes/src/lib/pathways-from-analytes/pathways-from-analytes.component.ts b/libs/features/ramp/pathways-from-analytes/src/lib/pathways-from-analytes/pathways-from-analytes.component.ts index 4923eab..d280984 100644 --- a/libs/features/ramp/pathways-from-analytes/src/lib/pathways-from-analytes/pathways-from-analytes.component.ts +++ b/libs/features/ramp/pathways-from-analytes/src/lib/pathways-from-analytes/pathways-from-analytes.component.ts @@ -119,18 +119,4 @@ export class PathwaysFromAnalytesComponent ); } } - - /*private _mapData(data: any): void { - this.dataAsDataProperty = data.map((analyte: Pathway) => { - const newObj: { [key: string]: DataProperty } = {}; - Object.entries(analyte).map((value: any) => { - newObj[value[0]] = new DataProperty({ - name: value[0], - label: value[0], - value: value[1], - }); - }); - return newObj; - }); - }*/ } diff --git a/libs/features/ramp/properties-from-metabolites/src/lib/properties-from-metabolites/properties-from-metabolites.component.ts b/libs/features/ramp/properties-from-metabolites/src/lib/properties-from-metabolites/properties-from-metabolites.component.ts index c6f110c..b0f933f 100644 --- a/libs/features/ramp/properties-from-metabolites/src/lib/properties-from-metabolites/properties-from-metabolites.component.ts +++ b/libs/features/ramp/properties-from-metabolites/src/lib/properties-from-metabolites/properties-from-metabolites.component.ts @@ -145,7 +145,7 @@ export class PropertiesFromMetabolitesComponent const newObj: { [key: string]: DataProperty } = {}; Object.entries(obj).map((value: string[]) => { newObj[value[0]] = new DataProperty({ - name: value[0], + //name: value[0], label: value[0], value: value[1], }); diff --git a/libs/features/ramp/ramp-about/src/lib/about/about.component.ts b/libs/features/ramp/ramp-about/src/lib/about/about.component.ts index 7d2dcc7..ed3d945 100644 --- a/libs/features/ramp/ramp-about/src/lib/about/about.component.ts +++ b/libs/features/ramp/ramp-about/src/lib/about/about.component.ts @@ -150,11 +150,11 @@ export class AboutComponent implements OnInit { if (data.entityCounts) { this.entityCounts = data.entityCounts.map((count: EntityCount) => { const newObj: { [key: string]: DataProperty } = {}; - Object.entries(count).map((value: unknown[]) => { + Object.entries(count).map((value: string[]) => { newObj[value[0]] = new DataProperty({ - name: value[0], - label: value[0], - value: value[1], + // name: value[0], + label: value[0], + value: value[1], }); }); return newObj; diff --git a/libs/models/ramp-models/src/lib/_utils.ts b/libs/models/ramp-models/src/lib/_utils.ts index b113c25..79a337a 100644 --- a/libs/models/ramp-models/src/lib/_utils.ts +++ b/libs/models/ramp-models/src/lib/_utils.ts @@ -13,7 +13,7 @@ export interface RampAPIResponse { export interface RampResponse { data: Array; query: RampQuery; - dataframe?: FishersDataframe; + dataframe?: unknown[]; } export interface RampPathwayEnrichmentAPIResponse { diff --git a/libs/models/ramp-models/src/lib/classes.ts b/libs/models/ramp-models/src/lib/classes.ts index d849d86..b6678dd 100644 --- a/libs/models/ramp-models/src/lib/classes.ts +++ b/libs/models/ramp-models/src/lib/classes.ts @@ -6,53 +6,54 @@ export class Classes { lipidMapsCategory!: string; lipidMapsMainClass!: string; lipidMapsSubClass!: string; - private _classyFireClasses: ClassLevelNode[] = []; - classyFireTree?: any; - lipidMapsTree?: any; - private _lipidMapsClasses: ClassLevelNode[] = []; - treePath!: string; + // private _classyFireClasses: ClassLevelNode[] = []; + // classyFireTree?: any; + // lipidMapsTree?: any; + // private _lipidMapsClasses: ClassLevelNode[] = []; + // treePath!: string; sourceId!: string; - constructor(obj: any) { - if (obj.sourceId) { - this.sourceId = obj.sourceId; + constructor(obj: {[key: string]: unknown}) { + if (obj['sourceId']) { + this.sourceId = obj['sourceId']; } - if (obj.levels) { - obj.levels.forEach((level: any) => { - if (level.common_names) { - this.commonNames = level.common_names; + if (obj['levels']) { + const arrs: {[key: string]: string}[] = obj['levels'] as {[key: string]: string}[]; + arrs.forEach((level: {[key: string]: string}) => { + if (level['common_names']) { + this.commonNames = level['common_names']; } - if (level.class_level_name === 'ClassyFire_super_class') { - this.classyFireSuperClass = level.class_name; + if (level['class_level_name'] === 'ClassyFire_super_class') { + this.classyFireSuperClass = level['class_name']; } - if (level.class_level_name === 'ClassyFire_class') { - this.classyFireClass = level.class_name; + if (level['class_level_name'] === 'ClassyFire_class') { + this.classyFireClass = level['class_name']; } - if (level.class_level_name === 'ClassyFire_sub_class') { - this.classyFireSubClass = level.class_name; + if (level['class_level_name'] === 'ClassyFire_sub_class') { + this.classyFireSubClass = level['class_name']; } - if (level.class_level_name === 'LipidMaps_category') { - this.lipidMapsCategory = level.class_name; + if (level['class_level_name'] === 'LipidMaps_category') { + this.lipidMapsCategory = level['class_name']; } - if (level.class_level_name === 'LipidMaps_main_class') { - this.lipidMapsMainClass = level.class_name; + if (level['class_level_name'] === 'LipidMaps_main_class') { + this.lipidMapsMainClass = level['class_name']; } - if (level.class_level_name === 'LipidMaps_sub_class') { - this.lipidMapsSubClass = level.class_name; + if (level['class_level_name'] === 'LipidMaps_sub_class') { + this.lipidMapsSubClass = level['class_name']; } // this[class_level_name] = - if (level.class_level_name.includes('LipidMaps')) { + /* if (level['class_level_name.includes('LipidMaps')) { this._lipidMapsClasses.push(new ClassLevelNode(level)); } else { this._classyFireClasses.push(new ClassLevelNode(level)); - } + }*/ }); } - if (this._classyFireClasses.length) { +/* if (this._classyFireClasses.length) { this.classyFireTree = [ { value: this._classyFireClasses.find((node) => node.level === 0) @@ -107,10 +108,11 @@ export class Classes { ) .toLocaleLowerCase() .replace(/ /g, ''); - } + }*/ } } +/* export class ClassLevelNode { class_level_name!: string; // label!: string; @@ -139,3 +141,4 @@ export class ClassLevelNode { } } } +*/ diff --git a/libs/models/ramp-models/src/lib/metabolite.ts b/libs/models/ramp-models/src/lib/metabolite.ts index e36efc9..7bd2959 100644 --- a/libs/models/ramp-models/src/lib/metabolite.ts +++ b/libs/models/ramp-models/src/lib/metabolite.ts @@ -1,21 +1,10 @@ export class Metabolite { ontologyCategory!: string; - metabolites!: string; - ontology!: string; metIds!: string; + metNames!: string; + ontologyTerm!: string; - constructor(obj: any) { - if (obj.ontologyCategory) { - this.ontologyCategory = obj.ontologyCategory; - } - if (obj.metNames) { - this.metabolites = obj.metNames; - } - if (obj.ontologyTerm) { - this.ontology = obj.ontologyTerm; - } - if (obj.metIds) { - this.metIds = obj.metIds; - } + constructor(obj: Partial) { + Object.assign(this, obj); } } diff --git a/libs/models/ramp-models/src/lib/ontology.ts b/libs/models/ramp-models/src/lib/ontology.ts index 8f46a5b..c4a2a39 100644 --- a/libs/models/ramp-models/src/lib/ontology.ts +++ b/libs/models/ramp-models/src/lib/ontology.ts @@ -17,7 +17,7 @@ export class Ontology { HMDBOntologyType!: string; idType?: string; metabolites?: string; - ontology?: string; + ontology!: string; sourceId!: string; commonName?: string; rampOntologyId?: string; @@ -25,34 +25,34 @@ export class Ontology { value?: string; source?: string; - constructor(obj: any) { - if (obj.HMDBOntologyType) { - this.HMDBOntologyType = obj.HMDBOntologyType; - this.source = obj.HMDBOntologyType; + constructor(obj: {[key: string]:unknown}) { + if (obj['HMDBOntologyType']) { + this.HMDBOntologyType = obj['HMDBOntologyType']; + this.source = obj['HMDBOntologyType']; } - if (obj.IDtype) { - this.idType = obj.IDtype; + if (obj['IDtype']) { + this.idType = obj['IDtype']; } - if (obj.Metabolites) { - this.metabolites = obj.Metabolites; + if (obj['Metabolites']) { + this.metabolites = obj['Metabolites']; } - if (obj.Ontology) { - this.ontology = obj.Ontology; - this.value = obj.Ontology; + if (obj['Ontology']) { + this.ontology = obj['Ontology']; + this.value = obj['Ontology']; } - if (obj.sourceId) { - this.sourceId = obj.sourceId; + if (obj['sourceId']) { + this.sourceId = obj['sourceId']; } - if (obj.commonName) { - this.ontology = obj.commonName; - this.value = obj.commonName; + if (obj['commonName']) { + this.ontology = obj['commonName']; + this.value = obj['commonName']; } - if (obj.rampOntologyId) { - this.rampOntologyId = obj.rampOntologyId; + if (obj['rampOntologyId']) { + this.rampOntologyId = obj['rampOntologyId']; } - if (obj.metCount) { - this.count = obj.metCount; + if (obj['metCount']) { + this.count = obj['metCount']; } } } diff --git a/libs/models/ramp-models/src/lib/pathway.ts b/libs/models/ramp-models/src/lib/pathway.ts index 2af8811..fe457ed 100644 --- a/libs/models/ramp-models/src/lib/pathway.ts +++ b/libs/models/ramp-models/src/lib/pathway.ts @@ -6,7 +6,7 @@ export class Pathway { analyteName!: string; inputId!: string; - constructor(obj: any) { + constructor(obj: Partial) { Object.assign(this, obj); } } diff --git a/libs/models/ramp-models/src/lib/properties.ts b/libs/models/ramp-models/src/lib/properties.ts index 6b16470..1b9b8d0 100644 --- a/libs/models/ramp-models/src/lib/properties.ts +++ b/libs/models/ramp-models/src/lib/properties.ts @@ -10,7 +10,7 @@ export class Properties { mol_formula!: string; imageUrl!: string; - constructor(obj: any) { + constructor(obj: Partial) { Object.assign(this, obj); this.imageUrl = this.iso_smiles; } diff --git a/libs/models/ramp-models/src/lib/reaction.ts b/libs/models/ramp-models/src/lib/reaction.ts index f8f080b..78312ba 100644 --- a/libs/models/ramp-models/src/lib/reaction.ts +++ b/libs/models/ramp-models/src/lib/reaction.ts @@ -6,26 +6,26 @@ export class Reaction { rxnPartnerIdsString!: string; queryRelation!: string; - constructor(obj: any) { - if (obj.input_analyte) { - this.inputAnalyte = obj.input_analyte; + constructor(obj: { [key:string]: unknown }) { + if (obj['input_analyte']) { + this.inputAnalyte = obj['input_analyte']; } - if (obj.query_relation) { - this.queryRelation = obj.query_relation; + if (obj['query_relation']) { + this.queryRelation = obj['query_relation']; } - if (obj.input_common_names) { - this.inputCommonNames = obj.input_common_names; + if (obj['input_common_names']) { + this.inputCommonNames = obj['input_common_names']; } - if (obj.rxn_partner_common_name) { - this.rxnPartnerCommonName = obj.rxn_partner_common_name; + if (obj['rxn_partner_common_name']) { + this.rxnPartnerCommonName = obj['rxn_partner_common_name']; } - if (obj.rxn_partner_ids) { - this.rxnPartnerIdsString = obj.rxn_partner_ids; - this.rxnPartnerIds = obj.rxn_partner_ids.split('; '); + if (obj['rxn_partner_ids']) { + this.rxnPartnerIdsString = obj['rxn_partner_ids']; + this.rxnPartnerIds = this.rxnPartnerIdsString.split('; '); } } } diff --git a/libs/models/ramp-models/src/lib/source-version.ts b/libs/models/ramp-models/src/lib/source-version.ts index 99154f5..9c0510b 100644 --- a/libs/models/ramp-models/src/lib/source-version.ts +++ b/libs/models/ramp-models/src/lib/source-version.ts @@ -11,10 +11,10 @@ export interface SourceVersion { } export interface Stats { - entityCounts: EntityCount[]; - supportedIds: [{ analyteType: string; idTypes: string[] }]; - metaboliteIntersects: any[]; - geneIntersects: { id: string; sets: string[]; size: number }[]; - sourceVersions: SourceVersion[]; - databaseUrl: string[]; + entityCounts?: EntityCount[]; + supportedIds?: { analyteType: string; idTypes: string[] }[]; + metaboliteIntersects?: { id: string; sets: string[]; size: number }[]; + geneIntersects?: { id: string; sets: string[]; size: number }[]; + sourceVersions?: SourceVersion[]; + databaseUrl?: string; } diff --git a/libs/shared/ncats/data-download/src/lib/data-download-button/data-download-button.component.ts b/libs/shared/ncats/data-download/src/lib/data-download-button/data-download-button.component.ts index a7c651b..8ddcb7c 100644 --- a/libs/shared/ncats/data-download/src/lib/data-download-button/data-download-button.component.ts +++ b/libs/shared/ncats/data-download/src/lib/data-download-button/data-download-button.component.ts @@ -13,23 +13,23 @@ import { MatButtonModule } from '@angular/material/button'; }) export class DataDownloadButtonComponent { @Input() source!: string; - @Input() data!: any; - file!: any; + @Input() data!: unknown[]; + constructor(@Inject(DOCUMENT) private dom: Document) {} downloadData(): void { const lines: string[] = [[...Object.keys(this.data[0])].join(',')]; - this.data.forEach((data: any) => + this.data.forEach((data: {[key: string]: unknown}) => lines.push([...Object.values(data)].join('\t')), ); const csv = lines.join('\n'); - this.file = new Blob([csv], { type: 'text/tsv' }); + const file = new Blob([csv], { type: 'text/tsv' }); const link = this.dom.createElement('a'); if (link.download !== undefined) { // feature detection // Browsers that support HTML5 download attribute - const url = URL.createObjectURL(this.file); + const url = URL.createObjectURL(file); link.setAttribute('href', url); link.setAttribute('download', `${this.source}-download.tsv`); link.style.visibility = 'hidden'; diff --git a/libs/shared/ramp/page-core/src/lib/page-core/page-core.component.ts b/libs/shared/ramp/page-core/src/lib/page-core/page-core.component.ts index f55f38b..7a0ad31 100644 --- a/libs/shared/ramp/page-core/src/lib/page-core/page-core.component.ts +++ b/libs/shared/ramp/page-core/src/lib/page-core/page-core.component.ts @@ -10,8 +10,6 @@ import { import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { select, Store } from '@ngrx/store'; import { - FisherResult, - FishersDataframe, Ontology, RampDataGeneric, RampQuery } from "@ramp/models/ramp-models"; @@ -34,7 +32,7 @@ export class PageCoreComponent { @Input() supportedIdTypes!: string[]; - supportedIds!: { analyteType: string; idTypes: string[] }[]; + supportedIds!: {analyteType: string; idTypes: string[] }[]; @Input() function!: string; @@ -51,7 +49,7 @@ export class PageCoreComponent { @Input() description!: string; - dataframe!: FishersDataframe; + dataframe!: unknown[]; query: RampQuery = { functionCall: '', @@ -64,17 +62,33 @@ export class PageCoreComponent { dataAsDataProperty: { [key: string]: DataProperty }[] = []; downloadQueued = false; fuzzy = false; + fileName = ''; + file?: File; - _toTSV(data: any): string { + constructor() { + this.store + .pipe( + select(RampSelectors.getSupportedIds), + takeUntilDestroyed(this.destroyRef), + map((res: { analyteType: string; idTypes: string[] }[] | undefined) => { + if (res) { + this.supportedIds = res; + } + }), + ) + .subscribe(); + } + + _toTSV(data: unknown[]): string { if (data) { // grab the column headings (separated by tabs) - const headings: string = Object.keys(data[0]).join('\t'); + const headings: string = Object.keys(data[0] as string[]).join('\t'); // iterate over the data - const rows: any = data.reduce( - (acc: string[], c: T) => { + const rows: string[] = data.reduce( + (acc: string[], c: unknown) => { // for each row object get its values and add tabs between them // then add them as a new array to the outgoing array - return acc.concat([Object.values(c).join('\t')]); + return acc.concat([Object.values(c as T).join('\t')]); // finally joining each row with a line break }, @@ -84,23 +98,9 @@ export class PageCoreComponent { } else return ''; } - constructor() { - this.store - .pipe( - select(RampSelectors.getSupportedIds), - takeUntilDestroyed(this.destroyRef), - map((res: any) => { - if (res && res.data) { - this.supportedIds = res.data; - } - }), - ) - .subscribe(); - } - - _downloadFile(data: any, name: string, type: string = 'text/tsv') { + _downloadFile(data: unknown, name: string, type: string = 'text/tsv') { if (this.dom) { - const file = new Blob([data], { type: type }); + const file = new Blob([data as Blob], { type: type }); const link = this.dom.createElement('a'); if (link.download !== undefined) { // feature detection @@ -116,6 +116,17 @@ export class PageCoreComponent { } } + _onFileSelected(event: Event) { + const target = event.target as HTMLInputElement; + if (target && target?.files?.length) { + this.file = target?.files[0]; + if (this.file) { + this.fileName = this.file.name; + this.changeRef.markForCheck(); + } + } + } + _getSupportedIds() { this.supportedIds = this.supportedIds?.filter( (type: { analyteType: string }) => @@ -128,7 +139,7 @@ export class PageCoreComponent { const newObj: { [key: string]: DataProperty } = {}; Object.entries(obj).map((value: string[]) => { newObj[value[0]] = new DataProperty({ - name: value[0], + // name: value[0], label: value[0], value: value[1], }); diff --git a/libs/shared/ui/complete-dialog/src/lib/complete-dialog/complete-dialog.component.spec.ts b/libs/shared/ui/complete-dialog/src/lib/complete-dialog/complete-dialog.component.spec.ts index 0344028..d9425cd 100644 --- a/libs/shared/ui/complete-dialog/src/lib/complete-dialog/complete-dialog.component.spec.ts +++ b/libs/shared/ui/complete-dialog/src/lib/complete-dialog/complete-dialog.component.spec.ts @@ -1,6 +1,4 @@ -import { Dialog } from '@angular/cdk/dialog'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { FlexLayoutModule } from '@angular/flex-layout'; import { MatButtonModule } from '@angular/material/button'; import { MAT_DIALOG_DATA, diff --git a/libs/shared/ui/complete-dialog/src/lib/complete-dialog/complete-dialog.component.ts b/libs/shared/ui/complete-dialog/src/lib/complete-dialog/complete-dialog.component.ts index f77a78f..d6ca481 100644 --- a/libs/shared/ui/complete-dialog/src/lib/complete-dialog/complete-dialog.component.ts +++ b/libs/shared/ui/complete-dialog/src/lib/complete-dialog/complete-dialog.component.ts @@ -28,7 +28,11 @@ import { MatIconModule } from '@angular/material/icon'; export class CompleteDialogComponent { constructor( public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any, + @Inject(MAT_DIALOG_DATA) public data: { + title?: string, + message?: string, + tabs?: string[], + }, ) {} close(tab?: number): void { diff --git a/libs/shared/ui/filter-panel/src/lib/filter-panel/filter-panel.component.ts b/libs/shared/ui/filter-panel/src/lib/filter-panel/filter-panel.component.ts index fc85b02..94daba6 100644 --- a/libs/shared/ui/filter-panel/src/lib/filter-panel/filter-panel.component.ts +++ b/libs/shared/ui/filter-panel/src/lib/filter-panel/filter-panel.component.ts @@ -1,9 +1,9 @@ -import { SelectionModel } from '@angular/cdk/collections'; +import { SelectionChange, SelectionModel } from "@angular/cdk/collections"; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { UntypedFormControl, ReactiveFormsModule } from '@angular/forms'; import { MatTableDataSource } from '@angular/material/table'; import { BehaviorSubject, distinctUntilChanged } from 'rxjs'; -import { MatCheckboxModule } from '@angular/material/checkbox'; +import { MatCheckboxModule } from "@angular/material/checkbox"; import { CdkVirtualScrollViewport, CdkFixedSizeVirtualScroll, @@ -12,7 +12,14 @@ import { import { MatInputModule } from '@angular/material/input'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatCardModule } from '@angular/material/card'; -import { HighlightPipe } from '../../../../highlight/src'; +import { HighlightPipe } from "@ramp/shared/ui/highlight"; + +export interface FilterValue { + count?: number; + label?: string; + value?: string; + key?: string; +} @Component({ selector: 'ramp-filter-panel', @@ -31,12 +38,12 @@ import { HighlightPipe } from '../../../../highlight/src'; HighlightPipe, ], }) -export class FilterPanelComponent implements OnInit { +export class FilterPanelComponent implements OnInit { @Input() displayColumns = ['select', 'value', 'count']; @Input() label?: string; @Input() globalFilter?: string; - @Output() selectionChange: EventEmitter = new EventEmitter(); - filteredData!: any[]; + @Output() selectionChange: EventEmitter> = new EventEmitter>(); + filteredData!: T[]; filterFormCtrl: UntypedFormControl = new UntypedFormControl(); @@ -47,17 +54,17 @@ export class FilterPanelComponent implements OnInit { /** * initialize a private variable _data, it's a BehaviorSubject - * @type {BehaviorSubject} + * @type {BehaviorSubject} * @private */ - protected _data = new BehaviorSubject(null); + protected _data = new BehaviorSubject([]); /** * pushes changed data to {BehaviorSubject} * @param value */ @Input() - set data(value: any[]) { + set data(value: T[]) { this._data.next(value); } @@ -65,20 +72,19 @@ export class FilterPanelComponent implements OnInit { * returns value of {BehaviorSubject} * @returns UpsetData[] */ - get data(): any[] { + get data(): T[] { return this._data.getValue(); } - dataSource: MatTableDataSource = new MatTableDataSource(); - // todo load selected - fieldSelection = new SelectionModel(true, []); + dataSource: MatTableDataSource = new MatTableDataSource(); + fieldSelection = new SelectionModel(true, []); ngOnInit() { - this._data.subscribe((data) => { + this._data.subscribe((data: T[]) => { this.filteredData = data; }); - this.fieldSelection.changed.subscribe((change) => { + this.fieldSelection.changed.subscribe((change:SelectionChange) => { this.selectionChange.emit(change); }); @@ -86,8 +92,11 @@ export class FilterPanelComponent implements OnInit { .pipe(distinctUntilChanged()) .subscribe((term) => { if (term && term.length > 0) { - this.filteredData = this.data.filter((obj) => - obj.value.toLowerCase().includes(term), + this.filteredData = this.data.filter((obj: T) => { + if(obj['value']) { + return obj['value'].toLowerCase().includes(term) + } else return 0 + } ); } else { this.filteredData = this.data; @@ -102,34 +111,12 @@ export class FilterPanelComponent implements OnInit { return numSelected === numRows; } - /** Selects all rows if they are not all selected; otherwise clear selection. */ +/* /!** Selects all rows if they are not all selected; otherwise clear selection. *!/ masterToggle() { this.isAllSelected() ? this.fieldSelection.clear() - : this.dataSource.data.forEach((row) => + : this.dataSource.data.forEach((row:T[]) => this.fieldSelection.select(row.key), ); - } - - /** - * detects scrolling of the options div - * @param event - */ - scrollDetected(event: any) { - if ( - event.target.scrollHeight - - event.target.offsetHeight - - event.target.scrollTop <= - 5 - ) { - if (this.data.values.length < this.data.length) { - // this.fetchAllFilterOptions(); - } - } - } - - /** - * fetches all the filter options for the component's facet - */ - // fetchAllFilterOptions() {} + }*/ } diff --git a/libs/shared/ui/highlight/src/lib/highlight.pipe.ts b/libs/shared/ui/highlight/src/lib/highlight.pipe.ts index 30c0697..067ca1e 100644 --- a/libs/shared/ui/highlight/src/lib/highlight.pipe.ts +++ b/libs/shared/ui/highlight/src/lib/highlight.pipe.ts @@ -17,10 +17,7 @@ export class HighlightPipe implements PipeTransform { constructor(private sanitizer: DomSanitizer) {} transform(text: string, search: string): SafeHtml | string { if (search && text) { - let pattern = search.replace( - /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, - '\\$&', - ); + let pattern = search.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&'); pattern = pattern .split(' ') .filter((t) => { diff --git a/libs/shared/ui/ncats-datatable/.eslintrc.json b/libs/shared/ui/ncats-datatable/.eslintrc.json index eb78159..e239bfb 100644 --- a/libs/shared/ui/ncats-datatable/.eslintrc.json +++ b/libs/shared/ui/ncats-datatable/.eslintrc.json @@ -13,7 +13,7 @@ "error", { "type": "attribute", - "prefix": "ramp", + "prefix": "ncats", "style": "camelCase" } ], @@ -21,7 +21,7 @@ "error", { "type": "element", - "prefix": "ramp", + "prefix": "ncats", "style": "kebab-case" } ] diff --git a/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/models/data-property.ts b/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/models/data-property.ts index 2aafdad..2df566b 100644 --- a/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/models/data-property.ts +++ b/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/models/data-property.ts @@ -1,4 +1,5 @@ import { InjectionToken } from '@angular/core'; +import { Params } from "@angular/router"; /** * main config object for a table cell, contains column/field data nad value info @@ -73,7 +74,7 @@ export class DataProperty { /** * pass a query params object for a routerLink */ - queryParams?: any; + queryParams?: Params; /** * text description of the field. used for table tooltips @@ -86,10 +87,12 @@ export class DataProperty { * deconstruct json as dataproperty object * @param data */ - constructor(data?: any) { + constructor(data?: Partial) { Object.assign(this, data); if (!this.field) { - this.field = data.label; + if (data) { + this.field = data['label']; + } } } } diff --git a/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.html b/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.html index 5194be5..1d4c23a 100644 --- a/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.html +++ b/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.html @@ -19,7 +19,6 @@ matSort #dataTable [dataSource]="dataSource" - [trackBy]="trackByFn" [multiTemplateDataRows]="expandable" (matSortChange)="changeSort($event)" [ngClass]="{ condensed: condensed }" @@ -61,7 +60,7 @@ @if (checkCustomComponent(field)) {
diff --git a/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.ts b/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.ts index 7316144..6a01806 100644 --- a/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.ts +++ b/libs/shared/ui/ncats-datatable/src/lib/ncats-datatable/ncats-datatable.component.ts @@ -1,20 +1,18 @@ import { - AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, - Component, - EventEmitter, + Component, ComponentRef, DestroyRef, + EventEmitter, inject, Injector, Input, - OnDestroy, OnInit, Output, QueryList, Type, ViewChild, ViewChildren, - ViewContainerRef, -} from '@angular/core'; + ViewContainerRef +} from "@angular/core"; import { animate, state, @@ -22,7 +20,8 @@ import { transition, trigger, } from '@angular/animations'; -import { BehaviorSubject, Subject } from 'rxjs'; +import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; +import { BehaviorSubject, Observable } from "rxjs"; import { MatRow, MatTable, @@ -35,30 +34,31 @@ import { MatPaginatorModule, } from '@angular/material/paginator'; import { MatSort, Sort, MatSortModule } from '@angular/material/sort'; -import { ComponentPortal, PortalModule } from '@angular/cdk/portal'; +import { CdkPortalOutletAttachedRef, ComponentPortal, PortalModule } from "@angular/cdk/portal"; import { SelectionModel } from '@angular/cdk/collections'; -import { takeUntil } from 'rxjs/operators'; import { PageData } from './models/page-data'; import { DataProperty } from './models/data-property'; import { PropertyDisplayComponent } from './components/property-display/property-display.component'; import { MatCheckboxModule } from '@angular/material/checkbox'; import { NgClass } from '@angular/common'; + const _sortingDataAccessor = ( - item: { [key: string]: DataProperty }, + data: { [key: string]: DataProperty }, property: string, ) => { - if (item[property] && item[property].value) { - if (!isNaN(Number(item[property].value))) { - return item[property].value; + if (data[property] && data[property].value) { + if (!isNaN(Number(data[property].value))) { + return data[property].value; } else { - return item[property].value.toLocaleUpperCase(); + return data[property].value.toLocaleUpperCase(); } } else { return 0; } }; + /** * component to show flexible data consisting of multiple data types, custom components * also handles standard table operations, primarily with event emitters for the end user to react to @@ -97,37 +97,33 @@ const _sortingDataAccessor = ( * Generic table Component that iterates over a list of options to display fields */ export class NcatsDatatableComponent - implements OnInit, AfterViewInit, OnDestroy + implements OnInit { - /** - * Table object - */ - @ViewChild(MatTable) dataTable!: MatTable; + destroyRef = inject(DestroyRef); /** - * Behaviour subject to allow extending class to unsubscribe on destroy - * @type {Subject} + * Table object */ - protected ngUnsubscribe: Subject = new Subject(); + @ViewChild(MatTable) dataTable!: MatTable; /** * initialize a private variable _data, it's a BehaviorSubject * */ - protected _data = new BehaviorSubject(null); + protected _data = new BehaviorSubject<{ [key: string]: DataProperty; }[]>([]); /** * pushes changed data to {BehaviorSubject} */ @Input() - set data(value: any) { + set data(value: { [key: string]: DataProperty; }[]) { this._data.next(value); } /** * returns value of {BehaviorSubject} */ - get data(): any { + get data(): { [key: string]: DataProperty; }[] { return this._data.getValue(); } @@ -232,7 +228,7 @@ export class NcatsDatatableComponent * This compares each row of the table to the "expanded element - if they are equal, the row is expanded * todo: this only allows one open at a time, this might need to be a map to allow multiple expanded rows */ - expandedElement: any | null; + expandedElement: unknown | null; /** * event that emits when the sort value or direction is changed. The parent component will be responsible for @@ -258,7 +254,7 @@ export class NcatsDatatableComponent * main table datasource * @type {MatTableDataSource} */ - dataSource: MatTableDataSource = new MatTableDataSource(); + dataSource: MatTableDataSource<{[key: string]:DataProperty}> = new MatTableDataSource<{[key: string]: DataProperty}>(); /** * whether to toggle the condensed class to make a more compact table @@ -270,10 +266,10 @@ export class NcatsDatatableComponent @Input() internalSort = false; - @Output() rowSelectionChange: EventEmitter> = - new EventEmitter>(); + @Output() rowSelectionChange: EventEmitter> = + new EventEmitter>(); - selection = new SelectionModel(true, []); + selection = new SelectionModel(true, []); /** * Paginator object from Angular Material @@ -303,12 +299,15 @@ export class NcatsDatatableComponent this._data // listen to data as long as term is undefined or null // Unsubscribe once term has value - .pipe(takeUntil(this.ngUnsubscribe)) - .subscribe((res) => { + .pipe( + takeUntilDestroyed(this.destroyRef), + ) + .subscribe((res: {[key: string]: DataProperty}[]) => { if (res) { if (this.useInternalPaginator) { - this.dataSource = new MatTableDataSource( - res.map((val: any) => new DataProperty(val)), + this.dataSource = new MatTableDataSource<{[key: string]: DataProperty}>( + res + // res.map((val: Partial) => new DataProperty(val)), ); this.pageData = new PageData({ total: res.length }); } else { @@ -318,7 +317,7 @@ export class NcatsDatatableComponent if (this.internalSort) { this.dataSource.sortingDataAccessor = _sortingDataAccessor; this.dataSource.sort = this._sort; - this._sort.sortChange.subscribe((res) => { + this._sort.sortChange.subscribe(() => { if (this.dataSource.paginator) { this.dataSource.paginator.firstPage(); } @@ -329,28 +328,21 @@ export class NcatsDatatableComponent }); this._fieldsConfig - .pipe(takeUntil(this.ngUnsubscribe)) - .subscribe((res) => this.fetchTableFields()); + .pipe( + takeUntilDestroyed(this.destroyRef), + ) + .subscribe(() => this.fetchTableFields()); + this.selection.changed - .pipe(takeUntil(this.ngUnsubscribe)) - .subscribe((change) => { + .pipe( + takeUntilDestroyed(this.destroyRef), + ) + .subscribe(() => { this.ref.detectChanges(); this.rowSelectionChange.emit(this.selection); }); } - ngAfterViewInit() {} - - /** - * used to track data changes - * @param {number} index - * @param item - * @return {any} - */ - trackByFn(index: number, item: any) { - return item.name && item.name.term ? item.name.term : item; - } - /** * emit sort change events * @param sort @@ -412,7 +404,7 @@ export class NcatsDatatableComponent return ret; } - isArray(data: any) { + isArray(data: unknown) { return Array.isArray(data); } @@ -469,16 +461,12 @@ export class NcatsDatatableComponent * todo: the comtainer and object should be optional fields * todo: table injected components need to implement an interface to get the substance or container * @param field - * @param row - * @param index */ getCustomComponent( - field: DataProperty, - row: MatRow, - index: number, - ): ComponentPortal | null { + field: DataProperty + ): ComponentPortal | null { if (this.rowOutlet && field.customComponent) { - const comp = this._injector.get>(field.customComponent); + const comp = this._injector.get>(field.customComponent); return new ComponentPortal(comp); } else { return null; @@ -493,29 +481,35 @@ export class NcatsDatatableComponent * @param index * @param field */ - componentAttached(component: any, index: number, field: DataProperty) { - if (component.instance.data === null && this.data[index][field.field]) { - component.instance.data = this.data[index][field.field]; - } - - if (component.instance.object) { - component.instance.object = this.data[index]; - } - if (component.instance.container) { - component.instance.container = this.rowOutlet.toArray()[index]; - } - if (component.instance.parent) { - component.instance.parent = this.data[index]; - } - if (component.instance.clickEvent) { - component.instance.clickEvent.subscribe((res: any) => { - this.cellClicked(res); - }); - } + componentAttached(component: CdkPortalOutletAttachedRef, index: number, field: DataProperty) { + if(component ) { + console.log(this._injector) + const compRef: ComponentRef> = component as ComponentRef>; + if (compRef.instance['data'] === null && this.data[index][field.field]) { + const dataField: string = field.field; + const dataPoint: {[p: string]: DataProperty} = this.data[index]; + compRef.instance['data'] = dataPoint[dataField]; + } - if (component.instance.ref) { - // todo this is still problematic because injected components are redrawn. - this.ref.detach(); + if (compRef.instance['object']) { + compRef.instance['object'] = this.data[index]; + } + if (compRef.instance['container']) { + compRef.instance['container'] = this.rowOutlet.toArray()[index]; + } + if (compRef.instance['parent']) { + compRef.instance['parent'] = this.data[index]; + } + if (compRef.instance['clickEvent']) { + const clickRef: Observable = compRef.instance['clickEvent'] as Observable; + clickRef.subscribe((res: MatRow) => { + this.cellClicked(res); + }); + } + if (compRef.instance['ref']) { + // todo this is still problematic because injected components are redrawn. + this.ref.detach(); + } } } @@ -549,12 +543,4 @@ export class NcatsDatatableComponent : this.dataSource.data.forEach((row) => this.selection.select(row)); this.ref.detectChanges(); } - - /** - * clean up on leaving component - */ - ngOnDestroy() { - this.ngUnsubscribe.next(null); - this.ngUnsubscribe.complete(); - } } diff --git a/libs/shared/ui/ncats-structure-viewer/src/lib/structure-viewer/structure-viewer.component.ts b/libs/shared/ui/ncats-structure-viewer/src/lib/structure-viewer/structure-viewer.component.ts index 54d3581..a916c09 100644 --- a/libs/shared/ui/ncats-structure-viewer/src/lib/structure-viewer/structure-viewer.component.ts +++ b/libs/shared/ui/ncats-structure-viewer/src/lib/structure-viewer/structure-viewer.component.ts @@ -8,11 +8,10 @@ import { } from "@angular/core"; import { DataProperty } from '@ramp/shared/ui/ncats-datatable'; import { BehaviorSubject } from 'rxjs'; -import { takeWhile } from 'rxjs/operators'; import { NgClass } from '@angular/common'; -export const STRUCTURE_VIEWER_COMPONENT = new InjectionToken( +export const STRUCTURE_VIEWER_COMPONENT = new InjectionToken( 'StructureViewerComponent' ); diff --git a/libs/shared/ui/object-tree/.eslintrc.json b/libs/shared/ui/object-tree/.eslintrc.json deleted file mode 100644 index e239bfb..0000000 --- a/libs/shared/ui/object-tree/.eslintrc.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "extends": ["../../../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts"], - "extends": [ - "plugin:@nx/angular", - "plugin:@angular-eslint/template/process-inline-templates" - ], - "rules": { - "@angular-eslint/directive-selector": [ - "error", - { - "type": "attribute", - "prefix": "ncats", - "style": "camelCase" - } - ], - "@angular-eslint/component-selector": [ - "error", - { - "type": "element", - "prefix": "ncats", - "style": "kebab-case" - } - ] - } - }, - { - "files": ["*.html"], - "extends": ["plugin:@nx/angular-template"], - "rules": {} - } - ] -} diff --git a/libs/shared/ui/object-tree/README.md b/libs/shared/ui/object-tree/README.md deleted file mode 100644 index d397ac7..0000000 --- a/libs/shared/ui/object-tree/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# shared-ui-object-tree - -This library was generated with [Nx](https://nx.dev). - -## Running unit tests - -Run `nx test shared-ui-object-tree` to execute the unit tests. diff --git a/libs/shared/ui/object-tree/jest.config.ts b/libs/shared/ui/object-tree/jest.config.ts deleted file mode 100644 index 6c1b367..0000000 --- a/libs/shared/ui/object-tree/jest.config.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'shared-ui-object-tree', - preset: '../../../../jest.preset.js', - setupFilesAfterEnv: ['/src/test-setup.ts'], - globals: {}, - coverageDirectory: '../../../../coverage/libs/shared/ui/object-tree', - transform: { - '^.+\\.(ts|mjs|js|html)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - }, - ], - }, - transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], - snapshotSerializers: [ - 'jest-preset-angular/build/serializers/no-ng-attributes', - 'jest-preset-angular/build/serializers/ng-snapshot', - 'jest-preset-angular/build/serializers/html-comment', - ], -}; diff --git a/libs/shared/ui/object-tree/project.json b/libs/shared/ui/object-tree/project.json deleted file mode 100644 index bcd5ae1..0000000 --- a/libs/shared/ui/object-tree/project.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "shared-ui-object-tree", - "$schema": "../../../../node_modules/nx/schemas/project-schema.json", - "projectType": "library", - "sourceRoot": "libs/shared/ui/object-tree/src", - "prefix": "ramp", - "targets": { - "test": { - "executor": "@nx/jest:jest", - "outputs": ["{workspaceRoot}/coverage/libs/shared/ui/object-tree"], - "options": { - "jestConfig": "libs/shared/ui/object-tree/jest.config.ts", - "passWithNoTests": true - } - }, - "lint": { - "executor": "@nx/eslint:lint", - "options": { - "lintFilePatterns": [ - "libs/shared/ui/object-tree/src/**/*.ts", - "libs/shared/ui/object-tree/src/**/*.html" - ] - } - } - }, - "tags": [] -} diff --git a/libs/shared/ui/object-tree/src/index.ts b/libs/shared/ui/object-tree/src/index.ts deleted file mode 100644 index a95d151..0000000 --- a/libs/shared/ui/object-tree/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './lib/object-tree/object-tree.component'; diff --git a/libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.html b/libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.html deleted file mode 100644 index 4ae9253..0000000 --- a/libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - {{ node.label || node.value }} - - - -
- - {{ node.label || node.value }} -
- -
- -
-
-
- - - - diff --git a/libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.scss b/libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.scss deleted file mode 100644 index 581a223..0000000 --- a/libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.scss +++ /dev/null @@ -1,43 +0,0 @@ -/* -.invisible { - display: none; -} - -.object-tree ul, -.object-tree li { - margin-top: 0; - margin-bottom: 0; - list-style-type: none; -} - -.loading-bar { - max-width: 25vw; -} -*/ - -.object-tree-invisible { - display: none; -} - -.object-tree ul, -.object-tree li { - margin-top: 0; - margin-bottom: 0; - list-style-type: none; -} - -/* - * This padding sets alignment of the nested nodes. - */ -.object-tree .mat-nested-tree-node div[role='group'] { - padding-left: 40px; -} - -/* - * Padding for leaf nodes. - * Leaf nodes need to have padding so as to align with other non-leaf nodes - * under the same parent. - */ -.object-tree div[role='group'] > .mat-tree-node { - padding-left: 40px; -} diff --git a/libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.spec.ts b/libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.spec.ts deleted file mode 100644 index f27eea6..0000000 --- a/libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.spec.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MatButtonModule } from '@angular/material/button'; -import { MatCheckboxModule } from '@angular/material/checkbox'; -import { MatIconModule } from '@angular/material/icon'; -import { MatTreeModule } from '@angular/material/tree'; - -import { ObjectTreeComponent } from './object-tree.component'; - -describe('ObjectTreeComponent', () => { - let component: ObjectTreeComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ObjectTreeComponent], - imports: [ - MatTreeModule, - MatCheckboxModule, - MatIconModule, - MatButtonModule, - ], - }).compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(ObjectTreeComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.ts b/libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.ts deleted file mode 100644 index 0c0af0a..0000000 --- a/libs/shared/ui/object-tree/src/lib/object-tree/object-tree.component.ts +++ /dev/null @@ -1,201 +0,0 @@ -import { SelectionModel } from '@angular/cdk/collections'; -import { NestedTreeControl } from '@angular/cdk/tree'; -import { - ChangeDetectionStrategy, - ChangeDetectorRef, - Component, - EventEmitter, - Input, - OnInit, - Output, - ViewChild, -} from '@angular/core'; -import { - MatTree, - MatTreeNestedDataSource, - MatTreeModule, -} from '@angular/material/tree'; -import { BehaviorSubject } from 'rxjs'; -import { MatIconModule } from '@angular/material/icon'; -import { MatButtonModule } from '@angular/material/button'; - -/** Flat tree item node with expandable and level information */ -export class FlatNode { - value!: string; - children!: any[]; - level!: number; - expandable!: boolean; -} - -export class NestedNode { - value!: string; - children!: any[]; -} - -@Component({ - selector: 'ncats-object-tree', - templateUrl: './object-tree.component.html', - styleUrls: ['./object-tree.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, - standalone: true, - imports: [MatTreeModule, MatButtonModule, MatIconModule], -}) -export class ObjectTreeComponent implements OnInit { - @ViewChild(MatTree) objectTree!: MatTree; - - @Output() fieldSelectChange: EventEmitter = new EventEmitter(); - @Output() nodeExpandChange: EventEmitter = new EventEmitter(); - - @Input() selectable = false; - @Input() showLinks = false; - @Input() dynamic = false; - - @Input() expanded = true; - - @Input() loading = false; - - /** - * initialize a private variable _data, it's a BehaviorSubject - * @type {BehaviorSubject} - * @private - */ - protected _data = new BehaviorSubject(null); - - /** - * pushes changed data to {BehaviorSubject} - * @param value - */ - @Input() - set data(value: any) { - // This is a hacky way to strip out extra values from a DataProperty object, if this is dynamically added to a table - if (value && value.value) { - this._data.next(value.value); - } else { - this._data.next(value); - } - } - - /** - * returns value of {BehaviorSubject} - * @returns {any} - */ - get data() { - return this._data.getValue(); - } - - /** The selection for checklist */ - checklistSelection = new SelectionModel(true); - - treeControl = new NestedTreeControl((node) => node.children); - dataSource = new MatTreeNestedDataSource(); - - constructor(private changeRef: ChangeDetectorRef) {} - ngOnInit() { - this._data.subscribe((res) => { - if (res && res.length) { - this.dataSource.data = res; - this.treeControl.dataNodes = res; - if (this.expanded) { - this.treeControl.expandAll(); - } - this.changeRef.markForCheck(); - } - }); - } - - hasChild = (_: number, node: NestedNode) => - !!node.children && node.children.length > 0; - - /* - /!** Whether all the descendants of the node are selected. *!/ - descendantsAllSelected(node: FlatNode): boolean { - const descendants = this.treeControl.getDescendants(node); - return descendants.every(child => - this.checklistSelection.isSelected(child) - ); - } - - /!** Whether part of the descendants are selected *!/ - descendantsPartiallySelected(node: FlatNode): boolean { - const descendants = this.treeControl.getDescendants(node); - const result = descendants.some(child => this.checklistSelection.isSelected(child)); - return result && !this.descendantsAllSelected(node); - } -*/ - - /* /!** Toggle the to-do item selection. Select/deselect all the descendants node *!/ - todoItemSelectionToggle(node: FlatNode): void { - this.checklistSelection.toggle(node); - const descendants = this.treeControl.getDescendants(node); - this.checklistSelection.isSelected(node) - ? this.checklistSelection.select(...descendants) - : this.checklistSelection.deselect(...descendants); - -// Force update for the parent - descendants.every(child => - this.checklistSelection.isSelected(child) - ); - this.checkAllParentsSelection(node); - } - - /!** Toggle a leaf to-do item selection. Check all the parents to see if they changed *!/ - todoLeafItemSelectionToggle(node: FlatNode): void { - this.checklistSelection.toggle(node); - this.checkAllParentsSelection(node); - } - - /!* Checks all the parents when a leaf node is selected/unselected *!/ - checkAllParentsSelection(node: FlatNode): void { - let parent: FlatNode | null = this.getParentNode(node); - while (parent) { - this.checkRootNodeSelection(parent); - parent = this.getParentNode(parent); - } - } - - /!** Check root node checked state and change it accordingly *!/ - checkRootNodeSelection(node: FlatNode): void { - const nodeSelected = this.checklistSelection.isSelected(node); - const descendants = this.treeControl.getDescendants(node); - const descAllSelected = descendants.every(child => - this.checklistSelection.isSelected(child) - ); - if (nodeSelected && !descAllSelected) { - this.checklistSelection.deselect(node); - } else if (!nodeSelected && descAllSelected) { - this.checklistSelection.select(node); - } - } - - /!* Get the parent node of a node *!/ - getParentNode(node: FlatNode): FlatNode | null { - const currentLevel = node.level; - - if (currentLevel < 1) { - return null; - } - - const startIndex = this.treeControl.dataNodes.indexOf(node) - 1; - - for (let i = startIndex; i >= 0; i--) { - const currentNode = this.treeControl.dataNodes[i]; - - if (currentNode.level < currentLevel) { - return currentNode; - } - } - return null; - }*/ - - fetchData(node: any) { - if (this.dynamic && !node.children) { - this.nodeExpandChange.emit(node); - } - } - - fetchLeafData(node: any) { - if (this.dynamic && !node.children) { - this.nodeExpandChange.emit(node); - } - } -} diff --git a/libs/shared/ui/object-tree/src/test-setup.ts b/libs/shared/ui/object-tree/src/test-setup.ts deleted file mode 100644 index 1100b3e..0000000 --- a/libs/shared/ui/object-tree/src/test-setup.ts +++ /dev/null @@ -1 +0,0 @@ -import 'jest-preset-angular/setup-jest'; diff --git a/libs/shared/ui/object-tree/tsconfig.json b/libs/shared/ui/object-tree/tsconfig.json deleted file mode 100644 index 2ee92e8..0000000 --- a/libs/shared/ui/object-tree/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "extends": "../../../../tsconfig.base.json", - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json", - }, - { - "path": "./tsconfig.spec.json", - }, - ], - "compilerOptions": { - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "target": "es2020", - }, - "angularCompilerOptions": { - "strictInjectionParameters": true, - "strictInputAccessModifiers": true, - "strictTemplates": true, - }, -} diff --git a/libs/shared/ui/object-tree/tsconfig.lib.json b/libs/shared/ui/object-tree/tsconfig.lib.json deleted file mode 100644 index 601d409..0000000 --- a/libs/shared/ui/object-tree/tsconfig.lib.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../../../dist/out-tsc", - "declaration": true, - "declarationMap": true, - "inlineSources": true, - "types": [] - }, - "exclude": [ - "src/test-setup.ts", - "**/*.spec.ts", - "**/*.test.ts", - "jest.config.ts" - ], - "include": ["**/*.ts"] -} diff --git a/libs/shared/ui/object-tree/tsconfig.spec.json b/libs/shared/ui/object-tree/tsconfig.spec.json deleted file mode 100644 index 27fd771..0000000 --- a/libs/shared/ui/object-tree/tsconfig.spec.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"], - "target": "es2016" - }, - "files": ["src/test-setup.ts"], - "include": ["**/*.test.ts", "**/*.spec.ts", "**/*.d.ts", "jest.config.ts"] -} diff --git a/libs/shared/visualizations/upset-chart/src/lib/upset-data.ts b/libs/shared/visualizations/upset-chart/src/lib/upset-data.ts index ca546a3..e74ba54 100644 --- a/libs/shared/visualizations/upset-chart/src/lib/upset-data.ts +++ b/libs/shared/visualizations/upset-chart/src/lib/upset-data.ts @@ -1,18 +1,12 @@ export class UpsetData { id: string; sets: string[]; - size: number; + size: number = 0; combinations: { setId: string; member: boolean }[]; connectorIndices: [number, number] | [undefined, undefined]; - constructor(data: { - id: string | number; - sets: string[]; - size: number; - combinations?: { setId: string; member: boolean }[]; - connectorIndices?: [number, number] | [undefined, undefined]; - }) { - this.id = data.id.toString(); + constructor(data: Partial) { + this.id = data.id; this.sets = data.sets || []; this.size = data.size || 0; this.combinations = data.combinations || []; diff --git a/libs/shared/visualizations/upset-chart/src/lib/upset/upset.component.ts b/libs/shared/visualizations/upset-chart/src/lib/upset/upset.component.ts index b759609..dbb5040 100644 --- a/libs/shared/visualizations/upset-chart/src/lib/upset/upset.component.ts +++ b/libs/shared/visualizations/upset-chart/src/lib/upset/upset.component.ts @@ -1,18 +1,19 @@ import { - Component, + Component, DestroyRef, ElementRef, EventEmitter, - HostListener, + HostListener, inject, Inject, Input, OnInit, Output, PLATFORM_ID, ViewChild, - ViewEncapsulation, -} from '@angular/core'; -import { map, takeUntil } from 'rxjs/operators'; -import { BehaviorSubject, Subject } from 'rxjs'; + ViewEncapsulation +} from "@angular/core"; +import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; +import { map } from 'rxjs/operators'; +import { BehaviorSubject } from 'rxjs'; import { isPlatformBrowser } from '@angular/common'; import { select } from 'd3-selection'; import { axisLeft, AxisScale } from 'd3-axis'; @@ -39,31 +40,27 @@ export class UpsetComponent implements OnInit { @Output() upSetBarClicked = new EventEmitter(); @Input() title!: string; @ViewChild('upsetPlotBox', { static: true }) upsetPlotElement!: ElementRef; + destroyRef = inject(DestroyRef); - svg: any; + svg: unknown; width = 300; height = 300; margin = { top: 5, bottom: 5, left: 5, right: 5 }; allSetIds: string[] = []; - /** - * Behaviour subject to allow extending class to unsubscribe on destroy - * @type {Subject} - */ - protected ngUnsubscribe: Subject = new Subject(); /** * initialize a private variable _data, it's a BehaviorSubject - * @type {BehaviorSubject} + * @type {BehaviorSubject} * @private */ - protected _data = new BehaviorSubject(null); + protected _data = new BehaviorSubject([]); /** * pushes changed data to {BehaviorSubject} * @param value */ @Input() - set data(value: any[]) { + set data(value: Partial[]) { this._data.next(value.map((val) => new UpsetData(val))); } @@ -75,6 +72,12 @@ export class UpsetComponent implements OnInit { return this._data.getValue(); } + isBrowser =true; + + intersectionSizeScale!: + | AxisScale + | (number[] & ScaleLinear); + /** * function to redraw/scale the graph on window resize */ @@ -83,14 +86,16 @@ export class UpsetComponent implements OnInit { this.redrawChart(); } - constructor(@Inject(PLATFORM_ID) private platformID: any) {} + constructor(@Inject(PLATFORM_ID) platformId: object) { + this.isBrowser = isPlatformBrowser(platformId); + } ngOnInit(): void { this._data // listen to data as long as term is undefined or null // Unsubscribe once term has value .pipe( - takeUntil(this.ngUnsubscribe), + takeUntilDestroyed(this.destroyRef), map((data: UpsetData[]) => { data.forEach((d) => this.allSetIds.push(...d.sets)); this.allSetIds = [...new Set(this.allSetIds)]; @@ -117,7 +122,7 @@ export class UpsetComponent implements OnInit { }), ) .subscribe((data) => { - if (isPlatformBrowser(this.platformID)) { + if (this.isBrowser) { if (data.length > 0) { this.drawContainer(); } @@ -159,27 +164,24 @@ export class UpsetComponent implements OnInit { .range([0, bottomRowHeight]) .paddingInner(0.2); - let intersectionSizeScale: - | AxisScale - | (number[] & ScaleLinear); if (this.scale === 'log') { - intersectionSizeScale = scaleLog() + this.intersectionSizeScale = scaleLog() .domain([1, this._getMax()]) .range([topRowHeight, 0]); - axisLeft(intersectionSizeScale) - .scale(intersectionSizeScale) + axisLeft(this.intersectionSizeScale) + .scale(this.intersectionSizeScale) .tickFormat((d, i) => { return (i % 5 === 0 && format(',d')(Number(d))) || ''; }) .tickSize(5); } else { - intersectionSizeScale = scaleLinear() + this.intersectionSizeScale = scaleLinear() .domain([1, this._getMax()]) .range([topRowHeight, 0]); - axisLeft(intersectionSizeScale).tickSize(5); + axisLeft(this.intersectionSizeScale).tickSize(5); } // Prepare the overall layout @@ -218,9 +220,13 @@ export class UpsetComponent implements OnInit { .attr('class', 'combination') .attr( 'transform', - // @ts-ignore - //todo: fix the ts-ignore - (d) => `translate(${xScale(d.id) + xScale.bandwidth() / 2}, 0)`, + (d: UpsetData) => { + let ret = xScale(d.id); + if (!ret) { + ret = 0 + } + return`translate(${ret + xScale.bandwidth() / 2}, 0)` + } ); // Select all circles within each group and bind the inner array per data item @@ -232,33 +238,45 @@ export class UpsetComponent implements OnInit { .attr( 'cy', - // @ts-ignore - //todo: fix the ts-ignore - (d) => yCombinationScale(d.setId) + yCombinationScale.bandwidth() / 2, + (d) => { + const ret = yCombinationScale(d.setId); + if(ret) { + return ret + yCombinationScale.bandwidth() / 2 + } else { + return yCombinationScale.bandwidth() / 2 + } + }, ) .attr('r', () => yCombinationScale.bandwidth() / 4); // Connect the sets with a vertical line - const connector = combinationGroup + // const connector = + combinationGroup .filter((d) => d.connectorIndices.length > 0) .append('svg:line') .style('fill', '#265668') .attr('class', 'connector') .attr( 'y1', - (d) => - // @ts-ignore - //todo: fix the ts-ignore - yCombinationScale(this.allSetIds[d.connectorIndices[0]]) + - yCombinationScale.bandwidth() / 2, + (d) => { + if(d.connectorIndices && d.connectorIndices[0]) { + return yCombinationScale(this.allSetIds[d.connectorIndices[0]]) + + yCombinationScale.bandwidth() / 2 + } else { + return 0 + } + } ) - .attr( + .attr( 'y2', - (d) => - // @ts-ignore - //todo: fix the ts-ignore - yCombinationScale(this.allSetIds[d.connectorIndices[1]]) + - yCombinationScale.bandwidth() / 2, + (d) => { + if(d.connectorIndices && d.connectorIndices[1]) { + return yCombinationScale(this.allSetIds[d.connectorIndices[1]]) + + yCombinationScale.bandwidth() / 2 + } else { + return 0 + } + } ); /* @@ -278,22 +296,14 @@ export class UpsetComponent implements OnInit { .attr('x', leftColWidth - this.margin.left) .attr( 'y', - // @ts-ignore - //todo: fix the ts-ignore - (d) => yCombinationScale(d) + yCombinationScale.bandwidth() / 2, + (d: string) => yCombinationScale(d) + yCombinationScale.bandwidth() / 2, ) .attr('dy', '0.35em') .text((d) => d); - /* - * Intersection size chart - */ - - // const intersectionSizeAxis = d3.axisLeft(intersectionSizeScale).ticks(3); - //todo: this ignores the previous Yaxis assignment - const intersectionSizeAxis = axisLeft(intersectionSizeScale) - .scale(intersectionSizeScale) + const intersectionSizeAxis = axisLeft(this.intersectionSizeScale) + .scale(this.intersectionSizeScale) .tickFormat((d, i) => { return (i % 5 === 0 && format(',d')(Number(d))) || ''; }) @@ -321,16 +331,22 @@ export class UpsetComponent implements OnInit { .join('rect') .attr('class', 'bar') .style('fill', '#265668') - // @ts-ignore - //todo: fix the ts-ignore - .attr('height', (d) => topRowHeight - intersectionSizeScale(d.size)) + .attr('height', (d) => { + let ret = this.intersectionSizeScale(d.size); + if (!ret) { + ret = 0 + } + return topRowHeight - ret; + }) .attr('width', xScale.bandwidth()) - // @ts-ignore - //todo: fix the ts-ignore - .attr('x', (d) => xScale(d.id)) - // @ts-ignore - //todo: fix the ts-ignore - .attr('y', (d) => intersectionSizeScale(d.size)) + .attr('x', (d: UpsetData) => xScale(d.id)) + .attr('y', (d) => { + let ret = this.intersectionSizeScale(d.size); + if (!ret) { + ret = 0 + } + return ret; + }) .on('mouseover', () => { // d3.select("#tooltip").style("opacity", 1).html(d.values.join("
")); }) @@ -351,19 +367,20 @@ export class UpsetComponent implements OnInit { .enter() .append('text') .attr('font-size', '.6em') - // @ts-ignore - //todo: fix the ts-ignore - .attr('x', (d) => xScale(d.id)) - // @ts-ignore - //todo: fix the ts-ignore - .attr('y', (d) => - d.size > 0 - ? // @ts-ignore - //todo: fix the ts-ignore - intersectionSizeScale(d.size) + this.margin.top - : // @ts-ignore - //todo: fix the ts-ignore - intersectionSizeScale(1) + this.margin.top, + .attr('x', (d: UpsetData) => xScale(d.id)) + .attr('y', (d: UpsetData) => { + let scale: number = this.margin.top; + let ret; + if(d.size > 0) { + ret = this.intersectionSizeScale(d.size) + } else { + ret = this.intersectionSizeScale(1) + } + if(ret) { + scale = scale+ ret; + } + return scale; + } ) .text((d: { size: number }) => format(',d')(Number(d.size))); } diff --git a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.actions.ts b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.actions.ts index 604c57f..573cb3b 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.actions.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.actions.ts @@ -1,7 +1,6 @@ import { createActionGroup, emptyProps, props } from '@ngrx/store'; import { Analyte, - ChemicalEnrichment, Classes, FisherResult, FishersDataframe, @@ -14,36 +13,21 @@ import { RampQuery, RampResponse, Reaction, - SourceVersion, -} from '@ramp/models/ramp-models'; -import { RampEntity } from './ramp.models'; + SourceVersion, Stats +} from "@ramp/models/ramp-models"; export const LoadRampActions = createActionGroup({ source: 'Load Ramp', events: { loadRamp: emptyProps(), - loadRampSuccess: props<{ - data: [{ analyteType: string; idTypes: string[] }]; - }>(), - loadRampFailure: props<{ error: any }>(), + loadRampSuccess: props<{ supportedIds: { analyteType: string; idTypes: string[] }[];}>(), + loadRampFailure: props<{ error: string }>(), loadRampStats: emptyProps(), - loadRampStatsSuccess: props<{ data: any }>(), - loadRampStatsFailure: props<{ error: any }>(), + loadRampStatsSuccess: props<{ data: Stats }>(), + loadRampStatsFailure: props<{ error: string }>(), loadSourceVersions: emptyProps(), - loadSourceVersionsSuccess: props<{ versions: SourceVersion[] }>(), - loadSourceVersionsFailure: props<{ error: any }>(), - }, -}); - -export const RampAboutActions = createActionGroup({ - source: 'Ramp About Page', - events: { - loadEntityCounts: emptyProps(), - loadEntityCountsSuccess: props<{ rampStore: RampEntity[] }>(), - loadEntityCountsFailure: props<{ error: any }>(), - loadAnalyteIntersects: emptyProps(), - loadAnalyteIntersectsSuccess: props<{ rampStore: RampEntity[] }>(), - loadAnalyteIntersectsFailure: props<{ error: any }>(), + loadSourceVersionsSuccess: props<{ versions: SourceVersion[]}>(), + loadSourceVersionsFailure: props<{ error: string }>(), }, }); @@ -54,9 +38,9 @@ export const PathwayFromAnalyteActions = createActionGroup({ fetchPathwaysFromAnalytesSuccess: props<{ data: Pathway[]; query: RampQuery; - dataframe?: FishersDataframe; + dataframe?: unknown[]; }>(), - fetchPathwaysFromAnalytesFailure: props<{ error: any }>(), + fetchPathwaysFromAnalytesFailure: props<{ error: string }>(), }, }); @@ -67,9 +51,9 @@ export const AnalyteFromPathwayActions = createActionGroup({ fetchAnalytesFromPathwaysSuccess: props<{ data: Analyte[]; query: RampQuery; - dataframe?: FishersDataframe; + dataframe?: unknown[]; }>(), - fetchAnalytesFromPathwaysFailure: props<{ error: any }>(), + fetchAnalytesFromPathwaysFailure: props<{ error: string }>(), }, }); @@ -80,9 +64,9 @@ export const OntologyFromMetaboliteActions = createActionGroup({ fetchOntologiesFromMetabolitesSuccess: props<{ data: Ontology[]; query: RampQuery; - dataframe?: FishersDataframe; + dataframe?: unknown[]; }>(), - fetchOntologiesFromMetabolitesFailure: props<{ error: any }>(), + fetchOntologiesFromMetabolitesFailure: props<{ error: string }>(), }, }); @@ -93,7 +77,7 @@ export const MetaboliteFromOntologyActions = createActionGroup({ fetchOntologiesSuccess: props<{ data: OntologyList[]; }>(), - fetchOntologiesFailure: props<{ error: any }>(), + fetchOntologiesFailure: props<{ error: string }>(), fetchMetabolitesFromOntologies: props<{ ontologies: string[] }>(), fetchMetabolitesFromOntologiesFile: props<{ ontologies: string[]; @@ -102,9 +86,9 @@ export const MetaboliteFromOntologyActions = createActionGroup({ fetchMetabolitesFromOntologiesSuccess: props<{ data: Metabolite[]; query: RampQuery; - dataframe?: FishersDataframe; + dataframe?: unknown[]; }>(), - fetchMetaboliteFromOntologiesFailure: props<{ error: any }>(), + fetchMetaboliteFromOntologiesFailure: props<{ error: string }>(), }, }); @@ -119,9 +103,9 @@ export const ClassesFromMetabolitesActions = createActionGroup({ fetchClassesFromMetabolitesSuccess: props<{ data: Classes[]; query: RampQuery; - dataframe?: FishersDataframe; + dataframe?: unknown[]; }>(), - fetchClassesFromMetabolitesFailure: props<{ error: any }>(), + fetchClassesFromMetabolitesFailure: props<{ error: string }>(), }, }); @@ -130,7 +114,7 @@ export const PropertiesFromMetaboliteActions = createActionGroup({ events: { fetchPropertiesFromMetabolites: props<{ metabolites: string[] }>(), fetchPropertiesFromMetabolitesSuccess: props>(), - fetchPropertiesFromMetabolitesFailure: props<{ error: any }>(), + fetchPropertiesFromMetabolitesFailure: props<{ error: string }>(), }, }); @@ -141,9 +125,9 @@ export const CommonReactionAnalyteActions = createActionGroup({ fetchCommonReactionAnalytesSuccess: props<{ data: Reaction[]; query: RampQuery; - dataframe?: FishersDataframe; + dataframe?: unknown[]; }>(), - fetchCommonReactionAnalytesFailure: props<{ error: any }>(), + fetchCommonReactionAnalytesFailure: props<{ error: string }>(), }, }); @@ -154,9 +138,9 @@ export const PathwayEnrichmentsActions = createActionGroup({ fetchPathwaysFromAnalytesSuccess: props<{ data: Pathway[]; query: RampQuery; - dataframe?: FishersDataframe; + dataframe?: unknown[]; }>(), - fetchPathwaysFromAnalytesFailure: props<{ error: any }>(), + fetchPathwaysFromAnalytesFailure: props<{ error: string }>(), fetchEnrichmentFromPathways: props<{ analytes: string[]; biospecimen?: string; @@ -169,7 +153,7 @@ export const PathwayEnrichmentsActions = createActionGroup({ pval_type?: string; pval_cutoff?: number; }>(), - fetchEnrichmentFromPathwaysFailure: props<{ error: any }>(), + fetchEnrichmentFromPathwaysFailure: props<{ error: string }>(), filterEnrichmentFromPathways: props<{ pval_type: string; pval_cutoff: number; @@ -185,7 +169,7 @@ export const PathwayEnrichmentsActions = createActionGroup({ min_pathway_tocluster?: number; perc_pathway_overlap?: number; }>(), - filterEnrichmentFromPathwaysFailure: props<{ error: any }>(), + filterEnrichmentFromPathwaysFailure: props<{ error: string }>(), fetchClusterFromEnrichment: props<{ perc_analyte_overlap: number; min_pathway_tocluster: number; @@ -193,12 +177,12 @@ export const PathwayEnrichmentsActions = createActionGroup({ }>(), fetchClusterFromEnrichmentSuccess: props<{ data: FisherResult[]; - plot: any; + plot: string; query: RampQuery; dataframe?: FishersDataframe; openModal?: boolean; }>(), - fetchClusterFromEnrichmentFailure: props<{ error: any }>(), + fetchClusterFromEnrichmentFailure: props<{ error: string }>(), fetchClusterImageFile: props<{ perc_analyte_overlap: number; min_pathway_tocluster: number; @@ -218,9 +202,9 @@ export const MetaboliteEnrichmentsActions = createActionGroup({ fetchClassesFromMetabolitesSuccess: props<{ data: Classes[]; query: RampQuery; - dataframe?: FishersDataframe; + dataframe?: unknown[]; }>(), - fetchClassesFromMetabolitesFailure: props<{ error: any }>(), + fetchClassesFromMetabolitesFailure: props<{ error: string }>(), fetchEnrichmentFromMetabolites: props<{ metabolites: string[]; biospecimen?: string; @@ -232,7 +216,7 @@ export const MetaboliteEnrichmentsActions = createActionGroup({ pval_type?: string; pval_cutoff?: number; }>(), - fetchEnrichmentFromMetabolitesFailure: props<{ error: any }>(), + fetchEnrichmentFromMetabolitesFailure: props<{ error: string }>(), filterEnrichmentFromMetabolites: props<{ pval_type: string; pval_cutoff: number; @@ -240,6 +224,6 @@ export const MetaboliteEnrichmentsActions = createActionGroup({ filterEnrichmentFromMetabolitesSuccess: props<{ data: RampChemicalEnrichmentResponse; }>(), - filterEnrichmentFromMetabolitesFailure: props<{ error: any }>(), + filterEnrichmentFromMetabolitesFailure: props<{ error: string }>(), }, }); diff --git a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.spec.ts b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.spec.ts index 230579e..bd5b54e 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.spec.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.spec.ts @@ -5,13 +5,12 @@ import { Action } from '@ngrx/store'; import { provideMockStore } from '@ngrx/store/testing'; import { hot } from 'jasmine-marbles'; import { Observable } from 'rxjs'; +import { LoadRampActions } from "./ramp.actions"; -import * as RampActions from './ramp.actions'; -import { RampEffects } from './ramp.effects'; +import * as RampEffects from './ramp.effects'; describe('RampEffects', () => { let actions: Observable; - let effects: RampEffects; beforeEach(() => { TestBed.configureTestingModule({ @@ -23,14 +22,14 @@ describe('RampEffects', () => { ], }); - effects = TestBed.inject(RampEffects); + //effects = TestBed.inject(RampEffects); }); describe('initAbout$', () => { it('should work', () => { - actions = hot('-a-|', { a: RampActions.initAbout() }); + actions = hot('-a-|', { a: LoadRampActions.loadRamp() }); - const expected: any[] = []; + const expected: string[] = []; expect(expected).toStrictEqual([]); }); diff --git a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.ts b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.ts index 6c3629e..57377ae 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.effects.ts @@ -4,13 +4,11 @@ import { Store } from '@ngrx/store'; import { Analyte, Classes, - FishersDataframe, Metabolite, Ontology, OntologyList, Pathway, Properties, - RampAPIResponse, RampChemicalEnrichmentResponse, RampPathwayEnrichmentResponse, RampResponse, @@ -44,14 +42,14 @@ export const init$ = createEffect( (actions$ = inject(Actions), rampService = inject(RampService)) => { return actions$.pipe( ofType(LoadRampActions.loadRamp), - exhaustMap((action) => { + exhaustMap(() => { return rampService.fetchSupportedIds().pipe( map( - (ret: [{ analyteType: string; idTypes: string[] }]) => { - return LoadRampActions.loadRampSuccess({ data: ret }); + (ret: { analyteType: string; idTypes: string[] }[]) => { + return LoadRampActions.loadRampSuccess({ supportedIds: ret }); }, catchError((error: ErrorEvent) => - of(LoadRampActions.loadRampFailure({ error })), + of(LoadRampActions.loadRampFailure({ error: error.message })), ), ), ); @@ -65,10 +63,10 @@ export const fetchStats = createEffect( (actions$ = inject(Actions), rampService = inject(RampService)) => { return actions$.pipe( ofType(LoadRampActions.loadRampStats), - exhaustMap((action) => { + exhaustMap(() => { return rampService.loadAboutData().pipe( map( - (ret: unknown) => { + (ret: Stats) => { const data: Stats = ret as Stats; if (data) { return LoadRampActions.loadRampStatsSuccess({ data: data }); @@ -79,7 +77,7 @@ export const fetchStats = createEffect( } }, catchError((error: ErrorEvent) => - of(LoadRampActions.loadRampStatsFailure({ error })), + of(LoadRampActions.loadRampStatsFailure({ error: error.message })), ), ), ); @@ -107,7 +105,7 @@ export const fetchPathwaysFromAnalytes = createEffect( catchError((error: ErrorEvent) => { return of( PathwayFromAnalyteActions.fetchPathwaysFromAnalytesFailure({ - error, + error: error.message }), ); }), @@ -134,7 +132,7 @@ export const fetchAnalytesFromPathways = createEffect( catchError((error: ErrorEvent) => of( AnalyteFromPathwayActions.fetchAnalytesFromPathwaysFailure({ - error, + error: error.message, }), ), ), @@ -163,7 +161,7 @@ export const fetchOntologiesFromMetabolites = createEffect( catchError((error: ErrorEvent) => of( OntologyFromMetaboliteActions.fetchOntologiesFromMetabolitesFailure( - { error }, + { error: error.message }, ), ), ), @@ -179,7 +177,7 @@ export const fetchOntologies = createEffect( (actions$ = inject(Actions), rampService = inject(RampService)) => { return actions$.pipe( ofType(MetaboliteFromOntologyActions.fetchOntologies), - exhaustMap((action) => { + exhaustMap(() => { return rampService.fetchOntologies().pipe( map( (ret: RampResponse) => { @@ -187,7 +185,7 @@ export const fetchOntologies = createEffect( }, catchError((error: ErrorEvent) => of( - MetaboliteFromOntologyActions.fetchOntologiesFailure({ error }), + MetaboliteFromOntologyActions.fetchOntologiesFailure({ error: error.message }), ), ), ), @@ -214,7 +212,7 @@ export const fetchMetabolitesFromOntologies = createEffect( catchError((error: ErrorEvent) => of( MetaboliteFromOntologyActions.fetchMetaboliteFromOntologiesFailure( - { error }, + { error: error.message }, ), ), ), @@ -264,7 +262,7 @@ export const fetchClassesFromMetabolites = createEffect( catchError((error: ErrorEvent) => of( ClassesFromMetabolitesActions.fetchClassesFromMetabolitesFailure( - { error }, + { error: error.message }, ), ), ), @@ -292,7 +290,7 @@ export const fetchPropertiesFromMetabolites = createEffect( catchError((error: ErrorEvent) => of( PropertiesFromMetaboliteActions.fetchPropertiesFromMetabolitesFailure( - { error }, + { error: error.message }, ), ), ), @@ -318,7 +316,7 @@ export const fetchCommonReactionAnalytes = createEffect( catchError((error: ErrorEvent) => of( CommonReactionAnalyteActions.fetchCommonReactionAnalytesFailure( - { error }, + { error: error.message }, ), ), ), @@ -351,7 +349,7 @@ export const fetchPathwayAnalysis = createEffect( catchError((error: ErrorEvent) => of( PathwayEnrichmentsActions.fetchEnrichmentFromPathwaysFailure({ - error, + error: error.message }), ), ), @@ -374,7 +372,7 @@ export const filterEnrichedPathways = createEffect( PathwayEnrichmentsActions.filterEnrichmentFromPathways, PathwayEnrichmentsActions.fetchEnrichmentFromPathwaysSuccess, ), - concatLatestFrom((action) => store.select(getCombinedFishersDataframe)), + concatLatestFrom(() => store.select(getCombinedFishersDataframe)), mergeMap(([action, dataframe]) => { if (dataframe) { return rampService @@ -395,7 +393,7 @@ export const filterEnrichedPathways = createEffect( catchError((error: ErrorEvent) => of( PathwayEnrichmentsActions.filterEnrichmentFromPathwaysFailure( - { error }, + { error: error.message }, ), ), ), @@ -425,7 +423,7 @@ export const fetchPathwayCluster = createEffect( PathwayEnrichmentsActions.filterEnrichmentFromPathwaysSuccess, PathwayEnrichmentsActions.fetchClusterFromEnrichment, ), - concatLatestFrom((action) => store.select(getFilteredFishersDataframe)), + concatLatestFrom(() => store.select(getFilteredFishersDataframe)), mergeMap(([action, dataframe]) => { if (dataframe) { return rampService @@ -437,20 +435,20 @@ export const fetchPathwayCluster = createEffect( ) .pipe( map( - (ret: any) => { + (ret: { data: RampPathwayEnrichmentResponse, plot: string }) => { return PathwayEnrichmentsActions.fetchClusterFromEnrichmentSuccess( { data: ret.data.data, plot: ret.plot, - query: ret.query, - dataframe: ret.data.data, + query: ret.data.query, + dataframe: ret.data.combinedFishersDataframe, }, ); }, catchError((error: ErrorEvent) => of( PathwayEnrichmentsActions.fetchClusterFromEnrichmentFailure( - { error }, + { error: error.message }, ), ), ), @@ -476,9 +474,9 @@ export const fetchClusterImageFile = createEffect( ) => { return actions$.pipe( ofType(PathwayEnrichmentsActions.fetchClusterImageFile), - concatLatestFrom((action) => store.select(getClusterPlot)), + concatLatestFrom(() => store.select(getClusterPlot)), tap(([action, plot]) => { - if (plot) { + if (plot && action) { return rampService.fetchClusterImageFile(plot); } }), @@ -500,17 +498,17 @@ export const fetchChemicalAnalysis = createEffect( ) .pipe( map( - (ret: any) => { + (ret: RampChemicalEnrichmentResponse) => { return MetaboliteEnrichmentsActions.fetchEnrichmentFromMetabolitesSuccess( { - ...ret, + data: ret }, ); }, catchError((error: ErrorEvent) => of( MetaboliteEnrichmentsActions.fetchEnrichmentFromMetabolitesFailure( - { error }, + { error: error.message }, ), ), ), @@ -533,12 +531,12 @@ export const filterEnrichedChemicalClasses = createEffect( MetaboliteEnrichmentsActions.fetchEnrichmentFromMetabolitesSuccess, MetaboliteEnrichmentsActions.filterEnrichmentFromMetabolites, ), - concatLatestFrom((action) => store.select(getChemicalEnrichment)), + concatLatestFrom(() => store.select(getChemicalEnrichment)), mergeMap(([action, dataframe]) => { if (dataframe) { return rampService .filterMetaboliteEnrichment( - dataframe, + dataframe.data as RampChemicalEnrichmentResponse, action.pval_type, action.pval_cutoff, ) @@ -552,7 +550,7 @@ export const filterEnrichedChemicalClasses = createEffect( catchError((error: ErrorEvent) => of( MetaboliteEnrichmentsActions.filterEnrichmentFromMetabolitesFailure( - { error }, + { error: error.message }, ), ), ), @@ -579,9 +577,9 @@ export const fetchEnrichmentFromMetabolitesFile = createEffect( ) => { return actions$.pipe( ofType(MetaboliteEnrichmentsActions.fetchEnrichmentFromMetabolitesFile), - concatLatestFrom((action) => store.select(getChemicalEnrichment)), + concatLatestFrom(() => store.select(getChemicalEnrichment)), tap(([action, dataframe]) => { - if (dataframe) { + if (action && dataframe) { rampService.fetchEnrichmentFromMetabolitesFile( dataframe.enriched_chemical_class_list, ); diff --git a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.reducer.ts b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.reducer.ts index e555577..262c13c 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.reducer.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.reducer.ts @@ -38,11 +38,11 @@ export interface State extends EntityState { selectedId?: string | number; // which RampStore record has been selected loading: boolean; // has the RampStore list been loaded error?: string | null; // last known error (if any) - supportedIds?: [{ analyteType: string; idTypes: string[] }]; + supportedIds?: { analyteType: string; idTypes: string[]}[]; sourceVersions?: SourceVersion[]; entityCounts?: EntityCount[]; - metaboliteIntersects?: []; - geneIntersects?: []; + metaboliteIntersects?: { id: string; sets: string[]; size: number }[]; + geneIntersects?: { id: string; sets: string[]; size: number }[]; databaseUrl?: string; ontologies?: RampResponse; analytes?: RampResponse; @@ -136,10 +136,10 @@ export const rampReducer = createReducer( })), */ - on(LoadRampActions.loadRampSuccess, (state, { data }) => ({ + on(LoadRampActions.loadRampSuccess, (state, { supportedIds }) => ({ ...state, loading: false, - supportedIds: data, + supportedIds: supportedIds, })), on(LoadRampActions.loadSourceVersionsSuccess, (state, { versions }) => ({ diff --git a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.selectors.spec.ts b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.selectors.spec.ts index 2b3ff11..f8a9011 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.selectors.spec.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.selectors.spec.ts @@ -4,7 +4,7 @@ import * as RampSelectors from './ramp.selectors'; describe('Ramp Selectors', () => { const ERROR_MSG = 'No Error Available'; - const getRampStoreId = (it: RampEntity) => 'PRODUCT-BBB'; + const getRampStoreId = () => 'PRODUCT-BBB'; const createRampEntity = (id: string, name = '') => ({ id, diff --git a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.selectors.ts b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.selectors.ts index dfaffa3..1d50d67 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.selectors.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp-store/ramp.selectors.ts @@ -33,13 +33,6 @@ export const getSelectedId = createSelector( (state: State) => state.selectedId, ); -export const getSelected = createSelector( - getRampState, - getSelectedId, - // @ts-ignore - (entities, selectedId) => (selectedId ? entities[selectedId] : undefined), -); - export const getSourceVersions = createSelector( getRampState, (state: State) => { diff --git a/libs/stores/ramp-store/src/lib/+state/ramp.service.ts b/libs/stores/ramp-store/src/lib/+state/ramp.service.ts index ff77232..9fded72 100644 --- a/libs/stores/ramp-store/src/lib/+state/ramp.service.ts +++ b/libs/stores/ramp-store/src/lib/+state/ramp.service.ts @@ -14,13 +14,13 @@ import { Properties, RampAPIResponse, RampChemicalEnrichmentAPIResponse, - RampChemicalEnrichmentResponse, + RampChemicalEnrichmentResponse, RampDataGeneric, RampPathwayEnrichmentAPIResponse, RampPathwayEnrichmentResponse, RampResponse, Reaction, - SourceVersion, -} from '@ramp/models/ramp-models'; + SourceVersion +} from "@ramp/models/ramp-models"; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { forkJoin, Observable, of } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; @@ -68,31 +68,34 @@ export class RampService { fetchEntityCounts() { return this.http - .get<{ data: EntityCount[] }>(`${this.url}entity_counts`) // ,{responseType: 'text'}) + .get<{ data: {[p: string]: string}[] }>(`${this.url}entity_counts`) // ,{responseType: 'text'}) .pipe( - map((response: { data: EntityCount[] }) => - response.data.map((obj: any) => new EntityCount(obj)), + map((response: { data: {[p: string]: string}[] }) => + response.data.map((obj: {[p: string]: string}) => new EntityCount(obj)), ), catchError(this.handleError('fetchEntityCounts', [])), ); } fetchSupportedIds(): Observable< - [{ analyteType: string; idTypes: string[] }] + { analyteType: string; idTypes: string[] }[] > { - return this.http.get<[{ analyteType: string; idTypes: string[] }]>( + return this.http.get<{data: { analyteType: string; idTypes: string[] }[]}>( `${this.url}id-types`, - ); + ) + .pipe( + map((response) => { + return response.data; + }) + ) } fetchDatabaseUrl() { return this.http .get<{ data: string }>(`${this.url}current_db_file_url`) .pipe( - map((response) => { - return response.data; - }), - catchError(this.handleError('fetchAnalyteIntersects', [])), + map((response:{data:string}) => response.data), + // catchError(this.handleError('fetchAnalyteIntersects', [])), ); } @@ -106,13 +109,11 @@ export class RampService { fetchAnalyteIntersects(param: string) { return this.http - .get<{ - data: any[]; - }>( + .get<{ data: { id: string; sets: string[]; size: number }[]; }>( `${this.url}analyte_intersects?analytetype=${param}&query_scope=global`, ) .pipe( - map((response) => response.data), + map((response: {data: { id: string; sets: string[]; size: number }[]}) => response.data), catchError(this.handleError('fetchAnalyteIntersects', [])), ); } @@ -131,12 +132,12 @@ export class RampService { .pipe( map((response: RampAPIResponse) => { return { - data: response.data.map((obj: any) => new Pathway(obj)), + data: response.data.map((obj: Pathway) => new Pathway(obj)), query: { functionCall: response.function_call[0], numFoundIds: response.numFoundIds[0], }, - dataframe: response.data as FishersDataframe, + dataframe: response.data }; }), // catchError(this.handleError('pathways from analytes', of({}))) @@ -157,12 +158,12 @@ export class RampService { .pipe( map((response: RampAPIResponse) => { return { - data: response.data.map((obj: any) => new Analyte(obj)), + data: response.data.map((obj: Partial) => new Analyte(obj)), query: { functionCall: response.function_call[0], numFoundIds: response.numFoundIds[0], }, - dataframe: response.data as FishersDataframe, + dataframe: response.data }; }), ); @@ -182,12 +183,12 @@ export class RampService { .pipe( map((response: RampAPIResponse) => { return { - data: response.data.map((obj: any) => new Ontology(obj)), + data: response.data.map((obj: unknown) => new Ontology(obj as {[key: string]: unknown})), query: { functionCall: response.function_call[0], numFoundIds: response.numFoundIds[0], }, - dataframe: response.data as FishersDataframe, + dataframe: response.data }; }), ); @@ -207,12 +208,12 @@ export class RampService { .pipe( map((response: RampAPIResponse) => { return { - data: response.data.map((obj: any) => new Metabolite(obj)), + data: response.data.map((obj: Partial) => new Metabolite(obj)), query: { functionCall: response.function_call[0], numFoundIds: response.numFoundIds[0], }, - dataframe: response.data as FishersDataframe, + dataframe: response.data }; }), ); @@ -237,18 +238,15 @@ export class RampService { ontoType.HMDBOntologyType, ); if (cl) { - cl.values.push(new Ontology(ontoType)); + cl.values.push(new Ontology(ontoType as {[key: string]: unknown})); } else { cl = new OntologyList({ ontologyType: ontoType.HMDBOntologyType, - values: [new Ontology(ontoType)], + values: [new Ontology(ontoType as {[key: string]: unknown})], }); } ontoMap.set(ontoType.HMDBOntologyType, cl); }); - const retOnts = [...ontoMap.values()].map( - (ontl) => new OntologyList(ontl), - ); return { data: [...ontoMap.values()], query: {}, @@ -292,20 +290,23 @@ export class RampService { .post>(`${this.url}chemical-classes`, formData) .pipe( map((response: RampAPIResponse) => { + const tempResponse: {[key: string]: unknown}[] = response.data as {[key: string]: unknown}[]; let metClasses: Classes[] = []; - const metabMap: Map = new Map(); + const metabMap: Map = new Map(); if (response.data && response.data.length) { - response.data.forEach((chClass: any) => { - let cl = metabMap.get(chClass.sourceId); + tempResponse.forEach((chClass: {[key: string]: unknown}) => { + let cl = metabMap.get(chClass['sourceId']); if (cl) { - cl.levels.push(chClass); + const clArr: {[key: string]: unknown}[] = cl['levels'] as Array<{[key: string]: unknown}>; + clArr.push(chClass); + cl['levels'] = clArr; } else { - cl = { sourceId: chClass.sourceId, levels: [chClass] }; + cl = { sourceId: chClass['sourceId'], levels: [chClass] }; } - metabMap.set(chClass.sourceId, cl); + metabMap.set(chClass['sourceId'], cl); }); metClasses = [...metabMap.values()].map( - (obj: any) => new Classes(obj), + (obj: { [key:string]: unknown }) => new Classes(obj ), ); } return { @@ -314,7 +315,7 @@ export class RampService { functionCall: response.function_call[0], numFoundIds: response.numFoundIds[0], }, - dataframe: response.data as FishersDataframe, + dataframe: response.data as unknown[] }; }), ); @@ -334,12 +335,12 @@ export class RampService { .pipe( map((response: RampAPIResponse) => { return { - data: response.data.map((obj: any) => new Properties(obj)), + data: response.data.map((obj: Partial) => new Properties(obj)), query: { functionCall: response.function_call[0], numFoundIds: response.numFoundIds[0], }, - dataframe: response.data as FishersDataframe, + dataframe: response.data }; }), ); @@ -358,12 +359,12 @@ export class RampService { .pipe( map((response: RampAPIResponse) => { return { - data: response.data.map((obj: any) => new Reaction(obj)), + data: response.data.map((obj: unknown) => new Reaction(obj as { [key:string]: unknown })), query: { functionCall: response.function_call[0], numFoundIds: response.numFoundIds[0], }, - dataframe: response.data as FishersDataframe, + dataframe: response.data }; }), ); @@ -386,16 +387,19 @@ export class RampService { .post( `${this.url}chemical-enrichment`, formData, - ) // ,{responseType: 'text'}) + ) .pipe( map((response: RampChemicalEnrichmentAPIResponse) => { const retList: ChemicalEnrichment[] = []; const responseClone = response.data; // delete responseClone.result_type; - [...Object.values(responseClone)].forEach((val: any) => - val.forEach((cc: { [key: string]: unknown }) => { - retList.push(new ChemicalEnrichment(cc)); - }), + [...Object.values(responseClone)].forEach((val: unknown[]) => { + if (typeof val[0] !== 'string') { + val.forEach((cc: unknown) => { + retList.push(new ChemicalEnrichment(cc as { [key: string]: unknown })); + }) + } + } ); return { data: response, @@ -412,19 +416,20 @@ export class RampService { pval_cutoff?: number, ) { return this.http - .post(`${this.url}filter-fisher-test-results`, { + .post(`${this.url}filter-fisher-test-results`, { fishers_results: dataframe.data, pval_type: pval_type, pval_cutoff: pval_cutoff, }) .pipe( - map((response: any) => { + map((response:RampChemicalEnrichmentAPIResponse) => { const retList: ChemicalEnrichment[] = []; - [...Object.values(response.data)].forEach((val: any) => - val.forEach((cc: any) => { - if (cc != 'chemical_class_enrichment') - retList.push(new ChemicalEnrichment(cc)); - }), + [...Object.values(response.data)].forEach((val: unknown[]) => { + return val.forEach((cc: unknown) => { + if (cc != 'chemical_class_enrichment') + retList.push(new ChemicalEnrichment(cc as { [key: string]: unknown })); + }) + } ); return { data: response.data, @@ -517,7 +522,7 @@ export class RampService { perc_analyte_overlap?: number, min_pathway_tocluster?: number, perc_pathway_overlap?: number, - ) { + ):Observable<{ data: RampPathwayEnrichmentResponse, plot: string }> { return forkJoin({ data: this.clusterPathwayEnrichment( dataframe, @@ -554,7 +559,7 @@ export class RampService { map((response: RampPathwayEnrichmentAPIResponse) => { return { data: response.data.fishresults.map( - (obj: any) => new FisherResult(obj), + (obj: unknown) => new FisherResult(obj as Partial), ), query: {}, combinedFishersdataframe: response.data as FishersDataframe, @@ -582,35 +587,33 @@ export class RampService { perc_pathway_overlap: perc_pathway_overlap, filename: Date.now() + '.svg', }; - const options: Object = { responseType: 'text' as const }; return this.http - .post(`${this.url}cluster-plot`, body, options) + .post(`${this.url}cluster-plot`, body, HTTP_TEXT_OPTIONS) .pipe( - map((response: string) => { - return response; + map((response: unknown) => { + return response; }), - // catchError(this.handleError('chemical enrichment', [])), ); } } - fetchClusterImageFile(data: any) { + fetchClusterImageFile(data: string) { this._downloadFile( - this._makeBlob(data, 'image/svg+xml'), + this._makeBlob([data], 'image/svg+xml'), 'fetchClusterImageFile-download.svg', ); } - private _toTSV(data: any[]): string[] { + private _toTSV(data: unknown[]): string[] { // grab the column headings (separated by tabs) - const headings: string = Object.keys(data[0]).join('\t'); + const headings: string = Object.keys(data[0] as string[]).join('\t'); // iterate over the data - const rows: string[] = data + const rows: string[] = data .reduce( - (acc: string[], c: { [key: string]: string }) => { + (acc: string[], c: unknown) => { // for each row object get its values and add tabs between them // then add them as a new array to the outgoing array - const vals = Object.values(c); + const vals = Object.values(c as T); const row = vals.join('\t'); return acc.concat(row); @@ -628,12 +631,12 @@ export class RampService { * @param result - optional value to return as the observable result */ private handleError(operation = 'operation', result?: T) { - return (error: any): Observable => { + return (error: ErrorEvent): Observable => { // TODO: send the error to remote logging infrastructure - console.error(error); // log to console instead + // console.error(error); // log to console instead // TODO: better job of transforming error for user consumption - // console.log(`${operation} failed: ${error.message}`); + console.log(`${operation} failed: ${error.message}`); // Let the app keep running by returning an empty result. return of(result as T); diff --git a/tsconfig.base.json b/tsconfig.base.json index bc46eaf..3ae038e 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -97,8 +97,8 @@ "@ramp/shared/ui/ncats-structure-viewer": [ "libs/shared/ui/ncats-structure-viewer/src/index.ts" ], - "@ramp/shared/ui/object-tree": [ - "libs/shared/ui/object-tree/src/index.ts" + "@ramp/shared/ui/highlight": [ + "libs/shared/ui/highlight/src/index.ts" ], "@ramp/shared/visualizations/upset-chart": [ "libs/shared/visualizations/upset-chart/src/index.ts"