Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduction of React-based frontend #28

Merged
merged 41 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
e295c95
chore: initialise frontend in React
Dec 6, 2023
f57938b
feat: Accession with first result view and routing
Dec 8, 2023
32f9686
feat: added chart component
Dec 20, 2023
02d294f
feat: extension of backend interface to display real peaks in frontend
Dec 23, 2023
7cd88bd
feat: added peak table in accession tab
Dec 23, 2023
e128564
feat: added highlighting between peaks chart und table
Dec 23, 2023
9b353eb
fix: TS error when importing Highlight
Dec 23, 2023
815d9af
feat: enable zoom within chart
Jan 2, 2024
df5a3a5
fix: use scaleLinear instead of scaleBand for x axis
Jan 2, 2024
be3ede1
feat: enabled to return to last zoom level
Jan 6, 2024
30afada
chore: better adjustment of x labels according to the zoom level
Jan 6, 2024
b9b6acc
fix: ignore TS error in Chart.tsx
Jan 6, 2024
0f26078
fix: added route for not found page
Jan 7, 2024
415f8d7
chore: allow redirection of previous MassBank entry links
Jan 7, 2024
de45d9e
chore: use navigation when searching in Accession page
Jan 7, 2024
cafcd45
fix: do not show peaks without relative intensity
Jan 7, 2024
c473960
feat: show peak data in table according to zoom level in chart
Jan 7, 2024
baf44c0
fix: centered the m/z label and adjust chart height with show labels …
Jan 7, 2024
a569de4
chore: do not rotate peak label
Jan 7, 2024
23d5e7c
fix: renamings with capitel letters
michaelwenk Jan 7, 2024
3b412b9
fix: re-allow rotation of peak labels
Jan 7, 2024
85c3462
chore: adjust spectrum and peak table according to the window size
Jan 8, 2024
165985e
chore: do not show button in spinner
Jan 8, 2024
812c8f9
chore: moved structure view container styles into scss file
Jan 8, 2024
52adfd9
chore: moved search method content into handleOnSearch method
Jan 8, 2024
6d17f35
fix: removed unnecessary log
Jan 8, 2024
e347f48
fix: allow peaks with undefined relative intensity
Jan 8, 2024
e37c608
feat: show number of peaks per zoom level
Jan 8, 2024
e67399b
chore: increased chart container height to 0.7
Jan 10, 2024
fa6a078
fix: adapted types in test data according to peak data types
Jan 10, 2024
46f283a
chore: deactivated re-direction for old MassBank links
Jan 10, 2024
e3ca6a7
chore: removed unused import
Jan 10, 2024
8eef3c8
fix: reversion of data peak data types
Jan 10, 2024
e035946
fix: missing reversion of test peak data types
Jan 10, 2024
3eba9e9
Merge pull request #1 from michaelwenk/dev-frontend
michaelwenk Jan 10, 2024
47b2574
fix: only display 4 digits for mz values in peak table
Jan 10, 2024
4cffbe7
Merge pull request #2 from michaelwenk/dev-frontend
michaelwenk Jan 10, 2024
e9d4763
fix: changed docker files for frontend debugging and testing
Jan 10, 2024
0694ab3
Merge pull request #3 from michaelwenk/fix-docker-error
michaelwenk Jan 10, 2024
7fe9f0f
fix: fix frontend file name in workflow file
Jan 10, 2024
a3cd729
Merge pull request #4 from michaelwenk/fix-docker-error
michaelwenk Jan 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/create-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- 'main'
- 'dev'
- 'dev-*'
tags:
- 'v*'

Expand All @@ -18,7 +19,7 @@ jobs:
image: ipbhalle/mb3dbtool
- dockerfile: ./Dockerfile
image: ipbhalle/mb3server
- dockerfile: ./Dockerfile-svelte
- dockerfile: ./Dockerfile-frontend
image: ipbhalle/mb3frontend
steps:
- name: Checkout
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile-frontend
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:19-alpine
# Create app directory
WORKDIR /app

# Bundle app source
COPY ./web-frontend/ .

# install dependencies
# RUN npm install --legacy-peer-deps
RUN npm install

# for production mode
RUN node ./node_modules/rimraf dist && node ./node_modules/typescript/bin/tsc && node ./node_modules/vite/bin/vite.js build

EXPOSE 3000
CMD npm run preview
17 changes: 17 additions & 0 deletions Dockerfile-frontend-debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:19-alpine
# Create app directory
WORKDIR /app

# Bundle app source
COPY ./web-frontend/ .

# install dependencies
# RUN npm install --legacy-peer-deps
RUN npm install

# for production mode
RUN node ./node_modules/rimraf dist && node ./node_modules/typescript/bin/tsc && node ./node_modules/vite/bin/vite.js build

EXPOSE 5173
ENTRYPOINT ["npm", "run", "preview"]

16 changes: 0 additions & 16 deletions Dockerfile-svelte

This file was deleted.

12 changes: 0 additions & 12 deletions Dockerfile-svelte-debug

This file was deleted.

45 changes: 42 additions & 3 deletions cmd/mb3server/src/api-impl.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package mb3server

import (
"github.com/MassBank/MassBank3/pkg/config"
"github.com/MassBank/MassBank3/pkg/database"
"github.com/MassBank/MassBank3/pkg/massbank"
"io"
"log"
"net/http"
"net/url"
"regexp"

"github.com/MassBank/MassBank3/pkg/config"
"github.com/MassBank/MassBank3/pkg/database"
"github.com/MassBank/MassBank3/pkg/massbank"
)

