From e6cb01aba1ba0b657d02c87c5ea2ce16346cfdab Mon Sep 17 00:00:00 2001 From: NikoAnderson Date: Thu, 8 Aug 2024 16:32:53 -0400 Subject: [PATCH] feature setup --- src/app/core/config/config.model.ts | 1 + .../structure-post-response.model.ts | 1 + ...bstance-form-structure-card.component.html | 23 +++++++++++++- ...bstance-form-structure-card.component.scss | 19 ++++++++++++ ...substance-form-structure-card.component.ts | 30 +++++++++++++++++++ .../substance-form-structure.module.ts | 6 +++- 6 files changed, 78 insertions(+), 2 deletions(-) diff --git a/src/app/core/config/config.model.ts b/src/app/core/config/config.model.ts index 723c03750..350dd0ef3 100644 --- a/src/app/core/config/config.model.ts +++ b/src/app/core/config/config.model.ts @@ -81,6 +81,7 @@ export interface Config { disableKetcher?: boolean; useApprovalAPI?: boolean; dummyWhoami?: Auth; + enableStructureFeatures?: boolean; } export interface StagingAreaSettings { diff --git a/src/app/core/structure/structure-post-response.model.ts b/src/app/core/structure/structure-post-response.model.ts index 394801649..9b8e08b9c 100644 --- a/src/app/core/structure/structure-post-response.model.ts +++ b/src/app/core/structure/structure-post-response.model.ts @@ -8,6 +8,7 @@ export interface InterpretStructureResponse { structure: SubstanceStructure; moieties: Array; structuralUnits: Array; + featureList?: Array; } export interface ResolverResponse { diff --git a/src/app/core/substance-form/structure/substance-form-structure-card.component.html b/src/app/core/substance-form/structure/substance-form-structure-card.component.html index 5e7f9b789..2ed0c293e 100644 --- a/src/app/core/substance-form/structure/substance-form-structure-card.component.html +++ b/src/app/core/substance-form/structure/substance-form-structure-card.component.html @@ -1,13 +1,34 @@
- +
{{userMessage}}
+
+
+ + + Structure Features + + + + + + + + + + + + +
Feature{{element.key}}Value{{element.value}}
+
+
+
diff --git a/src/app/core/substance-form/structure/substance-form-structure-card.component.scss b/src/app/core/substance-form/structure/substance-form-structure-card.component.scss index f26adf203..ff3deeb27 100644 --- a/src/app/core/substance-form/structure/substance-form-structure-card.component.scss +++ b/src/app/core/substance-form/structure/substance-form-structure-card.component.scss @@ -43,6 +43,25 @@ } } + .feature-table { + display:block; + margin: auto; + width: 85%; + } + + .feature-expansion { + width:100%; + justify-content: center; + } + + .full-width { + width: 100%; + } + + tr.mat-row, tr.mat-footer-row { + height: 32px; +} + .SUCCESS { color: var(--success-green-color); background-color: var(--success-green-bg-color); diff --git a/src/app/core/substance-form/structure/substance-form-structure-card.component.ts b/src/app/core/substance-form/structure/substance-form-structure-card.component.ts index a5f768d76..de03874fb 100644 --- a/src/app/core/substance-form/structure/substance-form-structure-card.component.ts +++ b/src/app/core/substance-form/structure/substance-form-structure-card.component.ts @@ -20,6 +20,7 @@ import { ActivatedRoute, NavigationExtras, Router } from '@angular/router'; import { StructureEditorComponent } from '@gsrs-core/structure-editor'; import { take } from 'rxjs/operators'; import { ConfigService } from '@gsrs-core/config'; +import { MatTableDataSource } from '@angular/material/table'; @Component({ selector: 'app-substance-form-structure-card', @@ -34,10 +35,15 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple substanceType: string; smiles: string; mol: string; + features: Array; isInitializing = true; private overlayContainer: HTMLElement; structureErrorsArray: Array; subscriptions: Array = []; + privateFeatures: any; + enableStructureFeatures = true; + sortedFeatures = new MatTableDataSource(); + displayedColumns = ['key', 'value']; @ViewChild(StructureEditorComponent) structureEditorComponent!: StructureEditorComponent; constructor( @@ -165,6 +171,30 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple processStructurePostResponse(structurePostResponse?: InterpretStructureResponse): void { if (structurePostResponse && structurePostResponse.structure) { + if (structurePostResponse.featureList && structurePostResponse.featureList.length > 0) { + let temp = []; + Object.keys(structurePostResponse.featureList[0]).forEach(key => { + let label = key; + if(key === 'categoryScore'){ + label = 'Category Score'; + } + if(key === 'sumOfScores'){ + label = 'Sum Of Scores'; + } + temp.push({'key': label,'value': structurePostResponse.featureList[0][key] }); + }); + let customSort = (array: any[]): any[] => { + return array.sort((a, b) => { + if (a.key === 'Category Score') return -1; + if (b.key === 'Category Score') return 1; + if (a.key === 'Sum Of Scores') return a.key === 'Category Score' ? 1 : -1; + if (b.key === 'Sum Of Scores') return b.key === 'Category Score' ? -1 : 1; + return a.key.localeCompare(b.key); + }); + }; + this.features = customSort(temp); + this.sortedFeatures = new MatTableDataSource(this.features); + } // we should only be dealing with this stuff if the total hash changes // or if the charge changes, or if it's a polymer diff --git a/src/app/core/substance-form/structure/substance-form-structure.module.ts b/src/app/core/substance-form/structure/substance-form-structure.module.ts index 589fb9ef0..97a8eca5e 100644 --- a/src/app/core/substance-form/structure/substance-form-structure.module.ts +++ b/src/app/core/substance-form/structure/substance-form-structure.module.ts @@ -13,6 +13,8 @@ import { DragDropPasteDirective } from '@gsrs-core/substance-form/structure/drag import {MatIconModule} from '@angular/material/icon'; import {MatMenuModule} from '@angular/material/menu'; import {MatButtonModule} from '@angular/material/button'; +import { MatTableModule } from '@angular/material/table'; +import { MatExpansionModule } from '@angular/material/expansion'; @NgModule({ imports: [ @@ -28,7 +30,9 @@ import {MatButtonModule} from '@angular/material/button'; NameResolverModule, MatMenuModule, MatIconModule, - MatButtonModule + MatButtonModule, + MatTableModule, + MatExpansionModule ], declarations: [ SubstanceFormStructureCardComponent,