-
Notifications
You must be signed in to change notification settings - Fork 1
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
added docker support and debounce logic on door open button #1
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
COMPOSE_PROJECT_NAME=space-initlab | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM node:18-alpine | ||
|
||
RUN apk add --no-cache make gcc g++ bash git python3 py3-pip | ||
|
||
WORKDIR /etc/app | ||
|
||
COPY package.json package.json | ||
COPY yarn.lock . | ||
RUN yarn | ||
|
||
# copy files | ||
COPY src . | ||
COPY public . | ||
COPY index.html . | ||
COPY vite.config.js . | ||
COPY .env.development . | ||
|
||
# RUN bash bin/build.sh | ||
|
||
CMD ["yarn", "dev"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
version: '3' | ||
networks: | ||
lan: | ||
external: true | ||
internal: | ||
external: false | ||
services: | ||
app: | ||
build: | ||
context: ../ | ||
dockerfile: ./docker/Dockerfile | ||
volumes: | ||
- '../src:/etc/app/src' | ||
- '../public:/etc/app/public' | ||
- '../index.html:/etc/app/index.html' | ||
- '../vite.config.js:/etc/app/vite.config' | ||
- '../.env.development:/etc/app/.env.development' | ||
networks: | ||
- internal | ||
- lan | ||
# ports: | ||
# - '1234:1234' | ||
labels: | ||
- traefik.enable=true | ||
- traefik.http.routers.space-initlab.rule=Host(`space.initlab.lan`) | ||
- traefik.http.routers.space-initlab.service=dashboard | ||
- traefik.http.services.space-initlab.loadbalancer.server.port=5173 | ||
- traefik.http.routers.space-initlab-secure.rule=Host(`space.initlab.lan`) | ||
- traefik.http.routers.space-initlab-secure.service=space-initlab | ||
- traefik.http.routers.space-initlab-secure.entrypoints=websecure | ||
- traefik.http.routers.space-initlab-secure.tls |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"dev": "vite --no-open --host 0.0.0.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move these parameters to Dockerfile CMD line |
||
"build": "vite build", | ||
"preview": "vite preview", | ||
"lint": "eslint --ext .js,.jsx src/" | ||
|
@@ -17,6 +17,7 @@ | |
"bootstrap": "^5.3.1", | ||
"bootswatch": "^5.3.1", | ||
"date-fns": "^2.30.0", | ||
"debounce": "^2.0.0", | ||
"i18next": "^23.5.1", | ||
"i18next-http-backend": "^2.2.2", | ||
"js-pkce": "^1.3.0", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import './DeviceActionButton.scss'; | |
import { useDeviceActionMutation } from '../../features/apiSlice.js'; | ||
import RedirectToLogin from '../RedirectToLogin.jsx'; | ||
import { sleep } from '../../utils/time.js'; | ||
import debounce from 'debounce'; | ||
|
||
const types = { | ||
open: { | ||
|
@@ -50,15 +51,19 @@ const DeviceActionButton = ({ | |
icon: '', | ||
}; | ||
|
||
const openDoor = debounce(execute, 2000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep the timeout at 3000, since the door mechanisms are open for at least 3 seconds and there is no reason to request opening again. Also this is a generic function that is used for both doors and lights (and other things in the future) so please either use a more generic name like executeDelayed or limit debouncing to just the door device type. |
||
|
||
async function handleClick() { | ||
setDisabled(true); | ||
|
||
await execute({ | ||
deviceId, | ||
action, | ||
}); | ||
// await execute({ | ||
// deviceId, | ||
// action, | ||
// }); | ||
Comment on lines
+59
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove the old code, it can be easily recovered from the Git history. |
||
|
||
openDoor({deviceId, action}); | ||
|
||
await sleep(3000); | ||
// await sleep(3000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
setDisabled(false); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a new line at the end of the file.