Jwitt #1

Merged
jwitt merged 7 commits from Jwitt into main 2 years ago

@ -1,14 +1,14 @@
/* 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'
],
parserOptions: {
ecmaVersion: 'latest'
}
}
/* 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'
],
parserOptions: {
ecmaVersion: 'latest'
}
}

56
.gitignore vendored

@ -1,28 +1,28 @@
# 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
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# 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
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

@ -1,8 +1,8 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}

@ -1,3 +1,3 @@
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}

@ -1,35 +1,35 @@
# alarm-web-client
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=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
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Compile and Minify for Production
```sh
npm run build
```
### Lint with [ESLint](https://eslint.org/)
```sh
npm run lint
```
# alarm-web-client
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=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
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Compile and Minify for Production
```sh
npm run build
```
### Lint with [ESLint](https://eslint.org/)
```sh
npm run lint
```

@ -1,13 +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>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
<!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>Alarm Control Page</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

11918
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,26 +1,29 @@
{
"name": "alarm-web-client",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
"format": "prettier --write src/"
},
"dependencies": {
"vue": "^3.3.4",
"vue-router": "^4.2.4"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.3.2",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.0.1",
"@vue/eslint-config-prettier": "^8.0.0",
"eslint": "^8.45.0",
"eslint-plugin-vue": "^9.15.1",
"prettier": "^3.0.0",
"vite": "^4.4.6"
}
}
{
"name": "alarm-web-client",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
"format": "prettier --write src/"
},
"dependencies": {
"vue": "^3.3.4",
"vue-router": "^4.2.4"
},
"devDependencies": {
"@iconify/vue": "^4.1.1",
"@rushstack/eslint-patch": "^1.3.2",
"@vitejs/plugin-vue": "^4.2.3",
"@vitejs/plugin-vue-jsx": "^3.0.1",
"@vue/eslint-config-prettier": "^8.0.0",
"eslint": "^8.45.0",
"eslint-plugin-vue": "^9.15.1",
"prettier": "^3.0.0",
"sass": "^1.66.1",
"uid": "^2.0.2",
"vite": "^4.4.6"
}
}

@ -1,9 +1,28 @@
<script setup>
</script>
<template>
<RouterView />
</template>
<style scoped>
</style>
<script setup>
</script>
<template>
<RouterView />
</template>
<style lang="scss">
// None of this works, and at this point I don't really care.
body {
margin: auto;
width: 10%;
padding: 10px;
background-color: #1e6e6a;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container {
max-width: 1100px;
margin: 0 auto;
}
</style>

@ -1,44 +1,49 @@
<script>
export default {
name: "AlarmState",
data() {
return {
status: "",
timerId: undefined
}
},
created() {
// watch the params of the route to fetch the data again
// this.$watch(
// () => this.$route.params,
// () => {
// this.fetchData()
// },
// // fetch the data when the view is created and the data is
// // already being observed
// { immediate: true }
// )
this.fetchData();
this.timerId = setInterval(this.fetchData.bind(this), 2000);
},
methods: {
async fetchData() {
const res = await fetch(`${import.meta.env.VITE_BASE_API_URL}/alarm/state`);
const data = await res.json();
this.status = data.status;
},
},
beforeDestroy() {
clearInterval(this.timerId)
},
}
</script>
<template>
<div>
Current alarm state: {{ status }}
</div>
</template>
<style scoped></style>
<script>
export default {
name: "AlarmState",
data() {
return {
status: "",
timerId: undefined
}
},
created() {
// watch the params of the route to fetch the data again
// this.$watch(
// () => this.$route.params,
// () => {
// this.fetchData()
// },
// // fetch the data when the view is created and the data is
// // already being observed
// { immediate: true }
// )
this.fetchData();
this.timerId = setInterval(this.fetchData.bind(this), 2000);
},
methods: {
async fetchData() {
const res = await fetch(`${import.meta.env.VITE_BASE_API_URL}/alarm/state`);
const data = await res.json();
this.status = data.status;
},
},
beforeDestroy() {
clearInterval(this.timerId)
},
}
</script>
<template>
<div>
Current alarm state: {{ status }}
<br>
<br>
</div>
</template>
<style scoped>
</style>

@ -1,48 +1,50 @@
<script>
import States from "../states"
export default {
name: "AlarmState",
data() {
return {
status: "",
timerId: undefined,
text: ""
}
},
created() {
this.fetchData();
this.timerId = setInterval(this.fetchData.bind(this), 2000);
},
methods: {
async fetchData() {
const res = await fetch(`${import.meta.env.VITE_BASE_API_URL}/alarm/state`);
const data = await res.json();
this.status = data.status;
if (this.status === States.Disarmed) {
this.text = "Arm";
} else {
this.text = "Disarm";
}
},
async buttonPressed() {
const res = await fetch(`${import.meta.env.VITE_BASE_API_URL}/alarm/${this.status === States.Disarmed ? "arm" : "disarm"}`, {
method: "POST"
});
const data = await res.json();
this.fetchData();
}
},
beforeDestroy() {
clearInterval(this.timerId)
},
}
</script>
<template>
<button @click="buttonPressed">
{{ text }} Alarm
</button>
</template>
<style scoped></style>
<script>
import States from "../states"
export default {
name: "AlarmState",
data() {
return {
status: "",
timerId: undefined,
text: ""
}
},
created() {
this.fetchData();
this.timerId = setInterval(this.fetchData.bind(this), 2000);
},
methods: {
async fetchData() {
const res = await fetch(`${import.meta.env.VITE_BASE_API_URL}/alarm/state`);
const data = await res.json();
this.status = data.status;
if (this.status === States.Disarmed) {
this.text = "Arm";
} else {
this.text = "Disarm";
}
},
async buttonPressed() {
const res = await fetch(`${import.meta.env.VITE_BASE_API_URL}/alarm/${this.status === States.Disarmed ? "arm" : "disarm"}`, {
method: "POST"
});
const data = await res.json();
this.fetchData();
}
},
beforeDestroy() {
clearInterval(this.timerId)
},
}
</script>
<template>
<button @click="buttonPressed">
{{ text }} Alarm
</button>
</template>
<style scoped>
</style>

@ -1,9 +1,9 @@
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
const app = createApp(App)
app.use(router)
app.mount('#app')
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
const app = createApp(App)
app.use(router)
app.mount('#app')

@ -1,23 +1,23 @@
import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: HomeView
},
// {
// 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('../views/AboutView.vue')
// }
]
})
export default router
import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: HomeView
},
// {
// 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('../views/AboutView.vue')
// }
]
})
export default router

@ -1,7 +1,7 @@
export default {
Armed: "Armed",
Disarmed: "Disarmed",
Triggered: "Triggered",
Arming: "Arming",
Disarming: "Disarming"
export default {
Armed: "Armed",
Disarmed: "Disarmed",
Triggered: "Triggered",
Arming: "Arming",
Disarming: "Disarming"
};

@ -1,15 +1,17 @@
<script setup>
import AlarmState from '../components/AlarmState.vue';
import ChangeState from '../components/ChangeState.vue';
</script>
<template>
<div id="Home">
<AlarmState />
<ChangeState />
</div>
</template>
<style scoped>
</style>
<script setup>
import AlarmState from '../components/AlarmState.vue';
import ChangeState from '../components/ChangeState.vue';
</script>
<template>
<div id="Home" >
<AlarmState />
<ChangeState />
</div>
</template>
<style scoped>
</style>

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

Loading…
Cancel
Save