Skip to content

Commit

Permalink
feat: use and show compound names and classes in frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwenk committed Jan 15, 2024
1 parent 436c2e7 commit 804aa0b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
15 changes: 8 additions & 7 deletions cmd/mb3server/src/api-impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,14 @@ func GetRecords(limit int32, page int32, contributor []string, instrumentType []
for _, value := range searchResult.Data {
smiles := (value.Smiles)
svg, err := getSvgFromSmiles(&smiles)
re := regexp.MustCompile("<\\?xml[^>]*>\\n<!DOCTYPE[^>]*>\\n")
svgS := string(re.ReplaceAll([]byte(*svg), []byte("")))
re = regexp.MustCompile("\\n")
svgS = string(re.ReplaceAll([]byte(svgS), []byte(" ")))
var svgS string = ""
if err != nil {
log.Println(err)
*svg = ""
} else {
re := regexp.MustCompile("<\\?xml[^>]*>\\n<!DOCTYPE[^>]*>\\n")
svgS = string(re.ReplaceAll([]byte(*svg), []byte("")))
re = regexp.MustCompile("\\n")
svgS = string(re.ReplaceAll([]byte(svgS), []byte(" ")))
}
var val = SearchResultDataInner{
Data: map[string]interface{}{},
Expand Down Expand Up @@ -259,8 +260,8 @@ func GetRecord(accession string) (*MbRecord, error) {
Project: "",
Comments: nil,
Compound: MbRecordCompound{
Names: nil,
Classes: nil,
Names: *record.Compound.Names,
Classes: *record.Compound.Classes,
Formula: *record.Compound.Formula,
CdkDepict: nil,
Mass: *record.Compound.Mass,
Expand Down
15 changes: 3 additions & 12 deletions web-frontend/src/elements/record/RecordView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,7 @@ function RecordView({ record }: inputProps) {
</tr>
<tr>
<td>Title</td>
<td>
{record.title.split(';').map((r) => {
return (
<span key={r}>
<label>{r}</label>
<br />
</span>
);
})}
</td>
<td>{record.title}</td>
</tr>
<tr>
<td>Date</td>
Expand Down Expand Up @@ -154,11 +145,11 @@ function RecordView({ record }: inputProps) {
</tr>
<tr>
<td>Names</td>
<td colSpan={2}>{record.compound.names}</td>
<td colSpan={2}>{record.compound.names.join('; ')}</td>
</tr>
<tr>
<td>Classes</td>
<td colSpan={2}>{record.compound.classes}</td>
<td colSpan={2}>{record.compound.classes.join('; ')}</td>
</tr>
<tr>
<td>InChI</td>
Expand Down
4 changes: 2 additions & 2 deletions web-frontend/src/types/Record.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default interface Record {
authors: [{ name: string }];
license: string;
compound: {
names: string;
classes: string;
names: string[];
classes: string[];
formula: string;
mass: number;
smiles: string;
Expand Down

0 comments on commit 804aa0b

Please sign in to comment.