Skip to content

Commit

Permalink
Nuxt frontend (#100)
Browse files Browse the repository at this point in the history
* rework frontend with nuxt

* replace npm proxy to official npm

* fix ci

* add more implements

* clean unused config and views

* add cache stage for release workflow

* edit helpdesk title
  • Loading branch information
LeoQuote committed Nov 22, 2021
1 parent f97c79c commit 04fc5f2
Show file tree
Hide file tree
Showing 69 changed files with 18,355 additions and 22,754 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ jobs:

- name: Check out code
uses: actions/checkout@v2

- run: npm install
- name: Cache node_modules 📦
uses: actions/cache@v2.1.4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci --prefer-offline --no-audit
working-directory: frontend
- run: npm run lint
working-directory: frontend
- run: npm run test:unit
working-directory: frontend
- run: npm run build
- run: npm run generate
working-directory: frontend
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2
Expand Down
27 changes: 19 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,29 @@ jobs:
runs-on: ubuntu-latest
steps:

- uses: actions/setup-node@v1
- name: Checkout 🛎
uses: actions/checkout@master

- name: Setup node env 🏗
uses: actions/setup-node@v2.1.5
with:
node-version: '12'
node-version: ${{ matrix.node }}
check-latest: true

- name: Check out code
uses: actions/checkout@v2
- name: Cache node_modules 📦
uses: actions/cache@v2.1.4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm install
working-directory: frontend
- run: npm run lint
- name: Install dependencies 👨🏻‍💻
run: npm ci --prefer-offline --no-audit
working-directory: frontend
- run: npm run test:unit

- name: Run linter 👀
run: npm run lint
working-directory: frontend
backend:
name: Build backend
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ First make sure you have installed latest [nodejs](https://nodejs.org/en/downloa
```
cd frontend
npm install
npm start
npm run dev
```
Follow the link in the console.

Expand Down
2 changes: 1 addition & 1 deletion frontend/.dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules
node_modules
13 changes: 13 additions & 0 deletions frontend/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
20 changes: 20 additions & 0 deletions frontend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
root: true,
env: {
browser: true,
node: true
},
parserOptions: {
parser: '@babel/eslint-parser',
requireConfigFile: false
},
extends: [
'@nuxtjs',
'plugin:nuxt/recommended',
'prettier'
],
plugins: [
],
// add your custom rules here
rules: {}
}
106 changes: 85 additions & 21 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,90 @@
.DS_Store
node_modules
/dist

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

# Log files
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
/logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# Nuxt generate
dist

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# IDE / Editor
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# test reports
/test/unit/coverage/
/test/e2e/reports/

# Service worker
sw.*

# macOS
.DS_Store

# Vim swap files
*.swp
4 changes: 4 additions & 0 deletions frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"semi": false,
"singleQuote": true
}
81 changes: 63 additions & 18 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,69 @@
# helpdesk
# helpdesk-frontend

## Project setup
```
npm install
```
## Build Setup

### Compiles and hot-reloads for development
```
npm run serve
```
```bash
# install dependencies
$ npm install

### Compiles and minifies for production
```
npm run build
```
# serve with hot reload at localhost:3000
$ npm run dev

### Lints and fixes files
```
npm run lint
# build for production and launch server
$ npm run build
$ npm run start

# generate static project
$ npm run generate
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
For detailed explanation on how things work, check out the [documentation](https://nuxtjs.org).

## Special Directories

You can create the following extra directories, some of which have special behaviors. Only `pages` is required; you can delete them if you don't want to use their functionality.

### `assets`

The assets directory contains your uncompiled assets such as Stylus or Sass files, images, or fonts.

More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/assets).

### `components`

The components directory contains your Vue.js components. Components make up the different parts of your page and can be reused and imported into your pages, layouts and even other components.

More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/components).

### `layouts`

Layouts are a great help when you want to change the look and feel of your Nuxt app, whether you want to include a sidebar or have distinct layouts for mobile and desktop.

More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/layouts).


### `pages`

This directory contains your application views and routes. Nuxt will read all the `*.vue` files inside this directory and setup Vue Router automatically.

More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/get-started/routing).

### `plugins`

The plugins directory contains JavaScript plugins that you want to run before instantiating the root Vue.js Application. This is the place to add Vue plugins and to inject functions or constants. Every time you need to use `Vue.use()`, you should create a file in `plugins/` and add its path to plugins in `nuxt.config.js`.

More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/plugins).

### `static`

This directory contains your static files. Each file inside this directory is mapped to `/`.

Example: `/static/robots.txt` is mapped as `/robots.txt`.

More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/static).

### `store`

This directory contains your Vuex store files. Creating a file in this directory automatically activates Vuex.

More information about the usage of this directory in [the documentation](https://nuxtjs.org/docs/2.x/directory-structure/store).
5 changes: 0 additions & 5 deletions frontend/babel.config.js

This file was deleted.

36 changes: 36 additions & 0 deletions frontend/components/DynamicForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<div>
<component :is="getComponent(field)"
v-for="(field, index) in schema"
:key="index"
:value="formData[field.name]"
v-bind="field"
@input="updateForm(field.name, $event)">
</component>
</div>
</template>

<script>
export default {
name: 'DynamicForm',
props: ['schema', 'value'],
data () {
return {}
},
computed: {
formData () {
return this.value || {}
}
},
methods: {
updateForm (fieldName, v) {
this.$set(this.formData, fieldName, v)
this.$emit('input', this.formData)
},
getComponent(field) {
return "FormWidgets" + field.fieldType
}
}
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
:wrapper-col="{ span: 12 }"
>
<a-checkbox
@change="onCheckBoxChange"
:checked="value"
v-decorator="decorator"
:checked="value"
@change="onCheckBoxChange"
>
</a-checkbox>
</a-form-item>
Expand All @@ -18,18 +18,18 @@
export default {
name: 'CheckBoxInput',
props: ['label', 'name', 'value', 'extra'],
methods: {
onCheckBoxChange (event) {
this.$emit('input', event.target.checked)
}
},
computed: {
decorator () {
return [
this.name, {
rules: [{required: this.required, message: 'This field is required'}]
}]
}
},
methods: {
onCheckBoxChange (event) {
this.$emit('input', event.target.checked)
}
}
}
</script>
Expand Down
Loading

0 comments on commit 04fc5f2

Please sign in to comment.