25 Commits

Author SHA1 Message Date
Adrian Zürcher
33f7775800 .
Some checks failed
Build Quasar SPA and Go Backend for lightController / build (arm, 6, , linux, ubuntu-latest) (push) Successful in 6m30s
Build Quasar SPA and Go Backend for lightController / build (amd64, , linux, ubuntu-latest) (push) Successful in 6m39s
Build Quasar SPA and Go Backend for lightController / build (arm64, , linux, ubuntu-latest) (push) Successful in 4m30s
Build Quasar SPA and Go Backend for lightController / build (amd64, .exe, windows, windows-latest) (push) Has been cancelled
2025-08-11 10:52:31 +02:00
Adrian Zürcher
ac412bbffb fix npm for windows 2025-08-11 10:51:50 +02:00
Adrian Zürcher
6f532ef4b0 fix repo links
Some checks failed
Build Quasar SPA and Go Backend for lightController / build (amd64, .exe, windows) (push) Failing after 1m30s
Build Quasar SPA and Go Backend for lightController / build (amd64, , linux) (push) Successful in 6m1s
Build Quasar SPA and Go Backend for lightController / build (arm, 6, , linux) (push) Successful in 6m9s
Build Quasar SPA and Go Backend for lightController / build (arm64, , linux) (push) Successful in 4m45s
2025-08-11 10:37:48 +02:00
Adrian Zürcher
1155bafb30 lift version 2025-08-11 10:26:21 +02:00
Adrian Zürcher
0e3a14d69c change repo name
Some checks failed
Build Quasar SPA and Go Backend for lightController / build (amd64, , linux) (push) Failing after 5m18s
Build Quasar SPA and Go Backend for lightController / build (amd64, .exe, windows) (push) Failing after 5m23s
Build Quasar SPA and Go Backend for lightController / build (arm64, , linux) (push) Has been cancelled
Build Quasar SPA and Go Backend for lightController / build (arm, 6, , linux) (push) Has been cancelled
2025-08-11 10:25:25 +02:00
Adrian Zuercher
de88b2773c lift version 2025-08-09 18:01:19 +02:00
Adrian Zuercher
1697a4dcfd add new lights, add login and role to it, add services page 2025-08-09 18:00:36 +02:00
Adrian Zuercher
7d2ab814da increment app version 2025-07-31 12:30:18 +02:00
Adrian Zuercher
d50bf9c058 implement driver add update remove and improve rename tree experience 2025-07-31 12:29:16 +02:00
Adrian Zuercher
dac7130544 remove dead file from pull 2025-07-25 18:47:01 +02:00
Adrian Zuercher
7434f02c30 move file 2025-07-25 18:41:13 +02:00
Adrian Zuercher
81b7f96abc make new folder for reuse ngLib add new features for datatree like change add remove rename datapoints improve pingpong 2025-07-25 18:37:18 +02:00
zuadi
8c506b9af3 Rename dataTable.vue to DataTable.vue
bug fix of file name
2025-07-12 23:33:59 +02:00
Adrian Zuercher
ffb8e4994e optimize subscription model bug fixes 2025-07-12 23:29:44 +02:00
Adrian Zuercher
5b905bac24 lift version 2025-06-29 21:26:56 +02:00
Adrian Zuercher
e320156a47 add automatic localhost and local ip for allowOrigin 2025-06-29 21:26:16 +02:00
Adrian Zuercher
c58dbf34d0 add icon as asset, add refresh button 2025-06-29 20:27:18 +02:00
zuadi
472a446d3a Rename okDialog.vue to OkDialog.vue 2025-06-27 11:07:52 +02:00
Adrian Zuercher
38610471f3 fix scene load and add first version UpdateValueDialog 2025-06-27 11:02:27 +02:00
Adrian Zürcher
707d88fb7f add login to quasar backend 2025-06-19 19:33:27 +02:00
Adrian Zürcher
e5b1dc2052 add scene save and load in quasar backend 2025-06-19 19:33:13 +02:00
Adrian Zürcher
3d865f47b3 implement pong for backend 2025-06-19 19:31:41 +02:00
Adrian Zürcher
51622ac5fd add logo 2025-06-19 19:30:40 +02:00
Adrian Zürcher
3e2b95c1c3 update dbmData and Subscription so it is reactive
new save load scenes
2025-06-19 19:30:28 +02:00
Adrian Zürcher
fd970b6d1f ignore log files 2025-06-19 19:27:32 +02:00
103 changed files with 5338 additions and 1180 deletions

108
.gitea/workflows/build.yml Normal file
View File

@@ -0,0 +1,108 @@
name: Build Quasar SPA and Go Backend for lightController
on:
push:
tags:
- '*'
jobs:
build:
strategy:
matrix:
include:
- os: windows-latest
goos: windows
arch: amd64
ext: .exe
- os: ubuntu-latest
goos: linux
arch: amd64
ext: ""
- os: ubuntu-latest
goos: linux
arch: arm64
ext: ""
- os: ubuntu-latest
goos: linux
arch: arm
arm_version: 6
ext: ""
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependecies
run: npm install
- name: Install Quasar CLI
run: |
npm cache clean --force
npm install -g @quasar/cli --force
- name: Build Quasar SPA
run: quasar build
- name: Ensure latest Go is installed in /data/go
run: |
export GOROOT=/data/go/go
export PATH=$GOROOT/bin:$PATH
export GOCACHE=/data/gocache
export GOMODCACHE=/data/gomodcache
mkdir -p $GOCACHE $GOMODCACHE
if [ ! -x "$GOROOT/bin/go" ]; then
echo "Go not found in $GOROOT, downloading latest stable..."
GO_VERSION=$(curl -s https://go.dev/VERSION?m=text | head -n1)
echo "Latest version is $GO_VERSION"
mkdir -p /data/go
curl -sSL "https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" -o /tmp/go.tar.gz
tar -C /data/go -xzf /tmp/go.tar.gz
else
echo "Using cached Go from $GOROOT"
fi
go version
- name: Go Mod Tidy & Download
working-directory: ./backend
run: |
export GOROOT=/data/go/go
export PATH=$GOROOT/bin:$PATH
export GOCACHE=/data/gocache
export GOMODCACHE=/data/gomodcache
mkdir -p $GOCACHE $GOMODCACHE
go mod tidy -v
go mod download
- name: Build go backend binary
working-directory: ./backend
run: |
export GOROOT=/data/go/go
export PATH=$GOROOT/bin:$PATH
export GOCACHE=/data/gocache
export GOMODCACHE=/data/gomodcache
mkdir -p $GOCACHE $GOMODCACHE
OUTPUT="../server-${{ matrix.goos }}-${{ matrix.goarch }}"
if [ "${{ matrix.goos }}" == "windows" ]; then
OUTPUT="${OUTPUT}.exe"
fi
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -trimpath -o "$OUTPUT" main.go
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: lightcontroller-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
./dist/spa
server-${{ matrix.goos }}-${{ matrix.goarch }}${{ (matrix.goos == 'windows' && '.exe') || '' }}

View File

@@ -1,71 +0,0 @@
name: Build Quasar SPA and Go Backend for lightController
on:
push:
branches: [ main ]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows]
goarch: [amd64, arm, arm64]
exclude:
- goos: windows
goarch: arm
- goos: windows
goarch: arm64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set ip Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependecies
run: npm install
- name: Install Quasar CLI
run: npm install -g @quasar/cli
- name: Build Quasar SPA
run: quasar build
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24.0'
cache-dependency-path: backend/go.sum
- name: Set up Git credentials for private modules
run: |
git config --global url."https://oauth2:${{ secrets.GH_PAT }}@github.com".insteadOf "https://github.com"
env:
GH_PAT_FOR_MODULES: ${{ secrets.GH_PAT }}
- name: Go Mod Tidy & Download
working-directory: ./backend
run: go mod tidy -v
- name: Build go backend binary
working-directory: ./backend
run: |
if [ "${{ matrix.goos }}" == "windows" ]; then
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ../server-${{ matrix.goos }}-${{ matrix.goarch }}.exe main.go
else
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ../server-${{ matrix.goos }}-${{ matrix.goarch }} main.go
fi
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: lightcontroller-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
./dist/spa
server-${{ matrix.goos }}-${{ matrix.goarch }}${{ (matrix.goos == 'windows' && '.exe') || '' }}

7
.gitignore vendored
View File

@@ -14,6 +14,7 @@ node_modules
/src-cordova/www /src-cordova/www
# Capacitor related directories and files # Capacitor related directories and files
/src-capacitor
/src-capacitor/www /src-capacitor/www
/src-capacitor/node_modules /src-capacitor/node_modules
@@ -28,6 +29,7 @@ yarn-error.log*
*.ntvs* *.ntvs*
*.njsproj *.njsproj
*.sln *.sln
*.scene
# local .env files # local .env files
.env.local* .env.local*
@@ -35,5 +37,8 @@ yarn-error.log*
# local .db files # local .db files
*.db *.db
# local .db files # local .log files
*.log *.log
# golang quasar websever executable
backend/server-linux-arm64

View File

@@ -1,84 +0,0 @@
{"level":"info","timestamp":"2025-05-16T11:06:44.126","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-16T11:06:44.144","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-16T11:07:09.600","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-16T11:07:09.639","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-16T11:07:30.646","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T11:11:22.786","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T11:14:07.524","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T11:15:05.782","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T11:18:42.471","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T11:20:08.703","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T11:21:05.334","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T11:22:23.537","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T12:02:20.623","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T12:05:45.885","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T12:06:26.735","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T12:13:05.683","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T12:17:21.288","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T12:17:47.981","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T12:21:30.972","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T12:22:40.192","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T13:29:28.096","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T13:55:38.216","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T13:57:06.877","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T13:58:51.985","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:06:33.530","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:10:23.607","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:12:19.664","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:14:02.375","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:22:41.131","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:23:40.824","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:24:57.025","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:27:28.217","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:27:34.492","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"error","timestamp":"2025-05-16T14:27:34.502","msg":"error http server listen tcp 0.0.0.0:8088: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:27:42.592","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"error","timestamp":"2025-05-16T14:27:42.602","msg":"error http server listen tcp 0.0.0.0:8088: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:28:06.480","msg":"http listen on ip: 0.0.0.0 port: 8088","caller":"main"}
{"level":"error","timestamp":"2025-05-16T14:28:06.490","msg":"error http server listen tcp 0.0.0.0:8088: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:28:12.353","msg":"http listen on ip: 0.0.0.0 port: 8089","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:30:40.412","msg":"http listen on ip: 0.0.0.0 port: 8089","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:32:45.834","msg":"http listen on ip: 0.0.0.0 port: 8089","caller":"main"}
{"level":"info","timestamp":"2025-05-16T14:34:47.410","msg":"http listen on ip: 0.0.0.0 port: 8089","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:22:40.984","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:22:40.995","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:25:45.901","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:25:45.919","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:26:04.544","msg":"http listen on ip: 127.0.0.1 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:26:04.552","msg":"error http server listen tcp 127.0.0.1:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:26:18.968","msg":"http listen on ip: localhost port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:26:18.998","msg":"error http server listen tcp 127.0.0.1:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:26:37.288","msg":"http listen on ip: 0.0.0.0 port: 8080","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:36:02.157","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:36:02.168","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:36:15.150","msg":"http listen on ip: 0.0.0.0 port: 8080","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:42:12.925","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:42:12.935","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:42:23.735","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:42:23.751","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:42:38.098","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:42:38.114","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:43:08.854","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:43:08.867","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:43:33.337","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:43:33.347","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:43:54.154","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:43:54.164","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:44:32.352","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:44:32.370","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:45:16.468","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:45:16.479","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:45:43.373","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:45:43.383","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:45:49.084","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:45:49.103","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:46:03.457","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:46:03.466","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:46:50.673","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:46:50.682","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:47:04.563","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:47:04.571","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:48:25.067","msg":"http listen on ip: 0.0.0.0 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:48:25.080","msg":"error http server listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}
{"level":"info","timestamp":"2025-05-23T21:48:32.148","msg":"http listen on ip: 127.0.0.1 port: 80","caller":"main"}
{"level":"error","timestamp":"2025-05-23T21:48:32.156","msg":"error http server listen tcp 127.0.0.1:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.","caller":"main"}

View File

@@ -1,6 +1,7 @@
package dbRequest package dbRequest
import ( import (
"backend/models"
"fmt" "fmt"
"net/http" "net/http"
@@ -10,25 +11,22 @@ import (
var DBCreate string = `CREATE TABLE IF NOT EXISTS users ( var DBCreate string = `CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT NOT NULL, username TEXT NOT NULL,
role TEXT NOT NULL,
password TEXT NOT NULL password TEXT NOT NULL
);` );`
var DBNewUser string = `INSERT INTO users (username, password) VALUES (?, ?)` var DBNewUser string = `INSERT INTO users (username, role, password) VALUES (?, ?, ?)`
var DBQueryPassword string = `SELECT password FROM users WHERE username = ?` var DBQueryPassword string = `SELECT role, password FROM users WHERE username = ?`
var DBUserLookup string = `SELECT EXISTS(SELECT 1 FROM users WHERE username = ?)` var DBUserLookup string = `SELECT EXISTS(SELECT 1 FROM users WHERE username = ?)`
var DBRemoveUser string = `DELETE FROM users WHERE username = $1` var DBRemoveUser string = `DELETE FROM users WHERE username = $1`
func CheckDBError(c *gin.Context, username string, err error) bool { func CheckDBError(c *gin.Context, username string, err error) bool {
if err != nil { if err != nil {
if err.Error() == "sql: no rows in result set" { if err.Error() == "sql: no rows in result set" {
c.JSON(http.StatusBadRequest, gin.H{ c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse(fmt.Sprintf("no user '%s' found", username)))
"error": fmt.Sprintf("no user '%s' found", username),
})
return true return true
} }
c.JSON(http.StatusBadRequest, gin.H{ c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
"error": err.Error(),
})
return true return true
} }
return false return false

Binary file not shown.

View File

@@ -0,0 +1,28 @@
{
"drivers":[{
"name":"ArtNet",
"description":"ArtNet Driver DMX over UDP/IP",
"executablePath":"bin/tecamino-driver-artNet-linux-arm64",
"workingDirectory":"bin",
"arguments":[
"-cfg './cfg'",
"-serverIp '127.0.0.1'",
"-serverPort 8100",
"-port 8200"
]
},
{
"name":"OSC Driver",
"description":"OSC Driver Music Mixer over UDP/IP",
"executablePath":"bin/tecamino-driver-osc-linux-arm64",
"workingDirectory":"bin",
"arguments":[
"-cfg './cfg'",
"-serverIp '127.0.0.1'",
"-serverPort 8100",
"-port 8300"
]
}
]
}

View File

@@ -0,0 +1,36 @@
package drivers
import (
"backend/models"
"encoding/json"
"net/http"
"os"
"github.com/gin-gonic/gin"
)
type DriverHandler struct {
driversConfig string
}
func NewDriverHandler(cfgDir string) *DriverHandler {
return &DriverHandler{driversConfig: cfgDir}
}
func (dH *DriverHandler) GetDriverList(c *gin.Context) {
content, err := os.ReadFile(dH.driversConfig)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
var data struct {
Drivers []models.Drivers `json:"drivers"`
}
err = json.Unmarshal(content, &data)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
c.JSON(http.StatusOK, data.Drivers)
}

View File

@@ -5,50 +5,49 @@ go 1.24.0
toolchain go1.24.3 toolchain go1.24.3
require ( require (
gitea.tecamino.com/paadi/tecamino-dbm v0.1.1
gitea.tecamino.com/paadi/tecamino-logger v0.2.1
github.com/gin-contrib/cors v1.7.5
github.com/gin-gonic/gin v1.10.0 github.com/gin-gonic/gin v1.10.0
github.com/golang-jwt/jwt/v5 v5.2.2 github.com/golang-jwt/jwt/v5 v5.2.2
github.com/mattn/go-sqlite3 v1.14.28 github.com/google/uuid v1.6.0
github.com/tecamino/tecamino-dbm v0.0.10 golang.org/x/crypto v0.36.0
github.com/tecamino/tecamino-logger v0.2.0 modernc.org/sqlite v1.37.1
golang.org/x/crypto v0.23.0
) )
require ( require (
github.com/bytedance/sonic v1.11.6 // indirect github.com/bytedance/sonic v1.13.2 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect github.com/bytedance/sonic/loader v0.2.4 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/base64x v0.1.5 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect github.com/gin-contrib/sse v1.0.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect github.com/go-playground/validator/v10 v10.26.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect github.com/goccy/go-json v0.10.5 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/klauspost/cpuid/v2 v2.2.10 // indirect
github.com/leodido/go-urn v1.4.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect github.com/ugorji/go/codec v1.2.12 // indirect
go.uber.org/multierr v1.10.0 // indirect go.uber.org/multierr v1.10.0 // indirect
go.uber.org/zap v1.27.0 // indirect go.uber.org/zap v1.27.0 // indirect
golang.org/x/arch v0.8.0 // indirect golang.org/x/arch v0.15.0 // indirect
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
golang.org/x/net v0.25.0 // indirect golang.org/x/net v0.38.0 // indirect
golang.org/x/sys v0.33.0 // indirect golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.15.0 // indirect golang.org/x/text v0.23.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/libc v1.65.7 // indirect modernc.org/libc v1.65.7 // indirect
modernc.org/mathutil v1.7.1 // indirect modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect modernc.org/memory v1.11.0 // indirect
modernc.org/sqlite v1.37.1 // indirect
) )

View File

@@ -1,20 +1,26 @@
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= gitea.tecamino.com/paadi/tecamino-dbm v0.1.1 h1:vAq7mwUxlxJuLzCQSDMrZCwo8ky5usWi9Qz+UP+WnkI=
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= gitea.tecamino.com/paadi/tecamino-dbm v0.1.1/go.mod h1:+tmf1rjPaKEoNeUcr1vdtoFIFweNG3aUGevDAl3NMBk=
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= gitea.tecamino.com/paadi/tecamino-logger v0.2.1 h1:sQTBKYPdzn9mmWX2JXZBtGBvNQH7cuXIwsl4TD0aMgE=
gitea.tecamino.com/paadi/tecamino-logger v0.2.1/go.mod h1:FkzRTldUBBOd/iy2upycArDftSZ5trbsX5Ira5OzJgM=
github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ=
github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/cors v1.7.5 h1:cXC9SmofOrRg0w9PigwGlHG3ztswH6bqq4vJVXnvYMk=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-contrib/cors v1.7.5/go.mod h1:4q3yi7xBEDDWKapjT2o1V7mScKDDr8k+jZ0fSquGoy0=
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
@@ -23,29 +29,33 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k=
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A=
github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -53,12 +63,14 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@@ -69,12 +81,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tecamino/tecamino-dbm v0.0.10 h1:+6OTl7yTsqLuYqE8QVB8ski3x0seI5yBFLnuHdVz99k=
github.com/tecamino/tecamino-dbm v0.0.10/go.mod h1:8YYOr/jQ9mGVmmNj2NE8HajDvlJAVY3iGOZNfMjd8kA=
github.com/tecamino/tecamino-logger v0.2.0 h1:NPH/Gg9qRhmVoW8b39i1eXu/LEftHc74nyISpcRG+XU=
github.com/tecamino/tecamino-logger v0.2.0/go.mod h1:0M1E9Uei/qw3e3WA1x3lBo1eP3H5oeYE7GjYrMahnj8=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
@@ -85,41 +93,57 @@ go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM= golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM=
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8= golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
modernc.org/cc/v4 v4.26.1 h1:+X5NtzVBn0KgsBCBe+xkDC7twLb/jNVj9FPgiwSQO3s=
modernc.org/cc/v4 v4.26.1/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
modernc.org/ccgo/v4 v4.28.0 h1:rjznn6WWehKq7dG4JtLRKxb52Ecv8OUGah8+Z/SfpNU=
modernc.org/ccgo/v4 v4.28.0/go.mod h1:JygV3+9AV6SmPhDasu4JgquwU81XAKLd3OKTUDNOiKE=
modernc.org/fileutil v1.3.1 h1:8vq5fe7jdtEvoCf3Zf9Nm0Q05sH6kGx0Op2CPx1wTC8=
modernc.org/fileutil v1.3.1/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc=
modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=
modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
modernc.org/libc v1.65.7 h1:Ia9Z4yzZtWNtUIuiPuQ7Qf7kxYrxP1/jeHZzG8bFu00= modernc.org/libc v1.65.7 h1:Ia9Z4yzZtWNtUIuiPuQ7Qf7kxYrxP1/jeHZzG8bFu00=
modernc.org/libc v1.65.7/go.mod h1:011EQibzzio/VX3ygj1qGFt5kMjP0lHb0qCW5/D/pQU= modernc.org/libc v1.65.7/go.mod h1:011EQibzzio/VX3ygj1qGFt5kMjP0lHb0qCW5/D/pQU=
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI= modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=
modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw= modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=
modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
modernc.org/sqlite v1.37.1 h1:EgHJK/FPoqC+q2YBXg7fUmES37pCHFc97sI7zSayBEs= modernc.org/sqlite v1.37.1 h1:EgHJK/FPoqC+q2YBXg7fUmES37pCHFc97sI7zSayBEs=
modernc.org/sqlite v1.37.1/go.mod h1:XwdRtsE1MpiBcL54+MbKcaDvcuej+IYSMfLN6gSKV8g= modernc.org/sqlite v1.37.1/go.mod h1:XwdRtsE1MpiBcL54+MbKcaDvcuej+IYSMfLN6gSKV8g=
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

View File

@@ -2,7 +2,7 @@ package login
import ( import (
"backend/dbRequest" "backend/dbRequest"
"backend/login/models" "backend/models"
"backend/utils" "backend/utils"
"database/sql" "database/sql"
"encoding/json" "encoding/json"
@@ -19,25 +19,19 @@ import (
func (lm *LoginManager) AddUser(c *gin.Context) { func (lm *LoginManager) AddUser(c *gin.Context) {
body, err := io.ReadAll(c.Request.Body) body, err := io.ReadAll(c.Request.Body)
if err != nil { if err != nil {
c.JSON(http.StatusBadRequest, gin.H{ c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
"error": err.Error(),
})
return return
} }
user := models.User{} user := models.User{}
err = json.Unmarshal(body, &user) err = json.Unmarshal(body, &user)
if err != nil { if err != nil {
c.JSON(http.StatusBadRequest, gin.H{ c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
"error": err.Error(),
})
return return
} }
if !user.IsValid() { if !user.IsValid() {
c.JSON(http.StatusBadRequest, gin.H{ c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse("user empty"))
"error": "user empty",
})
return return
} }
@@ -54,20 +48,16 @@ func (lm *LoginManager) AddUser(c *gin.Context) {
} }
if exists { if exists {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, models.NewJsonErrorMessageResponse(fmt.Sprintf("user '%s' exists already", user.Name)))
"error": fmt.Sprintf("user '%s' exists already", user.Name),
})
return return
} }
hash, err := utils.HashPassword(user.Password) hash, err := utils.HashPassword(user.Password)
if err != nil { if err != nil {
c.JSON(http.StatusBadRequest, gin.H{ c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
"error": err.Error(),
})
return return
} }
if _, err := db.Exec(dbRequest.DBNewUser, user.Name, hash); dbRequest.CheckDBError(c, user.Name, err) { if _, err := db.Exec(dbRequest.DBNewUser, user.Role, user.Name, hash); dbRequest.CheckDBError(c, user.Name, err) {
return return
} }
@@ -79,25 +69,19 @@ func (lm *LoginManager) AddUser(c *gin.Context) {
func (lm *LoginManager) RemoveUser(c *gin.Context) { func (lm *LoginManager) RemoveUser(c *gin.Context) {
body, err := io.ReadAll(c.Request.Body) body, err := io.ReadAll(c.Request.Body)
if err != nil { if err != nil {
c.JSON(http.StatusBadRequest, gin.H{ c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
"error": err.Error(),
})
return return
} }
user := models.User{} user := models.User{}
err = json.Unmarshal(body, &user) err = json.Unmarshal(body, &user)
if err != nil { if err != nil {
c.JSON(http.StatusBadRequest, gin.H{ c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
"error": err.Error(),
})
return return
} }
if !user.IsValid() { if !user.IsValid() {
c.JSON(http.StatusBadRequest, gin.H{ c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse("user empty"))
"error": "user empty",
})
return return
} }
@@ -108,14 +92,12 @@ func (lm *LoginManager) RemoveUser(c *gin.Context) {
defer db.Close() defer db.Close()
var storedPassword string var storedPassword string
if err := db.QueryRow(dbRequest.DBQueryPassword, user.Name).Scan(&storedPassword); dbRequest.CheckDBError(c, user.Name, err) { if err := db.QueryRow(dbRequest.DBQueryPassword, user.Name).Scan(&storedPassword, &user.Role); dbRequest.CheckDBError(c, user.Name, err) {
return return
} }
if !utils.CheckPassword(user.Password, storedPassword) { if !utils.CheckPassword(user.Password, storedPassword) {
c.JSON(http.StatusBadRequest, gin.H{ c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse("wrong password"))
"error": "wrong password",
})
return return
} }
@@ -131,27 +113,19 @@ func (lm *LoginManager) RemoveUser(c *gin.Context) {
func (lm *LoginManager) Login(c *gin.Context) { func (lm *LoginManager) Login(c *gin.Context) {
body, err := io.ReadAll(c.Request.Body) body, err := io.ReadAll(c.Request.Body)
if err != nil { if err != nil {
c.JSON(http.StatusBadRequest, gin.H{ c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
"error": err.Error(),
})
return return
} }
user := models.User{} user := models.User{}
err = json.Unmarshal(body, &user) err = json.Unmarshal(body, &user)
if err != nil { if err != nil {
fmt.Println(2) c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
c.JSON(http.StatusBadRequest, gin.H{
"error": err.Error(),
})
return return
} }
if !user.IsValid() { if !user.IsValid() {
c.JSON(http.StatusBadRequest, gin.H{ c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse("user empty"))
"error": "user empty",
})
return return
} }
@@ -162,41 +136,36 @@ func (lm *LoginManager) Login(c *gin.Context) {
defer db.Close() defer db.Close()
var storedPassword string var storedPassword string
if err := db.QueryRow(dbRequest.DBQueryPassword, user.Name).Scan(&storedPassword); dbRequest.CheckDBError(c, user.Name, err) { if err := db.QueryRow(dbRequest.DBQueryPassword, user.Name).Scan(&user.Role, &storedPassword); dbRequest.CheckDBError(c, user.Name, err) {
return return
} }
if !utils.CheckPassword(user.Password, storedPassword) { if !utils.CheckPassword(user.Password, storedPassword) {
fmt.Println(2, user.Password) c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse("wrong password"))
c.JSON(http.StatusBadRequest, gin.H{
"error": "wrong password",
})
return return
} }
// Create token // Create token
token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
"username": user.Name, "username": user.Name,
"exp": time.Now().Add(time.Hour * 72).Unix(), // expires in 72h "role": user.Role,
"exp": time.Now().Add(time.Minute * 60).Unix(), // expires in 72h
}) })
secret, err := utils.GenerateJWTSecret(32) // 32 bytes = 256 bits secret, err := utils.GenerateJWTSecret(32) // 32 bytes = 256 bits
if err != nil { if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{ c.JSON(http.StatusInternalServerError, models.NewJsonErrorMessageResponse("error generate jwt token"))
"error": "error generate jwt token"})
return return
} }
// Sign and get the complete encoded token as a string // Sign and get the complete encoded token as a string
tokenString, err := token.SignedString(secret) tokenString, err := token.SignedString(secret)
if err != nil { if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{ c.JSON(http.StatusInternalServerError, models.NewJsonErrorMessageResponse("Could not generate token"))
"error": "Could not generate token"})
return return
} }
c.JSON(http.StatusOK, models.User{ c.JSON(http.StatusOK, models.User{
Name: user.Name,
Token: tokenString, Token: tokenString,
}) })
} }

