Merge branch 'vite-migration' into 'master'

Vite migration

See merge request mcrapts/sensor-web-v2!1
This commit is contained in:
2022-05-06 10:24:40 +00:00
18 changed files with 3947 additions and 12529 deletions

10
.eslintrc.cjs Normal file
View File

@@ -0,0 +1,10 @@
/* 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'],
env: {
'vue/setup-compiler-macros': true
}
}

View File

@@ -1,4 +1,4 @@
FROM node:10-slim FROM node:16-slim
WORKDIR /app WORKDIR /app
COPY package*.json ./ COPY package*.json ./
RUN npm install RUN npm install

View File

@@ -1,29 +1,35 @@
# sensor-web-v2 # vue-project
## Project setup This template should help get you started developing with Vue 3 in Vite.
```
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.vscode-typescript-vue-plugin).
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install npm install
``` ```
### Compiles and hot-reloads for development ### Compile and Hot-Reload for Development
```
npm run serve ```sh
npm run dev
``` ```
### Compiles and minifies for production ### Compile and Minify for Production
```
```sh
npm run build npm run build
``` ```
### Run your tests ### Lint with [ESLint](https://eslint.org/)
```
npm run test
```
### Lints and fixes files ```sh
```
npm run lint npm run lint
``` ```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

View File

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

12
docker-compose.yml Normal file
View File

@@ -0,0 +1,12 @@
version: "3.8"
services:
frontend:
build:
context: ./
network: host
env_file: .env
image: sensor-web-v2
ports:
- 3000:3000
restart: unless-stopped
container_name: sensor-web-v2

13
index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dht22</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

16262
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,57 +1,30 @@
{ {
"name": "sensor-web-v2", "name": "sensor-web-v2",
"version": "0.1.0", "version": "1.0.0",
"private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve --port 8080", "dev": "vite",
"build": "vue-cli-service build", "build": "vite build",
"lint": "vue-cli-service lint" "preview": "vite preview --port 5050",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore"
}, },
"dependencies": { "dependencies": {
"dayjs": "^1.8.14", "bulma": "^0.9.3",
"dotenv": "^8.0.0", "dayjs": "^1.11.1",
"express": "^4.17.1", "dotenv": "^16.0.0",
"highcharts": "^7.1.2", "express": "^4.18.1",
"mongodb": "^3.2.7", "highcharts": "^10.1.0",
"vue": "^3.0.3", "mongodb": "^4.5.0",
"vue-router": "^4.0.0-rc.5" "sass": "^1.51.0",
"vue": "^3.2.33",
"vue-router": "^4.0.14"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "^4.5.4", "@rushstack/eslint-patch": "^1.1.0",
"@vue/cli-plugin-eslint": "^4.5.4", "@vitejs/plugin-vue": "^2.3.1",
"@vue/cli-service": "^4.5.4", "@vue/eslint-config-prettier": "^7.0.0",
"@vue/compiler-sfc": "^3.0.3", "eslint": "^8.5.0",
"@vue/eslint-config-standard": "^4.0.0", "eslint-plugin-vue": "^8.2.0",
"babel-eslint": "^10.1.0", "prettier": "^2.5.1",
"bulma": "^0.7.5", "vite": "^2.9.5"
"eslint": "^6.7.2", }
"eslint-plugin-vue": "^7.1.0",
"node-sass": "^4.12.0",
"sass-loader": "^8.0.2"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"@vue/standard"
],
"rules": {
"space-before-function-paren": "off"
},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
} }

View File

@@ -1,17 +0,0 @@
<!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="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌡️</text></svg>">
<title>dht22</title>
</head>
<body>
<noscript>
<strong>We're sorry but sensor-web-v2 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>

View File

@@ -1,3 +1,4 @@
/* eslint-env node */
require('dotenv').config() require('dotenv').config()
const express = require('express') const express = require('express')
const app = express() const app = express()
@@ -6,7 +7,7 @@ const mongo = require('mongodb')
const MongoClient = mongo.MongoClient const MongoClient = mongo.MongoClient
console.log('Starting with parameters:') console.log('Starting with parameters:')
const parameters = ['PORT', 'MONGO_SERVER', 'MONGO_DB'] const parameters = ['PORT', 'MONGO_SERVER', 'MONGO_DB']
parameters.forEach(parameter => console.log(`${parameter}=${process.env[parameter]}`)) parameters.forEach((parameter) => console.log(`${parameter}=${process.env[parameter]}`))
app.listen(process.env.PORT, () => { app.listen(process.env.PORT, () => {
console.log('Listening on ' + process.env.PORT) console.log('Listening on ' + process.env.PORT)
}) })
@@ -50,7 +51,7 @@ app.get('/type/:type/startDate/:startDate/endDate/:endDate/sample/:sample', asyn
const docs = await db.collection('dht22').find(query).toArray() const docs = await db.collection('dht22').find(query).toArray()
const sampledDocs = docs const sampledDocs = docs
.filter((value, index) => index % sample === 0) .filter((value, index) => index % sample === 0)
.map(doc => { .map((doc) => {
return { ...doc, date: dateFromObjectId(doc._id) } return { ...doc, date: dateFromObjectId(doc._id) }
}) })
res.json(sampledDocs) res.json(sampledDocs)

View File

@@ -8,7 +8,7 @@
import { ref, watch, toRefs, nextTick } from 'vue' import { ref, watch, toRefs, nextTick } from 'vue'
import Highcharts from 'highcharts' import Highcharts from 'highcharts'
import 'highcharts/css/highcharts.scss' import 'highcharts/css/highcharts.scss'
import Loader from '@/components/Loader' import Loader from '@/components/Loader.vue'
import { capitalizeFirstLetter } from '@/utils/helpers' import { capitalizeFirstLetter } from '@/utils/helpers'
Highcharts.setOptions({ Highcharts.setOptions({

View File

@@ -11,9 +11,9 @@
<script> <script>
import { ref } from 'vue' import { ref } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import NavBar from '@/components/NavBar' import NavBar from '@/components/NavBar.vue'
import TimeWindows from '@/components/TimeWindows' import TimeWindows from '@/components/TimeWindows.vue'
import Chart from '@/components/Chart' import Chart from '@/components/Chart.vue'
export default { export default {
components: { components: {
NavBar, NavBar,

View File

@@ -1,5 +1,5 @@
import { createApp } from 'vue' import { createApp } from 'vue'
import App from '@/App' import App from '@/App.vue'
import router from '@/router' import router from '@/router'
import '@/style/style.scss' import '@/style/style.scss'

View File

@@ -1,8 +1,7 @@
import { createRouter, createWebHistory } from 'vue-router' import { createRouter, createWebHistory } from 'vue-router'
import Main from '@/components/Main' import Main from '@/components/Main.vue'
export default createRouter({ export default createRouter({
history: createWebHistory(), history: createWebHistory(import.meta.env.BASE_URL),
base: process.env.BASE_URL,
routes: [ routes: [
{ {
path: '/:type?/:window?', path: '/:type?/:window?',

View File

@@ -4,4 +4,4 @@ $tabs-link-active-border-bottom-color: #3498db;
$family-sans-serif: 'Fira Sans', sans-serif; $family-sans-serif: 'Fira Sans', sans-serif;
$gap: 32px !default; $gap: 32px !default;
$navbar-breakpoint: 960px + (2 * $gap); $navbar-breakpoint: 960px + (2 * $gap);
@import "~bulma/sass/utilities/_all.sass"; @import "bulma/sass/utilities/_all.sass";

View File

@@ -5,4 +5,4 @@ html, body {
overflow: auto!important; overflow: auto!important;
} }
@import "./variables"; @import "./variables";
@import "~bulma/bulma"; @import "bulma/bulma";

17
vite.config.js Normal file
View File

@@ -0,0 +1,17 @@
import { fileURLToPath, URL } from 'url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
port: '8080'
}
})

View File

@@ -1,3 +0,0 @@
module.exports = {
productionSourceMap: false
}