Skip to content

Commit 750282e

Browse files
author
Yan Xu
committed
Add webapp
1 parent 5264c3a commit 750282e

File tree

211 files changed

+38011
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+38011
-1
lines changed

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
**/work/**
44
*/logs/*
55
**/ec_info/*
6-
.nf-test*
6+
.nf-test*
7+
.DS_Store
8+
.env
9+
io
10+
node_modules

.vscode/settings.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"editor.codeActionsOnSave": {
3+
"source.fixAll.eslint": "explicit"
4+
},
5+
"eslint.validate": ["javascript"],
6+
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint",
7+
"editor.formatOnPaste": false, // required
8+
"editor.formatOnType": false, // required
9+
"editor.formatOnSave": true, // optional
10+
"editor.formatOnSaveMode": "file", // required to format on save
11+
"files.autoSave": "onFocusChange", // optional but recommended
12+
"vs-code-prettier-eslint.prettierLast": false, // set as "true" to run 'prettier' last not first
13+
"files.eol": "\n",
14+
}

installation/README.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## INSTALLATION PREREQUISITES
2+
3+
### Install Node20
4+
https://nodejs.org/dist/latest-v20.x/
5+
6+
### Install pm2
7+
`npm install pm2@latest -g`
8+
9+
### Install MongoDB Community Edition
10+
https://docs.mongodb.com/manual/installation/#mongodb-community-edition-installation-tutorials
11+
12+
## INSTALL webapp
13+
14+
1. Move/copy EDGEv3 folder to the installation directory
15+
16+
2. Inside EDGEv3/installation folder, run the installation script
17+
18+
`./install.sh`
19+
20+
3. Create environment variables
21+
22+
The web client and web server each rely on environment variables for their configuration.
23+
You can define those environment variables in `.env` files.
24+
25+
Here's how you can define them in `.env` files:
26+
27+
- Populate the "client build" environment configuration file (i.e. `webapp/client/.env`).
28+
29+
You can initialize it based upon the corresponding development/production example file:
30+
```shell
31+
cp webapp/client/.env.development.example \
32+
webapp/client/.env
33+
```
34+
> Those environment variables are used within `webapp/client/src/config.js`.
35+
- Populate the server environment configuration file (i.e. `webapp/server/.env`).
36+
37+
You can initialize it based upon the corresponding development/production example file:
38+
```shell
39+
cp webapp/server/.env.development.example \
40+
webapp/server/.env
41+
```
42+
> Those environment variables are used within `webapp/server/config.js`.
43+
44+
## START webapp
45+
46+
1. Start MongoDB if it's not started yet
47+
48+
2. Inside EDGEv3 folder, run the pm2 start command
49+
50+
`pm2 start pm2.config.js`
51+
52+
## STOP webapp
53+
54+
pm2 stop all

installation/install.sh

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
echo "Install LANL EDGE webapp..."
3+
pwd=$PWD
4+
app_home="$(dirname "$pwd")"
5+
6+
#create upload/log/projects/public directories, skip this step for reinstallation
7+
io_home=$app_home/io
8+
if [ ! -d $io_home ]; then
9+
echo "Create directories"
10+
mkdir ${io_home}
11+
dirs=(
12+
"upload"
13+
"upload/files"
14+
"upload/tmp"
15+
"log"
16+
"projects"
17+
"public"
18+
"sra"
19+
"db"
20+
"nextflow"
21+
"nextflow/work"
22+
)
23+
24+
for dir in "${dirs[@]}"
25+
do
26+
mkdir ${io_home}/${dir}
27+
done
28+
29+
test_data_home=$app_home/workflows/Nextflow/test_data
30+
if [ -d $test_data_home ]; then
31+
ln -s ${test_data_home} ${io_home}/public/test_data
32+
fi
33+
fi
34+
35+
echo "Setup LANL EDGE webapp ..."
36+
#build client
37+
echo "build client..."
38+
cd $app_home/webapp/client
39+
npm install --legacy-peer-deps
40+
npm run build
41+
#build server
42+
echo "build server..."
43+
cd $app_home/webapp/server
44+
npm install
45+
46+
echo "LANL EDGE webapp successfully installed!"
47+
echo "To start the webapp in EDGEv3's root directory:"
48+
echo "pm2 start pm2.config.js"

pm2.config.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* This is a PM2 configuration file.
3+
*
4+
* References:
5+
* - https://pm2.keymetrics.io/docs/usage/application-declaration/
6+
* - https://pm2.keymetrics.io/docs/usage/environment/
7+
*/
8+
9+
module.exports = {
10+
apps: [
11+
{
12+
name: "appserver",
13+
script: "server.js",
14+
instances: 4,
15+
exec_mode: "cluster",
16+
cwd: "./webapp/server",
17+
node_args: "--max_old_space_size=1024",
18+
max_memory_restart: "150M"
19+
},
20+
{
21+
name: "cronserver",
22+
script: "cronServer.js",
23+
cwd: "./webapp/server",
24+
node_args: "--max_old_space_size=1024",
25+
max_memory_restart: "150M"
26+
}
27+
]
28+
}