View File

@@ -37,7 +37,7 @@ func NewLoginManager(dir string) (*LoginManager, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
_, err = db.Exec(dbRequest.DBNewUser, "admin", hash) _, err = db.Exec(dbRequest.DBNewUser, "admin", "admin", hash)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@@ -1,22 +1,35 @@
package main package main
import ( import (
"backend/drivers"
"backend/login" "backend/login"
"backend/models"
secenes "backend/scenes"
"backend/server" "backend/server"
"backend/utils" "backend/utils"
"flag" "flag"
"fmt" "fmt"
"log" "log"
"net/http"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"time" "time"
"gitea.tecamino.com/paadi/tecamino-logger/logging"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/tecamino/tecamino-logger/logging"
) )
func main() { func main() {
var allowOrigins models.StringSlice
flag.Var(&allowOrigins, "allowOrigin", "Allowed origin (can repeat this flag)")
spa := flag.String("spa", "./dist/spa", "quasar spa files") spa := flag.String("spa", "./dist/spa", "quasar spa files")
cfgDir := flag.String("cfg", "./cfg", "config dir")
driversCfg := flag.String("drivers", "defaultConfigurations.json", "drivers config file name")
workingDir := flag.String("workingDirectory", ".", "quasar spa files") workingDir := flag.String("workingDirectory", ".", "quasar spa files")
ip := flag.String("ip", "0.0.0.0", "server listening ip") ip := flag.String("ip", "0.0.0.0", "server listening ip")
port := flag.Uint("port", 9500, "server listening port") port := flag.Uint("port", 9500, "server listening port")
@@ -28,7 +41,7 @@ func main() {
fmt.Println(1, *workingDir) fmt.Println(1, *workingDir)
os.Chdir(*workingDir) os.Chdir(*workingDir)
} }
fmt.Println(1.1, *workingDir)
wd, err := os.Getwd() wd, err := os.Getwd()
if err != nil { if err != nil {
log.Fatalf("Could not get working directory: %v", err) log.Fatalf("Could not get working directory: %v", err)
@@ -44,6 +57,10 @@ func main() {
Debug: *debug, Debug: *debug,
TerminalOut: true, TerminalOut: true,
}) })
if err != nil {
logger.Error("main new logger", err.Error())
panic(err)
}
//new login manager //new login manager
loginManager, err := login.NewLoginManager(".") loginManager, err := login.NewLoginManager(".")
@@ -52,26 +69,60 @@ func main() {
panic(err) panic(err)
} }
//new scenes handler
scenesHandler := secenes.NewScenesHandler("")
//new scenes handler
driversHandler := drivers.NewDriverHandler(filepath.Join(*cfgDir, *driversCfg))
// new server // new server
s := server.NewServer() s := server.NewServer()
//get local ip
allowOrigins = append(allowOrigins, "http://localhost:9000", "http://localhost:9500")
localIP, err := utils.GetLocalIP()
if err != nil {
logger.Error("main", fmt.Sprintf("get local ip : %s", err.Error()))
} else {
allowOrigins = append(allowOrigins, fmt.Sprintf("http://%s:9000", localIP), fmt.Sprintf("http://%s:9500", localIP))
}
s.Routes.Use(cors.New(cors.Config{
AllowOrigins: allowOrigins,
AllowMethods: []string{"POST", "GET", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Origin", "Content-Type"},
AllowCredentials: true,
}))
api := s.Routes.Group("/api") api := s.Routes.Group("/api")
//set routes //set routes
api.GET("/loadScenes", scenesHandler.LoadScenes)
api.GET("/allDrivers", driversHandler.GetDriverList)
api.POST("/login", loginManager.Login) api.POST("/login", loginManager.Login)
api.POST("/user/add", loginManager.AddUser) api.POST("/user/add", loginManager.AddUser)
api.POST("/saveScene", scenesHandler.SaveScene)
api.POST("/loadScene", scenesHandler.LoadScene)
api.DELETE("/user", loginManager.RemoveUser) api.DELETE("/user", loginManager.RemoveUser)
api.DELETE("/deleteScene", scenesHandler.DeleteScene)
// Serve static files // Serve static files
s.Routes.StaticFS("/", gin.Dir(*spa, true)) s.Routes.StaticFS("/assets", gin.Dir(filepath.Join(*spa, "assets"), true))
s.Routes.NoRoute(func(c *gin.Context) { s.Routes.NoRoute(func(c *gin.Context) {
// Disallow fallback for /api paths
if strings.HasPrefix(c.Request.URL.Path, "/api") {
c.JSON(http.StatusNotFound, models.NewJsonErrorMessageResponse("API endpoint not found"))
return
}
// Try to serve file from SPA directory // Try to serve file from SPA directory
filePath := filepath.Join(*spa, c.Request.URL.Path) filePath := filepath.Join(*spa, c.Request.URL.Path)
if _, err := os.Stat(filePath); err == nil { if _, err := os.Stat(filePath); err == nil {
c.File(filePath) c.File(filePath)
} else { return
// Fallback to index.html for SPA routing
c.File(filepath.Join(*spa, "index.html"))
} }
// Fallback to index.html for SPA routing
c.File(filepath.Join(*spa, "index.html"))
}) })
go func() { go func() {
@@ -80,7 +131,6 @@ func main() {
logger.Error("main", fmt.Sprintf("starting browser error : %s", err.Error())) logger.Error("main", fmt.Sprintf("starting browser error : %s", err.Error()))
} }
}() }()
fmt.Println(3, *ip, *port)
// start http server // start http server
logger.Info("main", fmt.Sprintf("http listen on ip: %s port: %d", *ip, *port)) logger.Info("main", fmt.Sprintf("http listen on ip: %s port: %d", *ip, *port))
if err := s.ServeHttp(*ip, *port); err != nil { if err := s.ServeHttp(*ip, *port); err != nil {

View File

@@ -0,0 +1,9 @@
package models
type Drivers struct {
Name string `json:"name"`
Description string `json:"description"`
ExecutablePath string `json:"executablePath,omitempty"`
WorkingDirectory string `json:"workingDirectory,omitempty"`
Arguments []string `json:"arguments,omitempty"`
}

View File

@@ -0,0 +1,20 @@
package models
type JsonResponse struct {
Error bool `json:"error,omitempty"`
Message string `json:"message,omitempty"`
}
func NewJsonErrorMessageResponse(msg string) JsonResponse {
return JsonResponse{
Error: true,
Message: msg,
}
}
func NewJsonErrorResponse(err error) JsonResponse {
return JsonResponse{
Error: true,
Message: err.Error(),
}
}

11
backend/models/scenes.go Normal file
View File

@@ -0,0 +1,11 @@
package models
type Scenes []Scene
type Scene struct {
Name string `json:"name"`
Desciption string `json:"description,omitempty"`
MovingHead bool `json:"movingHead"`
LightBar bool `json:"lightBar"`
Values []Value `json:"values,omitempty"`
}

View File

@@ -0,0 +1,14 @@
package models
import "strings"
type StringSlice []string
func (s *StringSlice) String() string {
return strings.Join(*s, ",")
}
func (s *StringSlice) Set(value string) error {
*s = append(*s, value)
return nil
}

View File

@@ -2,6 +2,7 @@ package models
type User struct { type User struct {
Name string `json:"user"` Name string `json:"user"`
Role string `json:"role"`
Password string `json:"password,omitempty"` Password string `json:"password,omitempty"`
Token string `json:"token,omitempty"` Token string `json:"token,omitempty"`
} }

9
backend/models/value.go Normal file
View File

@@ -0,0 +1,9 @@
package models
import "github.com/google/uuid"
type Value struct {
Uuid uuid.UUID `json:"uuid"`
Path string `json:"path"`
Value any `json:"value"`
}

9
backend/models/values.go Normal file
View File

@@ -0,0 +1,9 @@
package models
type Values struct {
Stagelights []Value `json:"stageLights,omitempty"`
LightBar []Value `json:"lightBar,omitempty"`
FloogLights []Value `json:"floodLights,omitempty"`
MovingHead []Value `json:"movingHead,omitempty"`
Value any `json:"value"`
}

179
backend/scenes/scenes.go Normal file
View File

@@ -0,0 +1,179 @@
package secenes
import (
"backend/models"
"backend/utils"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"path"
"path/filepath"
"sort"
"github.com/gin-gonic/gin"
)
type ScenesHandler struct {
dir string
}
func NewScenesHandler(dir string) *ScenesHandler {
if dir == "" {
dir = "./scenes"
}
return &ScenesHandler{
dir: dir,
}
}
func (sh *ScenesHandler) SaveScene(c *gin.Context) {
body, err := io.ReadAll(c.Request.Body)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
var scene models.Scene
err = json.Unmarshal(body, &scene)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
if _, err := os.Stat(path.Join(sh.dir)); err != nil {
err := os.MkdirAll(sh.dir, 0755)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
}
f, err := os.OpenFile(path.Join(sh.dir, scene.Name+".scene"), os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0644)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
defer f.Close()
_, err = f.Write(body)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
c.JSON(http.StatusOK, gin.H{
"message": fmt.Sprintf("Scene '%s' saved", scene.Name),
})
}
func (sh *ScenesHandler) DeleteScene(c *gin.Context) {
body, err := io.ReadAll(c.Request.Body)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
var scene models.Scene
err = json.Unmarshal(body, &scene)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
err = os.Remove(path.Join(sh.dir, scene.Name+".scene"))
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
c.JSON(http.StatusOK, gin.H{
"message": fmt.Sprintf("Scene '%s' deleted", scene.Name),
})
}
func (sh *ScenesHandler) LoadScenes(c *gin.Context) {
sceneMap := make(map[string]models.Scene)
files, err := utils.FindAllFiles("./scenes", ".scene")
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
for _, f := range files {
content, err := os.ReadFile(f)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
var scene models.Scene
err = json.Unmarshal(content, &scene)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
sceneMap[scene.Name] = scene
}
//sort scenes alphabetacally by name
keys := make([]string, 0, len(sceneMap))
for key := range sceneMap {
keys = append(keys, key)
}
// Sort keys alphabetically
sort.Strings(keys)
var scenes []models.Scene
// Iterate over sorted keys
for _, key := range keys {
scenes = append(scenes, sceneMap[key])
}
c.JSON(http.StatusOK, scenes)
}
func (sh *ScenesHandler) LoadScene(c *gin.Context) {
body, err := io.ReadAll(c.Request.Body)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
var scene models.Scene
err = json.Unmarshal(body, &scene)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
files, err := utils.FindAllFiles("./scenes", ".scene")
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
for _, f := range files {
if filepath.Base(f) != scene.Name+".scene" {
continue
}
content, err := os.ReadFile(f)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
err = json.Unmarshal(content, &scene)
if err != nil {
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
return
}
c.JSON(http.StatusOK, scene)
return
}
c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse(fmt.Sprintf("scene '%s' not found", scene.Name)))
}

View File

@@ -4,9 +4,9 @@ import (
"fmt" "fmt"
"sync" "sync"
"gitea.tecamino.com/paadi/tecamino-dbm/cert"
"gitea.tecamino.com/paadi/tecamino-logger/logging"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/tecamino/tecamino-dbm/cert"
"github.com/tecamino/tecamino-logger/logging"
) )
// server model for database manager websocket // server model for database manager websocket

Binary file not shown.

22
backend/utils/ip.go Normal file
View File

@@ -0,0 +1,22 @@
package utils
import (
"fmt"
"net"
)
func GetLocalIP() (string, error) {
addrs, err := net.InterfaceAddrs()
if err != nil {
return "", err
}
for _, addr := range addrs {
if ipNet, ok := addr.(*net.IPNet); ok && !ipNet.IP.IsLoopback() {
if ipNet.IP.To4() != nil {
return ipNet.IP.String(), nil
}
}
}
return "", fmt.Errorf("no local IP address found")
}

View File

