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

Add main frontend #342

Merged
merged 10 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/*global module*/
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
},
extends: ['eslint:recommended', 'plugin:vue/vue3-strongly-recommended'],
extends: [
'eslint:recommended',
'plugin:vue/vue3-strongly-recommended',
Williangalvani marked this conversation as resolved.
Show resolved Hide resolved
'@vue/typescript/recommended',
],
parserOptions: {
ecmaVersion: 12,
},
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ jobs:
# This should be the same hash as in core/tools/mavlink_router/bootstrap.py#L10
MAVLINK_ROUTER_COMMIT="94c4e3c6a9ff7c517b20b417e232caf52f12a6c6"
sudo apt install shellcheck
npm install eslint eslint-plugin-vue eslint-plugin-html --save-dev
npm install \
eslint eslint-plugin-vue eslint-plugin-html \
@vue/eslint-config-typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin typescript \
--save-dev
rafaellehmkuhl marked this conversation as resolved.
Show resolved Hide resolved
python -m pip install --upgrade pip
pip install wheel # wheel need to be installed before mavproxy
pip install mavproxy
Expand All @@ -51,4 +54,17 @@ jobs:
- uses: actions/upload-artifact@v2
with:
name: coverage
path: htmlcov
path: htmlcov
frontend-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: borales/[email protected]
with:
cmd: --cwd ./core/frontend install
- uses: borales/[email protected]
patrickelectric marked this conversation as resolved.
Show resolved Hide resolved
with:
cmd: --cwd ./core/frontend lint
- uses: borales/[email protected]
with:
cmd: --cwd ./core/frontend build
2 changes: 1 addition & 1 deletion .hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ echo "Running shellcheck..."
git ls-files '*.sh' | xargs --max-lines=1 shellcheck --exclude=SC2005,SC2015,SC2046,SC2086

echo "Running eslint.."
git ls-files '*.js' '*.html' | xargs --max-lines=1 ./node_modules/.bin/eslint
git ls-files '*.js' '*.html' '*.vue' '*.ts' | xargs --max-lines=1 ./node_modules/.bin/eslint

echo "Running isort.."
# Run isort for each python project
Expand Down
4 changes: 3 additions & 1 deletion core/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
**/.coverage
**/.mypy_cache
**/.pytest_cache
**/*.pyc
**/*.pyc
**/node_modules
**/dist
9 changes: 9 additions & 0 deletions core/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
FROM node:current-buster-slim AS frontendBuilder

# Build frontend
COPY frontend /home/pi/frontend
RUN cd /home/pi/frontend && yarn install && yarn build --skip-plugins @vue/cli-plugin-eslint

FROM bluerobotics/companion-base:v0.0.1

# Install necessary tools
Expand All @@ -23,5 +29,8 @@ COPY services /home/pi/services
COPY start-companion-core /usr/bin/start-companion-core
RUN /home/pi/services/install-services.sh

# Copy frontend built on frontendBuild to this stage
patrickelectric marked this conversation as resolved.
Show resolved Hide resolved
COPY --from=frontendBuilder /home/pi/frontend/dist /home/pi/frontend

# Start
ENTRYPOINT /usr/bin/start-companion-core && sleep infinity
1 change: 1 addition & 0 deletions core/frontend/.eslintrc.js
2 changes: 2 additions & 0 deletions core/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
71 changes: 71 additions & 0 deletions core/frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"name": "companion-frontend",
"version": "0.1.0",
"private": true,
"vue": {
"transpileDependencies": [
"vuetify"
],
"pwa": {
"name": "Companion",
"themeColor": "#08c",
"appleMobileWebAppCapable": "yes",
"appleMobileWebAppStatusBarStyle": "white",
"manifestOptions": {
"background_color": "#FFFFFF"
},
"iconPaths": {
"favicon32": "img/icons/favicon-32x32.png",
"favicon16": "img/icons/favicon-16x16.png",
"appleTouchIcon": "img/icons/apple-touch-icon.png"
}
}
},
"babel": {
"presets": [
"@vue/cli-plugin-babel/preset"
]
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
],
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@mdi/font": "^5.9.55",
"core-js": "^3.6.5",
"register-service-worker": "^1.7.1",
"roboto-fontface": "*",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vuetify": "^2.4.0",
"vuex": "^3.4.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.18.0",
"@typescript-eslint/parser": "^4.18.0",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-pwa": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-typescript": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-typescript": "^7.0.0",
"eslint": "^7.29.0",
"eslint-plugin-html": "^6.1.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-vue": "^7.11.1",
"sass": "~1.32.0",
"sass-loader": "^10.0.0",
"typescript": "~4.1.5",
"vue-cli-plugin-vuetify": "~2.4.1",
"vue-template-compiler": "^2.6.11",
"vuetify-loader": "^1.7.0"
}
}
Binary file added core/frontend/public/favicon.ico
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/frontend/public/img/icons/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/frontend/public/img/icons/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions core/frontend/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
78 changes: 78 additions & 0 deletions core/frontend/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<template>
<v-app>
<v-card
flat
>
<v-app-bar
color="#08c"
rounded="0"
>
<v-app-bar-nav-icon
color="white"
@click="drawer = true"
/>