webapp/README.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Development
2+
3+
## Dependencies
4+
5+
* node.js v20
6+
* MongoDB
7+
8+
## Install the webapp
9+
10+
cd installation
11+
./install-local.sh
12+
13+
## Start api server
14+
15+
cd webapp/server
16+
(change NODE_ENV=prod to NODE_ENV=dev in .env)
17+
npm start
18+
19+
## Start ui client
20+
21+
cd webapp/client
22+
npm start
23+
24+
## View the website
25+
26+
http://localhost:3000
27+
28+
## Note
29+
30+
- Have to restart the client when any changes made in client/.env.
31+
- Have to restart the server when any changes made in server code or server/.env.
32+
33+
#### Restart api server
34+
35+
cd webapp/server
36+
use Ctrl-C to stop the webapp server
37+
npm start
38+
39+
#### Restart ui client
40+
41+
cd webapp/client
42+
use Ctrl-C to stop the webapp client
43+
npm start
44+
45+

webapp/client/.browserslistrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# https://github.com/browserslist/browserslist#readme
2+
3+
[production]
4+
>0.2%
5+
not dead
6+
not op_mini all
7+
8+
[development]
9+
last 1 chrome version
10+
last 1 firefox version
11+
last 1 safari version

webapp/client/.editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_size = 2
8+
indent_style = space
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
max_line_length = off
14+
trim_trailing_whitespace = false
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# EDGE
2+
VITE_NAME=EDGE V3
3+
VITE_EMAIL_NOTIFICATION_ENABLED=false
4+
VITE_FILEUPLOAD_ENABLED=true
5+
VITE_API_URL=http://localhost:5000
6+
# ORCiD login
7+
VITE_IS_ORCID_AUTH_ENABLED=false
8+
VITE_ORCID_CLIENT_ID=<Your ORCiD client id>

webapp/client/.env.production.example

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# EDGE
2+
VITE_NAME=EDGE V3
3+
VITE_FILEUPLOAD_ENABLED=true
4+
# ORCiD login
5+
VITE_IS_ORCID_AUTH_ENABLED=false
6+
VITE_ORCID_CLIENT_ID=<Your ORCiD client id>

webapp/client/.eslintrc.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
// parser: '@typescript-eslint/parser', // Specifies the ESLint parser
3+
parserOptions: {
4+
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
5+
sourceType: 'module', // Allows for the use of imports
6+
ecmaFeatures: {
7+
jsx: true, // Allows for the parsing of JSX
8+
},
9+
},
10+
settings: {
11+
react: {
12+
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
13+
},
14+
},
15+
extends: [
16+
'plugin:react/recommended', // Uses the recommended rules from @eslint-plugin-react
17+
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
18+
],
19+
plugins: ['react', 'react-hooks'],
20+
rules: {
21+
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
22+
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
23+
},
24+
}

webapp/client/.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Enforce Unix newlines
2+
* text=auto eol=lf

webapp/client/.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
6+
# testing
7+
/coverage
8+
9+
# production
10+
/build
11+
12+
# misc
13+
.eslintcache
14+
.DS_Store
15+
.idea
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

webapp/client/.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/

webapp/client/.prettierrc.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
semi: false,
3+
trailingComma: 'all',
4+
singleQuote: true,
5+
printWidth: 100,
6+
tabWidth: 2,
7+
}

webapp/client/index.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7+
<meta name="description" content="LANL EDGE V3">
8+
<meta name="author" content="LANL EDGE Bioinformatics Team">
9+
<meta name="keyword" content="Bootstrap,Admin,Template,Open,Source,CSS,SCSS,HTML,RWD,Dashboard,React">
10+
<title>EDGE</title>
11+
<base href="/">
12+
<link rel="manifest" src="/manifest.json">
13+
<link rel="shortcut icon" src="/favicon.ico">
14+
</head>
15+
<body>
16+
<noscript>
17+
You need to enable JavaScript to run this app
18+
</noscript>
19+
<div id="root"></div>
20+
<script type="module" src="/src/index.js"></script>
21+
<!-- built files will be auto injected -->
22+
</body>
23+
</html>

0 commit comments

Comments
 (0)