@@ -2,10 +2,13 @@ package utils
import ( import (
"fmt" "fmt"
"io/fs"
"os"
"os/exec" "os/exec"
"path/filepath"
"runtime" "runtime"
"github.com/tecamino/tecamino-logger/logging" "gitea.tecamino.com/paadi/tecamino-logger/logging"
) )
func OpenBrowser(url string, logger *logging.Logger) error { func OpenBrowser(url string, logger *logging.Logger) error {
@@ -25,6 +28,10 @@ func OpenBrowser(url string, logger *logging.Logger) error {
{"open", url}, // fallback {"open", url}, // fallback
} }
default: // Linux default: // Linux
if os.Getenv("DISPLAY") == "" && os.Getenv("WAYLAND_DISPLAY") == "" && os.Getenv("XDG_SESSION_TYPE") != "wayland" {
return fmt.Errorf("os is running i headless mode do not start browser")
}
commands = [][]string{ commands = [][]string{
{"chromium-browser", "--kiosk", url}, {"chromium-browser", "--kiosk", url},
{"google-chrome", "--kiosk", url}, {"google-chrome", "--kiosk", url},
@@ -44,3 +51,15 @@ func OpenBrowser(url string, logger *logging.Logger) error {
return fmt.Errorf("could not open browser") return fmt.Errorf("could not open browser")
} }
func FindAllFiles(rootDir, fileExtention string) (files []string, err error) {
err = filepath.WalkDir(rootDir, func(path string, d fs.DirEntry, err error) error {
if d.IsDir() {
return nil
} else if filepath.Ext(d.Name()) == fileExtention {
files = append(files, path)
}
return err
})
return
}

158
package-lock.json generated
View File

@@ -1,16 +1,18 @@
{ {
"name": "lightcontrol", "name": "lightcontrol",
"version": "0.0.5", "version": "0.0.21",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "lightcontrol", "name": "lightcontrol",
"version": "0.0.5", "version": "0.0.21",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@quasar/extras": "^1.16.4", "@quasar/extras": "^1.16.4",
"axios": "^1.9.0", "axios": "^1.10.0",
"jwt-decode": "^4.0.0",
"pinia": "^3.0.3",
"quasar": "^2.16.0", "quasar": "^2.16.0",
"vue": "^3.4.18", "vue": "^3.4.18",
"vue-router": "^4.0.12" "vue-router": "^4.0.12"
@@ -1939,6 +1941,30 @@
"integrity": "sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==", "integrity": "sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/@vue/devtools-kit": {
"version": "7.7.7",
"resolved": "https://registry.npmjs.org/@vue/devtools-kit/-/devtools-kit-7.7.7.tgz",
"integrity": "sha512-wgoZtxcTta65cnZ1Q6MbAfePVFxfM+gq0saaeytoph7nEa7yMXoi6sCPy4ufO111B9msnw0VOWjPEFCXuAKRHA==",
"license": "MIT",
"dependencies": {
"@vue/devtools-shared": "^7.7.7",
"birpc": "^2.3.0",
"hookable": "^5.5.3",
"mitt": "^3.0.1",
"perfect-debounce": "^1.0.0",
"speakingurl": "^14.0.1",
"superjson": "^2.2.2"
}
},
"node_modules/@vue/devtools-shared": {
"version": "7.7.7",
"resolved": "https://registry.npmjs.org/@vue/devtools-shared/-/devtools-shared-7.7.7.tgz",
"integrity": "sha512-+udSj47aRl5aKb0memBvcUG9koarqnxNM5yjuREvqwK6T3ap4mn3Zqqc17QrBFTqSMjr3HK1cvStEZpMDpfdyw==",
"license": "MIT",
"dependencies": {
"rfdc": "^1.4.1"
}
},
"node_modules/@vue/eslint-config-prettier": { "node_modules/@vue/eslint-config-prettier": {
"version": "10.2.0", "version": "10.2.0",
"resolved": "https://registry.npmjs.org/@vue/eslint-config-prettier/-/eslint-config-prettier-10.2.0.tgz", "resolved": "https://registry.npmjs.org/@vue/eslint-config-prettier/-/eslint-config-prettier-10.2.0.tgz",
@@ -2312,9 +2338,9 @@
} }
}, },
"node_modules/axios": { "node_modules/axios": {
"version": "1.9.0", "version": "1.10.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.9.0.tgz", "resolved": "https://registry.npmjs.org/axios/-/axios-1.10.0.tgz",
"integrity": "sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==", "integrity": "sha512-/1xYAC4MP/HEG+3duIhFr4ZQXR4sQXOIe+o6sdqzeykGLx6Upp/1p8MHqhINOvGeP7xyNHe7tsiJByc4SSVUxw==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"follow-redirects": "^1.15.6", "follow-redirects": "^1.15.6",
@@ -2378,6 +2404,15 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/birpc": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/birpc/-/birpc-2.5.0.tgz",
"integrity": "sha512-VSWO/W6nNQdyP520F1mhf+Lc2f8pjGQOtoHHm7Ze8Go1kX7akpVIrtTa0fn+HB0QJEDVacl6aO08YE0PgXfdnQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/antfu"
}
},
"node_modules/bl": { "node_modules/bl": {
"version": "4.1.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz",
@@ -2998,6 +3033,21 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/copy-anything": {
"version": "3.0.5",
"resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-3.0.5.tgz",
"integrity": "sha512-yCEafptTtb4bk7GLEQoM8KVJpxAfdBJYaXyzQEgQQQgYrZiDp8SJmGKlYza6CYjEDNstAdNdKA3UuoULlEbS6w==",
"license": "MIT",
"dependencies": {
"is-what": "^4.1.8"
},
"engines": {
"node": ">=12.13"
},
"funding": {
"url": "https://github.com/sponsors/mesqueeb"
}
},
"node_modules/core-util-is": { "node_modules/core-util-is": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
@@ -4398,6 +4448,12 @@
"he": "bin/he" "he": "bin/he"
} }
}, },
"node_modules/hookable": {
"version": "5.5.3",
"resolved": "https://registry.npmjs.org/hookable/-/hookable-5.5.3.tgz",
"integrity": "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==",
"license": "MIT"
},
"node_modules/html-minifier-terser": { "node_modules/html-minifier-terser": {
"version": "7.2.0", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-7.2.0.tgz", "resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-7.2.0.tgz",
@@ -4696,6 +4752,18 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/is-what": {
"version": "4.1.16",
"resolved": "https://registry.npmjs.org/is-what/-/is-what-4.1.16.tgz",
"integrity": "sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A==",
"license": "MIT",
"engines": {
"node": ">=12.13"
},
"funding": {
"url": "https://github.com/sponsors/mesqueeb"
}
},
"node_modules/is-wsl": { "node_modules/is-wsl": {
"version": "3.1.0", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz",
@@ -4819,6 +4887,15 @@
"graceful-fs": "^4.1.6" "graceful-fs": "^4.1.6"
} }
}, },
"node_modules/jwt-decode": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz",
"integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==",
"license": "MIT",
"engines": {
"node": ">=18"
}
},
"node_modules/keyv": { "node_modules/keyv": {
"version": "4.5.4", "version": "4.5.4",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
@@ -5132,6 +5209,12 @@
"node": ">=16 || 14 >=14.17" "node": ">=16 || 14 >=14.17"
} }
}, },
"node_modules/mitt": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz",
"integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==",
"license": "MIT"
},
"node_modules/mlly": { "node_modules/mlly": {
"version": "1.7.4", "version": "1.7.4",
"resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.4.tgz", "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.4.tgz",
@@ -5560,6 +5643,12 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/perfect-debounce": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/perfect-debounce/-/perfect-debounce-1.0.0.tgz",
"integrity": "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA==",
"license": "MIT"
},
"node_modules/picocolors": { "node_modules/picocolors": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
@@ -5579,6 +5668,36 @@
"url": "https://github.com/sponsors/jonschlinkert" "url": "https://github.com/sponsors/jonschlinkert"
} }
}, },
"node_modules/pinia": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/pinia/-/pinia-3.0.3.tgz",
"integrity": "sha512-ttXO/InUULUXkMHpTdp9Fj4hLpD/2AoJdmAbAeW2yu1iy1k+pkFekQXw5VpC0/5p51IOR/jDaDRfRWRnMMsGOA==",
"license": "MIT",
"dependencies": {
"@vue/devtools-api": "^7.7.2"
},
"funding": {
"url": "https://github.com/sponsors/posva"
},
"peerDependencies": {
"typescript": ">=4.4.4",
"vue": "^2.7.0 || ^3.5.11"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/pinia/node_modules/@vue/devtools-api": {
"version": "7.7.7",
"resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-7.7.7.tgz",
"integrity": "sha512-lwOnNBH2e7x1fIIbVT7yF5D+YWhqELm55/4ZKf45R9T8r9dE2AIOy8HKjfqzGsoTHFbWbr337O4E0A0QADnjBg==",
"license": "MIT",
"dependencies": {
"@vue/devtools-kit": "^7.7.7"
}
},
"node_modules/pkg-types": { "node_modules/pkg-types": {
"version": "1.3.1", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.3.1.tgz", "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.3.1.tgz",
@@ -5954,6 +6073,12 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/rfdc": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.4.1.tgz",
"integrity": "sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==",
"license": "MIT"
},
"node_modules/rollup": { "node_modules/rollup": {
"version": "4.40.1", "version": "4.40.1",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.40.1.tgz", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.40.1.tgz",
@@ -6865,6 +6990,15 @@
"source-map": "^0.6.0" "source-map": "^0.6.0"
} }
}, },
"node_modules/speakingurl": {
"version": "14.0.1",
"resolved": "https://registry.npmjs.org/speakingurl/-/speakingurl-14.0.1.tgz",
"integrity": "sha512-1POYv7uv2gXoyGFpBCmpDVSNV74IfsWlDW216UPjbWufNf+bSU6GdbDsxdcxtfwb4xlI3yxzOTKClUosxARYrQ==",
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/stack-trace": { "node_modules/stack-trace": {
"version": "1.0.0-pre2", "version": "1.0.0-pre2",
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-1.0.0-pre2.tgz", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-1.0.0-pre2.tgz",
@@ -6980,6 +7114,18 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/superjson": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/superjson/-/superjson-2.2.2.tgz",
"integrity": "sha512-5JRxVqC8I8NuOUjzBbvVJAKNM8qoVuH0O77h4WInc/qC2q5IreqKxYwgkga3PfA22OayK2ikceb/B26dztPl+Q==",
"license": "MIT",
"dependencies": {
"copy-anything": "^3.0.2"
},
"engines": {
"node": ">=16"
}
},
"node_modules/supports-color": { "node_modules/supports-color": {
"version": "7.2.0", "version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",

View File

@@ -1,7 +1,7 @@
{ {
"name": "lightcontrol", "name": "lightcontrol",
"version": "0.0.4", "version": "0.1.2",
"description": "A Quasar Project", "description": "A Tecamino App",
"productName": "Light Control", "productName": "Light Control",
"author": "A. Zuercher", "author": "A. Zuercher",
"type": "module", "type": "module",
@@ -16,7 +16,9 @@
}, },
"dependencies": { "dependencies": {
"@quasar/extras": "^1.16.4", "@quasar/extras": "^1.16.4",
"axios": "^1.9.0", "axios": "^1.10.0",
"jwt-decode": "^4.0.0",
"pinia": "^3.0.3",
"quasar": "^2.16.0", "quasar": "^2.16.0",
"vue": "^3.4.18", "vue": "^3.4.18",
"vue-router": "^4.0.12" "vue-router": "^4.0.12"

View File

@@ -11,7 +11,7 @@ export default defineConfig((/* ctx */) => {
// app boot file (/src/boot) // app boot file (/src/boot)
// --> boot files are part of "main.js" // --> boot files are part of "main.js"
// https://v2.quasar.dev/quasar-cli-vite/boot-files // https://v2.quasar.dev/quasar-cli-vite/boot-files
boot: ['websocket', 'axios'], boot: ['websocket', 'axios', 'auth'],
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#css // https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#css
css: ['app.scss'], css: ['app.scss'],

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Adobe Illustrator 24.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Ebene_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="246px" height="246px" viewBox="0 0 246 246" style="enable-background:new 0 0 246 246;" xml:space="preserve">
<style type="text/css">
.st0{fill:#113A68;}
.st1{fill:#9E2D29;}
.st2{fill:#9B1515;}
.st3{fill:#FFFFFF;}
</style>
<g>
<path class="st0" d="M166.6,210.9c-11.6,5-24.4,7.8-37.8,7.8c-52.8,0-95.6-42.8-95.6-95.6c0-2.3,0.1-4.6,0.2-6.8
c2.4-1.8,10.8-5.2,31.7-5.2s46.4,3.4,71.6,9.4c-13,22.2-15.9,44.7-7.8,62.2C133.6,192.6,143.9,205.2,166.6,210.9"/>
<path class="st0" d="M146.9,103.8C102.4,90.7,61.4,88.5,39.7,88.4c0-0.1,0.1-0.2,0.1-0.2c2.5-1.4,8.9-3.3,22.1-3.3
c23.7,0,55.7,5.9,86.9,15.8C148.2,101.7,147.5,102.7,146.9,103.8"/>
<path class="st0" d="M168.4,49.9c0.7,7.9-2.7,18.9-10.6,34.4C117.3,69.2,78.9,63.7,55.4,61.7c17.5-21,43.9-34.3,73.4-34.3
c7.8,0,15.5,0.9,22.8,2.7l3.8,2.5C164.2,38.3,167.8,43.1,168.4,49.9"/>
<path class="st0" d="M209.6,71.8c8.7,13.7,14,29.8,14.7,47c-3.9-2.6-8.2-5.3-13.1-8.3C214,95.5,212.6,82.5,209.6,71.8"/>
<path class="st0" d="M206.8,144.8c4.5,2.1,9,4.5,13.2,6.7c-2.2,6.9-5.1,13.5-8.7,19.6c-0.6-4-2.2-7.4-3.5-10.3
c-2.5-5.6-4.2-9.3-1.2-15.7C206.8,145,206.8,144.9,206.8,144.8"/>
<path class="st0" d="M207.2,125.1c5.4,2.9,11.3,6.2,16.6,9.2c-0.1,1.2-0.3,2.4-0.5,3.7c-5.7-3.5-11.8-7-17.2-9.9
C206.4,127.1,206.8,126.1,207.2,125.1"/>
<path class="st1" d="M185.2,205.6c41.5-36.8,4.9-39.5,15.9-63.1c-14,12.6-44,47.2-18,64.1C164.7,168.9,207.4,157.8,185.2,205.6"/>
<path class="st2" d="M198.1,130.8c9.6,5,24.5,13.5,33.5,20c-9.4-5.4-24.7-13-34.9-17.4c-2,3.9-4.3,7.8-7,11.8
c-10.3,15-36.7,44.6-12.5,61.4c-51.2-7.1-57.1-49.2-33.1-86.7c0.8-1.2,1.5-2.4,2.3-3.6c-62.2-16.2-119.6-14.7-119.8,0.3
c-14.3-6.8-26.2-20.1-2.1-21.8c9.6-0.7,65.2-2.4,125.1,16.2c3-4.9,5.8-9.6,8.2-13.9c-63.3-21.6-124.4-24-125.5-8.6
C18.4,81,7.4,67,31.6,66.7c9.9-0.1,68.5,1.5,129.1,25.3c21.2-39.5,16.4-52.7-2-64.6c21.6,1.5,57.2,37,45.6,86.1
c8.8,5.4,22.8,14.1,31,20.7c-8.4-5.5-22.6-13.3-31.7-17.9C202.2,121.1,200.4,125.9,198.1,130.8"/>
<path class="st2" d="M185.2,205.6c41.5-36.8,4.9-39.5,15.9-63.1c-14,12.6-44,47.2-18,64.1C164.7,168.9,207.4,157.8,185.2,205.6"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 233 KiB

13
src/boot/auth.ts Normal file
View File

@@ -0,0 +1,13 @@
import { boot } from 'quasar/wrappers';
import { createPinia } from 'pinia';
import { useUserStore } from 'src/vueLib/login/userStore';
import type { QVueGlobals } from 'quasar';
export default boot(({ app }) => {
const $q = app.config.globalProperties.$q as QVueGlobals;
const pinia = createPinia();
app.use(pinia);
const useStore = useUserStore();
useStore.initStore($q);
useStore.loadFromStorage();
});

View File

@@ -2,11 +2,19 @@ import { boot } from 'quasar/wrappers';
import axios from 'axios'; import axios from 'axios';
const host = window.location.hostname; const host = window.location.hostname;
const port = 8100; const portDbm = 8100;
const baseURL = `http://${host}:${port}`; const portApp = 9500;
const api = axios.create({ const dbmApi = axios.create({
baseURL: baseURL, baseURL: `http://${host}:${portDbm}`,
timeout: 30000,
headers: {
'Content-Type': 'application/json',
},
});
const appApi = axios.create({
baseURL: `http://${host}:${portApp}/api`,
timeout: 10000, timeout: 10000,
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@@ -15,7 +23,8 @@ const api = axios.create({
export default boot(({ app }) => { export default boot(({ app }) => {
app.config.globalProperties.$axios = axios; app.config.globalProperties.$axios = axios;
app.config.globalProperties.$api = api; app.config.globalProperties.$dbmApi = dbmApi;
app.config.globalProperties.$appApi = appApi;
}); });
export { axios, api }; export { axios, dbmApi, appApi };

View File

@@ -1,14 +1,11 @@
import { boot } from 'quasar/wrappers'; import { boot } from 'quasar/wrappers';
import type { QVueGlobals } from 'quasar'; import type { QVueGlobals } from 'quasar';
import { initWebSocket } from 'src/services/websocket'; import { initWebSocket } from '../vueLib/services/websocket';
export default boot(({ app }) => { export default boot(({ app }) => {
const $q = app.config.globalProperties.$q as QVueGlobals; const $q = app.config.globalProperties.$q as QVueGlobals;
const host = window.location.hostname; // gets current domain or IP
const port = 8100; // your WebSocket port
const randomId = Math.floor(Math.random() * 10001); // random number from 0 to 10000 const ws = initWebSocket(window.location.hostname, 8100, $q);
const ws = initWebSocket(`ws://${host}:${port}/ws?id=q${randomId}`, $q);
app.config.globalProperties.$socket = ws; app.config.globalProperties.$socket = ws;
ws.connect(); ws.connect();

View File

@@ -1,246 +0,0 @@
<template>
<q-card>
<div class="row">
<q-card-section class="col-4 scroll tree-container">
<q-tree
class="text-blue text-bold"
dense
:nodes="dbmData"
node-key="key"
no-transition
:default-expand-all="false"
v-model:expanded="expanded"
@lazy-load="onLazyLoad"
>
<template v-slot:[`default-header`]="props">
<div
class="row items-center text-blue"
@contextmenu.prevent.stop="openContextMenu($event, props.node)"
>
<div class="row items-center text-blue"></div>
<div>{{ props.node.path }}</div>
</div>
<q-popup-edit
v-if="props.node.value !== undefined && props.node.value !== ''"
v-model="props.node.value"
class="q-ml-xl bg-grey text-white"
@save="(val) => onValueEdit(val, props.node)"
>
<template v-slot="scope">
<q-input
dark
color="white"
v-model="scope.value"
dense
autofocus
counter
@keyup.enter="scope.set"
>
<template v-slot:append>
<q-icon name="edit" />
</template>
</q-input>
</template>
</q-popup-edit>
</template>
</q-tree>
<sub-menu :node="selectedNode"></sub-menu>
</q-card-section>
<DataTable :rows="Subscriptions" class="col-8" />
</div>
</q-card>
</template>
<script setup lang="ts">
import { watch, onMounted, ref } from 'vue';
import DataTable from './dataTable.vue';
import type { TreeNode } from 'src/composables/dbm/dbmTree';
import {
dbmData,
buildTree,
getSubscriptionsByUuid,
addChildrentoTree,
removeSubtreeByParentKey,
getAllSubscriptions,
} from 'src/composables/dbm/dbmTree';
import { useQuasar } from 'quasar';
import { openContextMenu } from 'src/composables/dbm/useContextMenu';
import { NotifyResponse } from 'src/composables/notify';
import SubMenu from 'src/components/dbm/SubMenu.vue';
import { QCard } from 'quasar';
import { subscribe, unsubscribe, setValues } from 'src/services/websocket';
import { onBeforeRouteLeave } from 'vue-router';
import { api } from 'boot/axios';
import type { Subs } from 'src/models/Subscribe';
const $q = useQuasar();
const expanded = ref<string[]>([]);
const selectedNode = ref<TreeNode | null>(null);
const ZERO_UUID = '00000000-0000-0000-0000-000000000000';
const Subscriptions = ref<Subs>([]);
onMounted(() => {
const payload = {
get: [
{
path: '.*',
query: { depth: 1 },
},
],
};
api
.post('/json_data', payload)
.then((res) => {
if (res.data.get) {
dbmData.value = buildTree(res.data.get);
}
})
.catch((err) => {
NotifyResponse($q, err, 'error');
});
});
onBeforeRouteLeave(() => {
unsubscribe([
{
path: '.*',
depth: 0,
},
]).catch((err) => {
NotifyResponse($q, err, 'error');
});
});
function onLazyLoad({
node,
done,
fail,
}: {
node: TreeNode;
done: (children: TreeNode[]) => void;
fail: () => void;
}): void {
//first unsubsrice nodes
unsubscribe([
{
path: '.*',
depth: 0,
},
])
.then(() => {
Subscriptions.value = [];
})
.catch((err) => {
NotifyResponse($q, err, 'error');
});
// now subscribe nodes
subscribe([
{
uuid: node.key ?? ZERO_UUID,
path: '',
depth: 2,
},
])
.then((resp) => {
if (resp?.subscribe) {
// Optional: update your internal store too
addChildrentoTree(resp?.subscribe);
const toRemove = new Set(
resp.subscribe.filter((sub) => sub.uuid !== ZERO_UUID).map((sub) => sub.uuid),
);
Subscriptions.value = getAllSubscriptions().filter((sub) => toRemove.has(sub.uuid));
done(dbmData.value);
} else {
done([]); // no children returned
}
})
.catch((err) => {
NotifyResponse($q, err, 'error');
fail(); // trigger the fail handler
});
}
function onValueEdit(newValue: undefined, node: TreeNode) {
console.log(node.value, node.value === undefined);
const sub = getSubscriptionsByUuid(node.key);
if (sub) {
setValues([
{
path: sub.path ?? '',
value: newValue,
},
]).catch((err) => {
NotifyResponse($q, err, 'error');
});
}
}
watch(
expanded,
(newVal, oldVal) => {
const collapsedKeys = oldVal.filter((key) => !newVal.includes(key));
collapsedKeys.forEach((key: string) => {
// WebSocket unsubscribe
unsubscribe([
{
uuid: key,
path: '.*',
depth: 0,
},
])
.then((resp) => {
// Remove children of this node from the tree
removeSubtreeByParentKey(key);
if (resp?.unsubscribe) {
const toRemove = new Set(
resp.unsubscribe.filter((sub) => sub.uuid !== ZERO_UUID).map((sub) => sub.uuid),
);
Subscriptions.value = Subscriptions.value.filter((sub) => !toRemove.has(sub.uuid));
}
})
.catch((err) => {
NotifyResponse($q, err, 'error');
});
});
},
{ deep: false },
);
</script>
<style scoped>
.tree-container {
overflow-y: auto;
}
@media (max-width: 599px) {
.tree-container {
max-height: 50vh;
}
}
@media (min-width: 600px) and (max-width: 1023px) {
.tree-container {
max-height: 60vh;
}
}
@media (min-width: 1024px) and (max-width: 1439px) {
.tree-container {
max-height: 70vh;
}
}
@media (min-width: 1440px) and (max-width: 1919px) {
.tree-container {
max-height: 80vh;
}
}
@media (min-width: 1920px) {
.tree-container {
max-height: 90vh;
}
}
</style>

View File

@@ -1,53 +0,0 @@
<template>
<q-menu ref="contextMenuRef" context-menu>
<q-list>
<q-item clickable v-close-popup @click="handleAction('Add')">
<q-item-section>Add Datapoint</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="handleAction('Delete')">
<q-item-section>Delete Datapoint</q-item-section>
</q-item>
</q-list>
</q-menu>
</template>
<script setup lang="ts">
//import { useQuasar } from 'quasar';
//import { NotifyResponse, NotifyError } from 'src/composables/notify';
import { contextMenuState, contextMenuRef } from 'src/composables/dbm/useContextMenu';
//import AddDatapoint from 'src/components/dbm/AddDatapoint.vue';
//import { send } from 'src/services/websocket';
//const $q = useQuasar();
function handleAction(action: string) {
console.log(`Action '${action}' on node:`, contextMenuState.value);
// Add your actual logic here
switch (action) {
case 'Add':
// send({
// set: [
// {
// uuid: contextMenuState.value?.key,
// path: 'New',
// type: 'BIT',
// value: true,
// create: true,
// },
// ],
// })
// .then((response) => {
// if (response?.set) {
// console.log(response);
// } else {
// NotifyResponse($q, response);
// }
// })
// .catch((err) => {
// NotifyError($q, err);
// });
console.log(4);
}
}
</script>

View File

@@ -1,36 +0,0 @@
<template>
<div class="q-pa-md">
<q-table
v-if="props.rows.length > 0"
style="height: 600px"
flat
bordered
:title="props.rows[0]?.path"
:rows="props.rows ?? []"
:columns="columns"
row-key="path"
virtual-scroll
:rows-per-page-options="[0]"
/>
</div>
</template>
<script setup lang="ts">
import type { QTableProps } from 'quasar';
import type { Subscribe } from 'src/models/Subscribe';
// we generate lots of rows here
const props = defineProps<{
rows: Subscribe[];
}>();
const columns = [
{ name: 'path', label: 'Path', field: 'path', align: 'left' },
{
name: 'value',
label: 'Value',
field: 'value',
align: 'left',
},
] as QTableProps['columns'];
</script>

View File

@@ -0,0 +1,85 @@
<template>
<q-dialog v-model="internalShowDialog">
<q-card :style="'width:' + props.width">
<q-card-section
v-if="props.dialogLabel"
class="text-h6 text-center"
:class="'text-' + props.labelColor"
>{{ props.dialogLabel }}</q-card-section
>
<q-card-section v-if="props.text" class="text-center" style="white-space: pre-line">{{
props.text
}}</q-card-section>
<q-card-actions align="right" class="text-primary">
<q-btn v-if="props.buttonCancelLabel" flat :label="props.buttonCancelLabel" v-close-popup>
</q-btn>
<q-btn
v-if="props.buttonOkLabel"
flat
:label="props.buttonOkLabel"
v-close-popup
@click="closeDialog"
>
</q-btn>
</q-card-actions>
</q-card>
</q-dialog>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue';
const props = defineProps({
showDialog: {
type: Boolean,
required: true,
},
buttonOkLabel: {
type: String,
default: 'OK',
},
labelColor: {
type: String,
default: 'primary',
},
dialogLabel: {
type: String,
default: '',
},
text: {
type: String,
default: '',
},
buttonCancelLabel: {
type: String,
default: '',
},
width: {
type: String,
default: '300px',
},
});
const emit = defineEmits(['update:showDialog', 'confirmed', 'cancel']);
const internalShowDialog = ref(props.showDialog);
watch(
() => props.showDialog,
(newValue) => {
internalShowDialog.value = newValue;
},
);
watch(internalShowDialog, (newValue) => {
emit('update:showDialog', newValue);
if (!newValue) {
emit('cancel');
} else {
emit('confirmed');
}
});
function closeDialog() {
internalShowDialog.value = false;
emit('update:showDialog', false);
}
</script>

View File

@@ -18,7 +18,7 @@
reverse reverse
v-model="light.Brightness" v-model="light.Brightness"
:min="0" :min="0"
:max="100" :max="255"
:step="1" :step="1"
color="black" color="black"
style="opacity: 0.5" style="opacity: 0.5"
@@ -29,7 +29,7 @@
reverse reverse
v-model="light.Red" v-model="light.Red"
:min="0" :min="0"
:max="100" :max="255"
:step="1" :step="1"
label label
color="red" color="red"
@@ -41,7 +41,7 @@
reverse reverse
v-model="light.Green" v-model="light.Green"
:min="0" :min="0"
:max="100" :max="255"
:step="1" :step="1"
label label
color="green" color="green"
@@ -53,7 +53,7 @@
reverse reverse
v-model="light.Blue" v-model="light.Blue"
:min="0" :min="0"
:max="100" :max="255"
:step="1" :step="1"
label label
color="blue" color="blue"
@@ -65,7 +65,7 @@
reverse reverse
v-model="light.White" v-model="light.White"
:min="0" :min="0"
:max="100" :max="255"
:step="1" :step="1"
label label
color="grey" color="grey"
@@ -77,7 +77,7 @@
reverse reverse
v-model="light.Amber" v-model="light.Amber"
:min="0" :min="0"
:max="100" :max="255"
:step="1" :step="1"
label label
color="amber" color="amber"
@@ -89,7 +89,7 @@
reverse reverse
v-model="light.Purple" v-model="light.Purple"
:min="0" :min="0"
:max="100" :max="255"
:step="1" :step="1"
label label
color="purple" color="purple"
@@ -105,14 +105,14 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useQuasar } from 'quasar';
import { watch, reactive, ref } from 'vue'; import { watch, reactive, ref } from 'vue';
import type { Light } from 'src/models/Light'; import type { Light } from 'src/models/Light';
import { setValues } from 'src/services/websocket'; import { setValues } from 'src/vueLib/services/websocket';
import SettingDialog from 'src/components/lights/SettingDomeLight.vue'; import SettingDialog from 'src/components/lights/SettingDomeLight.vue';
import { NotifyResponse } from 'src/composables/notify'; import { useNotify } from 'src/vueLib/general/useNotify';
import { catchError } from 'src/vueLib/models/error';
const $q = useQuasar(); const { NotifyResponse } = useNotify();
const settings = ref(false); const settings = ref(false);
const light = reactive<Light>({ const light = reactive<Light>({
@@ -154,10 +154,10 @@ watch(light, (newVal: Light) => {
}, },
]) ])
.then((response) => { .then((response) => {
NotifyResponse($q, response); NotifyResponse(response);
}) })
.catch((err) => { .catch((err) => {
NotifyResponse($q, err, 'error'); NotifyResponse(catchError(err), 'error');
}); });
}); });
</script> </script>

View File

@@ -3,22 +3,35 @@
<div class="row q-ma-xs"> <div class="row q-ma-xs">
<div class="column items-center q-mr-md" :style="{ height: containerSize + 'px' }"> <div class="column items-center q-mr-md" :style="{ height: containerSize + 'px' }">
<div class="column justify-between items-center" :style="{ height: containerSize + 'px' }"> <div class="column justify-between items-center" :style="{ height: containerSize + 'px' }">
<q-item-label class="text-black text-bold q-mb-none">Tilt</q-item-label> <q-item-label
@click="toggleTilt = !toggleTilt"
:class="[
'cursor-pointer',
'text-bold',
'clickable-text-effect',
'q-mb-none',
`text-black`,
]"
>
{{ toggleTilt ? 'Tilt Fine' : 'Tilt' }}</q-item-label
>
<q-btn <q-btn
:size="buttonSize" :size="buttonSize"
round round
color="positive" color="positive"
icon="add_circle_outline" icon="add_circle_outline"
class="q-mb-md" class="q-mb-md"
@click="reverseTilt ? substractTiltOne : addTiltOne" @click="reverseTilt ? substractTilt : addTilt"
v-touch-repeat:300:300:300:300:50.mouse="reverseTilt ? substractTiltOne : addTiltOne" v-touch-repeat:0:300:300:300:300:50:50:50:20.mouse="
reverseTilt ? substractTilt : addTilt
"
/> />
<q-slider <q-slider
vertical vertical
:reverse="!props.reverseTilt" :reverse="!props.reverseTilt"
v-model="tilt" v-model="tilt"
:min="0" :min="0"
:max="100" :max="255"
:step="1" :step="1"
label label
class="col" class="col"
@@ -31,9 +44,9 @@
round round
color="negative" color="negative"
icon="remove_circle_outline" icon="remove_circle_outline"
@click="reverseTilt ? addTiltOne : substractTiltOne" @click="reverseTilt ? addTilt : substractTilt"
v-touch-repeat:300:300:300:300:50:50:50:50:20.mouse=" v-touch-repeat:0:300:300:300:300:50:50:50:20.mouse="
reverseTilt ? addTiltOne : substractTiltOne reverseTilt ? addTilt : substractTilt
" "
/> />
</div> </div>
@@ -49,7 +62,11 @@
> >
<div class="marker" :style="markerStyle" :class="{ crosshair: dragging }"></div> <div class="marker" :style="markerStyle" :class="{ crosshair: dragging }"></div>
</div> </div>
<q-item-label class="q-ma-sm text-black text-bold">Pan</q-item-label> <q-item-label
@click="togglePan = !togglePan"
:class="['cursor-pointer', 'text-bold', 'clickable-text-effect', 'q-mt-lg', `text-black`]"
>{{ togglePan ? 'Pan Fine' : 'Pan' }}</q-item-label
>
<div class="q-gutter-sm row items-center full-width"> <div class="q-gutter-sm row items-center full-width">
<q-btn <q-btn
@@ -58,9 +75,9 @@
round round
color="negative" color="negative"
icon="remove_circle_outline" icon="remove_circle_outline"
@click="reversePan ? addPanOne : substractPanOne" @click="reversePan ? addPan : substractPan"
v-touch-repeat:300:300:300:300:50:50:50:50:20.mouse=" v-touch-repeat:0:300:300:300:300:50:50:50:50:20.mouse="
reversePan ? addPanOne : substractPanOne reversePan ? addPan : substractPan
" "
/> />
<q-slider <q-slider
@@ -68,7 +85,7 @@
:reverse="props.reversePan" :reverse="props.reversePan"
v-model="pan" v-model="pan"
:min="0" :min="0"
:max="100" :max="255"
:step="1" :step="1"
label label
color="black" color="black"
@@ -80,8 +97,8 @@
round round
color="positive" color="positive"
icon="add_circle_outline" icon="add_circle_outline"
@click="reversePan ? substractPanOne : addPanOne" @click="reversePan ? substractPan : addPan"
v-touch-repeat:300:300:300:300:50.mouse="reversePan ? substractPanOne : addPanOne" v-touch-repeat:0:300:300:300:300:50:50:50:20.mouse="reversePan ? substractPan : addPan"
/> />
</div> </div>
</div> </div>
@@ -90,18 +107,52 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { addOne, substractOne } from 'src/utils/number-helpers';
import { ref, computed, onMounted, onUnmounted } from 'vue'; import { ref, computed, onMounted, onUnmounted } from 'vue';
import { updateValue } from 'src/vueLib/dbm/dbmTree';
import { useNotify } from 'src/vueLib/general/useNotify';
const props = defineProps({
reversePan: {
type: Boolean,
default: false,
},
reverseTilt: {
type: Boolean,
default: false,
},
panPath: {
type: String,
default: '',
required: true,
},
panPath2: {
type: String,
default: '',
},
tiltPath: {
type: String,
default: '',
required: true,
},
tiltPath2: {
type: String,
default: '',
},
});
const { NotifyResponse } = useNotify();
const togglePan = ref(false);
const toggleTilt = ref(false);
const pad = ref<HTMLElement | null>(null); const pad = ref<HTMLElement | null>(null);
const dragging = ref(false); const dragging = ref(false);
const containerSize = ref(0); const containerSize = ref(0);
const pan = defineModel<number>('pan', { default: 0 }); const pan = updateValue(NotifyResponse, props.panPath, togglePan, props.panPath2);
const tilt = defineModel<number>('tilt', { default: 0 }); const tilt = updateValue(NotifyResponse, props.tiltPath, toggleTilt, props.tiltPath2);
const props = defineProps<{
reversePan: boolean; const scaleFactor = computed(() => containerSize.value / 255);
reverseTilt: boolean; // 200px → 2, 400px → 4, etc.
}>();
const buttonSize = computed(() => (containerSize.value <= 200 ? 'sm' : 'md')); const buttonSize = computed(() => (containerSize.value <= 200 ? 'sm' : 'md'));
onMounted(() => { onMounted(() => {
@@ -120,16 +171,12 @@ onMounted(() => {
}); });
}); });
const scaleFactor = computed(() => containerSize.value / 100);
// 200px → 2, 400px → 4, etc.
const markerStyle = computed(() => { const markerStyle = computed(() => {
const scale = scaleFactor.value; const scale = scaleFactor.value;
return { return {
position: 'absolute' as const, position: 'absolute' as const,
top: `${scale * (props.reverseTilt ? tilt.value : 100 - tilt.value)}px`, top: `${scale * (props.reverseTilt ? tilt.value : 255 - tilt.value)}px`,
left: `${scale * (props.reversePan ? 100 - pan.value : pan.value)}px`, left: `${scale * (props.reversePan ? 255 - pan.value : pan.value)}px`,
width: '12px', width: '12px',
height: '12px', height: '12px',
borderRadius: '50%', borderRadius: '50%',
@@ -154,7 +201,7 @@ function stopDrag() {
} }
function startTouch(e: TouchEvent) { function startTouch(e: TouchEvent) {
e.preventDefault(); // ✅ block scroll e.preventDefault();
const touch = e.touches[0]; const touch = e.touches[0];
if (!touch) return; if (!touch) return;
dragging.value = true; dragging.value = true;
@@ -191,35 +238,27 @@ function updatePosition(e: MouseEvent | Touch) {
const newY = Math.min(Math.max(0, e.clientY - rect.top), rect.height); const newY = Math.min(Math.max(0, e.clientY - rect.top), rect.height);
pan.value = props.reversePan pan.value = props.reversePan
? Math.round((1 - newX / rect.width) * 100) ? Math.round((1 - newX / rect.width) * 255)
: Math.round((newX / rect.width) * 100); : Math.round((newX / rect.width) * 255);
tilt.value = props.reverseTilt tilt.value = props.reverseTilt
? Math.round((newY / rect.height) * 100) ? Math.round((newY / rect.height) * 255)
: Math.round(100 - (newY / rect.height) * 100); : Math.round(255 - (newY / rect.height) * 255);
} }
function addTiltOne() { function addTilt() {
if (tilt.value <= 255) { addOne(tilt, 255);
tilt.value++;
}
} }
function substractTiltOne() { function substractTilt() {
if (tilt.value >= 0) { substractOne(tilt, 0);
tilt.value--;
}
} }
function addPanOne() { function addPan() {
if (pan.value <= 255) { addOne(pan, 255);
pan.value++;
}
} }
function substractPanOne() { function substractPan() {
if (pan.value >= 0) { substractOne(pan, 0);
pan.value--;
}
} }
</script> </script>

View File

@@ -0,0 +1,98 @@
<template>
<div>
<q-card>
<div class="q-pt-md text-black text-bold text-center">{{ cardTitle }}</div>
<q-card-section class="row items-start">
<div class="column justify-center q-mr-xs" style="height: 200px">
<q-btn
@click="changeState"
round
:color="brightness > 0 ? 'yellow' : 'blue'"
icon="lightbulb"
style="position: relative"
/>
</div>
<LightSlider
mainTitle="Dimmer"
:dbm-path="props.path + ':Brightness'"
:opacity="0.5"
class="q-ma-sm"
></LightSlider>
<LightSlider
mainTitle="Red"
:dbm-path="props.path + ':Red'"
color="red"
:opacity="0.8"
class="q-ma-sm"
></LightSlider>
<LightSlider
mainTitle="Green"
:dbm-path="props.path + ':Green'"
:opacity="0.8"
color="green"
class="q-ma-sm"
></LightSlider>
<LightSlider
mainTitle="Blue"
:dbm-path="props.path + ':Blue'"
:opacity="0.8"
color="blue"
class="q-ma-sm"
></LightSlider>
</q-card-section>
</q-card>
</div>
</template>
<script setup lang="ts">
import LightSlider from './LightSlider.vue';
import { onMounted, onUnmounted } from 'vue';
import { unsubscribe, subscribeToPath } from 'src/vueLib/services/websocket';
import { useNotify } from 'src/vueLib/general/useNotify';
import { updateValue } from 'src/vueLib/dbm/dbmTree';
import { removeAllSubscriptions } from 'src/vueLib/models/Subscriptions';
import { catchError } from 'src/vueLib/models/error';
const props = defineProps({
cardTitle: {
type: String,
default: '',
},
path: {
type: String,
required: true,
},
});
const { NotifyResponse } = useNotify();
const brightness = updateValue(NotifyResponse, props.path + ':Brightness');
const state = updateValue(NotifyResponse, props.path + ':State');
onMounted(() => {
subscribeToPath(NotifyResponse, props.path + ':.*');
});
onUnmounted(() => {
unsubscribe([
{
path: props.path,
depth: 0,
},
]).catch((err) => {
NotifyResponse(catchError(err), 'error');
});
removeAllSubscriptions();
});
function changeState() {
if (brightness.value === 0) {
if (state.value === 0) {
brightness.value = 255;
return;
}
brightness.value = state.value;
return;
}
state.value = brightness.value;
brightness.value = 0;
}
</script>

View File

@@ -0,0 +1,18 @@
<template>
<div class="">
<q-card>
<div class="row items-start">
<q-card-section>
<FloodPanel card-title="Left" path="FloodPanels:001" />
</q-card-section>
<q-card-section>
<FloodPanel card-title="Right" path="FloodPanels:002" />
</q-card-section>
</div>
</q-card>
</div>
</template>
<script setup lang="ts">
import FloodPanel from './FloodPanel.vue';
</script>

View File

@@ -12,106 +12,87 @@
/> />
</div> </div>
<LightSlider <LightSlider
title="Dimmer" mainTitle="Dimmer"
:dbm-path="'LightBar:Brightness'" dbm-path="LightBar:Brightness"
:opacity="0.5" :opacity="0.5"
class="q-ma-sm" class="q-ma-sm"
></LightSlider> ></LightSlider>
<LightSlider <LightSlider
title="Strobe" mainTitle="Strobe"
:dbm-path="'LightBar:Strobe'" dbm-path="LightBar:Strobe"
:opacity="0.5" :opacity="0.5"
class="q-ma-sm" class="q-ma-sm"
></LightSlider> ></LightSlider>
<LightSlider <LightSlider
title="Program" mainTitle="Program"
:dbm-path="'LightBar:Program'" dbm-path="LightBar:Program"
:opacity="0.5" :opacity="0.5"
class="q-ma-sm" class="q-ma-sm"
></LightSlider> ></LightSlider>
<LightSlider <LightSlider
title="Program Speed" mainTitle="Program Speed"
:dbm-path="'LightBar:Program:Speed'" dbm-path="LightBar:Program:Speed"
:opacity="0.8" :opacity="0.8"
class="q-ma-sm" class="q-ma-sm"
></LightSlider> ></LightSlider>
<LightSlider <LightSlider
title="Red" mainTitle="Red"
:dbm-path="'LightBar:Red'" dbm-path="LightBar:Red"
color="red" color="red"
:opacity="0.8" :opacity="0.8"
class="q-ma-sm" class="q-ma-sm"
></LightSlider> ></LightSlider>
<LightSlider <LightSlider
title="Green" mainTitle="Green"
:dbm-path="'LightBar:Green'" dbm-path="LightBar:Green"
:opacity="0.8" :opacity="0.8"
color="green" color="green"
class="q-ma-sm" class="q-ma-sm"
></LightSlider> ></LightSlider>
<LightSlider <LightSlider
title="Blue" mainTitle="Blue"
:dbm-path="'LightBar:Blue'" dbm-path="LightBar:Blue"
:opacity="0.8" :opacity="0.8"
color="blue" color="blue"
class="q-ma-sm" class="q-ma-sm"
></LightSlider> ></LightSlider>
<div class="colums q-ma-xl">
<q-btn color="secondary" @click="settings = !settings" icon="settings">Settings</q-btn>
<SettingDialog :settings-dialog="settings"></SettingDialog>
</div>
</q-card-section> </q-card-section>
</q-card> </q-card>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useQuasar } from 'quasar';
import { ref, onMounted, onUnmounted } from 'vue';
import { subscribe, unsubscribe } from 'src/services/websocket';
import SettingDialog from 'src/components/lights/SettingDomeLight.vue';
import { NotifyResponse } from 'src/composables/notify';
import { updateValue, buildTree, dbmData } from 'src/composables/dbm/dbmTree';
import LightSlider from './LightSlider.vue'; import LightSlider from './LightSlider.vue';
import { onMounted, onUnmounted } from 'vue';
import { unsubscribe, subscribeToPath } from 'src/vueLib/services/websocket';
import { useNotify } from 'src/vueLib/general/useNotify';
import { updateValue } from 'src/vueLib/dbm/dbmTree';
import { removeAllSubscriptions } from 'src/vueLib/models/Subscriptions';
import { catchError } from 'src/vueLib/models/error';
const $q = useQuasar(); const { NotifyResponse } = useNotify();
const settings = ref(false); const brightness = updateValue(NotifyResponse, 'LightBar:Brightness');
const brightness = updateValue('LightBar:Brightness', $q); const state = updateValue(NotifyResponse, 'LightBar:State');
const state = updateValue('LightBar:State', $q);
onMounted(() => { onMounted(() => {
subscribe([ subscribeToPath(NotifyResponse, 'LightBar:.*');
{
path: 'LightBar:.*',
depth: 0,
},
])
.then((response) => {
if (response?.subscribe) {
dbmData.value = buildTree(response.subscribe ?? []);
} else {
NotifyResponse($q, response);
}
})
.catch((err) => {
NotifyResponse($q, err, 'error');
});
}); });
onUnmounted(() => { onUnmounted(() => {
unsubscribe([ unsubscribe([
{ {
path: '.*', path: 'LightBar',
depth: 0, depth: 0,
}, },
]).catch((err) => { ]).catch((err) => {
NotifyResponse($q, err, 'error'); NotifyResponse(catchError(err), 'error');
}); });
removeAllSubscriptions();
}); });
function changeState() { function changeState() {
if (brightness.value === 0) { if (brightness.value === 0) {
if (state.value === 0) { if (state.value === 0) {
brightness.value = 100; brightness.value = 255;
return; return;
} }
brightness.value = state.value; brightness.value = state.value;

View File

@@ -1,14 +1,22 @@
<template> <template>
<div :class="'column items-center ' + props.class"> <div :class="'column items-center ' + props.class">
<q-item-label :class="['text-bold', `text-${textColor}`]"><p v-html="title"></p></q-item-label> <q-item-label v-if="!toggleHighLow" :class="['text-bold', `text-${textColor}`]"
><p v-html="mainTitle"></p>
</q-item-label>
<q-item-label
v-else
@click="toggle = !toggle"
:class="['cursor-pointer', 'text-bold', 'clickable-text-effect', `text-${textColor}`]"
><p v-html="toggle ? secondTitle : mainTitle"></p>
</q-item-label>
<q-btn <q-btn
size="sm" size="sm"
class="q-mb-sm" class="q-mb-md"
round round
color="positive" color="positive"
icon="add_circle_outline" icon="add_circle_outline"
@click="addOne" @click="reverse ? add : substract"
v-touch-repeat:300:300:300:300:50:50:50:50:20.mouse="addOne" v-touch-repeat:0:300:300:300:300:50:50:50:50:20.mouse="reverse ? add : substract"
/> />
<div> <div>
<q-slider <q-slider
@@ -29,20 +37,28 @@
round round
color="negative" color="negative"
icon="remove_circle_outline" icon="remove_circle_outline"
@click="substractOne" @click="reverse ? substract : add"
v-touch-repeat:300:300:300:300:50:50:50:50:20.mouse="substractOne" v-touch-repeat:0:300:300:300:300:50:50:50:50:20.mouse="reverse ? substract : add"
/> />
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useQuasar } from 'quasar'; import { ref } from 'vue';
import { updateValue } from 'src/composables/dbm/dbmTree'; import { updateValue } from 'src/vueLib/dbm/dbmTree';
import { addOne, substractOne } from 'src/utils/number-helpers';
const $q = useQuasar(); import { useNotify } from 'src/vueLib/general/useNotify';
const props = defineProps({ const props = defineProps({
title: { toggleHighLow: {
type: Boolean,
default: false,
},
mainTitle: {
type: String,
default: '',
},
secondTitle: {
type: String, type: String,
default: '', default: '',
}, },
@@ -77,7 +93,7 @@ const props = defineProps({
}, },
max: { max: {
type: Number, type: Number,
default: 100, default: 255,
}, },
vertical: { vertical: {
type: Boolean, type: Boolean,
@@ -105,17 +121,36 @@ const props = defineProps({
}, },
}); });
const localValue = updateValue(props.dbmPath, $q, props.dbmPath2, props.dbmPath3, props.dbmValue3); const { NotifyResponse } = useNotify();
const toggle = ref(false);
const localValue = updateValue(
NotifyResponse,
props.dbmPath,
toggle,
props.dbmPath2,
props.dbmPath3,
props.dbmValue3,
);
function addOne() { function add() {
if (localValue.value <= 255) { addOne(localValue, 255);
localValue.value++;
}
} }
function substractOne() { function substract() {
if (localValue.value >= 0) { substractOne(localValue, 0);
localValue.value--;
}
} }
</script> </script>
<style>
.clickable-text-effect {
cursor: pointer;
color: #040303; /* Static text color */
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
/* Add hover effect here if you want it part of this class */
transition: text-shadow 0.2s ease-in-out;
}
.clickable-text-effect:hover {
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}
</style>

View File

@@ -21,49 +21,59 @@ select
</div> </div>
<LightSlider <LightSlider
title="Dimmer" mainTitle="Dimmer"
:dbm-path="'MovingHead:Brightness'" second-title="Dimmer Fine"
:dbm-path2="'MovingHead:BrightnessFine'" :toggle-high-low="true"
:dbm-path3="'MovingHead:Strobe'" dbm-path="MovingHead:Brightness"
dbm-path2="MovingHead:BrightnessFine"
dbm-path3="MovingHead:Strobe'"
:dbm-value3="255" :dbm-value3="255"
:opacity="0.5" :opacity="0.5"
class="q-ma-md" class="q-ma-md"
/> />
<LightSlider <LightSlider
title="Red" mainTitle="Red"
:dbm-path="'MovingHead:Red'" second-title="Red Fine"
:dbm-path2="'MovingHead:RedFine'" :toggle-high-low="true"
dbm-path="MovingHead:Red"
dbm-path2="MovingHead:RedFine"
:opacity="0.8" :opacity="0.8"
color="red" color="red"
class="q-ma-md" class="q-ma-md"
/> />
<LightSlider <LightSlider
title="Green" mainTitle="Green"
:dbm-path="'MovingHead:Green'" second-title="Green Fine"
:dbm-path2="'MovingHead:GreenFine'" :toggle-high-low="true"
dbm-path="MovingHead:Green"
dbm-path2="MovingHead:GreenFine"
:opacity="0.8" :opacity="0.8"
color="green" color="green"
class="q-ma-md" class="q-ma-md"
/> />
<LightSlider <LightSlider
title="Blue" mainTitle="Blue"
:dbm-path="'MovingHead:Blue'" second-title="Blue Fine"
:dbm-path2="'MovingHead:BlueFine'" :toggle-high-low="true"
dbm-path="MovingHead:Blue"
dbm-path2="MovingHead:BlueFine"
:opacity="0.8" :opacity="0.8"
color="blue" color="blue"
class="q-ma-md" class="q-ma-md"
/> />
<LightSlider <LightSlider
title="White" mainTitle="White"
:dbm-path="'MovingHead:White'" second-title="White Fine"
:dbm-path2="'MovingHead:WhiteFine'" :toggle-high-low="true"
dbm-path="MovingHead:White"
dbm-path2="MovingHead:WhiteFine"
:opacity="0.3" :opacity="0.3"
color="grey" color="grey"
class="q-ma-md" class="q-ma-md"
/> />
<LightSlider <LightSlider
title="Zoom" mainTitle="Zoom"
:dbm-path="'MovingHead:Zoom'" dbm-path="MovingHead:Zoom"
:opacity="1" :opacity="1"
color="black" color="black"
class="q-ma-md" class="q-ma-md"
@@ -71,9 +81,11 @@ select
<div> <div>
<DragPad <DragPad
class="q-ma-md" class="q-ma-md"
v-model:pan="pan" pan-path="MovingHead:Pan"
pan-path2="MovingHead:PanFine"
v-model:reverse-pan="settings.reversePan" v-model:reverse-pan="settings.reversePan"
v-model:tilt="tilt" tilt-path="MovingHead:Tilt"
tilt-path2="MovingHead:TiltFine"
v-model:reverse-tilt="settings.reverseTilt" v-model:reverse-tilt="settings.reverseTilt"
/> />
</div> </div>
@@ -89,50 +101,35 @@ select
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useQuasar } from 'quasar';
import LightSlider from './LightSlider.vue'; import LightSlider from './LightSlider.vue';
import { NotifyResponse } from 'src/composables/notify'; import { useNotify } from 'src/vueLib/general/useNotify';
import { computed, onMounted, onUnmounted, ref } from 'vue'; import { onBeforeUpdate, computed, onMounted, onUnmounted, ref } from 'vue';
import { subscribe, unsubscribe, setValues } from 'src/services/websocket'; import { subscribeToPath, unsubscribe, setValues } from 'src/vueLib/services/websocket';
import { LocalStorage } from 'quasar'; import { LocalStorage } from 'quasar';
import { getSubscriptionsByPath, buildTree, dbmData } from 'src/composables/dbm/dbmTree'; import { updateValue } from 'src/vueLib/dbm/dbmTree';
import DragPad from 'src/components/lights/DragPad.vue'; import DragPad from 'src/components/lights/DragPad.vue';
import SettingDialog from './SettingMovingHead.vue'; import SettingDialog from './SettingMovingHead.vue';
import type { Settings } from 'src/models/MovingHead'; import type { Settings } from 'src/models/MovingHead';
import { findSubscriptionByPath, removeAllSubscriptions } from 'src/vueLib/models/Subscriptions';
import { catchError } from 'src/vueLib/models/error';
const $q = useQuasar(); const { NotifyResponse } = useNotify();
const brightness = updateBrightnessValue('MovingHead:Brightness');
const pan = updateValue('MovingHead:Pan', true);
const tilt = updateValue('MovingHead:Tilt', true);
const state = updateValue('MovingHead:State');
const settings = ref<Settings>({ const settings = ref<Settings>({
show: false, show: false,
reversePan: false, reversePan: false,
reverseTilt: false, reverseTilt: false,
startAddress: 0,
}); });
const brightness = updateBrightnessValue('MovingHead:Brightness');
const state = updateValue(NotifyResponse, 'MovingHead:State');
onMounted(() => { onMounted(() => {
settings.value.reversePan = LocalStorage.getItem('reversePan') ?? false; settings.value.reversePan = LocalStorage.getItem('reversePan') ?? false;
settings.value.reverseTilt = LocalStorage.getItem('reverseTilt') ?? false; settings.value.reverseTilt = LocalStorage.getItem('reverseTilt') ?? false;
subscribeToPath(NotifyResponse, 'MovingHead:.*');
});
subscribe([ onBeforeUpdate(() => {
{ subscribeToPath(NotifyResponse, 'MovingHead:.*');
path: 'MovingHead:.*',
depth: 0,
},
])
.then((response) => {
console.log(response);
if (response?.subscribe) {
dbmData.value = buildTree(response.subscribe ?? []);
} else {
NotifyResponse($q, response);
}
})
.catch((err) => {
NotifyResponse($q, err, 'error');
});
}); });
onUnmounted(() => { onUnmounted(() => {
@@ -142,14 +139,15 @@ onUnmounted(() => {
depth: 0, depth: 0,
}, },
]).catch((err) => { ]).catch((err) => {
NotifyResponse($q, err, 'error'); NotifyResponse(catchError(err), 'error');
}); });
removeAllSubscriptions();
}); });
function changeState() { function changeState() {
if (brightness.value === 0) { if (brightness.value === 0) {
if (state.value === 0) { if (state.value === 0) {
brightness.value = 100; brightness.value = 255;
return; return;
} }
brightness.value = state.value; brightness.value = state.value;
@@ -159,43 +157,21 @@ function changeState() {
brightness.value = 0; brightness.value = 0;
} }
function updateValue(path: string, isDouble = false) {
return computed({
get() {
const sub = getSubscriptionsByPath(path);
const value = sub ? Number(sub.value ?? 0) : 0;
return isDouble ? Math.round((100 / 255) * value) : Math.round((100 / 255) * value);
},
set(val) {
const baseValue = Math.round((255 / 100) * val);
const setPaths = [{ path, value: baseValue }];
if (isDouble) {
setPaths.push({ path: `${path}Fine`, value: baseValue });
}
setValues(setPaths)
.then((response) => NotifyResponse($q, response))
.catch((err) => console.error(`Failed to update ${path.split(':')[1]}:`, err));
},
});
}
function updateBrightnessValue(path: string) { function updateBrightnessValue(path: string) {
return computed({ return computed({
get() { get() {
const sub = getSubscriptionsByPath(path); const sub = findSubscriptionByPath(path);
const value = sub ? Number(sub.value ?? 0) : 0; if (!sub) return 0;
return Math.round((100 / 255) * value); if (!sub.value) return 0;
return Number(sub.value);
}, },
set(val) { set(val) {
const baseValue = Math.round((255 / 100) * val); const setPaths = [{ path, value: val }];
const setPaths = [{ path, value: baseValue }]; setPaths.push({ path: `${path}Fine`, value: val });
setPaths.push({ path: `${path}Fine`, value: baseValue });
setPaths.push({ path: `MovingHead:Strobe`, value: 255 }); setPaths.push({ path: `MovingHead:Strobe`, value: 255 });
setValues(setPaths) setValues(setPaths)
.then((response) => NotifyResponse($q, response)) .then((response) => NotifyResponse(response))
.catch((err) => console.error(`Failed to update ${path.split(':')[1]}:`, err)); .catch((err) => console.error(`Failed to update ${path.split(':')[1]}:`, err));
}, },
}); });

View File

@@ -21,13 +21,6 @@
>{{ settings.reversePan ? 'Reversed Pan' : 'Normal Pan' }}</q-btn >{{ settings.reversePan ? 'Reversed Pan' : 'Normal Pan' }}</q-btn
> >
</q-card-section> </q-card-section>
<q-card-section>
<q-input
type="number"
label="Start Address"
v-model:model-value="settings.startAddress"
></q-input>
</q-card-section>
<q-card-actions align="right"> <q-card-actions align="right">
<q-btn flat label="Cancel" v-close-popup /> <q-btn flat label="Cancel" v-close-popup />
<q-btn flat label="Save" @click="saveSettings" /> <q-btn flat label="Save" @click="saveSettings" />
@@ -45,7 +38,6 @@ const settings = defineModel<Settings>('settings', {
show: false, show: false,
reversePan: false, reversePan: false,
reverseTilt: false, reverseTilt: false,
startAddress: 0,
}, },
required: true, required: true,
}); });

View File

@@ -0,0 +1,117 @@
<template>
<div>
<q-card>
<div class="q-pt-md text-black text-bold text-center">{{ cardTitle }}</div>
<q-card-section class="row items-start">
<div class="column justify-center q-mr-xs" style="height: 200px">
<q-btn
@click="changeState"
round
:color="brightness > 0 ? 'yellow' : 'blue'"
icon="lightbulb"
style="position: relative"
/>
</div>
<LightSlider
mainTitle="Dimmer"
:dbm-path="props.path + ':Brightness'"
:opacity="0.5"
class="q-ma-sm"
></LightSlider>
<LightSlider
mainTitle="Strobe"
:dbm-path="props.path + ':Strobe'"
:opacity="0.5"
class="q-ma-sm"
></LightSlider>
<LightSlider
mainTitle="DimmerFade"
:dbm-path="props.path + ':DimmerFade'"
:opacity="0.5"
:step="50"
class="q-ma-sm"
></LightSlider>
<LightSlider
mainTitle="Red"
:dbm-path="props.path + ':Red'"
color="red"
:opacity="0.8"
class="q-ma-sm"
></LightSlider>
<LightSlider
mainTitle="Green"
:dbm-path="props.path + ':Green'"
:opacity="0.8"
color="green"
class="q-ma-sm"
></LightSlider>
<LightSlider
mainTitle="Blue"
:dbm-path="props.path + ':Blue'"
:opacity="0.8"
color="blue"
class="q-ma-sm"
></LightSlider>
<LightSlider
mainTitle="White"
:dbm-path="props.path + ':White'"
:opacity="0.5"
class="q-ma-sm"
></LightSlider>
</q-card-section>
</q-card>
</div>
</template>
<script setup lang="ts">
import LightSlider from './LightSlider.vue';
import { onMounted, onUnmounted } from 'vue';
import { unsubscribe, subscribeToPath } from 'src/vueLib/services/websocket';
import { useNotify } from 'src/vueLib/general/useNotify';
import { updateValue } from 'src/vueLib/dbm/dbmTree';
import { removeAllSubscriptions } from 'src/vueLib/models/Subscriptions';
import { catchError } from 'src/vueLib/models/error';
const props = defineProps({
cardTitle: {
type: String,
default: '',
},
path: {
type: String,
required: true,
},
});
const { NotifyResponse } = useNotify();
const brightness = updateValue(NotifyResponse, props.path + ':Brightness');
const state = updateValue(NotifyResponse, props.path + ':State');
onMounted(() => {
subscribeToPath(NotifyResponse, props.path + ':.*');
});
onUnmounted(() => {
unsubscribe([
{
path: props.path,
depth: 0,
},
]).catch((err) => {
NotifyResponse(catchError(err), 'error');
});
removeAllSubscriptions();
});
function changeState() {
if (brightness.value === 0) {
if (state.value === 0) {
brightness.value = 255;
return;
}
brightness.value = state.value;
return;
}
state.value = brightness.value;
brightness.value = 0;
}
</script>

View File

@@ -0,0 +1,18 @@
<template>
<div class="">
<q-card>
<div class="row items-start">
<q-card-section>
<StageLight card-title="Left" path="StageLights:001" />
</q-card-section>
<q-card-section>
<StageLight card-title="Right" path="StageLights:002" />
</q-card-section>
</div>
</q-card>
</div>
</template>
<script setup lang="ts">
import StageLight from './StageLight.vue';
</script>

View File

@@ -0,0 +1,388 @@
<template>
<!-- new edit scene dialog-->
<DialogFrame ref="sceneDialog" width="350px">
<q-card>
<q-card-section>
<div class="text-primary text-h6">{{ dialogLabel }}</div>
</q-card-section>
<q-card-section class="q-pt-none">
<q-input
:readonly="dialog === 'load'"
class="q-mb-md"
dense
v-model="newScene.name"
placeholder="Name"
autofocus
:rules="[(val) => !!val || 'Field is required']"
@keyup.enter="saveScene"
/>
<q-input
:readonly="dialog === 'load'"
dense
v-model="newScene.description"
placeholder="Description"
autofocus
@keyup.enter="saveScene"
/>
<div class="q-py-md">
<div class="q-gutter-sm">
<q-checkbox v-model="newScene.stageLights" label="Stage Lights" />
<q-checkbox v-model="newScene.lightBar" label="Light Bar" />
<q-checkbox v-model="newScene.floodPanels" label="Flood Panels" />
<q-checkbox v-model="newScene.movingHead" label="Moving Head" />
</div>
</div>
</q-card-section>
<q-card-actions align="right" class="text-primary">
<q-btn flat :label="dialogLabel" v-close-popup @click="saveScene()" />
</q-card-actions>
</q-card>
</DialogFrame>
<Dialog
dialogLabel="Duplicate Scene"
:text="`Scene '${newScene.name}' exists already`"
:show-dialog="existsAlready"
v-on:update:show-dialog="existsAlready = $event"
/>
<q-list
bordered
v-if="scenes?.length > 0"
class="q-mx-auto"
style="max-width: 100%; max-width: 500px"
>
<q-btn
rounded
no-caps
color="primary"
:class="['q-ma-md', 'text-bold', 'text-white']"
@click="openDialog('add')"
>Add New Scene</q-btn
>
<q-item class="row">
<q-item-section :class="['text-black', 'text-bold', 'col-5']">Name</q-item-section>
<q-item-section :class="['text-black', 'text-left', 'text-bold', 'text-left']"
>Description</q-item-section
>
</q-item>
<q-item
v-for="(item, index) in scenes"
:key="item.name"
bordered
style="border: 0.1px solid lightgray; border-radius: 5px; margin-bottom: 1px"
>
<q-item-section
@click="openDialog('load', item)"
:class="['text-black', 'text-left', 'cursor-pointer']"
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis"
>{{ item.name }}</q-item-section
>
<q-item-section
@click="openDialog('load', item)"
:class="['text-black', 'text-left', 'cursor-pointer']"
left
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis"
>{{ item.description }}</q-item-section
>
<q-item-section top side>
<div class="text-grey-8 q-gutter-xs">
<q-btn size="12px" flat dense round icon="delete" @click="removeScene(item.name)" />
<q-btn
size="12px"
flat
dense
round
icon="more_vert"
@click="openDialog('edit', item, index)"
/>
</div>
</q-item-section>
</q-item>
</q-list>
<!-- Fallback if list is empty -->
<div v-else class="q-pa-md text-grey text-center">
<div>No scenes available</div>
<q-btn
rounded
no-caps
color="primary"
:class="['q-ma-md', 'text-bold', 'text-white']"
@click="openDialog('add')"
>Add First Scene</q-btn
>
</div>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue';
import type { Scene } from 'src/models/Scene';
import type { Set } from 'src/vueLib/models/Set';
import { dbmApi } from 'src/boot/axios';
import { useNotify } from 'src/vueLib/general/useNotify';
import Dialog from 'src/components/dialog/OkDialog.vue';
import { setValues } from 'src/vueLib/services/websocket';
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
import { catchError } from 'src/vueLib/models/error';
import { appApi } from 'src/boot/axios';
const { NotifyResponse, NotifyDialog } = useNotify();
const sceneDialog = ref();
const dialog = ref('');
const existsAlready = ref(false);
const editIndex = ref(-1);
const dialogLabel = ref('');
const newScene = reactive<Scene>({
name: '',
stageLights: false,
lightBar: false,
floodPanels: false,
movingHead: false,
});
const scenes = ref<Scene[]>([]);
onMounted(() => {
appApi
.get('/loadScenes')
.then((resp) => {
if (resp.data) {
scenes.value = resp.data;
}
})
.catch((err) => {
NotifyResponse(catchError(err), 'error');
});
});
function removeScene(name: string) {
dialog.value = '';
NotifyDialog('Delete', 'Do you want to delete scene: ' + name, 'YES', 'NO')
.then((res) => {
if (res) {
scenes.value = scenes.value.filter((s) => s.name !== name);
appApi
.delete('/deleteScene', {
data: { name },
})
.then((res) => {
if (res.data) {
NotifyResponse(res.data, 'warning');
}
})
.catch((err) => {
NotifyResponse(catchError(err), 'error');
});
}
})
.catch((err) => NotifyResponse(catchError(err), 'warning'));
}
function openDialog(dialogType: string, scene?: Scene, index?: number) {
switch (dialogType) {
case 'add':
dialog.value = 'add';
dialogLabel.value = 'Add Scene';
newScene.name = '';
newScene.stageLights = true;
newScene.lightBar = true;
newScene.floodPanels = true;
newScene.movingHead = true;
break;
case 'edit':
if (!scene) return;
if (index === undefined) return;
dialog.value = 'edit';
dialogLabel.value = 'Update Scene';
editIndex.value = index;
Object.assign(newScene, JSON.parse(JSON.stringify(scene)));
break;
case 'load':
if (!scene) return;
dialog.value = 'load';
dialogLabel.value = 'Load Scene';
appApi
.post('/loadScene', scene)
.then((res) => {
if (res.data) {
Object.assign(newScene, JSON.parse(JSON.stringify(res.data)));
}
})
.catch((err) => NotifyResponse(catchError(err), 'error'));
break;
}
sceneDialog.value.open();
}
const saveScene = async () => {
const sendValues = [];
if (!newScene.name) {
return;
}
const exists = scenes.value.some(
(item, index) => item.name === newScene.name && index !== editIndex.value,
);
switch (dialog.value) {
case 'add':
if (exists) {
existsAlready.value = true;
return;
}
if (newScene.stageLights) {
sendValues.push({
path: 'StageLights',
query: { depth: 0 },
});
}
if (newScene.lightBar) {
sendValues.push({
path: 'LightBar',
query: { depth: 0 },
});
}
if (newScene.floodPanels) {
sendValues.push({
path: 'FloodPanels',
query: { depth: 0 },
});
}
if (newScene.movingHead) {
sendValues.push({
path: 'MovingHead',
query: { depth: 0 },
});
}
if (sendValues.length > 0) {
try {
const res = await dbmApi.post('/json_data', { get: sendValues });
newScene.values = res.data.get;
} catch (err) {
NotifyResponse(err as Error, 'error');
}
} else {
newScene.values = [];
}
scenes.value = [...scenes.value, JSON.parse(JSON.stringify(newScene))];
// Sort alphabetically by scene name
scenes.value.sort((a, b) => a.name.localeCompare(b.name));
appApi
.post('/saveScene', JSON.stringify(newScene))
.then((res) => {
if (res.data) {
NotifyResponse(res.data);
}
})
.catch((err) => {
NotifyResponse(catchError(err), 'error');
});
scenes.value = [...scenes.value];
break;
case 'edit':
if (exists) {
existsAlready.value = true;
return;
}
if (newScene.stageLights) {
sendValues.push({
path: 'StageLights',
query: { depth: 0 },
});
}
if (newScene.lightBar) {
sendValues.push({
path: 'LightBar',
query: { depth: 0 },
});
}
if (newScene.floodPanels) {
sendValues.push({
path: 'FloodPanels',
query: { depth: 0 },
});
}
if (newScene.movingHead) {
sendValues.push({
path: 'MovingHead',
query: { depth: 0 },
});
}
if (sendValues.length > 0) {
try {
const res = await dbmApi.post('/json_data', { get: sendValues });
newScene.values = res.data.get;
} catch (err) {
NotifyResponse(err as Error, 'error');
}
} else {
newScene.values = [];
}
scenes.value.splice(editIndex.value, 1, JSON.parse(JSON.stringify(newScene)));
scenes.value.sort((a, b) => a.name.localeCompare(b.name));
scenes.value = [...scenes.value];
appApi
.post('/saveScene', JSON.stringify(newScene))
.then((res) => {
if (res.data) {
NotifyResponse(res.data);
}
})
.catch((err) => {
NotifyResponse(catchError(err), 'error');
});
scenes.value = [...scenes.value];
break;
case 'load':
{
const setPaths = <Set[]>[];
newScene.values?.forEach((element) => {
if (!element.path) return;
if (newScene.stageLights && element.path.includes('StageLights'))
setPaths.push({ uuid: element.uuid, path: element.path, value: element.value });
if (newScene.lightBar && element.path.includes('LightBar'))
setPaths.push({ uuid: element.uuid, path: element.path, value: element.value });
if (newScene.floodPanels && element.path.includes('FloodPanels'))
setPaths.push({ uuid: element.uuid, path: element.path, value: element.value });
if (newScene.movingHead && element.path.includes('MovingHead'))
setPaths.push({ uuid: element.uuid, path: element.path, value: element.value });
});
setValues(setPaths)
.then((response) => {
NotifyResponse(response);
})
.catch((err) => {
NotifyResponse(`Failed to load scene ${newScene.name}`, 'warning');
NotifyResponse(catchError(err), 'error');
});
}
break;
}
dialog.value = '';
};
</script>

View File

@@ -1,158 +0,0 @@
import type { Subs } from 'src/models/Subscribe';
import { ref, nextTick, computed } from 'vue';
import { setValues } from 'src/services/websocket';
import { NotifyResponse } from 'src/composables/notify';
import type { QVueGlobals } from 'quasar';
const Subscriptions = ref<Subs>([]);
export const dbmData = ref<TreeNode[]>([]);
export interface TreeNode {
path: string | undefined;
key?: string; // optional: useful for QTree's node-key
value?: string | number | boolean | undefined;
lazy: boolean;
children?: TreeNode[];
}
export function buildTree(subs: Subs): TreeNode[] {
type TreeMap = {
[key: string]: {
__children: TreeMap;
uuid?: string;
value?: string | undefined;
lazy: boolean;
};
};
const root: TreeMap = {};
Subscriptions.value = subs;
for (const item of subs) {
const pathParts = item.path?.split(':') ?? [];
let current = root;
for (let i = 0; i < pathParts.length; i++) {
const part = pathParts[i];
if (!part) continue;
if (!current[part]) {
current[part] = { __children: {}, lazy: true };
}
// Optionally attach uuid only at the final part
if (i === pathParts.length - 1 && item.uuid) {
current[part].uuid = item.uuid;
current[part].value = item.value !== undefined ? String(item.value) : '';
current[part].lazy = item.hasChild ?? false;
}
current = current[part].__children;
}
}
function convert(map: TreeMap): TreeNode[] {
return Object.entries(map).map(([path, node]) => ({
path,
key: node.uuid ?? path, // `key` is used by QTree
value: node.value,
lazy: node.lazy,
children: convert(node.__children),
}));
}
return [
{
path: 'DBM',
key: '00000000-0000-0000-0000-000000000000',
lazy: true,
children: convert(root),
},
];
}
export function getTreeElementByPath(path: string) {
return dbmData.value.find((s) => s.path === path);
}
export function getSubscriptionsByUuid(uid: string | undefined) {
return Subscriptions.value.find((s) => s.uuid === uid);
}
export function addChildrentoTree(subs: Subs) {
const ZERO_UUID = '00000000-0000-0000-0000-000000000000';
const existingIds = new Set(Subscriptions.value.map((sub) => sub.uuid));
const newSubs = subs
.filter((sub) => sub.uuid !== ZERO_UUID) // Skip UUIDs with all zeroes
.filter((sub) => !existingIds.has(sub.uuid));
Subscriptions.value.push(...newSubs);
void nextTick(() => {
dbmData.value = buildTree(Subscriptions.value);
});
}
export function removeSubtreeByParentKey(parentKey: string) {
function removeChildrenAndMarkLazy(nodes: TreeNode[], targetKey: string): boolean {
for (const node of nodes) {
if (node.key === targetKey) {
delete node.children;
node.lazy = true;
return true;
}
if (node.children) {
const found = removeChildrenAndMarkLazy(node.children, targetKey);
if (found) return true;
}
}
return false;
}
removeChildrenAndMarkLazy(dbmData.value, parentKey);
}
export function getSubscriptionsByPath(path: string | undefined) {
return Subscriptions.value.find((s) => s.path === path);
}
export function getAllSubscriptions() {
return Subscriptions.value;
}
export function updateValue(
path1: string,
$q: QVueGlobals,
path2?: string,
path3?: string,
value3?: number,
) {
return computed({
get() {
const sub = getSubscriptionsByPath(path1);
const value = sub ? Number(sub.value ?? 0) : 0;
return Math.round((100 / 255) * value);
},
set(val) {
const baseValue = Math.round((255 / 100) * val);
const setPaths = [{ path: path1, value: baseValue }];
if (path2) {
setPaths.push({ path: path2, value: baseValue });
}
if (path3) {
setPaths.push({ path: path3, value: value3 ? value3 : baseValue });
}
setValues(setPaths)
.then((response) => NotifyResponse($q, response))
.catch((err) => {
NotifyResponse(
$q,
`Failed to update [${path1 + ' ' + path2 + ' ' + path3}]: ${err}`,
'error',
);
});
},
});
}

View File

@@ -1,12 +0,0 @@
import { ref } from 'vue';
import type { TreeNode } from './dbmTree';
export const contextMenuRef = ref();
export const contextMenuState = ref<TreeNode | undefined>();
export function openContextMenu(event: MouseEvent, node: undefined) {
event.preventDefault();
contextMenuState.value = node;
contextMenuRef.value?.show(event);
}

View File

@@ -1,39 +0,0 @@
import type { Response } from 'src/models/Response';
import type { QVueGlobals } from 'quasar';
export function NotifyResponse(
$q: QVueGlobals,
response: Response | string | undefined,
type?: 'warning' | 'error',
timeout: number = 5000,
) {
let color = 'green';
let icon = 'check_circle';
switch (type) {
case 'warning':
color = 'orange';
icon = 'warning';
break;
case 'error':
color = 'orange';
icon = 'error';
break;
}
if (response) {
const message = typeof response === 'string' ? response : (response.message ?? '');
if (message === '') {
return;
}
color = typeof response === 'string' ? response : response?.error ? 'red' : color;
icon = typeof response === 'string' ? response : response?.error ? 'error' : icon;
$q?.notify({
message: message,
color: color,
position: 'bottom-right',
icon: icon,
timeout: timeout,
});
}
}

View File

@@ -2,23 +2,36 @@
<q-layout view="lHh Lpr lFf"> <q-layout view="lHh Lpr lFf">
<q-header elevated> <q-header elevated>
<q-toolbar> <q-toolbar>
<q-img
:src="logo"
alt="Logo"
style="width: 40px; height: 40px; background-color: var(--q-primary)"
class="q-mr-sm"
/>
<q-btn flat dense round icon="menu" aria-label="Menu" @click="toggleLeftDrawer" /> <q-btn flat dense round icon="menu" aria-label="Menu" @click="toggleLeftDrawer" />
<q-toolbar-title> Light Control </q-toolbar-title> <q-toolbar-title> {{ productName }} </q-toolbar-title>
<div>Version {{ version }}</div> <div>Version {{ version }}</div>
<q-btn dense icon="refresh" square class="q-px-md q-ml-md" @click="refresh" />
<LoginMenu />
</q-toolbar> </q-toolbar>
</q-header> </q-header>
<q-drawer v-model="leftDrawerOpen" bordered> <q-drawer v-model="leftDrawerOpen" bordered>
<q-list> <q-list>
<q-item to="/" clickable v-ripple> <q-item to="/" exact clickable v-ripple @click="closeDrawer">
<q-item-section>Home</q-item-section> <q-item-section>Home</q-item-section>
</q-item> </q-item>
<q-item to="/scenes" clickable v-ripple @click="closeDrawer">
<q-item to="/data" clickable v-ripple> <q-item-section>Scenes</q-item-section>
</q-item>
<q-item v-if="autorized" to="/data" clickable v-ripple @click="closeDrawer">
<q-item-section>Data</q-item-section> <q-item-section>Data</q-item-section>
</q-item> </q-item>
<q-item to="/services" clickable v-ripple @click="closeDrawer">
<q-item-section>Services</q-item-section>
</q-item>
</q-list> </q-list>
</q-drawer> </q-drawer>
<q-page-container> <q-page-container>
@@ -28,12 +41,25 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'; import logo from 'src/assets/LOGO_CF-ICON_color.svg';
import { version } from '../..//package.json'; import { computed, ref } from 'vue';
import { version, productName } from '../../package.json';
import LoginMenu from 'src/vueLib/login/LoginMenu.vue';
import { useUserStore } from 'src/vueLib/login/userStore';
const leftDrawerOpen = ref(false); const leftDrawerOpen = ref(false);
const user = useUserStore();
const autorized = computed(() => !!user.isAuthorizedAs(['admin']));
function toggleLeftDrawer() { function toggleLeftDrawer() {
leftDrawerOpen.value = !leftDrawerOpen.value; leftDrawerOpen.value = !leftDrawerOpen.value;
} }
function closeDrawer() {
leftDrawerOpen.value = false;
}
function refresh() {
window.location.reload();
}
</script> </script>

View File

@@ -14,5 +14,4 @@ export type Settings = {
show: boolean; show: boolean;
reversePan: boolean; reversePan: boolean;
reverseTilt: boolean; reverseTilt: boolean;
startAddress: number;
}; };

View File

@@ -1,8 +0,0 @@
export type Publish = {
event: string;
uuid?: string;
path?: string;
type?: string;
value?: undefined;
};
export type Pubs = Publish[];

View File

@@ -1,10 +0,0 @@
import type { Gets } from './Get';
import type { Sets } from './Set';
import type { Subs } from './Subscribe';
export type Request = {
get?: Gets;
set?: Sets;
subscribe?: Subs;
unsubscribe?: Subs;
};

11
src/models/Scene.ts Normal file
View File

@@ -0,0 +1,11 @@
import type { Value } from '../vueLib/models/Value';
export interface Scene {
name: string;
description?: string;
stageLights: boolean;
lightBar: boolean;
floodPanels: boolean;
movingHead: boolean;
values?: Value[];
}

View File

@@ -1,9 +0,0 @@
export type Subscribe = {
uuid?: string | undefined;
path?: string | undefined;
depth?: number;
value?: string | number | boolean | undefined;
hasChild?: boolean;
};
export type Subs = Subscribe[];

View File

@@ -4,16 +4,17 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import DBMTree from 'src/components/dbm/DBMTree.vue'; import DBMTree from 'src/vueLib/dbm/DBMTree.vue';
import { api } from 'src/boot/axios'; import { dbmApi } from 'src/boot/axios';
import { NotifyResponse } from 'src/composables/notify'; import { useNotify } from 'src/vueLib/general/useNotify';
import { useQuasar } from 'quasar'; import { catchError } from 'src/vueLib/models/error';
const { NotifyResponse } = useNotify();
const $q = useQuasar();
function saveDBM() { function saveDBM() {
api dbmApi
.get('saveData') .get('saveData')
.then((resp) => NotifyResponse($q, resp.data)) .then((resp) => NotifyResponse(resp.data))
.catch((err) => NotifyResponse($q, err)); .catch((err) => NotifyResponse(catchError(err), 'error'));
} }
</script> </script>

View File

@@ -1,16 +1,24 @@
<template> <template>
<q-page> <q-page>
<q-tabs v-model="tab"> <q-tabs v-model="tab">
<q-tab name="movingHead" label="Moving Head" /> <q-tab no-caps name="stageLights" label="Stage Lights" />
<q-tab name="lightBar" label="Light Bar" /> <q-tab no-caps name="movingHead" label="Moving Head" />
<q-tab no-caps name="lightBar" label="Light Bar" />
<q-tab no-caps name="floodPanels" label="Flood Panels" />
</q-tabs> </q-tabs>
<q-tab-panels v-model="tab" animated class="text-white"> <q-tab-panels v-model="tab" animated class="text-white">
<q-tab-panel name="movingHead"> <q-tab-panel name="stageLights">
<moving-head /> <stage-lights />
</q-tab-panel> </q-tab-panel>
<q-tab-panel name="lightBar"> <q-tab-panel name="lightBar">
<LightBar /> <LightBar />
</q-tab-panel> </q-tab-panel>
<q-tab-panel name="floodPanels">
<FloodPanels />
</q-tab-panel>
<q-tab-panel name="movingHead">
<moving-head />
</q-tab-panel>
</q-tab-panels> </q-tab-panels>
</q-page> </q-page>
</template> </template>
@@ -18,6 +26,8 @@
<script setup lang="ts"> <script setup lang="ts">
import MovingHead from 'src/components/lights/MovingHead.vue'; import MovingHead from 'src/components/lights/MovingHead.vue';
import LightBar from 'src/components/lights/LightBarCBL.vue'; import LightBar from 'src/components/lights/LightBarCBL.vue';
import FloodPanels from 'src/components/lights/FloodPanels.vue';
import StageLights from 'src/components/lights/StageLights.vue';
import { ref, onMounted, watch } from 'vue'; import { ref, onMounted, watch } from 'vue';
const tab = ref('movingHead'); const tab = ref('movingHead');
const STORAGE_KEY = 'lastTabUsed'; const STORAGE_KEY = 'lastTabUsed';

View File

@@ -0,0 +1,60 @@
<template>
<q-card>
<q-card-section>
<div class="text-bold text-primary">Services</div>
</q-card-section>
<q-card-section>
<q-table v-if="driverRows?.length > 0" :rows="driverRows" :columns="columns"> </q-table>
<div v-else class="q-pa-md text-grey text-center">
<div>No services available</div>
<q-btn
no-caps
rounded
color="primary"
:class="['q-ma-md', 'text-bold', 'text-white']"
:disable="userStore.user?.role !== 'admin'"
@click="addNewDriver"
>Add First Service</q-btn
>
</div>
</q-card-section>
</q-card>
<service-dialog ref="refServiceDialog"></service-dialog>
</template>
<script setup lang="ts">
import { reactive, ref } from 'vue';
import type { QTableProps } from 'quasar';
import { useUserStore } from 'src/vueLib/login/userStore';
import ServiceDialog from 'src/vueLib/services/dialog/ServiceDialog.vue';
const userStore = useUserStore();
const refServiceDialog = ref();
const driverRows = reactive([]);
const columns = [
{ name: 'path', label: 'Path', field: 'path', align: 'left' },
{
name: 'type',
label: 'Type',
field: 'type',
align: 'left',
},
{
name: 'value',
label: 'Value',
field: 'value',
align: 'left',
},
{
name: 'drivers',
label: 'Drivers',
field: 'drivers',
align: 'center',
},
] as QTableProps['columns'];
function addNewDriver() {
refServiceDialog.value.open();
}
</script>

View File

@@ -19,7 +19,9 @@ import routes from './routes';
export default defineRouter(function (/* { store, ssrContext } */) { export default defineRouter(function (/* { store, ssrContext } */) {
const createHistory = process.env.SERVER const createHistory = process.env.SERVER
? createMemoryHistory ? createMemoryHistory
: (process.env.VUE_ROUTER_MODE === 'history' ? createWebHistory : createWebHashHistory); : process.env.VUE_ROUTER_MODE === 'history'
? createWebHistory
: createWebHashHistory;
const Router = createRouter({ const Router = createRouter({
scrollBehavior: () => ({ left: 0, top: 0 }), scrollBehavior: () => ({ left: 0, top: 0 }),
@@ -30,6 +32,5 @@ export default defineRouter(function (/* { store, ssrContext } */) {
// quasar.conf.js -> build -> publicPath // quasar.conf.js -> build -> publicPath
history: createHistory(process.env.VUE_ROUTER_BASE), history: createHistory(process.env.VUE_ROUTER_BASE),
}); });
return Router; return Router;
}); });

View File

@@ -5,8 +5,17 @@ const routes: RouteRecordRaw[] = [
path: '/', path: '/',
component: () => import('layouts/MainLayout.vue'), component: () => import('layouts/MainLayout.vue'),
children: [ children: [
{ path: '', component: () => import('pages/IndexPage.vue') }, { path: '', component: () => import('pages/MainPage.vue') },
{ path: '/data', component: () => import('pages/DataPage.vue') }, {
path: '/data',
component: () => import('pages/DataPage.vue'),
meta: { requiresAuth: true, requiresAdmin: true },
},
{ path: '/scenes', component: () => import('components/scenes/ScenesPage.vue') },
{
path: '/services',
component: () => import('pages/ServicesPage.vue'),
},
], ],
}, },

View File

@@ -0,0 +1,50 @@
import type { Ref } from 'vue';
export function separate16BitUint(value: number): { highByte: number; lowByte: number } {
// Ensure the value is treated as a 16-bit unsigned integer
// (optional, but good for clarity and safety if 'value' might be outside 0-65535)
const normalizedValue = value & 0xffff; // Mask to ensure it's within 16 bits
// Extract the low byte (least significant 8 bits)
// This is simply the value modulo 256, or bitwise AND with 0xFF
const lowByte = normalizedValue & 0xff;
// Extract the high byte (most significant 8 bits)
// Right shift by 8 bits to move the high byte into the low byte's position,
// then mask with 0xFF to get just those 8 bits.
const highByte = (normalizedValue >> 8) & 0xff;
return { highByte, lowByte };
}
export function combineBytesTo16BitUint(highByte: number, lowByte: number): number {
// Ensure both bytes are within the 0-255 range for safety
const safeHighByte = highByte & 0xff;
const safeLowByte = lowByte & 0xff;
// Shift the high byte 8 bits to the left to place it in the higher position.
// Example: if highByte is 0xA4 (10100100), after shifting it becomes 0xA400 (1010010000000000).
const shiftedHighByte = safeHighByte << 8;
// Combine the shifted high byte with the low byte using a bitwise OR.
// Example: if shiftedHighByte is 0xA400 and lowByte is 0x78 (01111000),
// the result is 0xA478 (1010010001111000).
const combinedValue = shiftedHighByte | safeLowByte;
// Optional: Mask the result to ensure it's strictly within the 16-bit unsigned range (0 to 65535).
// This is good practice as JavaScript numbers are 64-bit floats, and this ensures
// the value wraps correctly if intermediate operations somehow exceeded 16 bits.
return combinedValue & 0xffff;
}
export function addOne(val: Ref<number>, limit: number) {
if (val.value < limit) {
val.value++;
}
}
export function substractOne(val: Ref<number>, limit: number) {
if (val.value > limit) {
val.value--;
}
}

View File

@@ -0,0 +1,103 @@
<template>
<q-card>
<div class="text-primary q-ma-md">Datatypes *</div>
<div>
<div class="row q-gutter-sm q-ml-sm">
<div>
<div class="text-grey text-bold">General</div>
<RadioButton
class="q-my-xs q-px-lg q-mr-sm"
v-model:opt="datatype"
text="None"
hint="none"
>
</RadioButton>
<RadioButton
class="q-my-xs q-px-lg q-mr-sm"
v-model:opt="datatype"
text="String"
hint="Text"
>
</RadioButton>
<RadioButton class="q-my-xs q-px-lg" v-model:opt="datatype" text="Bool" hint="On / Off">
</RadioButton>
</div>
<div>
<div class="text-grey text-bold">Numbers</div>
<div>
<RadioButton
class="q-my-xs q-px-lg q-mr-sm"
v-model:opt="datatype"
text="Uint8"
hint="0 - 255"
>
</RadioButton>
<RadioButton
class="q-my-xs q-px-lg q-mr-sm"
v-model:opt="datatype"
text="Uint16"
hint="0 - 65535"
>
</RadioButton>
<RadioButton
class="q-my-xs q-px-sm"
v-model:opt="datatype"
text="Uint32"
hint="0 - 429496..."
>
</RadioButton>
</div>
<div>
<RadioButton
class="q-my-xs q-mr-sm"
v-model:opt="datatype"
text="Int8"
hint="-128 - 127"
>
</RadioButton>
<RadioButton
class="q-my-xs q-mr-sm"
v-model:opt="datatype"
text="Int16"
hint="-32768 - 3..."
>
</RadioButton>
<RadioButton
class="q-my-xs q-px-sm"
v-model:opt="datatype"
text="Int32"
hint="-21474836..."
>
</RadioButton>
</div>
<div>
<RadioButton
class="q-my-xs q-px-sm q-mr-sm"
v-model:opt="datatype"
text="Int"
hint="-2^63 - (2^...)"
>
</RadioButton>
<RadioButton
class="q-my-xs q-px-md"
v-model:opt="datatype"
text="Double"
hint="1.7E 1/- 3..."
>
</RadioButton>
</div>
</div>
</div>
</div>
</q-card>
</template>
<script setup lang="ts">
import RadioButton from './RadioButton.vue';
import { ref, watch } from 'vue';
const emit = defineEmits(['update:datatype']);
const datatype = ref('None');
watch(datatype, (newVal) => emit('update:datatype', newVal));
</script>

View File

@@ -0,0 +1,31 @@
<template>
<q-btn style="border-radius: 8px" no-caps
><q-radio v-model="opt" :val="props.text"></q-radio>
<div class="column items-start q-mx-sm">
<div class="text-body1 text-black">{{ props.text }}</div>
<div class="text-caption text-grey">{{ props.hint }}</div>
</div>
</q-btn>
</template>
<script setup lang="ts">
import { watch, ref } from 'vue';
const opt = defineModel('opt');
const props = defineProps({
text: {
type: String,
required: true,
},
hint: {
type: String,
},
});
const localOption = ref('');
const emit = defineEmits(['update:option']);
watch(localOption, (val) => emit('update:option', val));
</script>

125
src/vueLib/dbm/DBMTree.vue Normal file
View File

@@ -0,0 +1,125 @@
<template>
<q-card>
<div class="row">
<q-card-section class="col-4 scroll tree-container">
<q-tree
class="text-blue text-bold"
dense
:nodes="dbmData"
node-key="key"
no-transition
:default-expand-all="false"
v-model:expanded="expanded"
@update:expanded="onExpandedChange(expanded)"
@lazy-load="onLazyLoad"
>
<template v-slot:[`default-header`]="props">
<div
class="row items-center text-blue"
@contextmenu.prevent.stop="openSubMenu($event, props.node)"
>
<div class="row items-center text-blue"></div>
<div>{{ props.node.path }}</div>
</div>
</template>
</q-tree>
<sub-menu ref="subMenuRef"></sub-menu>
</q-card-section>
<dataTable class="col-8" />
</div>
</q-card>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import {
type TreeNode,
dbmData,
onExpandedChange,
expanded,
buildTree,
} from '../../vueLib/dbm/dbmTree';
import DataTable from './DataTable.vue';
import { useNotify } from '../general/useNotify';
import { QCard } from 'quasar';
import { unsubscribe } from '../services/websocket';
import { onBeforeRouteLeave } from 'vue-router';
import SubMenu from './SubMenu.vue';
import { convertToSubscribes, type RawSubs } from '../models/Subscribe';
import { getRequest } from '../models/Request';
import { catchError } from '../models/error';
const { NotifyResponse } = useNotify();
const ZERO_UUID = '00000000-0000-0000-0000-000000000000';
onMounted(() => {
getRequest('', '.*', 1)
.then((res) => {
const test = res;
if (res) buildTree(convertToSubscribes(test as RawSubs));
})
.catch((err) => NotifyResponse(catchError(err), 'error'));
});
onBeforeRouteLeave(() => {
unsubscribe([{ path: '.*', depth: 0 }]).catch((err) => NotifyResponse(catchError(err), 'error'));
});
function onLazyLoad({
node,
done,
fail,
}: {
node: TreeNode;
done: (children: TreeNode[]) => void;
fail: () => void;
}) {
getRequest(node.key ?? ZERO_UUID, '', 2)
.then((resp) => {
if (resp) done(buildTree(convertToSubscribes(resp as RawSubs)));
else done([]); // no children returned
})
.catch((err) => {
NotifyResponse(err, 'error');
fail(); // trigger the fail handler
});
}
const subMenuRef = ref();
function openSubMenu(event: MouseEvent, uuid: string) {
subMenuRef.value?.open(event, uuid);
}
</script>
<style scoped>
.tree-container {
overflow-y: auto;
}
@media (max-width: 599px) {
.tree-container {
max-height: 50vh;
}
}
@media (min-width: 600px) and (max-width: 1023px) {
.tree-container {
max-height: 60vh;
}
}
@media (min-width: 1024px) and (max-width: 1439px) {
.tree-container {
max-height: 70vh;
}
}
@media (min-width: 1440px) and (max-width: 1919px) {
.tree-container {
max-height: 80vh;
}
}
@media (min-width: 1920px) {
.tree-container {
max-height: 90vh;
}
}
</style>

View File

@@ -0,0 +1,139 @@
<template>
<div class="q-pa-md">
<q-table
v-if="tableRows.length > 0"
style="height: 600px"
flat
bordered
:title="tableRows[0]?.path"
:rows="tableRows"
:columns="columns"
row-key="path"
virtual-scroll
:rows-per-page-options="[0]"
>
<template v-slot:body-cell-path="props">
<q-td :props="props" @click="openDialog(props.row, 'rename')">
<div
:class="[
'text-left',
props.row.path?.split(':')[0] !== 'System' && props.row.path !== 'DBM'
? 'cursor-pointer'
: '',
'q-mx-sm',
]"
>
{{ props.row.path?.split(':').pop() ?? '' }}
</div>
</q-td>
</template>
<template v-slot:body-cell-type="props">
<q-td :props="props" @click="openDialog(props.row, 'type')">
<div
:class="[
'text-center',
props.row.path?.split(':')[0] !== 'System' && props.row.path !== 'DBM'
? 'cursor-pointer'
: '',
'q-mx-sm',
]"
>
{{ convertFromType(props.row.type) }}
</div>
</q-td>
</template>
<template v-slot:body-cell-value="props">
<q-td :props="props" @click="openDialog(props.row, 'value')">
<div :class="['text-center', 'cursor-pointer', 'q-mx-sm']">
{{ props.row.value }}
</div>
</q-td>
</template>
<template v-slot:body-cell-drivers="props">
<q-td :props="props" @click="openDialog(props.row, 'drivers')">
<div
v-if="props.row.type !== 'NONE' || props.row.path?.split(':')[0] !== 'System'"
:class="['cursor-pointer']"
>
<q-icon size="sm" name="cell_tower" :color="props.row.drivers ? 'blue-5' : 'grey-4'" />
</div>
</q-td>
</template>
</q-table>
<RenameDialog
dialogLabel="Rename Datapoint"
width="400px"
button-ok-label="Rename"
ref="renameDialog"
/>
<UpdateDialog width="400px" button-ok-label="Write" ref="updateDialog" />
<UpdateDriver width="400px" ref="updateDriverDialog" />
<UpdateDatatype
width="400px"
button-ok-label="Update"
ref="updateDatatype"
dialog-label="Update Datatype"
/>
</div>
</template>
<script setup lang="ts">
import UpdateDialog from './dialog/UpdateValueDialog.vue';
import RenameDialog from './dialog/RenameDatapoint.vue';
import UpdateDatatype from './dialog/UpdateDatatype.vue';
import UpdateDriver from './dialog/UpdateDriverDialog.vue';
import type { QTableProps } from 'quasar';
import type { Subscribe } from '../models/Subscribe';
import { computed, ref } from 'vue';
import { TableSubs } from '../dbm/updateTable';
import { convertFromType } from './Datapoint';
const renameDialog = ref();
const updateDialog = ref();
const updateDriverDialog = ref();
const updateDatatype = ref();
const openDialog = (sub: Subscribe, type?: string) => {
if (sub.path?.split(':')[0] === 'System' && sub.path !== 'DBM') return;
switch (type) {
case 'type':
updateDatatype.value.open(sub.uuid);
break;
case 'rename':
renameDialog.value.open(sub.uuid);
break;
case 'value':
if (sub.type === 'NONE') return;
updateDialog.value?.open(ref(sub), type);
break;
case 'drivers':
if (sub.path === 'DBM' || sub.type === 'NONE') return;
updateDriverDialog.value?.open(sub);
break;
}
};
const tableRows = computed(() => [...(TableSubs.value ?? [])]);
const columns = [
{ name: 'path', label: 'Path', field: 'path', align: 'left' },
{
name: 'type',
label: 'Type',
field: 'type',
align: 'left',
},
{
name: 'value',
label: 'Value',
field: 'value',
align: 'left',
},
{
name: 'drivers',
label: 'Drivers',
field: 'drivers',
align: 'center',
},
] as QTableProps['columns'];
</script>

View File

@@ -0,0 +1,72 @@
import type { Gets } from '../models/Get';
import type { Sets } from '../models/Set';
export function datapointRequestForCopy(response: Gets, oldPath: string, newPath: string): Sets {
const copySet = <Sets>[];
response.forEach((get) => {
copySet.push({
path: typeof get.path === 'string' ? get.path.replace(oldPath, newPath) : '',
type: get.type ? get.type : '',
value: get.value,
rights: get.rights ? get.rights : '',
});
});
return copySet;
}
export function convertFromType(type: string): string {
switch (type) {
case 'STR':
return 'string';
case 'BIT':
return 'bool';
case 'BYU':
return 'uint8';
case 'WOU':
return 'uint16';
case 'DWU':
return 'uint32';
case 'BYS':
return 'int8';
case 'WOS':
return 'int16';
case 'DWS':
return 'int32';
case 'LOU':
return 'uint64';
case 'LOS':
return 'int64';
case 'F64':
return 'double';
default:
return 'none';
}
}
export function convertToType(type: string): string {
switch (type) {
case 'String':
return 'STR';
case 'Bool':
return 'BIT';
case 'Uint8':
return 'BYU';
case 'Int8':
return 'BYS';
case 'Uint16':
return 'WOU';
case 'Int16':
return 'WOS';
case 'Uint32':
return 'DWU';
case 'Int32':
return 'DWS';
case 'Int':
return 'LOS';
case 'Double':
return 'F64';
default:
return 'NONE';
}
}

179
src/vueLib/dbm/SubMenu.vue Normal file
View File

@@ -0,0 +1,179 @@
<template>
<q-menu ref="contextMenuRef" context-menu>
<q-list>
<q-item :clickable="!disableAll" v-close-popup @click="handleAction('Add')">
<q-item-section>
<div class="row">
<div class="col-5">
<q-icon
:color="disableAll ? 'grey-5' : 'primary'"
class="q-pr-sm"
name="add"
size="xs"
left
/>
</div>
<div :class="['col-7', disableAll ? 'text-grey-5' : 'text-primary']">Add</div>
</div>
</q-item-section>
</q-item>
<q-item
:class="disable ? 'text-grey-5' : ''"
:clickable="!disable"
v-close-popup
@click="handleAction('Rename')"
><q-item-section>
<div class="row">
<div class="col-5">
<q-icon
:color="disable ? 'grey-5' : 'primary'"
class="q-pr-sm"
name="edit"
size="xs"
left
/>
</div>
<div :class="['col-7', disable ? 'text-grey-5' : 'text-primary']">Rename</div>
</div>
</q-item-section>
</q-item>
<q-item
:class="disable ? 'text-grey-5' : ''"
:clickable="!disable"
v-close-popup
@click="handleAction('Delete')"
><q-item-section>
<div class="row">
<div class="col-5">
<q-icon
:color="disable ? 'grey-5' : 'primary'"
class="q-pr-sm"
name="delete"
size="xs"
left
/>
</div>
<div :class="['col-7', disable ? 'text-grey-5' : 'text-primary']">Delete</div>
</div>
</q-item-section>
</q-item>
<q-item
:color="disable ? 'grey-5' : 'primary'"
:clickable="!disable"
v-close-popup
@click="handleAction('Copy')"
>
<q-item-section>
<div class="row">
<div class="col-5">
<q-icon
:color="disable ? 'grey-5' : 'primary'"
class="q-pr-sm"
name="content_copy"
size="xs"
left
/>
</div>
<div :class="['col-7', disable ? 'text-grey-5' : 'text-primary']">Copy</div>
</div>
</q-item-section>
</q-item>
<q-item
:color="disable ? 'grey-5' : 'primary'"
:clickable="!disable"
v-close-popup
@click="handleAction('Datatype')"
>
<q-item-section>
<div class="row">
<div class="col-5">
<q-icon
:color="disable ? 'grey-5' : 'primary'"
class="q-pr-sm"
name="text_fields"
size="xs"
left
/>
</div>
<div :class="['col-7', disable ? 'text-grey-5' : 'text-primary']">Datatype</div>
</div>
</q-item-section>
</q-item>
</q-list>
</q-menu>
<RenameDatapoint :dialogLabel="label" width="700px" button-ok-label="Rename" ref="renameDialog" />
<AddDialog :dialogLabel="label" width="750px" button-ok-label="Add" ref="addDialog" />
<RemoveDialog :dialogLabel="label" width="350px" button-ok-label="Remove" ref="removeDialog" />
<CopyDialog :dialogLabel="label" width="300px" button-ok-label="Copy" ref="copyDialog" />
<UpdateDatapoint
:dialogLabel="label"
width="300px"
button-ok-label="Update"
ref="datatypeDialog"
/>
</template>
<script setup lang="ts">
import AddDialog from './dialog/AddDatapoint.vue';
import RemoveDialog from './dialog/RemoveDatapoint.vue';
import CopyDialog from './dialog/CopyDatapoint.vue';
import UpdateDatapoint from './dialog/UpdateDatatype.vue';
import { ref } from 'vue';
import { type TreeNode } from '../dbm/dbmTree';
import { findSubscriptionByUuid } from '../models/Subscriptions';
import RenameDatapoint from './dialog/RenameDatapoint.vue';
const ZERO_UUID = '00000000-0000-0000-0000-000000000000';
const renameDialog = ref();
const addDialog = ref();
const removeDialog = ref();
const copyDialog = ref();
const datatypeDialog = ref();
const datapointUuid = ref('');
const contextMenuRef = ref();
const label = ref('');
const disable = ref(false);
const disableAll = ref(false);
function handleAction(action: string) {
switch (action) {
case 'Rename':
label.value = 'Rename Datapoint';
renameDialog.value?.open(datapointUuid.value);
break;
case 'Add':
label.value = 'Add New Datapoint';
addDialog.value?.open(datapointUuid.value);
break;
case 'Delete':
label.value = 'Remove Datapoint';
removeDialog.value.open(datapointUuid.value);
break;
case 'Copy':
label.value = 'Copy Datapoint';
copyDialog.value.open(datapointUuid.value);
break;
case 'Datatype':
label.value = 'Update Datatype';
datatypeDialog.value.open(datapointUuid.value);
break;
}
}
const open = (event: MouseEvent, sub: TreeNode) => {
disable.value = false;
disableAll.value = false;
if (findSubscriptionByUuid(sub.key ?? '')?.path?.includes('System')) {
disable.value = true;
disableAll.value = true;
}
if (sub.key === ZERO_UUID) disable.value = true;
event.preventDefault();
datapointUuid.value = sub.key ?? '';
contextMenuRef.value?.show(event);
};
defineExpose({ open });
</script>

264
src/vueLib/dbm/dbmTree.ts Normal file
View File

@@ -0,0 +1,264 @@
import { ref, computed, type Ref } from 'vue';
import { convertToSubscribes, type Subs } from '../models/Subscribe';
import { setValues, subscribe, unsubscribe } from '../services/websocket';
import {
findSubscriptionByPath,
addRawSubscriptions,
removeAllSubscriptions,
} from '../models/Subscriptions';
import { UpdateTable } from '..//dbm/updateTable';
import type { Response } from '..//models/Response';
import type { RawSubs } from '..//models/Subscribe';
import { getRequest } from '../models/Request';
import type { Pubs } from '../models/Publish';
const ZERO_UUID = '00000000-0000-0000-0000-000000000000';
export const dbmData = ref<TreeNode[]>([]);
export const expanded = ref<string[]>([]);
let lastExpanded: string[] = [];
export type TreeNode = {
path?: string;
key?: string;
lazy: boolean;
children?: TreeNode[];
};
type TreeMap = {
[key: string]: {
__children: TreeMap;
uuid?: string;
value?: string | number | boolean | null;
lazy: boolean;
};
};
const root: TreeMap = {};
export function buildTreeWithRawSubs(subs: RawSubs): TreeNode[] {
return buildTree(convertToSubscribes(subs));
}
export function buildTree(subs: Subs | null): TreeNode[] {
if (subs) {
for (const { path, uuid, value, hasChild } of subs) {
if (!path) continue;
const parts = path.split(':');
let current = root;
parts.forEach((part, idx) => {
if (!part) return;
if (!current[part]) current[part] = { __children: {}, lazy: true };
if (idx === parts.length - 1 && uuid) {
current[part].uuid = uuid;
current[part].value = value?.value ?? null;
current[part].lazy = !!hasChild;
}
current = current[part].__children;
});
}
}
const toTreeNodes = (map: TreeMap): TreeNode[] =>
Object.entries(map)
.sort(([a], [b]) => a.localeCompare(b))
.map(([key, node]) => ({
path: key,
key: node.uuid ?? key,
value: node.value,
lazy: node.lazy,
children: toTreeNodes(node.__children),
}));
const newTree = [
{
path: 'DBM',
key: ZERO_UUID,
lazy: true,
children: toTreeNodes(root),
},
];
dbmData.value.splice(0, dbmData.value.length, ...newTree);
return newTree;
}
export function removeNodes(pubs: Pubs) {
pubs.forEach((pub) => {
removeNode(pub.uuid);
});
}
export function removeNode(uuid: string) {
removeFromTreeMap(root, uuid);
removeFromTree(dbmData.value, uuid);
collapseNode(uuid);
}
function removeFromTreeMap(tree: TreeMap, uuid: string): boolean {
for (const [key, node] of Object.entries(tree)) {
if (node.uuid === uuid) {
delete tree[key];
return true;
}
if (removeFromTreeMap(node.__children, uuid)) return true;
}
return false;
}
function removeFromTree(nodes: TreeNode[], uuid: string): boolean {
const index = nodes.findIndex((n) => n.key === uuid);
if (index !== -1) {
nodes.splice(index, 1);
return true;
}
for (const node of nodes) {
if (node.children && removeFromTree(node.children, uuid)) {
if (node.children.length === 0) {
delete node.children;
node.lazy = true;
}
return true;
}
}
return false;
}
export function removeSubtreeByParentKey(parentKey: string) {
const recurse = (nodes: TreeNode[]): boolean => {
for (const node of nodes) {
if (node.key === parentKey) {
delete node.children;
node.lazy = true;
return true;
}
if (node.children && recurse(node.children)) return true;
}
return false;
};
recurse(dbmData.value);
}
function collapseNode(uuid: string) {
const idx = expanded.value.indexOf(uuid);
if (idx !== -1) {
expanded.value.splice(idx, 1);
const lastIdx = lastExpanded.indexOf(uuid);
if (lastIdx !== -1) lastExpanded.splice(lastIdx, 1);
onExpandedChange([...expanded.value]).catch(console.error);
}
}
export function updateValue(
NotifyResponse: (
response: Response | string | undefined,
type?: 'warning' | 'error',
timeout?: 5000,
) => void,
path1: string,
toggle?: Ref<boolean>,
path2?: string,
path3?: string,
value3?: number,
) {
return computed({
get() {
const path = toggle?.value && path2 ? path2 : path1;
return Number(findSubscriptionByPath(path)?.value ?? 0);
},
set(val) {
const baseValue = val;
const updates = [
{ path: toggle?.value && path2 ? path2 : path1, value: baseValue },
...(path3 ? [{ path: path3, value: value3 ?? baseValue }] : []),
];
setValues(updates)
.then((response) => NotifyResponse(response))
.catch((err) =>
NotifyResponse(`Failed to update [${[path1, path2, path3].join(' ')}]: ${err}`, 'error'),
);
},
});
}
export async function onExpandedChange(newExpanded: readonly string[]) {
const collapsed = lastExpanded.filter((k) => !newExpanded.includes(k));
const newlyExpanded = newExpanded.filter((k) => !lastExpanded.includes(k));
try {
await unsubscribe([{ path: '.*', depth: 0 }]).then(removeAllSubscriptions);
for (const key of collapsed) {
removeSubtreeByParentKey(key);
fetchAndUpdateNode(key);
}
for (const key of newlyExpanded) {
fetchAndUpdateNode(key);
}
lastExpanded = [...newExpanded];
} catch (err) {
console.error('error in expand function', err);
}
}
function fetchAndUpdateNode(key: string) {
getRequest(key, '', 2)
.then((resp) => {
if (resp) {
buildTreeWithRawSubs(resp);
subscribe([{ uuid: key, path: '', depth: 2 }]).catch((err) => console.error(err));
addRawSubscriptions(resp);
}
UpdateTable(key);
})
.catch((err) => console.error(err));
}
export function findParentKey(
childKey: string,
parentKey: string | null = null,
nodes?: TreeNode[],
): string | null {
if (!nodes) nodes = dbmData.value;
for (const node of nodes) {
if (node.key === childKey) return parentKey;
if (node.children) {
const found = findParentKey(childKey, node.key ?? null, node.children);
if (found) return found;
}
}
return null;
}
function getNodeUuidByPath(path: string, nodes?: TreeNode[]): string {
if (!nodes) nodes = dbmData.value;
for (const node of nodes) {
if (node.path === path) return node.key ?? '';
if (node.children) {
const found = getNodeUuidByPath(path, node.children);
if (found !== '') return found;
}
}
return '';
}
export function pathIsExpanded(path: string): boolean {
if (!path.includes(':')) {
return true;
}
let p = path.replace(/:.+$/, '');
if (expanded.value.includes(getNodeUuidByPath(p))) {
return true;
}
p = path.replace(/:.+$/, '');
return expanded.value.includes(getNodeUuidByPath(p));
}

View File

@@ -0,0 +1,160 @@
<template>
<DialogFrame
ref="Dialog"
:width="props.width"
:height="props.height"
:header-title="props.dialogLabel"
>
<q-card-section
v-if="props.dialogLabel"
class="text-bold text-left q-mb-none q-pb-none"
:class="'text-' + props.labelColor"
>
</q-card-section>
<q-form ref="addForm" class="q-gutter-md">
<q-input
class="q-mt-lg q-mb-none q-pl-lg q-pr-xl"
filled
v-model="addingForm.path"
label=""
:rules="[(val) => !!val || 'Path is required']"
>
<template #prepend>
<div class="column">
<span class="text-caption text-primary non-editable-prefix">Path *</span>
<span class="text-body2 text-grey-6 non-editable-prefix"
>{{ addingForm.prefix }}{{ addingForm.staticPrefix }}</span
>
</div>
</template>
</q-input>
<DataTypes class="q-mt-lg q-pl-md q-pr-xl" flat v-model:datatype="datatype"></DataTypes>
<div class="q-pl-lg">
<div class="text-grey text-bold">Read Write Access</div>
<q-checkbox v-model="addingForm.read">Read</q-checkbox>
<q-checkbox v-model="addingForm.write">Write</q-checkbox>
</div>
<q-input
:type="valueType"
stack-label
label="Value"
class="q-pl-md q-pr-xl"
filled
v-model="addingForm.value"
></q-input>
<div class="row justify-end">
<q-btn no-caps class="q-mb-xl q-mx-xl q-px-lg" @click="onSubmit" color="primary">{{
props.buttonOkLabel
}}</q-btn>
</div>
</q-form>
</DialogFrame>
</template>
<script setup lang="ts">
import { reactive, ref, watch } from 'vue';
import DialogFrame from '../../dialog/DialogFrame.vue';
import { useNotify } from '../../general/useNotify';
import DataTypes from '../../buttons/DataTypes.vue';
import { addRawSubscription } from '../../models/Subscriptions';
import { UpdateTable } from '../../dbm/updateTable';
import { getRequest, setRequest } from 'src/vueLib/models/Request';
import { convertToType } from '../Datapoint';
import { catchError } from 'src/vueLib/models/error';
const { NotifyResponse } = useNotify();
const addingForm = reactive({
path: '',
value: '',
staticPrefix: '',
read: true,
write: true,
prefix: 'DBM:',
});
const Dialog = ref();
const valueType = ref<'text' | 'number'>('text');
const datatype = ref('None');
const addForm = ref();
const open = (uuid: string) => {
Dialog.value?.open();
getDatapoint(uuid);
};
watch(datatype, (newVal) => {
if (newVal === 'String') valueType.value = 'text';
else valueType.value = 'number';
});
function onSubmit() {
let type = 'NONE';
let access = '';
addForm.value.validate().then((success: undefined) => {
if (success) {
type = convertToType(datatype.value);
if (addingForm.read) access = 'R';
if (addingForm.write) access += 'W';
if (access == '') access = 'R';
setRequest(addingForm.staticPrefix + addingForm.path, type, addingForm.value, access)
.then((respond) => {
if (respond) {
respond.forEach((set) => {
NotifyResponse("Datapoint '" + addingForm.prefix + set.path + "' added");
});
addRawSubscription(respond[0]);
UpdateTable();
}
})
.catch((err) => {
NotifyResponse(catchError(err), 'error');
});
} else {
if (addingForm.path === '') {
NotifyResponse("Field 'Path' is requierd", 'error');
return;
} else NotifyResponse('Form not validated', 'error');
}
});
}
const props = defineProps({
buttonOkLabel: {
type: String,
default: 'OK',
},
labelColor: {
type: String,
default: 'primary',
},
dialogLabel: {
type: String,
default: '',
},
width: {
type: String,
default: '300px',
},
height: {
type: String,
default: '650px',
},
});
function getDatapoint(uuid: string) {
getRequest(uuid, '', 1)
.then((resp) => {
if (resp[0]) {
addingForm.staticPrefix = resp[0].path ?? '';
if (addingForm.staticPrefix !== '') addingForm.staticPrefix += ':';
}
})
.catch((err) => NotifyResponse(catchError(err), 'error'));
}
defineExpose({ open });
</script>

View File

@@ -0,0 +1,145 @@
<template>
<DialogFrame
ref="Dialog"
:width="props.width"
:height="props.height"
:header-title="props.dialogLabel"
>
<q-card-section
v-if="props.dialogLabel"
class="text-bold text-left q-mb-none q-pb-none"
:class="'text-' + props.labelColor"
>
</q-card-section>
<q-form ref="copyForm" class="q-gutter-md">
<q-input
class="q-mt-lg q-mb-none q-pl-md q-mx-lg"
filled
v-model="copyData.path"
label="Current Path"
label-color="primary"
readonly
>
</q-input>
<q-input
class="q-mt-lg q-mt-none q-pl-md q-mx-lg"
filled
v-model="copyData.copyPath"
label="New Path *"
label-color="primary"
@keyup.enter="onSubmit"
:rules="[(val) => !!val || 'Path is required']"
>
</q-input>
<div class="q-mx-sm">
<div class="row justify-end">
<q-btn no-caps class="q-mb-xl q-mr-md q-px-lg" @click="onSubmit" color="primary">{{
props.buttonOkLabel
}}</q-btn>
</div>
</div>
</q-form>
</DialogFrame>
</template>
<script setup lang="ts">
import { reactive, ref } from 'vue';
import DialogFrame from '../../dialog/DialogFrame.vue';
import { useNotify } from '../../general/useNotify';
import { getRequest, setsRequest } from 'src/vueLib/models/Request';
import { datapointRequestForCopy } from '../Datapoint';
import { catchError } from 'src/vueLib/models/error';
const { NotifyResponse } = useNotify();
const copyData = reactive({
path: '',
copyPath: '',
prefix: 'DBM:',
});
const Dialog = ref();
const copyForm = ref();
const open = (uuid: string) => {
Dialog.value?.open();
getDatapoint(uuid);
};
function onSubmit() {
copyForm.value.validate().then((success: undefined) => {
if (success) {
if (copyData.copyPath === copyData.path) {
NotifyResponse('copy path can not be the same as current path', 'error');
return;
}
const absolutePath = copyData.path.slice(copyData.prefix.length);
const absolutecopyPath = copyData.copyPath.slice(copyData.prefix.length);
getRequest('', absolutecopyPath, 1)
.then((response) => {
if (response?.length > 0) {
NotifyResponse("path '" + copyData.copyPath + "' already exists", 'warning');
return;
}
})
.catch((err) => {
if (err instanceof Error && err.message === 'No data returned') {
getRequest('', absolutePath, 0)
.then((response) => {
setsRequest(
datapointRequestForCopy(response, absolutePath, absolutecopyPath),
).catch((err) => console.error(err));
NotifyResponse(copyData.copyPath + ' copied');
})
.catch((err) => NotifyResponse(catchError(err), 'error'));
} else {
NotifyResponse(catchError(err), 'error');
}
return;
});
} else {
if (copyData.copyPath === '') {
NotifyResponse("Field 'New Path' is requierd", 'error');
return;
} else NotifyResponse('Form not validated', 'error');
}
});
}
const props = defineProps({
buttonOkLabel: {
type: String,
default: 'OK',
},
labelColor: {
type: String,
default: 'primary',
},
dialogLabel: {
type: String,
default: '',
},
width: {
type: String,
default: '300px',
},
height: {
type: String,
default: '400px',
},
});
function getDatapoint(uuid: string) {
getRequest(uuid)
.then((resp) => {
if (resp[0]) {
copyData.path = copyData.prefix + resp[0].path;
copyData.copyPath = copyData.prefix + resp[0].path;
}
})
.catch((err) => NotifyResponse(catchError(err), 'error'));
}
defineExpose({ open });
</script>

View File

@@ -0,0 +1,258 @@
<template>
<DialogFrame
ref="Dialog"
:width="props.width"
:height="props.height"
:header-title="localDialogLabel"
>
<q-card-section
v-if="dialogLabel"
class="text-bold text-left q-mb-none q-pb-none"
:class="'text-' + props.labelColor"
>{{ dialogLabel }}
</q-card-section>
<q-card-section v-if="props.text" class="text-center" style="white-space: pre-line">{{
props.text
}}</q-card-section>
<q-form ref="form">
<q-card-section class="q-gutter-xs row q-col-gutter-xs q-ml-sm">
<div>
<q-select
filled
label="Driver Name"
type="text"
name="Type"
dense
:options="options"
:rules="[(val) => !!val || 'Name is required']"
v-model="driverForm.type"
/>
<q-input
filled
label="Bus"
type="text"
name="Bus"
dense
:rules="[(val) => !!val || 'Bus is required']"
v-model="driverForm.bus"
/>
<q-input
v-if="driverForm.isAddress"
filled
dense
label="Address"
type="number"
name="Address"
@keyup.enter="updateDriver"
v-model.number="driverForm.address"
/>
</div>
<div v-if="!driverForm.isAddress" class="q-gutter-xs row q-col-gutter-xs">
<q-input
filled
dense
label="Subscribe"
type="text"
name="Address"
v-model="driverForm.subscribe"
/>
<q-input
filled
dense
label="Publish"
type="text"
name="Address"
@keyup.enter="updateDriver"
v-model="driverForm.publish"
/>
</div>
</q-card-section>
</q-form>
<q-card-actions align="right" class="text-primary">
<q-btn v-if="props.buttonCancelLabel" flat :label="props.buttonCancelLabel" v-close-popup />
<q-btn
class="q-mb-xl q-mr-lg"
v-if="props.buttonOkLabel"
color="primary"
no-caps
:label="props.buttonOkLabel"
@click="updateDriver"
>
</q-btn>
</q-card-actions>
</DialogFrame>
</template>
<script setup lang="ts">
import { reactive, ref, watch, computed } from 'vue';
import DialogFrame from '../../dialog/DialogFrame.vue';
import type { Driver } from '../../models/Drivers';
import { deleteRequest, setRequest } from 'src/vueLib/models/Request';
import { addRawSubscriptions } from 'src/vueLib/models/Subscriptions';
import { convertToSubscribe, type RawSubs } from 'src/vueLib/models/Subscribe';
import { useNotify } from 'src/vueLib/general/useNotify';
import { UpdateTable } from '../updateTable';
import { updateDriverTable, type DriverTableRow } from 'src/vueLib/models/driverTable';
const { NotifyResponse } = useNotify();
const Dialog = ref();
const dialogLabel = computed(() => props.dialogLabel || localDialogLabel.value);
const options = ['ArtNetDriver', 'OSCDriver'];
const driverForm = reactive({
type: 'ArtNetDriver',
bus: '',
isAddress: true,
address: 0,
subscribe: '',
publish: '',
});
const props = defineProps({
buttonOkLabel: {
type: String,
default: 'OK',
},
labelColor: {
type: String,
default: 'primary',
},
dialogLabel: {
type: String,
default: '',
},
text: {
type: String,
default: '',
},
buttonCancelLabel: {
type: String,
default: '',
},
width: {
type: String,
default: '300px',
},
height: {
type: String,
default: '480px',
},
});
const localDialogLabel = ref('');
const driver = ref<Driver>();
let dpUuid = '';
const form = ref();
const address = ref();
const topic = ref();
const edit = ref(false);
watch(
() => driverForm.type,
(val) => {
driverForm.isAddress = val === options[0];
if (driverForm.isAddress) {
driverForm.subscribe = '';
driverForm.publish = '';
topic.value = undefined;
} else {
driverForm.address = -1;
address.value = undefined;
}
},
);
const open = (uuid: string, drvs: DriverTableRow, type: 'add' | 'edit') => {
switch (type) {
case 'add':
localDialogLabel.value = 'Add Driver';
edit.value = false;
Object.assign(driverForm, {
type: 'ArtNetDriver',
bus: '',
isAddress: true,
address: 0,
subscribe: '',
publish: '',
});
break;
case 'edit':
localDialogLabel.value = 'Edit Driver';
edit.value = true;
fillDriverFormFromRow(drvs);
}
dpUuid = uuid;
driver.value = drvs;
if (drvs.address) driverForm.address = drvs.address;
if (drvs.subscribe) driverForm.subscribe = drvs.subscribe;
if (drvs.publish) driverForm.publish = drvs.publish;
Dialog.value?.open();
};
async function updateDriver() {
const valid = await form.value?.validate();
if (!valid) {
NotifyResponse('Please fill in all required fields', 'warning');
return;
}
if (driverForm.address > -1) {
address.value = [driverForm.address];
}
if (driverForm.subscribe !== '' || driverForm.publish !== '') {
topic.value = { subscribe: [driverForm.subscribe], publish: [driverForm.publish] };
}
if (edit.value) {
deleteRequest(dpUuid, '', driver.value)
.then((resp) => {
resp.forEach((set) => {
updateDriverTable(convertToSubscribe(set));
});
})
.catch((err) => NotifyResponse(err, 'error'));
}
setRequest('', undefined, undefined, undefined, dpUuid, {
type: driverForm.type,
buses: [
{
name: driverForm.bus,
address: address.value,
topic: topic.value,
},
],
})
.then((resp) => {
addRawSubscriptions(resp as RawSubs);
resp.forEach((set) => {
updateDriverTable(convertToSubscribe(set));
});
UpdateTable();
Dialog.value.close();
})
.catch((err) => {
NotifyResponse(err, 'error');
});
}
function fillDriverFormFromRow(drvs: DriverTableRow) {
driverForm.type = drvs.type;
driverForm.bus = drvs.buses?.[0]?.name ?? '';
driverForm.address = drvs.buses?.[0]?.address?.[0] ?? -1;
driverForm.subscribe = drvs.topic?.subscribe?.[0] ?? '';
driverForm.publish = drvs.topic?.publish?.[0] ?? '';
}
defineExpose({ open });
</script>
<style scoped>
.outercard {
border-radius: 10px;
}
</style>

View File

@@ -0,0 +1,104 @@
<template>
<DialogFrame ref="Dialog" :width="props.width" :header-title="props.dialogLabel">
<q-card-section
v-if="props.dialogLabel"
class="text-bold text-left q-mb-none q-pb-none"
:class="'text-' + props.labelColor"
>
</q-card-section>
<div class="text-center text-bold text-primary">
Do you want to remove Datapoint
<br /><br />
'{{ datapoint.path ?? '' }}'
</div>
<div class="row justify-end">
<q-btn no-caps class="q-ma-lg q-mr-xl" filled color="negative" @click="remove">{{
props.buttonOkLabel
}}</q-btn>
</div>
</DialogFrame>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import DialogFrame from '../../dialog/DialogFrame.vue';
import { useNotify } from '../../general/useNotify';
import { subscribe } from '../../services/websocket';
import { findParentKey, buildTree } from '../../dbm/dbmTree';
import { addRawSubscriptions } from '../../models/Subscriptions';
import { UpdateTable } from '../../dbm/updateTable';
import { convertToSubscribes } from '../../models/Subscribe';
import { deleteRequest, getRequest } from 'src/vueLib/models/Request';
import { catchError } from 'src/vueLib/models/error';
const { NotifyResponse } = useNotify();
const Dialog = ref();
const datapoint = ref();
const prefix = 'DBM:';
const open = (uuid: string) => {
getDatapoint(uuid)
.then(() => Dialog.value?.open())
.catch((err) => NotifyResponse(catchError(err), 'error'));
};
function remove() {
deleteRequest(datapoint.value.uuid)
.then((respond) => {
const sub = respond[respond.length - 1];
if (sub) NotifyResponse("Datapoint '" + prefix + sub.path + "' removed", 'warning');
Dialog.value.close();
{
const parentKey = findParentKey(datapoint.value.uuid);
if (parentKey) {
subscribe([{ uuid: parentKey, path: '', depth: 2 }])
.then((res) => {
if (res?.subscribe) {
addRawSubscriptions(res.subscribe);
buildTree(convertToSubscribes(res.subscribe));
UpdateTable();
}
})
.catch((err) => NotifyResponse('Subscribe failed ' + catchError(err), 'error'));
}
}
})
.catch((err) => {
if (err.response) {
NotifyResponse(err.response.data.message, 'error');
} else console.error(err);
});
}
const props = defineProps({
buttonOkLabel: {
type: String,
default: 'OK',
},
labelColor: {
type: String,
default: 'primary',
},
dialogLabel: {
type: String,
default: '',
},
width: {
type: String,
default: '300px',
},
});
async function getDatapoint(uuid: string) {
await getRequest(uuid, '', 1)
.then((resp) => {
if (resp) {
datapoint.value = resp[0];
}
})
.catch((err) => NotifyResponse(catchError(err), 'error'));
}
defineExpose({ open, close });
</script>

View File

@@ -0,0 +1,153 @@
<template>
<DialogFrame
ref="Dialog"
:width="props.width"
:height="props.height"
:header-title="props.dialogLabel"
>
<q-card-section
v-if="props.dialogLabel"
class="text-bold text-left q-mb-none q-pb-none"
:class="'text-' + props.labelColor"
>
</q-card-section>
<q-form ref="copyForm" class="q-gutter-md">
<q-input
class="q-mt-lg q-mb-none q-pl-md q-mx-lg"
filled
v-model="removeData.path"
label="Current Path"
label-color="primary"
readonly
>
</q-input>
<q-input
class="q-mt-lg q-mt-none q-pl-md q-mx-lg"
filled
v-model="removeData.newPath"
label="New Path *"
label-color="primary"
@keyup.enter="onSubmit"
:rules="[(val) => !!val || 'Path is required']"
>
</q-input>
<div class="row justify-end q-mr-lg">
<q-btn no-caps class="q-mb-xl q-ml-lg q-px-lg" @click="onSubmit" color="primary">{{
props.buttonOkLabel
}}</q-btn>
</div>
</q-form>
</DialogFrame>
</template>
<script setup lang="ts">
import { reactive, ref } from 'vue';
import DialogFrame from '../../dialog/DialogFrame.vue';
import { useNotify } from '../../general/useNotify';
import { getRequest, setRequest } from 'src/vueLib/models/Request';
import { catchError } from 'src/vueLib/models/error';
import { convertToSubscribes, type RawSubs } from 'src/vueLib/models/Subscribe';
import { UpdateTable } from '../updateTable';
import { addRawSubscriptions } from 'src/vueLib/models/Subscriptions';
import { buildTree } from '../dbmTree';
const { NotifyResponse } = useNotify();
const Dialog = ref();
const datapoint = ref();
const removeData = reactive({
path: '',
newPath: '',
prefix: 'DBM:',
});
const copyForm = ref();
const open = (uuid: string) => {
Dialog.value?.open();
getDatapoint(uuid);
};
function onSubmit() {
copyForm.value.validate().then((success: undefined) => {
if (success) {
if (removeData.newPath === removeData.path) {
NotifyResponse('same name', 'warning');
return;
}
getRequest('', removeData.newPath.slice(removeData.prefix.length), 1)
.then((response) => {
if (response?.length > 0) {
NotifyResponse("path '" + response[0]?.path + "' already exists", 'warning');
return;
}
})
.catch((err) => {
const error = catchError(err);
if (error !== 'No data returned') {
NotifyResponse(error, 'error');
return;
}
setRequest(
removeData.newPath.slice(removeData.prefix.length),
datapoint.value.type,
datapoint.value.value,
datapoint.value.rights,
datapoint.value.uuid,
undefined,
true,
)
.then((res) => {
addRawSubscriptions(res as RawSubs);
buildTree(convertToSubscribes(res as RawSubs));
UpdateTable();
})
.catch((err) => NotifyResponse(err, 'error'));
});
} else {
if (removeData.newPath === '') {
NotifyResponse("Field 'New Path' is requierd", 'error');
return;
} else NotifyResponse('Form not validated', 'error');
}
});
}
const props = defineProps({
buttonOkLabel: {
type: String,
default: 'OK',
},
labelColor: {
type: String,
default: 'primary',
},
dialogLabel: {
type: String,
default: '',
},
width: {
type: String,
default: '300px',
},
height: {
type: String,
default: '400px',
},
});
function getDatapoint(uuid: string) {
getRequest(uuid)
.then((resp) => {
if (resp[0]) {
datapoint.value = resp[0];
removeData.path = removeData.prefix + resp[0].path;
removeData.newPath = removeData.prefix + resp[0].path;
}
})
.catch((err) => NotifyResponse(catchError(err), 'error'));
}
defineExpose({ open });
</script>

View File

@@ -0,0 +1,152 @@
<template>
<DialogFrame
ref="Dialog"
:width="props.width"
:height="props.height"
:header-title="props.dialogLabel"
>
<q-card-section
v-if="props.dialogLabel"
class="text-bold text-left q-mb-none q-pb-none"
:class="'text-' + props.labelColor"
>{{
datapoint.uuid === '00000000-0000-0000-0000-000000000000' ? 'DBM' : 'DBM:' + datapoint.path
}}
</q-card-section>
<q-form ref="datatypeForm" class="q-gutter-md">
<q-input
class="q-mt-lg q-mb-none q-pl-md q-mx-lg"
filled
dense
v-model="currentDatatype"
label="Current Datatype"
label-color="primary"
readonly
>
</q-input>
<q-select
class="q-mt-lg q-mt-none q-pl-md q-mx-lg"
popup-content-class="small-dropdown"
label="New Datatype"
filled
dense
v-model="selectedDatatype"
:options="options"
option-label="label"
>
</q-select>
<div class="row justify-end q-mr-lg">
<q-btn no-caps class="q-mb-xl q-ml-lg q-px-lg" @click="onSubmit" color="primary">{{
props.buttonOkLabel
}}</q-btn>
</div>
</q-form>
</DialogFrame>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import DialogFrame from '../../dialog/DialogFrame.vue';
import { useNotify } from '../../general/useNotify';
import { getRequest, setRequest } from 'src/vueLib/models/Request';
import { UpdateTable } from '../updateTable';
import { updateSubscription } from 'src/vueLib/models/Subscriptions';
import { convertToSubscribe } from 'src/vueLib/models/Subscribe';
import { convertFromType } from '../Datapoint';
import { catchError } from 'src/vueLib/models/error';
const { NotifyResponse } = useNotify();
const Dialog = ref();
const datapoint = ref();
const currentDatatype = ref('');
const datatypeForm = ref();
const selectedDatatype = ref({ label: 'None', value: 'NONE' });
const options = [
{ label: 'None', value: 'NONE' },
{ label: 'String (Text)', value: 'STR' },
{ label: 'Bool (On/Off)', value: 'BIT' },
{ label: 'Uint8 (0 - 256)', value: 'BYU' },
{ label: 'Uint16 (0 - 65535)', value: 'WOU' },
{ label: 'Uint32 (0 - 429496...)', value: 'DWU' },
{ label: 'Int8 (-128 - 127)', value: 'BYS' },
{ label: 'Int16 (-32768 -3...)', value: 'WOS' },
{ label: 'Int32 (-21474836...)', value: 'DWS' },
{ label: 'Int64 (-2^63 -(2^...))', value: 'DWS' },
{ label: 'Double (1.7E 1/-3...)', value: 'F64' },
];
const open = async (uuid: string) => {
await getDatapoint(uuid);
Dialog.value?.open();
};
async function onSubmit() {
const success = await datatypeForm.value.validate();
if (!success) {
NotifyResponse('Form not validated', 'error');
return;
}
const datatype = options.find((s) => s.label === selectedDatatype.value.label)?.value;
if (datatype === undefined) return;
try {
const response = await setRequest(datapoint.value.path, datatype, datapoint.value.value);
if (response[0]) updateSubscription(convertToSubscribe(response[0]));
NotifyResponse(
'new datatype: ' +
convertFromType(response[0]?.type ?? '') +
' for datapoint :DBM:' +
response[0]?.path,
);
UpdateTable();
return;
} catch (err) {
console.error(err);
}
}
const props = defineProps({
buttonOkLabel: {
type: String,
default: 'OK',
},
labelColor: {
type: String,
default: 'primary',
},
dialogLabel: {
type: String,
default: '',
},
width: {
type: String,
default: '300px',
},
height: {
type: String,
default: '340px',
},
});
async function getDatapoint(uuid: string) {
await getRequest(uuid)
.then((resp) => {
if (resp[0]) {
datapoint.value = resp[0];
const type = options.find((s) => s.value === (resp[0]?.type ?? 'NONE'))?.label ?? 'None';
currentDatatype.value = type;
selectedDatatype.value.value = type;
}
})
.catch((err) => NotifyResponse(catchError(err), 'error'));
}
defineExpose({ open });
</script>
<style scope>
.small-dropdown .q-item {
min-height: 28px; /* default is 48px */
padding: 4px 8px;
}
</style>

View File

@@ -0,0 +1,212 @@
<template>
<DialogFrame
ref="Dialog"
:width="props.width"
:height="props.height"
:header-title="'DBM:' + datapoint?.path"
>
<q-card-section
v-if="props.dialogLabel || localDialogLabel"
class="text-bold text-left q-mb-none q-pb-none"
:class="'text-' + props.labelColor"
>{{ props.dialogLabel || localDialogLabel }}</q-card-section
>
<q-card-section>
<q-table
flat
dense
virtual-scroll
:rows-per-page-options="[0]"
:rows="drivers"
:columns="columns"
row-key="type"
>
<!-- add symbol on top right of table-->
<template v-slot:top-right>
<q-btn
size="sm"
ripple
rounded
color="primary"
icon="add"
round
dense
@click="handleRow(driver, 'add')"
/>
</template>
<template v-slot:body-cell-settings="props">
<q-td :props="props" class="cursor-pointer">
<q-btn
dense
flat
size="sm"
icon="more_vert"
@click="(evt) => openSubMenu(evt, props.row)"
></q-btn>
</q-td>
</template>
</q-table>
<q-menu ref="contextMenuRef" context-menu>
<q-list>
<q-item>
<q-item-section v-close-popup class="cursor-pointer" @click="handleRow(driver, 'edit')">
Edit
</q-item-section>
</q-item>
<q-item>
<q-item-section
v-close-popup
class="text-negative cursor-pointer"
@click="deleteDriver(driver)"
>
Delete
</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-card-section>
<q-card-section v-if="props.text" class="text-center" style="white-space: pre-line">{{
props.text
}}</q-card-section>
<q-card-actions align="right" class="text-primary">
<q-btn v-if="props.buttonCancelLabel" flat :label="props.buttonCancelLabel" v-close-popup>
</q-btn>
<q-btn
class="q-mb-xl q-ml-lg q-mt-none"
v-if="props.buttonOkLabel"
color="primary"
no-caps
:label="props.buttonOkLabel"
v-close-popup
>
</q-btn>
</q-card-actions>
</DialogFrame>
<DriverDialog :button-ok-label="driverOkLabel" ref="driverDialog"></DriverDialog>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import DialogFrame from '../../dialog/DialogFrame.vue';
import DriverDialog from './DriverDialog.vue';
import { convertToSubscribe, type Subscribe } from '../../models/Subscribe';
import type { Driver } from '../../models/Drivers';
import { driverDefault } from '../../models/Drivers';
import type { DriverTableRow } from 'src/vueLib/models/driverTable';
import { updateDriverTable, useDriverTable } from 'src/vueLib/models/driverTable';
import { deleteRequest } from 'src/vueLib/models/Request';
import { useNotify } from 'src/vueLib/general/useNotify';
import type { Bus } from 'src/vueLib/models/Bus';
const { NotifyResponse } = useNotify();
const Dialog = ref();
const driverDialog = ref();
const writeValue = ref();
const onlyRead = ref(false);
const props = defineProps({
buttonOkLabel: {
type: String,
default: 'OK',
},
labelColor: {
type: String,
default: 'primary',
},
dialogLabel: {
type: String,
default: '',
},
text: {
type: String,
default: '',
},
buttonCancelLabel: {
type: String,
default: '',
},
width: {
type: String,
default: '300px',
},
height: {
type: String,
default: '500px',
},
});
const datapoint = ref();
const localDialogLabel = ref('');
const contextMenuRef = ref();
const table = useDriverTable();
const drivers = table.driverTable;
const driver: Driver = { type: '' };
const driverOkLabel = ref('');
const columns = table.columns;
const open = (sub: Subscribe) => {
datapoint.value = sub;
if (datapoint.value.rights == 'R') onlyRead.value = true;
table.emptyTable();
localDialogLabel.value = 'Update Drivers';
updateDriverTable(sub);
writeValue.value = sub.drivers;
Dialog.value?.open();
};
function openSubMenu(evt: Event, d: DriverTableRow) {
if (d) {
const bus: Bus = {
name: d.bus,
};
bus.name = d.bus;
if (d.address) bus.address = d.address !== undefined ? [d.address] : [];
if (d.subscribe || d.publish)
bus.topic = {
subscribe:
typeof d.subscribe === 'string' ? d.subscribe.split(',').map((s) => s.trim()) : [],
publish: typeof d.publish === 'string' ? d.publish.split(',').map((s) => s.trim()) : [],
};
driver.type = d.type;
driver.buses = [bus];
}
const mouseEvent = evt as MouseEvent;
contextMenuRef.value?.show(mouseEvent);
}
function handleRow(driver: Driver | undefined, type: 'add' | 'edit') {
driverOkLabel.value = 'Add';
switch (type) {
case 'add':
driver = driverDefault;
break;
case 'edit':
driverOkLabel.value = 'Update';
break;
}
driverDialog.value?.open(datapoint.value.uuid, driver, type);
}
function deleteDriver(driver: Driver | undefined) {
deleteRequest(datapoint.value.uuid, '', driver)
.then((resp) => {
resp.forEach((set) => {
updateDriverTable(convertToSubscribe(set));
});
})
.catch((err) => {
NotifyResponse(err, 'error');
});
}
defineExpose({ open });
</script>
<style scoped>
.outercard {
border-radius: 10px;
}
</style>

View File

@@ -0,0 +1,159 @@
<template>
<DialogFrame
ref="Dialog"
:width="props.width"
:height="props.height"
:header-title="datapoint?.path"
>
<q-card-section
v-if="props.dialogLabel || localDialogLabel"
class="text-bold text-left q-mb-none q-pb-none"
:class="'text-' + props.labelColor"
>{{ props.dialogLabel ? props.dialogLabel : localDialogLabel }}</q-card-section
>
<q-card-section v-if="datapoint.type !== 'BIT'">
<q-input
class="q-px-md q-ma-sm"
label="current value"
dense
filled
readonly
v-model="inputValue as string | number"
></q-input>
<q-input
class="q-px-md q-mx-sm"
label="new value"
dense
filled
:readonly="onlyRead"
@keyup.enter="write"
:type="writeType"
v-model="writeValue as string | number"
></q-input>
</q-card-section>
<q-card-section v-else>
<div class="column q-pr-xs q-ma-sm">
<div class="row items-center q-gutter-sm">
<div>current value</div>
<div class="row items-left">
<q-toggle class="readonly-toggle" left-label v-model="inputValue"></q-toggle>
</div>
</div>
<div class="row items-center q-gutter-lg">
<div>new value</div>
<div class="row items-left">
<q-toggle left-label v-model="writeValue"></q-toggle>
</div>
</div>
</div>
</q-card-section>
<q-card-section v-if="props.text" class="text-center" style="white-space: pre-line">{{
props.text
}}</q-card-section>
<q-card-actions align="right" class="text-primary">
<q-btn v-if="props.buttonCancelLabel" flat :label="props.buttonCancelLabel" v-close-popup>
</q-btn>
<q-btn
class="q-mb-xl q-mr-lg q-mt-none"
v-if="props.buttonOkLabel"
color="primary"
no-caps
:label="props.buttonOkLabel"
@click="write"
>
</q-btn>
</q-card-actions>
</DialogFrame>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue';
import DialogFrame from '../../dialog/DialogFrame.vue';
import type { Subscribe } from '../../models/Subscribe';
import type { Ref } from 'vue';
import { setValues } from '../../services/websocket';
import { useNotify } from '../../general/useNotify';
import { catchError } from 'src/vueLib/models/error';
const { NotifyResponse } = useNotify();
const Dialog = ref();
const localDialogLabel = ref('');
const writeValue = ref();
const onlyRead = ref(false);
const writeType = ref<'text' | 'number'>('text');
const datapoint = ref();
const inputValue = ref(datapoint?.value);
const props = defineProps({
buttonOkLabel: {
type: String,
default: 'OK',
},
labelColor: {
type: String,
default: 'primary',
},
dialogLabel: {
type: String,
default: '',
},
text: {
type: String,
default: '',
},
buttonCancelLabel: {
type: String,
default: '',
},
width: {
type: String,
default: '300px',
},
height: {
type: String,
default: '350px',
},
});
const open = (sub: Ref<Subscribe>) => {
datapoint.value = sub.value;
if (datapoint.value.rights == 'R') onlyRead.value = true;
localDialogLabel.value = 'Update Value';
if (sub.value.type === 'STR') writeType.value = 'text';
else writeType.value = 'number';
writeValue.value = sub.value.value;
Dialog.value?.open();
};
watch(
() => datapoint.value?.value,
(newVal) => {
inputValue.value = newVal;
},
);
function write() {
setValues([{ uuid: datapoint.value?.uuid ?? '', value: writeValue.value ?? undefined }])
.then((resp) => {
if (resp?.set) {
resp.set.forEach((set) => {
inputValue.value = set.value;
});
}
})
.catch((err) => NotifyResponse(catchError(err), 'error'));
}
defineExpose({ open });
</script>
<style scoped>
.outercard {
border-radius: 10px;
}
.readonly-toggle {
pointer-events: none;
opacity: 0.7;
}
</style>

View File

@@ -0,0 +1,22 @@
import type { Subs } from '../models/Subscribe';
import { Subscriptions } from '../models/Subscriptions';
import { ref } from 'vue';
export const TableSubs = ref<Subs>();
export function UpdateTable(targetUuid?: string) {
TableSubs.value = Object.values(Subscriptions)
.map((sub) => {
sub.type = sub.type ?? 'none';
return sub;
})
.sort((a, b) => {
if (targetUuid) {
if (a.uuid === targetUuid) return -1; // move `a` to front
if (b.uuid === targetUuid) return 1; // move `b` to front
}
const aPath = a.path ?? '';
const bPath = b.path ?? '';
return aPath.localeCompare(bPath);
});
}

View File

@@ -0,0 +1,147 @@
<template>
<q-dialog
ref="dialogRef"
:maximized="minMaxState"
:full-width="minMaxState"
:no-focus="!minMaxState"
:no-refocus="!minMaxState"
:seamless="!minMaxState"
>
<q-card class="layout" :style="cardStyle">
<!-- Draggable Header -->
<div
class="dialog-header row items-center justify-between bg-grey-1"
v-touch-pan.mouse.prevent.stop="handlePan"
>
<div v-if="headerTitle" class="text-left text-bold text-caption q-mx-sm">
{{ headerTitle }}
</div>
<div class="row justify-end q-mx-sm">
<q-btn dense flat :icon="minMaxIcon" size="md" @click="minMax" />
<q-btn dense flat icon="close" size="md" v-close-popup />
</div>
</div>
<q-separator color="black" />
<!-- Content Slot -->
<div class="scrollArea">
<slot />
</div>
<!-- Resize Handle -->
<div v-if="!minMaxState" class="resize-handle" @mousedown.prevent="startResizing" />
</q-card>
</q-dialog>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue';
const dialogRef = ref();
const open = () => dialogRef.value?.show();
const close = () => dialogRef.value?.hide();
defineExpose({ open, close });
const props = defineProps({
headerTitle: { type: String, default: '' },
width: { type: String, default: '400' },
height: { type: String, default: '250' },
});
// Fullscreen toggle
const minMaxIcon = ref('fullscreen');
const minMaxState = ref(false);
function minMax() {
minMaxState.value = !minMaxState.value;
minMaxIcon.value = minMaxState.value ? 'fullscreen_exit' : 'fullscreen';
}
// Position and Size
const position = ref({ x: 0, y: 0 });
const width = ref(parseInt(props.width));
const height = ref(parseInt(props.height));
// Dragging (only from header)
const handlePan = (details: { delta: { x: number; y: number } }) => {
if (!minMaxState.value) {
position.value.x += details.delta.x;
position.value.y += details.delta.y;
}
};
// Resizing
const isResizing = ref(false);
function startResizing(e: MouseEvent) {
isResizing.value = true;
const startX = e.clientX;
const startY = e.clientY;
const startWidth = width.value;
const startHeight = height.value;
function onMouseMove(e: MouseEvent) {
width.value = Math.max(200, startWidth + e.clientX - startX);
height.value = Math.max(200, startHeight + e.clientY - startY);
}
function onMouseUp() {
isResizing.value = false;
window.removeEventListener('mousemove', onMouseMove);
window.removeEventListener('mouseup', onMouseUp);
}
window.addEventListener('mousemove', onMouseMove);
window.addEventListener('mouseup', onMouseUp);
}
// Styles
const cardStyle = computed(() => {
if (minMaxState.value) {
return {};
}
return {
width: `${width.value}px`,
height: `${height.value}px`,
transform: `translate(${position.value.x}px, ${position.value.y}px)`,
};
});
</script>
<style scoped>
.layout {
position: relative;
display: flex;
flex-direction: column;
border-radius: 10px;
background-color: white;
}
/* Draggable header */
.dialog-header {
padding: 8px 0;
background: #f5f5f5;
cursor: move;
user-select: none;
}
/* Scrollable content */
.scrollArea {
flex: 1 1 auto;
min-height: 0;
overflow-y: auto;
padding: 16px;
}
/* Resize handle in bottom right */
.resize-handle {
position: absolute;
width: 16px;
height: 16px;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.1);
cursor: nwse-resize;
z-index: 10;
}
</style>

View File

@@ -0,0 +1,80 @@
import type { Response } from '../models/Response';
import { useQuasar } from 'quasar';
export function useNotify() {
const $q = useQuasar();
function NotifyResponse(
response: Response | string | undefined,
type?: 'warning' | 'error',
timeout: number = 5000,
) {
let color = 'green';
let icon = 'check_circle';
switch (type) {
case 'warning':
color = 'orange';
icon = 'warning';
break;
case 'error':
color = 'red';
icon = 'error';
break;
}
if (response instanceof Error) {
const resp = response as Response;
if (resp.response?.data?.error) {
$q?.notify({
message: resp.response.data.message as string,
color: color,
position: 'bottom-right',
icon: icon,
timeout: timeout,
});
return;
}
}
if (response) {
const message = typeof response === 'string' ? response : (response.message ?? '');
if (message === '') {
return;
}
color = typeof response === 'string' ? color : response?.error ? 'red' : color;
icon = typeof response === 'string' ? icon : response?.error ? 'error' : icon;
$q?.notify({
message: message,
color: color,
position: 'bottom-right',
icon: icon,
timeout: timeout,
});
}
}
function NotifyDialog(title: string, text: string, okText?: string, cancelText?: string) {
return new Promise((resolve) => {
$q.dialog({
title: title,
message: text,
persistent: true,
ok: okText ?? 'OK',
cancel: cancelText ?? 'CANCEL',
})
.onOk(() => {
resolve(true);
})
.onCancel(() => {
resolve(false);
})
.onDismiss(() => {
resolve(false);
});
});
}
return {
NotifyDialog,
NotifyResponse,
};
}

View File

@@ -0,0 +1,109 @@
<template>
<DialogFrame ref="Dialog" width="300px" height="380px" header-title="Login">
<div class="text-black"></div>
<q-form ref="refForm">
<q-item-section class="q-gutter-md q-pa-md">
<q-card :class="['q-gutter-xs q-items-center q-pa-lg', { shake: shake }]">
<div class="text-h5 text-primary text-center">{{ productName }}</div>
<q-input
ref="refUserInput"
dense
filled
type="text"
label="User"
v-model="user"
:rules="[(val) => !!val || 'User is required']"
></q-input>
<q-input
dense
filled
type="password"
label="Password"
v-model="password"
@keyup.enter="onSubmit"
:rules="[(val) => !!val || 'Password is required']"
></q-input>
<div class="q-pt-sm q-mr-md row justify-end">
<q-btn color="primary" label="Login" @click="onSubmit"></q-btn>
</div>
</q-card>
</q-item-section>
</q-form>
</DialogFrame>
</template>
<script setup lang="ts">
import { productName } from '../../../package.json';
import { ref, nextTick } from 'vue';
import DialogFrame from '../dialog/DialogFrame.vue';
import { useNotify } from '../general/useNotify';
import { useLogin } from './login';
const { NotifyResponse } = useNotify();
const Dialog = ref();
const refForm = ref();
const refUserInput = ref();
const user = ref('');
const password = ref('');
const { login } = useLogin();
const shake = ref(false);
const open = () => {
Dialog.value?.open();
nextTick(() => {
refUserInput.value?.focus();
}).catch((err) => console.error(err));
};
const onSubmit = () => {
refForm.value?.validate().then((success: boolean) => {
if (success) {
login(user.value, password.value)
.then(() => {
NotifyResponse("logged in as '" + user.value + "'");
Dialog.value.close();
})
.catch((err) => {
NotifyResponse(err, 'error');
shake.value = true;
setTimeout(() => {
shake.value = false;
}, 500);
});
} else {
NotifyResponse('error submitting login form', 'error');
}
});
};
defineExpose({ open });
</script>
<style scoped>
@keyframes shake {
0% {
transform: translateX(0);
}
20% {
transform: translateX(-8px);
}
40% {
transform: translateX(8px);
}
60% {
transform: translateX(-6px);
}
80% {
transform: translateX(6px);
}
100% {
transform: translateX(0);
}
}
.shake {
animation: shake 0.4s ease;
border: 2px solid #f44336;
}
</style>

View File

@@ -0,0 +1,43 @@
<template>
<div class="q-gutter-md">
<q-btn dense flat round icon="person" :color="userStore.user ? 'green' : ''">
<q-menu ref="refLoginMenu">
<q-list style="min-width: 100px">
<q-item v-if="userStore.user" class="text-primary">{{ userStore.user?.username }}</q-item>
<q-item clickable v-close-popup @click="openLogin">
<q-item-section class="text-primary">{{ loginText }}</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</div>
<LoginForm ref="refLoginForm"></LoginForm>
</template>
<script setup lang="ts">
import LoginForm from './LoginForm.vue';
import { computed, ref } from 'vue';
import { useLogin } from './login';
import { useUserStore } from './userStore';
import { useNotify } from '../general/useNotify';
const userStore = useUserStore();
const userLogin = useLogin();
const { NotifyResponse } = useNotify();
const loginText = computed(() => {
return userStore.user ? 'Logout' : 'Login';
});
const refLoginForm = ref();
function openLogin() {
if (userStore.user) {
const username = userStore.user.username;
userLogin.logout();
NotifyResponse("user '" + username + "' logged out", 'warning');
return;
}
refLoginForm.value?.open();
}
</script>

31
src/vueLib/login/login.ts Normal file
View File

@@ -0,0 +1,31 @@
import { appApi } from 'src/boot/axios';
import { useUserStore } from './userStore';
const useStore = useUserStore();
export function useLogin() {
async function login(user: string, password: string) {
await appApi
.post('/login', { user: user, password: password })
.then((resp) => {
useStore.setToken(resp.data.token);
})
.catch((err) => {
throw err;
});
}
function logout() {
useStore.logout();
}
function isTokenValid() {
const token = localStorage.getItem('token');
if (token === null) return false;
const payload = JSON.parse(atob(token.split('.')[1] ?? ''));
const currentTime = Math.floor(Date.now() / 1000);
return payload.exp > currentTime;
}
return { login, logout, isTokenValid };
}

View File

@@ -0,0 +1,80 @@
import { defineStore } from 'pinia';
import { jwtDecode } from 'jwt-decode';
import type { QVueGlobals } from 'quasar';
interface JwtPayload {
id: string;
role: string;
username: string;
exp?: number;
iat?: number;
}
interface UserState {
token: string | null;
user: JwtPayload | null;
}
let $q = <QVueGlobals>{};
export const useUserStore = defineStore('user', {
state: (): UserState => ({
token: null,
user: null,
}),
getters: {
isAuthenticated: (state): boolean => !!state.token && !!state.user,
},
actions: {
isAuthorizedAs(roles: string[]) {
return !!this.token && !!this.user && roles.includes(this.user.role);
},
setToken(token: string) {
try {
const decoded = jwtDecode<JwtPayload>(token);
this.token = token;
this.user = decoded;
localStorage.setItem('token', token);
if (decoded.exp) {
const timeUntilExpiry = decoded.exp * 1000 - Date.now();
if (timeUntilExpiry > 0) {
setTimeout(() => {
this.logout();
}, timeUntilExpiry);
} else {
this.logout();
}
}
} catch (err) {
console.error('Invalid token:', err);
this.logout();
}
},
logout() {
$q?.notify({
message: "user '" + this.user?.username + "' logged out",
color: 'orange',
position: 'bottom-right',
icon: 'warning',
timeout: 5000,
});
this.token = null;
this.user = null;
localStorage.removeItem('token');
setTimeout(() => {
window.location.href = '/';
}, 5000);
},
loadFromStorage() {
const token = localStorage.getItem('token');
if (token) {
this.setToken(token);
}
},
initStore(q: QVueGlobals) {
$q = q;
},
},
});

7
src/vueLib/models/Bus.ts Normal file
View File

@@ -0,0 +1,7 @@
import type { Topic } from './Topic';
export interface Bus {
name: string;
address?: number[];
topic?: Topic;
}

View File

@@ -0,0 +1,9 @@
import type { Bus } from './Bus';
export interface Driver {
type: string;
buses?: Bus[];
}
export const driverDefault = <Driver>{
type: '',
};

View File

@@ -7,7 +7,7 @@ type Get = {
path?: string; path?: string;
type?: string; type?: string;
rights?: string; rights?: string;
value?: undefined; value?: string | number | boolean | null;
query?: Query; query?: Query;
hasChild?: boolean; hasChild?: boolean;
}; };

View File

@@ -0,0 +1,3 @@
export interface PongMessage {
type: 'pong';
}

View File

@@ -0,0 +1,62 @@
import type { Driver } from './Drivers';
export type Publish = {
event: string;
uuid: string;
path: string;
type: string;
drivers?: Record<string, Driver>;
value: string | number | boolean | null;
hasChild: boolean;
};
export type Pubs = Publish[];
import {
updateSubscriptionValue,
removeRawSubscriptions,
addRawSubscription,
removeRawSubscription,
} from './Subscriptions';
import { buildTree, buildTreeWithRawSubs, removeNodes } from '../dbm/dbmTree';
import type { RawSubs, RawSubscribe } from '../models/Subscribe';
import { ref } from 'vue';
import { UpdateTable } from '../dbm/updateTable';
import { pathIsExpanded } from '../dbm/dbmTree';
export function publishToSubscriptions(pubs: Pubs) {
let event = '';
const rawSubs = ref<RawSubs>([]);
pubs.forEach((pub) => {
switch (pub.event) {
case 'onCreate':
event = 'onCreate';
if (!pathIsExpanded(pub.path)) break;
pub.hasChild = pubs.length > 0;
rawSubs.value.push(pub as RawSubscribe);
break;
case 'onChange':
break;
case 'onDelete':
event = 'onDelete';
rawSubs.value.push(pub as RawSubscribe);
break;
}
if (pub.drivers) {
removeRawSubscription(pub as RawSubscribe);
addRawSubscription(pub as RawSubscribe);
UpdateTable();
}
updateSubscriptionValue(pub.uuid, pub.value);
});
switch (event) {
case 'onCreate':
buildTreeWithRawSubs(rawSubs.value);
break;
case 'onDelete':
buildTree(null);
removeRawSubscriptions(rawSubs.value);
UpdateTable();
removeNodes(pubs);
break;
}
}

View File

@@ -0,0 +1,128 @@
import type { Driver } from './Drivers';
import type { Gets } from './Get';
import type { Sets } from './Set';
import type { Subs } from './Subscribe';
import { dbmApi } from 'src/boot/axios';
export type Request = {
get?: Gets;
set?: Sets;
subscribe?: Subs;
unsubscribe?: Subs;
};
const query = '/json_data';
export async function getRequest(
uuid: string,
path: string = '',
depth: number = 1,
): Promise<Gets> {
let payload = {};
if (uuid !== '') {
payload = { uuid: uuid, path: path, query: { depth: depth } };
} else {
payload = { path: path, query: { depth: depth } };
}
const resp = await dbmApi.post(query, {
get: [payload],
});
if (resp.data.get && resp.data.get.length > 0) {
return resp.data.get;
} else {
throw new Error('No data returned');
}
}
export async function getRequests(gets: Gets): Promise<Gets> {
const resp = await dbmApi.post(query, {
get: gets,
});
if (resp.data.get && resp.data.get.length > 0) {
return resp.data.get;
} else {
throw new Error('No data returned');
}
}
export async function rawSetsRequest(sets: Sets): Promise<Sets> {
const resp = await dbmApi.post(query, {
set: sets,
});
if (resp.data.set && resp.data.set.length > 0) {
return resp.data.set;
} else {
throw new Error('No data returned');
}
}
export async function setRequest(
path: string,
type?: string,
value?: string | number | boolean,
rights?: string,
uuid?: string,
driver?: Driver,
rename?: boolean,
): Promise<Sets> {
const payload = {
path: path,
type: type,
value: value,
rights: rights,
uuid: uuid,
driver: driver,
rename: rename,
};
const resp = await dbmApi.post(query, {
set: [payload],
});
if (resp.data.set && resp.data.set.length > 0) {
return resp.data.set;
} else {
throw new Error('No data returned');
}
}
export async function setsRequest(sets: Sets): Promise<Sets> {
const resp = await dbmApi.post(query, {
set: sets,
});
if (resp.data.set && resp.data.set.length > 0) {
return resp.data.set;
} else {
throw new Error('No data returned');
}
}
export async function deleteRequest(
uuid?: string,
path?: string,
driver?: Driver,
rename?: boolean,
): Promise<Sets> {
let payload = {};
if (uuid) {
payload = { uuid: uuid, driver: driver, rename: rename };
} else if (path) {
payload = { path: path, driver: driver };
}
const resp = await dbmApi.delete('/json_data', {
data: {
set: [payload],
},
});
if (resp.data.set && resp.data.set.length > 0) {
return resp.data.set;
} else {
throw new Error('No data returned');
}
}

View File

@@ -1,14 +1,20 @@
import type { Gets } from './Get'; import type { Gets } from './Get';
import type { Sets } from './Set'; import type { Sets } from './Set';
import type { Subs } from './Subscribe'; import type { RawSubs } from './Subscribe';
import type { Pubs } from './Publish'; import type { Pubs } from './Publish';
export type Response = { export type Response = {
get?: Gets; get?: Gets;
set?: Sets; set?: Sets;
subscribe?: Subs; subscribe?: RawSubs;
unsubscribe?: Subs; unsubscribe?: RawSubs;
publish?: Pubs; publish?: Pubs;
error?: boolean; error?: boolean;
message?: string; message?: string;
response?: {
data?: {
error?: boolean;
message?: string;
};
};
}; };

View File

@@ -1,9 +1,11 @@
export type Set = { export type Set = {
uuid?: string | undefined; uuid?: string | undefined;
path: string; path?: string;
type?: string; type?: string;
value: number | boolean | undefined; value: string | number | boolean | null | undefined;
rights?: string;
create?: boolean; create?: boolean;
hasChild?: boolean;
}; };
export type Sets = Set[]; export type Sets = Set[];

View File

@@ -0,0 +1,55 @@
import { ref } from 'vue';
import type { Ref } from 'vue';
import type { Driver } from './Drivers';
import type { Set } from './Set';
export type Subscribe = {
uuid?: string;
path?: string;
depth?: number;
type?: string;
drivers?: Record<string, Driver>;
value?: Ref<string | number | boolean | null | undefined>;
hasChild?: boolean;
};
export type Subs = Subscribe[];
export type RawSubscribe = {
uuid?: string;
path?: string;
depth?: number;
value?: string | number | boolean | null;
drivers?: Record<string, Driver>;
rights?: string;
hasChild?: boolean;
};
export type RawSubs = RawSubscribe[];
export function convertToSubscribe(raw: RawSubscribe | Set): Subscribe {
return {
...raw,
uuid: raw.uuid ?? '',
value: ref(raw.value ?? null),
};
}
export function convertToSubscribes(rawList: RawSubs): Subs {
const subs = rawList.map(convertToSubscribe).sort((a, b) => {
const aPath = a.path ?? '';
const bPath = b.path ?? '';
return aPath.localeCompare(bPath);
});
return subs as Subs;
}
export function convertToRaw(sub: Subscribe): RawSubscribe {
return {
...(sub.uuid !== undefined ? { uuid: sub.uuid } : {}),
...(sub.path !== undefined ? { path: sub.path } : {}),
...(sub.depth !== undefined ? { depth: sub.depth } : {}),
...(sub.value?.value !== undefined ? { value: sub.value.value } : {}),
...(sub.hasChild !== undefined ? { hasChild: sub.hasChild } : {}),
};
}

View File

@@ -0,0 +1,73 @@
import type { Ref } from 'vue';
import { reactive, ref } from 'vue';
import { convertToSubscribe } from '../models/Subscribe';
import type { Subscribe, RawSubs, RawSubscribe } from '../models/Subscribe';
import type { Set } from './Set';
const EMPTYUUID = '00000000-0000-0000-0000-000000000000';
export const Subscriptions = reactive<Record<string, Subscribe>>({});
export type TableSubscription = {
path: string;
value: Ref<string | number | boolean | null | undefined>;
};
export function addRawSubscription(sub: RawSubscribe | Set | undefined) {
if (sub === undefined) return;
addSubscription(convertToSubscribe(sub as RawSubscribe));
}
export function addRawSubscriptions(subs: RawSubs) {
subs.forEach((sub) => addSubscription(convertToSubscribe(sub)));
}
function addSubscription(sub: Subscribe) {
if (EMPTYUUID === sub.uuid) {
sub.path = 'DBM';
}
if (!sub.uuid) return;
Subscriptions[sub.uuid] = sub;
}
export function updateSubscription(sub: Subscribe) {
if (!sub.uuid) return;
Subscriptions[sub.uuid] = sub;
}
export function updateSubscriptionValue(
uuid: string,
value: string | number | boolean | null | undefined,
) {
if (!uuid) return;
if (!Subscriptions[uuid]) return;
Subscriptions[uuid].value = ref(value);
}
export function removeRawSubscription(sub: RawSubscribe | string) {
removeSubscription(typeof sub === 'string' ? sub : sub.uuid);
}
export function removeRawSubscriptions(subs: RawSubs) {
subs.forEach((sub) => {
removeSubscription(sub.uuid);
});
}
export function removeAllSubscriptions() {
Object.keys(Subscriptions).forEach((key) => delete Subscriptions[key]);
}
export function removeSubscription(uuid: string | undefined) {
if (uuid === undefined) return;
if (!Subscriptions || Subscriptions[uuid] === undefined) return;
delete Subscriptions[uuid];
}
export function findSubscriptionByPath(path: string): Subscribe | undefined {
return Object.values(Subscriptions).find((sub) => sub.path === path);
}
export function findSubscriptionByUuid(uuid: string): Subscribe | undefined {
if (!Subscriptions[uuid]) return;
return Subscriptions[uuid];
}

View File

@@ -0,0 +1,4 @@
export interface Topic {
subscribe: string[];
publish: string[];
}

View File

@@ -0,0 +1,7 @@
import type { UUID } from 'crypto';
export interface Value {
uuid?: UUID;
path: string;
value: number | string | undefined;
}

View File

@@ -0,0 +1,87 @@
import { reactive, ref } from 'vue';
import type { QTableColumn } from 'quasar';
import type { Subscribe } from './Subscribe';
import type { Bus } from './Bus';
import type { Topic } from './Topic';
export type DriverTableRow = {
type: string;
buses?: Bus[];
topic?: Topic;
bus: string;
address?: number | undefined;
subscribe?: string;
publish?: string;
};
const driverTable = reactive<DriverTableRow[]>([]);
const columns = ref<QTableColumn[]>([]);
const baseColumns: QTableColumn[] = [
{ name: 'type', label: 'Driver Name', field: 'type', align: 'left' },
{ name: 'bus', label: 'Bus Name', field: 'bus', align: 'center' },
{ name: 'address', label: 'Address', field: 'address', align: 'center' },
{ name: 'settings', label: '', field: 'settings', align: 'center' },
];
export function updateDriverTable(sub: Subscribe) {
driverTable.length = 0;
let hasSubs = false;
let hasPubs = false;
if (sub.drivers)
Object.entries(sub.drivers).forEach(([driverName, driverData]) => {
driverData.buses?.forEach((bus) => {
hasSubs = bus.topic?.subscribe !== undefined || hasSubs;
hasPubs = bus.topic?.publish !== undefined || hasPubs;
const subscribeList = bus.topic?.subscribe ?? [];
const publishList = bus.topic?.publish ?? [];
const addresses = bus.address?.length ? bus.address : [undefined];
addresses.forEach((addr) => {
driverTable.push({
type: driverName,
bus: bus.name,
address: addr,
subscribe: subscribeList.join(', '),
publish: publishList.join(', '),
});
});
});
});
reloadColumns(hasSubs, hasPubs);
}
export function useDriverTable() {
function emptyTable() {
driverTable.length = 0;
}
return {
driverTable,
emptyTable,
columns,
};
}
function reloadColumns(hasSubs: boolean, hasPubs: boolean) {
columns.value = [...baseColumns];
const settingsIndex = columns?.value.findIndex((col) => col.name === 'settings');
if (hasSubs) {
columns.value?.splice(settingsIndex ?? -1, 0, {
name: 'subscribe',
label: 'subscribe',
field: 'subscribe',
align: 'left',
});
}
if (hasPubs) {
columns.value?.splice(settingsIndex ?? -1, 0, {
name: 'publish',
label: 'publish',
field: 'publish',
align: 'left',
});
}
}

Some files were not shown because too many files have changed in this diff Show More