init web ui (Vue & Shoelace), implement example path lookup

feat/vaults
Tomáš Mládek 2020-08-30 02:19:46 +02:00
parent 0b24990436
commit 0d8d585161
19 changed files with 13241 additions and 0 deletions

3
ui/.browserslistrc Normal file
View File

@ -0,0 +1,3 @@
> 1%
last 2 versions
not dead

5
ui/.editorconfig Normal file
View File

@ -0,0 +1,5 @@
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

2
ui/.env Normal file
View File

@ -0,0 +1,2 @@
VUE_APP_TITLE=UpEnd
VUE_APP_ASSET_PATH="assets"

18
ui/.eslintrc.js Normal file
View File

@ -0,0 +1,18 @@
module.exports = {
root: true,
env: {
node: true
},
extends: [
"eslint:recommended",
"plugin:vue/essential",
"@vue/typescript/recommended"
],
parserOptions: {
ecmaVersion: 2020
},
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off"
}
};

23
ui/.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

24
ui/README.md Normal file
View File

@ -0,0 +1,24 @@
# upend
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

5
ui/babel.config.js Normal file
View File

@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

12923
ui/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

37
ui/package.json Normal file
View File

@ -0,0 +1,37 @@
{
"name": "upend",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@shoelace-style/shoelace": "^2.0.0-beta.16",
"core-js": "^3.6.5",
"vue": "^2.6.11",
"vue-class-component": "^7.2.3",
"vue-property-decorator": "^8.4.2",
"vue-router": "^3.2.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0",
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-typescript": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/eslint-config-standard": "^5.1.2",
"@vue/eslint-config-typescript": "^5.0.2",
"eslint": "^6.7.2",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^6.2.2",
"typescript": "~3.9.3",
"vue-template-compiler": "^2.6.11"
}
}

17
ui/public/index.html Normal file
View File

@ -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>

12
ui/src/App.vue Normal file
View File

@ -0,0 +1,12 @@
<template>
<div id="app">
<router-view />
</div>
</template>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
color: #2c3e50;
}
</style>

34
ui/src/main.ts Normal file
View File

@ -0,0 +1,34 @@
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import "@shoelace-style/shoelace/dist/shoelace/shoelace.css";
import { defineCustomElements, setAssetPath } from "@shoelace-style/shoelace";
import { VNode } from "vue/types/umd";
import { DirectiveBinding } from "vue/types/options";
setAssetPath(`${window.location.origin}/${process.env.VUE_APP_ASSET_PATH}/`);
defineCustomElements();
interface SlInput extends HTMLElement {
value: string;
}
Vue.directive("sl-model", {
inserted: (element: Element, binding: DirectiveBinding, vnode) => {
element.addEventListener("slInput", event => {
const val = (event?.srcElement as SlInput | undefined)?.value;
if (val) {
(vnode as any).context[binding.expression] = val;
}
});
}
});
Vue.config.ignoredElements = [/^sl-/];
Vue.config.productionTip = false;
new Vue({
router,
render: h => h(App)
}).$mount("#app");

27
ui/src/router/index.ts Normal file
View File

@ -0,0 +1,27 @@
import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import Home from '../views/Home.vue'
Vue.use(VueRouter)
const routes: Array<RouteConfig> = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
}
]
const router = new VueRouter({
routes
})
export default router

13
ui/src/shims-tsx.d.ts vendored Normal file
View File

@ -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;
}
}
}

4
ui/src/shims-vue.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}

5
ui/src/views/About.vue Normal file
View File

@ -0,0 +1,5 @@
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>

28
ui/src/views/Home.vue Normal file
View File

@ -0,0 +1,28 @@
<template>
<div class="home">
<sl-input placeholder="Search" v-sl-model="searchQuery">
<sl-icon name="search" slot="prefix"></sl-icon>
</sl-input>
<ul>
<li v-for="result in results" :key="result.id">{{ result.path }}</li>
</ul>
</div>
</template>
<script lang="ts">
import { Component, Vue, Watch } from "vue-property-decorator";
@Component
export default class Home extends Vue {
private searchQuery = "";
private results = [];
@Watch("searchQuery")
private async onSearchQueryChange() {
const response = await fetch(
`/api/lookup?${new URLSearchParams({ query: this.searchQuery })}`
);
this.results = await response.json();
}
}
</script>

40
ui/tsconfig.json Normal file
View File

@ -0,0 +1,40 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}

21
ui/vue.config.js Normal file
View File

@ -0,0 +1,21 @@
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
module.exports = {
chainWebpack: config => {
config.plugin("copy-icons").use(CopyPlugin, [
[
{
from: path.resolve(
__dirname,
"node_modules/@shoelace-style/shoelace/dist/shoelace/icons"
),
to: path.resolve(__dirname, "dist/assets/icons")
}
]
]);
config.devServer.proxy({
"/api": { target: "http://localhost:8093" }
});
}
};