Skip to content

Commit e6cb01a

Browse files
committed
feature setup
1 parent 9292657 commit e6cb01a

File tree

6 files changed

+78
-2
lines changed

6 files changed

+78
-2
lines changed

src/app/core/config/config.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export interface Config {
8181
disableKetcher?: boolean;
8282
useApprovalAPI?: boolean;
8383
dummyWhoami?: Auth;
84+
enableStructureFeatures?: boolean;
8485
}
8586

8687
export interface StagingAreaSettings {

src/app/core/structure/structure-post-response.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface InterpretStructureResponse {
88
structure: SubstanceStructure;
99
moieties: Array<SubstanceMoiety>;
1010
structuralUnits: Array<StructuralUnit>;
11+
featureList?: Array<any>;
1112
}
1213

1314
export interface ResolverResponse {

src/app/core/substance-form/structure/substance-form-structure-card.component.html

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
11
<div>
22
<div>
33
<div>
4-
<app-structure-editor (loadedMolfile)="molvecUpdate($event)" (editorOnLoad)="editorOnLoad($event)" (editorSwitched) = "changeEditor($event)" style="z-index: 9999">
4+
<app-structure-editor (loadedMolfile)="molvecUpdate($event)" (editorOnLoad)="editorOnLoad($event)" (editorSwitched) = "changeEditor($event)" style="z-index: 9999">
55
</app-structure-editor>
66
</div>
77
<div [ngClass]="{'messages-container': true, collapsed: !userMessage, expanded: userMessage}">
88
{{userMessage}}
99
</div>
1010
</div>
11+
<div class="button-row feature-table" *ngIf = "enableStructureFeatures && features && features.length > 0" >
12+
<div class = "feature-expansion">
13+
<mat-expansion-panel expanded="true" >
14+
<mat-expansion-panel-header>
15+
<mat-panel-title> Structure Features </mat-panel-title>
16+
</mat-expansion-panel-header>
17+
<table class = "full-width" mat-table [dataSource]="sortedFeatures">
18+
<ng-container matColumnDef="key">
19+
<th mat-header-cell *matHeaderCellDef>Feature</th>
20+
<td mat-cell *matCellDef="let element" >{{element.key}}</td>
21+
</ng-container>
22+
<ng-container matColumnDef="value">
23+
<th mat-header-cell *matHeaderCellDef>Value</th>
24+
<td mat-cell *matCellDef="let element">{{element.value}}</td>
25+
</ng-container>
26+
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
27+
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
28+
</table>
29+
</mat-expansion-panel>
30+
</div>
31+
</div>
1132
<div class="button-row" *ngIf="structure && substanceType === 'polymer'">
1233
<span class="middle-fill"></span>
1334
<span class="right-buttons">

src/app/core/substance-form/structure/substance-form-structure-card.component.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@
4343
}
4444
}
4545

46+
.feature-table {
47+
display:block;
48+
margin: auto;
49+
width: 85%;
50+
}
51+
52+
.feature-expansion {
53+
width:100%;
54+
justify-content: center;
55+
}
56+
57+
.full-width {
58+
width: 100%;
59+
}
60+
61+
tr.mat-row, tr.mat-footer-row {
62+
height: 32px;
63+
}
64+
4665
.SUCCESS {
4766
color: var(--success-green-color);
4867
background-color: var(--success-green-bg-color);

src/app/core/substance-form/structure/substance-form-structure-card.component.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
2020
import { StructureEditorComponent } from '@gsrs-core/structure-editor';
2121
import { take } from 'rxjs/operators';
2222
import { ConfigService } from '@gsrs-core/config';
23+
import { MatTableDataSource } from '@angular/material/table';
2324

2425
@Component({
2526
selector: 'app-substance-form-structure-card',
@@ -34,10 +35,15 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple
3435
substanceType: string;
3536
smiles: string;
3637
mol: string;
38+
features: Array<any>;
3739
isInitializing = true;
3840
private overlayContainer: HTMLElement;
3941
structureErrorsArray: Array<StructureDuplicationMessage>;
4042
subscriptions: Array<Subscription> = [];
43+
privateFeatures: any;
44+
enableStructureFeatures = true;
45+
sortedFeatures = new MatTableDataSource();
46+
displayedColumns = ['key', 'value'];
4147
@ViewChild(StructureEditorComponent) structureEditorComponent!: StructureEditorComponent;
4248

4349
constructor(
@@ -165,6 +171,30 @@ export class SubstanceFormStructureCardComponent extends SubstanceFormBase imple
165171

166172
processStructurePostResponse(structurePostResponse?: InterpretStructureResponse): void {
167173
if (structurePostResponse && structurePostResponse.structure) {
174+
if (structurePostResponse.featureList && structurePostResponse.featureList.length > 0) {
175+
let temp = [];
176+
Object.keys(structurePostResponse.featureList[0]).forEach(key => {
177+
let label = key;
178+
if(key === 'categoryScore'){
179+
label = 'Category Score';
180+
}
181+
if(key === 'sumOfScores'){
182+
label = 'Sum Of Scores';
183+
}
184+
temp.push({'key': label,'value': structurePostResponse.featureList[0][key] });
185+
});
186+
let customSort = (array: any[]): any[] => {
187+
return array.sort((a, b) => {
188+
if (a.key === 'Category Score') return -1;
189+
if (b.key === 'Category Score') return 1;
190+
if (a.key === 'Sum Of Scores') return a.key === 'Category Score' ? 1 : -1;
191+
if (b.key === 'Sum Of Scores') return b.key === 'Category Score' ? -1 : 1;
192+
return a.key.localeCompare(b.key);
193+
});
194+
};
195+
this.features = customSort(temp);
196+
this.sortedFeatures = new MatTableDataSource(this.features);
197+
}
168198

169199
// we should only be dealing with this stuff if the total hash changes
170200
// or if the charge changes, or if it's a polymer

src/app/core/substance-form/structure/substance-form-structure.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { DragDropPasteDirective } from '@gsrs-core/substance-form/structure/drag
1313
import {MatIconModule} from '@angular/material/icon';
1414
import {MatMenuModule} from '@angular/material/menu';
1515
import {MatButtonModule} from '@angular/material/button';
16+
import { MatTableModule } from '@angular/material/table';
17+
import { MatExpansionModule } from '@angular/material/expansion';
1618

1719
@NgModule({
1820
imports: [
@@ -28,7 +30,9 @@ import {MatButtonModule} from '@angular/material/button';
2830
NameResolverModule,
2931
MatMenuModule,
3032
MatIconModule,
31-
MatButtonModule
33+
MatButtonModule,
34+
MatTableModule,
35+
MatExpansionModule
3236
],
3337
declarations: [
3438
SubstanceFormStructureCardComponent,

0 commit comments

Comments
 (0)