Skip to content

Commit 9e3cf8b

Browse files
committed
feat: prototype for using browse options in content view
1 parent 4e8ba54 commit 9e3cf8b

File tree

14 files changed

+367
-82
lines changed

14 files changed

+367
-82
lines changed

cmd/mb3dbtool/main.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ import (
55
"bufio"
66
"bytes"
77
"fmt"
8-
"github.com/MassBank/MassBank3/pkg/config"
9-
"github.com/MassBank/MassBank3/pkg/database"
10-
"github.com/MassBank/MassBank3/pkg/massbank"
11-
"github.com/go-git/go-git/v5"
128
"io"
139
"log"
1410
"net/http"
1511
"os"
1612
"path/filepath"
1713
"strings"
14+
15+
"github.com/MassBank/MassBank3/pkg/config"
16+
"github.com/MassBank/MassBank3/pkg/database"
17+
"github.com/MassBank/MassBank3/pkg/massbank"
18+
"github.com/go-git/go-git/v5"
1819
)
1920

2021
func main() {

cmd/mb3server/src/api_default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (c *DefaultApiController) GetBrowseOptions(w http.ResponseWriter, r *http.R
9999
query := r.URL.Query()
100100
instrumentTypeParam := strings.Split(query.Get("instrument_type"), ",")
101101
msTypeParam := strings.Split(query.Get("ms_type"), ",")
102-
ionModeParam := query.Get("ion-mode")
102+
ionModeParam := query.Get("ion_mode")
103103
contributorParam := strings.Split(query.Get("contributor"), ",")
104104
result, err := c.service.GetBrowseOptions(r.Context(), instrumentTypeParam, msTypeParam, ionModeParam, contributorParam)
105105
// If an error occurred, encode the error with the status code

docker/env.dist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ MB3_FRONTEND_BASE_URL=/massbank3/
3131
# ----------------------
3232

3333
# The database type: "mongodb" or "postgres"
34-
DB_TYPE=postgres
34+
DB_TYPE=mongodb
3535

3636
# The port of the database
37-
DB_PORT=5432
37+
DB_PORT=27017
3838

3939
# The database user name
4040
DB_USER=massbank3
@@ -43,7 +43,7 @@ DB_USER=massbank3
4343
DB_PASSWORD=massbank3password
4444

4545
# The database host name
46-
DB_HOST=postgres
46+
DB_HOST=mongodb
4747

4848
# The name of the database
4949
DB_NAME=massbank3

web-frontend/package-lock.json

Lines changed: 91 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web-frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
},
3434
"dependencies": {
3535
"@types/d3": "^7.4.3",
36+
"axios": "^1.6.8",
3637
"chart.js": "^4.4.2",
3738
"d3": "^7.8.5",
3839
"openchemlib": "^8.7.2",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.CheckBox {
2+
text-align: center;
3+
width: 100%;
4+
height: 100%;
5+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import './CheckBox.scss';
2+
import {
3+
CSSProperties,
4+
ChangeEvent,
5+
useCallback,
6+
useMemo,
7+
useState,
8+
} from 'react';
9+
10+
type InputProps = {
11+
defaultValue: boolean;
12+
// eslint-disable-next-line no-unused-vars
13+
onChange: (isChecked: boolean) => void;
14+
label?: string;
15+
className?: string;
16+
style?: CSSProperties;
17+
};
18+
19+
function CheckBox({
20+
defaultValue,
21+
onChange,
22+
label,
23+
className = 'CheckBox',
24+
style,
25+
}: InputProps) {
26+
const [isChecked, setIsChecked] = useState<boolean>(defaultValue);
27+
28+
const handleOnChange = useCallback(
29+
(e: ChangeEvent<HTMLInputElement>) => {
30+
// e.preventDefault();
31+
e.stopPropagation();
32+
33+
setIsChecked(!isChecked);
34+
onChange(!isChecked);
35+
},
36+
[isChecked, onChange],
37+
);
38+
39+
return useMemo(
40+
() => (
41+
<div className={className} style={style}>
42+
<input type="checkbox" checked={isChecked} onChange={handleOnChange} />
43+
<label>{label}</label>
44+
</div>
45+
),
46+
[className, handleOnChange, isChecked, label, style],
47+
);
48+
}
49+
50+
export default CheckBox;

web-frontend/src/elements/routes/pages/accession/AccessionView.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Button from '../../../basic/Button';
77
import RecordView from '../../../record/RecordView';
88
import generateID from '../../../../utils/generateID';
99
import Record from '../../../../types/Record';
10+
import axios from 'axios';
1011
import {
1112
createSearchParams,
1213
useNavigate,
@@ -26,14 +27,13 @@ function AccessionView() {
2627
async function getRecord(id: string) {
2728
const url = import.meta.env.VITE_MB3_API_URL + '/v1/records/' + id;
2829

29-
const resp = await fetch(url);
30-
if (resp.ok) {
31-
const jsonData = await resp.json();
32-
33-
if (typeof jsonData === 'string') {
30+
const resp = await axios.get(url);
31+
if (resp.status === 200) {
32+
const data = await resp.data;
33+
if (typeof data === 'string') {
3434
return undefined;
3535
}
36-
return jsonData;
36+
return data;
3737
}
3838

3939
return undefined;

0 commit comments

Comments
 (0)