Skip to content

Commit

Permalink
Merge pull request #99 from moleculemaker/sort-by-atom-count
Browse files Browse the repository at this point in the history
feat: allow sorting by Number of Atoms
  • Loading branch information
bodom0015 authored Feb 22, 2024
2 parents 7032e94 + 900f13d commit 435f935
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/app/api/mmli-backend/v1/model/molecule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 0.1.0
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


export interface Molecule {
export interface Molecule {
id: number;
flagged: boolean;
atom_count: number;
doc_no: string;
file_path: string;
page_no: string;
Expand Down
8 changes: 8 additions & 0 deletions src/app/components/chemscraper/results/results.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class ResultsComponent {
this.sortOptions = [
{ label: 'Location In PDF (default)', value: 'Location In PDF', disabled: false },
{ label: 'Molecular Weight', value: 'Molecular Weight', disabled: false },
{ label: 'Number of Atoms', value: 'Number of Atoms', disabled: false },
{ label: 'Occurrences', value: 'Occurrences', disabled: false },
{ label: 'Similarity', value: 'Similarity', disabled: true }
];
Expand Down Expand Up @@ -466,6 +467,13 @@ export class ResultsComponent {
}
return data2.id - data1.id;
});
} else if(value == "Number of Atoms") {
this.molecules.sort((data1: Molecule, data2: Molecule) => {
if (this.isAscending) {
return data1.atom_count - data2.atom_count;
}
return data2.atom_count - data1.atom_count;
});
} else if (value == "Molecular Weight") {
this.molecules.sort((data1: Molecule, data2: Molecule) => {
if(!data2.molecularWeight || data2.molecularWeight == 'Unavailable'){
Expand Down

0 comments on commit 435f935

Please sign in to comment.