<v-spacer />
</v-app-bar>
</v-card>

<v-navigation-drawer
v-model="drawer"
absolute
temporary
>
<v-list
nav
dense
>
<v-list-item-group
active-class="deep-blue--text text--accent-4"
>
<v-card
elevation="0"
class="d-flex justify-center"
>
<v-img
alt="Blue Robotics Logo"
class="shrink mr-2"
contain
src="./assets/logo.svg"
width="60"
/>
</v-card>

<v-card
elevation="0"
height="30"
class="pa-4"
>
<v-divider />
</v-card>

<v-list-item to="/">
<v-list-item-icon>
<v-icon>mdi-home</v-icon>
</v-list-item-icon>
<v-list-item-title>Main</v-list-item-title>
</v-list-item>
</v-list-item-group>
</v-list>
</v-navigation-drawer>

<v-main>
<router-view />
</v-main>
</v-app>
</template>

<script lang="ts">
import Vue from 'vue'

export default Vue.extend({
name: 'App',

data: () => ({
drawer: false,
}),
})
</script>
1 change: 1 addition & 0 deletions core/frontend/src/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions core/frontend/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import vuetify from './plugins/vuetify'

new Vue({
router,
store,
vuetify,
render: (h) => h(App),
}).$mount('#app')
11 changes: 11 additions & 0 deletions core/frontend/src/plugins/vuetify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import '@mdi/font/css/materialdesignicons.css'
import Vue from 'vue'
import Vuetify from 'vuetify/lib/framework'

Vue.use(Vuetify)

export default new Vuetify({
icons: {
iconfont: 'mdi',
},
})
21 changes: 21 additions & 0 deletions core/frontend/src/router/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import Main from '../views/MainView.vue'

Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
{
path: '/',
name: 'Main',
component: Main,
},
]

const router = new VueRouter({
mode: 'history',
base: process.env.BASE_URL,
routes,
})

export default router
15 changes: 15 additions & 0 deletions core/frontend/src/store/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
state: {
},
mutations: {
},
actions: {
},
modules: {
},
})
4 changes: 4 additions & 0 deletions core/frontend/src/types/shims-general.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.svg' {
const value: string
export default value
}
13 changes: 13 additions & 0 deletions core/frontend/src/types/shims-tsx.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Vue, { VNode } from 'vue'

declare global {
namespace JSX {
// tslint:disable no-empty-interface
interface Element extends VNode {}
// tslint:disable no-empty-interface
interface ElementClass extends Vue {}
interface IntrinsicElements {
[elem: string]: any
}
}
}
5 changes: 5 additions & 0 deletions core/frontend/src/types/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.vue' {
import Vue from 'vue'

export default Vue
}
5 changes: 5 additions & 0 deletions core/frontend/src/types/shims-vuetify.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module 'vuetify/lib/framework' {
import Vuetify from 'vuetify'

export default Vuetify
}
11 changes: 11 additions & 0 deletions core/frontend/src/views/MainView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<v-container>Main</v-container>
</template>

<script lang="ts">
import Vue from 'vue'

export default Vue.extend({
name: 'Main',
})
</script>
Loading