Skip to content

Commit

Permalink
Merge pull request #1 from michaelwenk/dev-frontend
Browse files Browse the repository at this point in the history
Introduction of React-based frontend with accession webpage containing an interactive spectrum chart and peak table
  • Loading branch information
michaelwenk authored Jan 10, 2024
2 parents 31bdacb + e035946 commit 3eba9e9
Show file tree
Hide file tree
Showing 108 changed files with 9,104 additions and 4,163 deletions.
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
File renamed without changes.
16 changes: 0 additions & 16 deletions Dockerfile-svelte

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
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"
}
38 changes: 0 additions & 38 deletions web-frontend/README.md

This file was deleted.

13 changes: 13 additions & 0 deletions web-frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MassBank Europe</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
Loading

0 comments on commit 3eba9e9

Please sign in to comment.