Skip to content

Commit

Permalink
Merge pull request #215 from SmartAPI/redesign
Browse files Browse the repository at this point in the history
New Feature
  • Loading branch information
marcodarko authored Jan 25, 2024
2 parents fb5b590 + bcc869b commit 89c0513
Show file tree
Hide file tree
Showing 102 changed files with 29,329 additions and 45,838 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Deploy-to-EC2-Dev

on:
push:
branches:
- vite-app

jobs:
deploy:
name: Deploy to EC2 on branch push
runs-on: ubuntu-latest

steps:
- name: Step 0 - Install APT Dependences
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev libssl-dev libxml2-dev libxmlsec1-dev libxmlsec1-openssl libxml2 libxmlsec1 pkg-config

- name: Step 1 - Checkout the Files
uses: actions/checkout@v3

- name: Step 2 - Install Node.js
uses: actions/setup-node@v1
with:
node-version: '20.9.0'

- name: Step 3 - Build Frontend
run: |
cd web-app
npm install
NODE_OPTIONS="--max-old-space-size=1512" npm run build
- name: Step 4 - Deploy to Dev Server
uses: easingthemes/ssh-deploy@main
env:
SOURCE: "/"
SSH_PRIVATE_KEY: ${{ secrets.AWS_DEV_EC2_SSH_KEY }}
REMOTE_HOST: ${{ secrets.AWS_DEV_HOST_DNS }}
REMOTE_USER: ${{ secrets.AWS_DEV_USERNAME }}
TARGET: ${{ secrets.AWS_DEV_TARGET_DIR }}
SCRIPT_AFTER: |
set -x
echo "Activate python env."
cd /home/ubuntu/smartapi
source .env/bin/activate
echo "Installing backend requirements."
pip install -Ur requirements.txt --no-cache-dir --ignore-installed --force-reinstall
echo "Restarting smartapi backend services..."
sudo systemctl restart smartapi@8000
sleep 10
sudo systemctl restart smartapi@8080
echo "Smartapi backend services restarted!!!"
set +x
echo $RSYNC_STDOUT
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ boto3

# Biolink Model Toolkit, used in /api/metakg endpoint
bmt-lite-v3.1.0==2.2.2

networkx==3.1.0
2 changes: 1 addition & 1 deletion src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get(self):
(r"/oauth", "handlers.oauth.GitHubLoginHandler"),
(r"/logout/?", "handlers.api.LogoutHandler"),
(r"/sitemap.xml()", "tornado.web.StaticFileHandler", {"path": "../web-app/dist/sitemap.xml"}),
(r"/((?:img|css|js|fonts)/.*)", "tornado.web.StaticFileHandler", {"path": "../web-app/dist/"}),
(r"/((?:img|assets)/.*)", "tornado.web.StaticFileHandler", {"path": "../web-app/dist/"}),
],
{
"default_handler_class": WebAppHandler,
Expand Down
24 changes: 24 additions & 0 deletions web-app/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')

module.exports = {
root: true,
'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-prettier/skip-formatting'
],
overrides: [
{
files: [
'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}'
],
'extends': [
'plugin:cypress/recommended'
]
}
],
parserOptions: {
ecmaVersion: 'latest'
}
}
27 changes: 16 additions & 11 deletions web-app/.gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
.DS_Store
node_modules
/dist


# local env files
.env.local
.env.*.local

# Log files
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_Store
dist
dist-ssr
coverage
*.local

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
Expand Down
8 changes: 8 additions & 0 deletions web-app/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": true,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}
55 changes: 44 additions & 11 deletions web-app/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,57 @@
# web-app
# SmartAPI web app

## Project setup
```
Developed with Vue 3 in Vite.

## Recommended IDE Setup

[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).

## Customize configuration

See [Vite Configuration Reference](https://vitejs.dev/config/).

## Project Setup

```sh
npm install
```

### Compiles and hot-reloads for development
### Compile and Hot-Reload for Development

```sh
npm run dev
```
npm run serve

### Compile and Minify for Production

```sh
npm run build
```

### Compiles and minifies for production
### Run Unit Tests with [Vitest](https://vitest.dev/)

```sh
npm run test:unit
```
npm run build

### Run End-to-End Tests with [Cypress](https://www.cypress.io/)

```sh
npm run test:e2e:dev
```

### Lints and fixes files
This runs the end-to-end tests against the Vite development server.
It is much faster than the production build.

But it's still recommended to test the production build with `test:e2e` before deploying (e.g. in CI environments):

```sh
npm run build
npm run test:e2e
```

### Lint with [ESLint](https://eslint.org/)

```sh
npm run lint
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
5 changes: 0 additions & 5 deletions web-app/babel.config.js

This file was deleted.

8 changes: 8 additions & 0 deletions web-app/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
e2e: {
specPattern: 'cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}',
baseUrl: 'http://localhost:4173'
}
})
8 changes: 8 additions & 0 deletions web-app/cypress/e2e/example.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// https://on.cypress.io/api

describe('My First Test', () => {
it('visits the app root url', () => {
cy.visit('/')
cy.contains('h1', 'You did it!')
})
})
8 changes: 8 additions & 0 deletions web-app/cypress/e2e/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress"]
},
"include": ["./**/*", "../support/**/*"]
}
5 changes: 5 additions & 0 deletions web-app/cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]",
"body": "Fixtures are a great way to mock data for responses to routes"
}
25 changes: 25 additions & 0 deletions web-app/cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
20 changes: 20 additions & 0 deletions web-app/cypress/support/e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
6 changes: 2 additions & 4 deletions web-app/public/index.html → web-app/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en" class="blue-grey darken-4">
<html lang="en">
<head>
<!-- NO CHANGE -->
<meta charset="UTF-8">
Expand Down Expand Up @@ -52,10 +52,8 @@
<link rel="stylesheet" href="https://unpkg.com/tippy.js@4/themes/light.css"/>
</head>
<body>
<noscript>
<strong>We're sorry but SmartAPI doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
<!-- Swagger Editor Preset-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/swagger-editor-standalone-preset.js"></script>
Expand Down
6 changes: 0 additions & 6 deletions web-app/jest.config.js

This file was deleted.

Loading

0 comments on commit 89c0513

Please sign in to comment.