var db database.MB3Database = nil
Expand Down Expand Up @@ -307,6 +308,44 @@ func GetRecord(accession string) (*MbRecord, error) {
MarcRelator: author.MarcRelator,
})
}

var mzs = *&record.Peak.Peak.Mz //[]float64{}
var ints = *&record.Peak.Peak.Intensity //[]float64{}
var rels = *&record.Peak.Peak.Rel //[]uint{}
// for _, mz := range *&record.Peak.Peak.Mz {
// mzs = append(mzs, mz)
// }
// for _, int := range *&record.Peak.Peak.Intensity {
// ints = append(ints, int)
// }
// for _, rel := range *&record.Peak.Peak.Rel {
// rels = append(rels, rel)
// }

for i := 0; i < len(mzs); i++ {
result.Peak.Peak.Values = append(result.Peak.Peak.Values, MbRecordPeakPeakValuesInner{
Mz: mzs[i],
Intensity: ints[i],
Rel: rels[i],
})
}

// var header = []string{}
// for _, h := range *&record.Peak.Annotation.Header {
// fmt.Printf("%v\n", h)
// header = append(header, h)
// }
// result.Peak.Annotation.Header = header

// for _, v := range *&record.Peak.Annotation.Values {
// fmt.Printf("%v\n", v)
// // for _, k := range *&v {
// // fmt.Printf("%v\n", k)
// // }
// }

// // result.Peak.Annotation.Values =

return &result, nil

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type MbRecordPeakPeakValuesInner struct {
Intensity float64 `json:"intensity,omitempty"`

// Relative intensity of the peak
Rel int32 `json:"rel,omitempty"`
Rel uint `json:"rel,omitempty"`
}

// AssertMbRecordPeakPeakValuesInnerRequired checks if the required fields are not zero-ed
Expand Down
7 changes: 2 additions & 5 deletions docker/docker-compose-debug.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
version: '3.1'
version: "3.1"

services:

mongodb:
extends:
file: docker-compose-common.yaml
Expand Down Expand Up @@ -41,13 +40,11 @@ services:
service: mb3frontend
build:
context: ..
dockerfile: Dockerfile-svelte-debug
dockerfile: Dockerfile-frontend-debug
environment:
VITE_SERVER_API_URL: "http://${MB3_API_HOST}:${MB3_API_PORT}"
ports:
- "127.0.0.1:${MB3_FRONTEND_PORT}:5173/tcp"
volumes:
- ../web-frontend:/app

mb3tool:
extends:
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
service: mb3frontend
build:
context: ..
dockerfile: Dockerfile-svelte
dockerfile: Dockerfile-frontend
environment:
MB3_API_URL: "http://${MB3_API_HOST}:${MB3_API_PORT}"
ports:
Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pkg/database/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"encoding/json"
"errors"
"fmt"
"log"
"strconv"

"github.com/Code-Hex/dd"
"github.com/MassBank/MassBank3/pkg/massbank"
"github.com/lib/pq"
_ "github.com/lib/pq"
"github.com/nullism/bqb"
"log"
"strconv"
)

// PostgresSQLDB is a struct representing a postgres connection. This should implement
Expand Down
3 changes: 2 additions & 1 deletion pkg/database/testdata_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package database

import (
"github.com/MassBank/MassBank3/pkg/massbank"
"os"
"time"

"github.com/MassBank/MassBank3/pkg/massbank"
)

func getEnv(name string, fallback string) string {
Expand Down
5 changes: 3 additions & 2 deletions pkg/massbank/bson.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package massbank

import (
"fmt"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
"strings"
"time"

"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
)

func (p DatabaseProperty) MarshalBSONValue() (bsontype.Type, []byte, error) {
Expand Down
1 change: 1 addition & 0 deletions pkg/massbank/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func (mb *MassBank2) parsePeakValue(line string) error {
var mz, intens float64
var err error
var rel uint64

if mz, err = strconv.ParseFloat(svals[0], 32); err != nil {
return errors.New("could not parse mz Value")
}
Expand Down
7 changes: 7 additions & 0 deletions web-frontend/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": ["@babel/plugin-transform-modules-commonjs"],
"presets": [
"@babel/preset-typescript",
["@babel/preset-react", { "runtime": "automatic" }]
]
}
4 changes: 4 additions & 0 deletions web-frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
npm-debug.log
dist
data
14 changes: 2 additions & 12 deletions web-frontend/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
.DS_Store
dist
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
public
16 changes: 16 additions & 0 deletions web-frontend/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"env": { "browser": true, "node": true },
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier", "react"],
"extends": [
"prettier",
"eslint:recommended",
"plugin:react-hooks/recommended"
],
"rules": {
"@typescript-eslint/no-explicit-any": "warn",
"no-undef": "off",
"no-console": "warn",
"no-unused-vars": "warn"
}
}
20 changes: 0 additions & 20 deletions web-frontend/.eslintrc.cjs

This file was deleted.

36 changes: 27 additions & 9 deletions web-frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# VSCode
.vscode

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/dist

# misc
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

.eslintcache
1 change: 0 additions & 1 deletion web-frontend/.npmrc

This file was deleted.

7 changes: 7 additions & 0 deletions web-frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"arrowParens": "always",
"tabWidth": 2,
"singleQuote": true,
"semi": true,
"trailingComma": "all"
}
Loading