Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
11b48c548e | ||
![]() |
9585fb1b7a | ||
![]() |
a648be3bcb | ||
![]() |
33f7775800 | ||
![]() |
ac412bbffb | ||
![]() |
6f532ef4b0 | ||
![]() |
1155bafb30 | ||
![]() |
0e3a14d69c | ||
![]() |
de88b2773c | ||
![]() |
1697a4dcfd | ||
![]() |
7d2ab814da | ||
![]() |
d50bf9c058 | ||
![]() |
dac7130544 | ||
![]() |
7434f02c30 | ||
![]() |
8c506b9af3 |
120
.gitea/workflows/build.yml
Normal file
120
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
name: Build Quasar SPA and Go Backend for lightController
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-spa:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '20'
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
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: Upload SPA artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: quasar-dist
|
||||||
|
path: ./dist/spa
|
||||||
|
|
||||||
|
build-backend:
|
||||||
|
needs: build-spa
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- goos: windows
|
||||||
|
arch: amd64
|
||||||
|
ext: .exe
|
||||||
|
- goos: linux
|
||||||
|
arch: amd64
|
||||||
|
ext: ""
|
||||||
|
- goos: linux
|
||||||
|
arch: arm64
|
||||||
|
ext: ""
|
||||||
|
- goos: linux
|
||||||
|
arch: arm
|
||||||
|
arm_version: 6
|
||||||
|
ext: ""
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Download SPA artifact
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: quasar-dist
|
||||||
|
path: ./dist/spa
|
||||||
|
|
||||||
|
- 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.arch }}${{ matrix.ext }}"
|
||||||
|
if [ "${{ matrix.arch }}" = "arm" ]; then
|
||||||
|
GOARM=${{ matrix.arm_version }}
|
||||||
|
fi
|
||||||
|
|
||||||
|
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.arch }} go build -ldflags="-s -w" -trimpath -o "$OUTPUT" main.go
|
||||||
|
|
||||||
|
- name: Upload combined package
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: lightcontroller-${{ matrix.goos }}-${{ matrix.arch }}
|
||||||
|
path: |
|
||||||
|
./dist/spa
|
||||||
|
server-${{ matrix.goos }}-${{ matrix.arch }}${{ matrix.ext }}
|
71
.github/workflows/build.yml
vendored
71
.github/workflows/build.yml
vendored
@@ -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 -ldflags="-s -w" -trimpath -o ../server-${{ matrix.goos }}-${{ matrix.goarch }}.exe main.go
|
|
||||||
else
|
|
||||||
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -trimpath -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') || '' }}
|
|
@@ -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
|
||||||
|
1
backend/dist/cfg/configuration.json
vendored
Executable file
1
backend/dist/cfg/configuration.json
vendored
Executable file
@@ -0,0 +1 @@
|
|||||||
|
{"services":[{"name":"ArtNet Driver","description":"ArtNet Driver DMX over UDP/IP","executablePath":"../../tecamino-driver-artNet/artNet","workingDirectory":"../../tecamino-driver-artNet","arguments":["-cfg ./dist/cfg","-serverIp 127.0.0.1","-serverPort 8100","-port 8200"]}]}
|
29
backend/dist/cfg/defaultConfigurations.json
vendored
Normal file
29
backend/dist/cfg/defaultConfigurations.json
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"cfgFileName": "configuration.json",
|
||||||
|
"services":[{
|
||||||
|
"name":"ArtNet Driver",
|
||||||
|
"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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
@@ -5,27 +5,31 @@ go 1.24.0
|
|||||||
toolchain go1.24.3
|
toolchain go1.24.3
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gin-contrib/cors v1.7.5
|
gitea.tecamino.com/paadi/statusServer v1.0.3
|
||||||
github.com/gin-gonic/gin v1.10.0
|
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.6
|
||||||
|
github.com/gin-gonic/gin v1.10.1
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.2
|
github.com/golang-jwt/jwt/v5 v5.2.2
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/tecamino/tecamino-dbm v0.0.10
|
golang.org/x/crypto v0.39.0
|
||||||
github.com/tecamino/tecamino-logger v0.2.0
|
|
||||||
golang.org/x/crypto v0.36.0
|
|
||||||
modernc.org/sqlite v1.37.1
|
modernc.org/sqlite v1.37.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/bytedance/sonic v1.13.2 // indirect
|
gitea.tecamino.com/paadi/pubSub v1.0.2 // indirect
|
||||||
|
gitea.tecamino.com/paadi/tecamino-json_data v0.1.0 // indirect
|
||||||
|
github.com/bytedance/sonic v1.13.3 // indirect
|
||||||
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
||||||
github.com/cloudwego/base64x v0.1.5 // indirect
|
github.com/cloudwego/base64x v0.1.5 // 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.8 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
|
||||||
github.com/gin-contrib/sse v1.0.0 // indirect
|
github.com/gin-contrib/sse v1.1.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.26.0 // indirect
|
github.com/go-playground/validator/v10 v10.26.0 // indirect
|
||||||
github.com/goccy/go-json v0.10.5 // indirect
|
github.com/goccy/go-json v0.10.5 // indirect
|
||||||
|
github.com/gorilla/websocket v1.5.3 // 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.10 // 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
|
||||||
@@ -33,17 +37,17 @@ require (
|
|||||||
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.3 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.4 // 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.3.0 // 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.15.0 // indirect
|
golang.org/x/arch v0.18.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.38.0 // indirect
|
golang.org/x/net v0.41.0 // indirect
|
||||||
golang.org/x/sys v0.33.0 // indirect
|
golang.org/x/sys v0.33.0 // indirect
|
||||||
golang.org/x/text v0.23.0 // indirect
|
golang.org/x/text v0.26.0 // indirect
|
||||||
google.golang.org/protobuf v1.36.6 // 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
|
||||||
|
@@ -1,5 +1,15 @@
|
|||||||
github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ=
|
gitea.tecamino.com/paadi/pubSub v1.0.2 h1:9Q9KLTIHRSjxrTkDyuF8mDYOLkI8DjjPNSnoS2GKflY=
|
||||||
github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
|
gitea.tecamino.com/paadi/pubSub v1.0.2/go.mod h1:SBPTSD/JQWRbwqsSNoSPhV81IDTreP0TMyvLhmK3P2M=
|
||||||
|
gitea.tecamino.com/paadi/statusServer v1.0.3 h1:bRw+Jz9AIoiwqNLTBnrus2aUxq2Em2gA8NDANtqVHEA=
|
||||||
|
gitea.tecamino.com/paadi/statusServer v1.0.3/go.mod h1:kNO/ASrrmsLGgo+k49TLpVP6PpxG3I3D1moJ6Ke+ocg=
|
||||||
|
gitea.tecamino.com/paadi/tecamino-dbm v0.1.1 h1:vAq7mwUxlxJuLzCQSDMrZCwo8ky5usWi9Qz+UP+WnkI=
|
||||||
|
gitea.tecamino.com/paadi/tecamino-dbm v0.1.1/go.mod h1:+tmf1rjPaKEoNeUcr1vdtoFIFweNG3aUGevDAl3NMBk=
|
||||||
|
gitea.tecamino.com/paadi/tecamino-json_data v0.1.0 h1:zp3L8qUvkVqzuesQdMh/SgZZZbX3pGD9NYa6jtz+JvA=
|
||||||
|
gitea.tecamino.com/paadi/tecamino-json_data v0.1.0/go.mod h1:/FKhbVYuhiNlQp4552rJJQIhynjLarDzfrgXpupkwZU=
|
||||||
|
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.3 h1:MS8gmaH16Gtirygw7jV91pDCN33NyMrPbN7qiYhEsF0=
|
||||||
|
github.com/bytedance/sonic v1.13.3/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/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
|
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
|
||||||
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||||
@@ -11,14 +21,14 @@ 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.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok=
|
||||||
github.com/gin-contrib/cors v1.7.5 h1:cXC9SmofOrRg0w9PigwGlHG3ztswH6bqq4vJVXnvYMk=
|
github.com/gin-contrib/cors v1.7.6 h1:3gQ8GMzs1Ylpf70y8bMw4fVpycXIeX1ZemuSQIsnQQY=
|
||||||
github.com/gin-contrib/cors v1.7.5/go.mod h1:4q3yi7xBEDDWKapjT2o1V7mScKDDr8k+jZ0fSquGoy0=
|
github.com/gin-contrib/cors v1.7.6/go.mod h1:Ulcl+xN4jel9t1Ry8vqph23a60FwH9xVLd+3ykmTjOk=
|
||||||
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
|
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||||
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
|
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
||||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ=
|
||||||
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
github.com/gin-gonic/gin v1.10.1/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=
|
||||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||||
@@ -31,13 +41,15 @@ github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
|||||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
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.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
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 h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs=
|
||||||
github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
|
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/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||||
|
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
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=
|
||||||
@@ -59,8 +71,8 @@ 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.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||||
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=
|
||||||
@@ -70,46 +82,40 @@ github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6po
|
|||||||
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=
|
||||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
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.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
github.com/stretchr/testify v1.10.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.3.0 h1:Qd2W2sQawAfG8XSvzwhBeoGq71zXOC/Q1E9y/wUcsUA=
|
||||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
github.com/ugorji/go/codec v1.3.0/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
|
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.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
|
golang.org/x/arch v0.18.0 h1:WN9poc33zL4AzGxqf8VtpKUnGvMi8O9lhNyBMF/85qc=
|
||||||
golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
|
golang.org/x/arch v0.18.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
|
||||||
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
|
||||||
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
|
||||||
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/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
|
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
|
||||||
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
|
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
|
||||||
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
|
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
|
||||||
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
|
||||||
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
|
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
|
||||||
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
golang.org/x/sync v0.15.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.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.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
|
||||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
|
||||||
golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc=
|
golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc=
|
||||||
golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI=
|
golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI=
|
||||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||||
|
@@ -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,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -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
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@ import (
|
|||||||
"backend/models"
|
"backend/models"
|
||||||
secenes "backend/scenes"
|
secenes "backend/scenes"
|
||||||
"backend/server"
|
"backend/server"
|
||||||
|
"backend/services"
|
||||||
"backend/utils"
|
"backend/utils"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -15,9 +16,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gitea.tecamino.com/paadi/statusServer"
|
||||||
|
"gitea.tecamino.com/paadi/tecamino-logger/logging"
|
||||||
"github.com/gin-contrib/cors"
|
"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() {
|
||||||
@@ -27,6 +29,8 @@ func main() {
|
|||||||
flag.Var(&allowOrigins, "allowOrigin", "Allowed origin (can repeat this flag)")
|
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")
|
||||||
|
servicesCfg := flag.String("services", "defaultConfigurations.json", "services 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")
|
||||||
@@ -35,7 +39,6 @@ func main() {
|
|||||||
|
|
||||||
//change working directory only if value is given
|
//change working directory only if value is given
|
||||||
if *workingDir != "." && *workingDir != "" {
|
if *workingDir != "." && *workingDir != "" {
|
||||||
fmt.Println(1, *workingDir)
|
|
||||||
os.Chdir(*workingDir)
|
os.Chdir(*workingDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,15 +72,25 @@ func main() {
|
|||||||
//new scenes handler
|
//new scenes handler
|
||||||
scenesHandler := secenes.NewScenesHandler("")
|
scenesHandler := secenes.NewScenesHandler("")
|
||||||
|
|
||||||
|
//new scenes handler
|
||||||
|
servicesHandler := services.NewServicesHandler(*cfgDir, *servicesCfg)
|
||||||
|
|
||||||
// new server
|
// new server
|
||||||
s := server.NewServer()
|
s := server.NewServer()
|
||||||
|
|
||||||
|
// new status websocket
|
||||||
|
statusWs, err := statusServer.NewStatusWebsocket(5, 256, logger)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("main", fmt.Sprintf("initialize status websocket: %s", err.Error()))
|
||||||
|
}
|
||||||
|
|
||||||
|
servicesHandler.LinkStatusServer(statusWs)
|
||||||
//get local ip
|
//get local ip
|
||||||
allowOrigins = append(allowOrigins, "http://localhost:9000", "http://localhost:9500")
|
allowOrigins = append(allowOrigins, "http://localhost:9000", "http://localhost:9500")
|
||||||
|
|
||||||
localIP, err := utils.GetLocalIP()
|
localIP, err := utils.GetLocalIP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("main", fmt.Sprintf("get local ip : %s", err.Error()))
|
logger.Error("main", fmt.Sprintf("get local ip: %s", err.Error()))
|
||||||
} else {
|
} else {
|
||||||
allowOrigins = append(allowOrigins, fmt.Sprintf("http://%s:9000", localIP), fmt.Sprintf("http://%s:9500", localIP))
|
allowOrigins = append(allowOrigins, fmt.Sprintf("http://%s:9000", localIP), fmt.Sprintf("http://%s:9500", localIP))
|
||||||
}
|
}
|
||||||
@@ -91,20 +104,28 @@ func main() {
|
|||||||
|
|
||||||
api := s.Routes.Group("/api")
|
api := s.Routes.Group("/api")
|
||||||
//set routes
|
//set routes
|
||||||
api.GET("/loadScenes", scenesHandler.LoadScenes)
|
api.GET("/status", statusWs.NewConection)
|
||||||
|
api.GET("/scenes/all", scenesHandler.LoadScenes)
|
||||||
|
api.GET("/services/all", servicesHandler.GetAllAvaiableServices)
|
||||||
|
api.GET("/services/load", servicesHandler.LoadAllServices)
|
||||||
|
api.GET("/services/:service/start", servicesHandler.StartService)
|
||||||
|
api.GET("/services/:service/stop", servicesHandler.StopService)
|
||||||
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("/scenes/save", scenesHandler.SaveScene)
|
||||||
api.POST("/loadScene", scenesHandler.LoadScene)
|
api.POST("/scenes/load", scenesHandler.LoadScene)
|
||||||
api.DELETE("/user", loginManager.RemoveUser)
|
api.POST("/services/add", servicesHandler.AddNewService)
|
||||||
api.DELETE("/deleteScene", scenesHandler.DeleteScene)
|
|
||||||
|
api.DELETE("/user",
|
||||||
|
loginManager.RemoveUser)
|
||||||
|
api.DELETE("/scenes", scenesHandler.DeleteScene)
|
||||||
|
|
||||||
// Serve static files
|
// Serve static files
|
||||||
s.Routes.StaticFS("/assets", gin.Dir(filepath.Join(*spa, "assets"), 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
|
// Disallow fallback for /api paths
|
||||||
if strings.HasPrefix(c.Request.URL.Path, "/api") {
|
if strings.HasPrefix(c.Request.URL.Path, "/api") {
|
||||||
c.JSON(http.StatusNotFound, gin.H{"error": "API endpoint not found"})
|
c.JSON(http.StatusNotFound, models.NewJsonErrorMessageResponse("API endpoint not found"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Try to serve file from SPA directory
|
// Try to serve file from SPA directory
|
||||||
|
6
backend/models/configuration.go
Normal file
6
backend/models/configuration.go
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
type Configuration struct {
|
||||||
|
CfgFileName string `json:"cfgFileName,omitempty"`
|
||||||
|
Services []Service `json:"services,omitempty"`
|
||||||
|
}
|
20
backend/models/jsonResponse.go
Normal file
20
backend/models/jsonResponse.go
Normal 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(),
|
||||||
|
}
|
||||||
|
}
|
@@ -1,3 +0,0 @@
|
|||||||
package models
|
|
||||||
|
|
||||||
type LightBar []Value
|
|
@@ -1,3 +0,0 @@
|
|||||||
package models
|
|
||||||
|
|
||||||
type MovingHead []Value
|
|
80
backend/models/service.go
Normal file
80
backend/models/service.go
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Service struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
ExecutablePath string `json:"executablePath,omitempty"`
|
||||||
|
WorkingDirectory string `json:"workingDirectory,omitempty"`
|
||||||
|
Arguments []string `json:"arguments,omitempty"`
|
||||||
|
State string `json:"-"`
|
||||||
|
Cmd *exec.Cmd `json:"-"`
|
||||||
|
Stopping bool `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Service) Start(errFunc func(e string)) error {
|
||||||
|
s.State = "Error"
|
||||||
|
absolutePath, err := filepath.Abs(s.ExecutablePath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var arguments []string
|
||||||
|
|
||||||
|
for _, a := range s.Arguments {
|
||||||
|
arguments = append(arguments, strings.Split(a, " ")...)
|
||||||
|
}
|
||||||
|
s.Cmd = exec.Command(absolutePath, arguments...)
|
||||||
|
s.Cmd.Dir = s.WorkingDirectory
|
||||||
|
s.Cmd.Stdout = os.Stdout
|
||||||
|
s.Cmd.Stderr = os.Stderr
|
||||||
|
|
||||||
|
err = s.Cmd.Start()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
err := s.Cmd.Wait()
|
||||||
|
if err != nil {
|
||||||
|
// Process exited with error
|
||||||
|
if exitErr, ok := err.(*exec.ExitError); ok {
|
||||||
|
if !s.Stopping {
|
||||||
|
errFunc(fmt.Sprintf("Command failed with exit code %d: %v", exitErr.ExitCode(), err))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
errFunc(fmt.Sprintf("Command wait error: %v", err))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.Stopping = false
|
||||||
|
}()
|
||||||
|
|
||||||
|
s.State = "Running"
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Service) Stop() error {
|
||||||
|
s.State = "Error"
|
||||||
|
|
||||||
|
if s.Cmd == nil {
|
||||||
|
return errors.New("process nil pointer")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop (kill) the process
|
||||||
|
s.Stopping = true
|
||||||
|
err := s.Cmd.Process.Kill()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
s.State = "Stopped"
|
||||||
|
return nil
|
||||||
|
}
|
@@ -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"`
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
type Values struct {
|
type Values struct {
|
||||||
MovingHead *MovingHead `json:"movingHead"`
|
Stagelights []Value `json:"stageLights,omitempty"`
|
||||||
LightBar *LightBar `json:"lightBar"`
|
LightBar []Value `json:"lightBar,omitempty"`
|
||||||
Value any `json:"value"`
|
FloogLights []Value `json:"floodLights,omitempty"`
|
||||||
|
MovingHead []Value `json:"movingHead,omitempty"`
|
||||||
|
Value any `json:"value"`
|
||||||
}
|
}
|
||||||
|
@@ -31,45 +31,35 @@ func NewScenesHandler(dir string) *ScenesHandler {
|
|||||||
func (sh *ScenesHandler) SaveScene(c *gin.Context) {
|
func (sh *ScenesHandler) SaveScene(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
|
||||||
}
|
}
|
||||||
|
|
||||||
var scene models.Scene
|
var scene models.Scene
|
||||||
err = json.Unmarshal(body, &scene)
|
err = json.Unmarshal(body, &scene)
|
||||||
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 := os.Stat(path.Join(sh.dir)); err != nil {
|
if _, err := os.Stat(path.Join(sh.dir)); err != nil {
|
||||||
err := os.MkdirAll(sh.dir, 0755)
|
err := os.MkdirAll(sh.dir, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
"error": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.OpenFile(path.Join(sh.dir, scene.Name+".scene"), os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0644)
|
f, err := os.OpenFile(path.Join(sh.dir, scene.Name+".scene"), os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
"error": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
_, err = f.Write(body)
|
_, err = f.Write(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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,26 +71,20 @@ func (sh *ScenesHandler) SaveScene(c *gin.Context) {
|
|||||||
func (sh *ScenesHandler) DeleteScene(c *gin.Context) {
|
func (sh *ScenesHandler) DeleteScene(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
|
||||||
}
|
}
|
||||||
|
|
||||||
var scene models.Scene
|
var scene models.Scene
|
||||||
err = json.Unmarshal(body, &scene)
|
err = json.Unmarshal(body, &scene)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
"error": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = os.Remove(path.Join(sh.dir, scene.Name+".scene"))
|
err = os.Remove(path.Join(sh.dir, scene.Name+".scene"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
"error": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,26 +98,20 @@ func (sh *ScenesHandler) LoadScenes(c *gin.Context) {
|
|||||||
|
|
||||||
files, err := utils.FindAllFiles("./scenes", ".scene")
|
files, err := utils.FindAllFiles("./scenes", ".scene")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
"error": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
content, err := os.ReadFile(f)
|
content, err := os.ReadFile(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
"error": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var scene models.Scene
|
var scene models.Scene
|
||||||
err = json.Unmarshal(content, &scene)
|
err = json.Unmarshal(content, &scene)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
"error": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sceneMap[scene.Name] = scene
|
sceneMap[scene.Name] = scene
|
||||||
@@ -160,9 +138,7 @@ func (sh *ScenesHandler) LoadScenes(c *gin.Context) {
|
|||||||
func (sh *ScenesHandler) LoadScene(c *gin.Context) {
|
func (sh *ScenesHandler) LoadScene(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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,17 +146,13 @@ func (sh *ScenesHandler) LoadScene(c *gin.Context) {
|
|||||||
|
|
||||||
err = json.Unmarshal(body, &scene)
|
err = json.Unmarshal(body, &scene)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
"error": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
files, err := utils.FindAllFiles("./scenes", ".scene")
|
files, err := utils.FindAllFiles("./scenes", ".scene")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
"error": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,24 +162,18 @@ func (sh *ScenesHandler) LoadScene(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
content, err := os.ReadFile(f)
|
content, err := os.ReadFile(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
"error": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(content, &scene)
|
err = json.Unmarshal(content, &scene)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
"error": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, scene)
|
c.JSON(http.StatusOK, scene)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse(fmt.Sprintf("scene '%s' not found", scene.Name)))
|
||||||
"error": fmt.Errorf("scene '%s' not found", scene.Name),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
@@ -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
|
||||||
|
260
backend/services/services.go
Normal file
260
backend/services/services.go
Normal file
@@ -0,0 +1,260 @@
|
|||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"backend/models"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"gitea.tecamino.com/paadi/statusServer"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ServicesHandler struct {
|
||||||
|
cfgDir string
|
||||||
|
cfgFile string
|
||||||
|
config models.Configuration
|
||||||
|
statusWs *statusServer.StatusWebsocket
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewServicesHandler(cfgDir, cfgFile string) *ServicesHandler {
|
||||||
|
return &ServicesHandler{cfgDir: cfgDir, cfgFile: cfgFile}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ServicesHandler) LinkStatusServer(statusServer *statusServer.StatusWebsocket) {
|
||||||
|
s.statusWs = statusServer
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ServicesHandler) GetAllAvaiableServices(c *gin.Context) {
|
||||||
|
var services []models.Service
|
||||||
|
|
||||||
|
defaultCfg, err := s.readDefaultConfig()
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
configFile := filepath.Join(s.cfgDir, defaultCfg.CfgFileName)
|
||||||
|
if _, err := os.Stat(configFile); err != nil {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"services": defaultCfg.Services})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
content, err := os.ReadFile(configFile)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var cfg models.Configuration
|
||||||
|
err = json.Unmarshal(content, &cfg)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// check wether service was already initiated then skip
|
||||||
|
next:
|
||||||
|
for _, new := range defaultCfg.Services {
|
||||||
|
for _, old := range cfg.Services {
|
||||||
|
if new.Name == old.Name {
|
||||||
|
continue next
|
||||||
|
}
|
||||||
|
}
|
||||||
|
services = append(services, new)
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, gin.H{"services": services})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ServicesHandler) LoadAllServices(c *gin.Context) {
|
||||||
|
|
||||||
|
defaultCfg, err := s.readDefaultConfig()
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
configFile := filepath.Join(s.cfgDir, defaultCfg.CfgFileName)
|
||||||
|
if _, err := os.Stat(configFile); err != nil {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"message": "no services"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
content, err := os.ReadFile(configFile)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(content, &s.config)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(s.config.Services) == 0 {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"message": "no services"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, gin.H{"services": s.config.Services})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ServicesHandler) AddNewService(c *gin.Context) {
|
||||||
|
body, err := io.ReadAll(c.Request.Body)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var newService struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(body, &newService)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultCfg, err := s.readDefaultConfig()
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var config models.Configuration
|
||||||
|
|
||||||
|
if _, err := os.Stat(filepath.Join(s.cfgDir, defaultCfg.CfgFileName)); err == nil {
|
||||||
|
content, err := os.ReadFile(filepath.Join(s.cfgDir, defaultCfg.CfgFileName))
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = json.Unmarshal(content, &config)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, service := range defaultCfg.Services {
|
||||||
|
if service.Name == newService.Name {
|
||||||
|
config.Services = append(config.Services, service)
|
||||||
|
|
||||||
|
f, err := os.OpenFile(filepath.Join(s.cfgDir, defaultCfg.CfgFileName), os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0774)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
output, err := json.Marshal(config)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = f.Write(output)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, gin.H{"message": "service '" + newService.Name + "' added"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(errors.New("no service '"+newService.Name+"' found")))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ServicesHandler) StartService(c *gin.Context) {
|
||||||
|
service := c.Param("service")
|
||||||
|
|
||||||
|
s.statusWs.Publish("status/"+service, gin.H{
|
||||||
|
"state": "Starting",
|
||||||
|
})
|
||||||
|
|
||||||
|
for i := range s.config.Services {
|
||||||
|
if s.config.Services[i].Name == service {
|
||||||
|
if err := s.config.Services[i].Start(func(e string) {
|
||||||
|
s.statusWs.Publish("status/"+service, gin.H{"state": "Error", "message": e})
|
||||||
|
}); err != nil {
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
||||||
|
s.statusWs.Publish("status/"+service, gin.H{
|
||||||
|
"state": "Error",
|
||||||
|
"message": err.Error(),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
"message": fmt.Sprintf("service '%s' started", service),
|
||||||
|
})
|
||||||
|
s.statusWs.Publish("status/"+service, gin.H{
|
||||||
|
"state": "Started",
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse(fmt.Sprintf("no service '%s' found", service)))
|
||||||
|
s.statusWs.Publish("status/"+service, gin.H{
|
||||||
|
"state": "Error",
|
||||||
|
"message": fmt.Sprintf("no service '%s' found", service),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ServicesHandler) StopService(c *gin.Context) {
|
||||||
|
service := c.Param("service")
|
||||||
|
s.statusWs.Publish("status/"+service, gin.H{
|
||||||
|
"state": "Stopping",
|
||||||
|
})
|
||||||
|
|
||||||
|
for i := range s.config.Services {
|
||||||
|
if s.config.Services[i].Name == service {
|
||||||
|
if err := s.config.Services[i].Stop(); err != nil {
|
||||||
|
c.JSON(http.StatusBadGateway, gin.H{
|
||||||
|
"error": true,
|
||||||
|
"message": fmt.Sprintf("service '%s' error; %v", service, err),
|
||||||
|
})
|
||||||
|
|
||||||
|
s.statusWs.Publish("status/"+service, gin.H{
|
||||||
|
"state": "Error",
|
||||||
|
"message": fmt.Sprintf("service '%s' error; %v", service, err),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
"message": fmt.Sprintf("service '%s' stopped", service),
|
||||||
|
})
|
||||||
|
|
||||||
|
s.statusWs.Publish("status/"+service, gin.H{
|
||||||
|
"state": "Stopped",
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{
|
||||||
|
"error": true,
|
||||||
|
"message": fmt.Sprintf("no service '%s' found", service),
|
||||||
|
})
|
||||||
|
|
||||||
|
s.statusWs.Publish("status/"+service, gin.H{
|
||||||
|
"state": "Stopped",
|
||||||
|
"message": fmt.Sprintf("no service '%s' found", service),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ServicesHandler) readDefaultConfig() (data models.Configuration, err error) {
|
||||||
|
content, err := os.ReadFile(filepath.Join(s.cfgDir, s.cfgFile))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = json.Unmarshal(content, &data)
|
||||||
|
return
|
||||||
|
}
|
BIN
backend/user.db
BIN
backend/user.db
Binary file not shown.
@@ -8,7 +8,7 @@ import (
|
|||||||
"path/filepath"
|
"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 {
|
||||||
@@ -33,7 +33,7 @@ func OpenBrowser(url string, logger *logging.Logger) error {
|
|||||||
return fmt.Errorf("os is running i headless mode do not start browser")
|
return fmt.Errorf("os is running i headless mode do not start browser")
|
||||||
}
|
}
|
||||||
commands = [][]string{
|
commands = [][]string{
|
||||||
{"chromium-browser", "--kiosk", url},
|
{"chromium-browser", url},
|
||||||
{"google-chrome", "--kiosk", url},
|
{"google-chrome", "--kiosk", url},
|
||||||
{"firefox", "--kiosk", url},
|
{"firefox", "--kiosk", url},
|
||||||
{"xdg-open", url}, // fallback
|
{"xdg-open", url}, // fallback
|
||||||
|
1756
package-lock.json
generated
1756
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "lightcontrol",
|
"name": "lightcontrol",
|
||||||
"version": "0.0.19",
|
"version": "0.1.4",
|
||||||
"description": "A Tecamino App",
|
"description": "A Tecamino App",
|
||||||
"productName": "Light Control",
|
"productName": "Light Control",
|
||||||
"author": "A. Zuercher",
|
"author": "A. Zuercher",
|
||||||
@@ -15,9 +15,12 @@
|
|||||||
"postinstall": "quasar prepare"
|
"postinstall": "quasar prepare"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@quasar/cli": "^2.5.0",
|
||||||
"@quasar/extras": "^1.16.4",
|
"@quasar/extras": "^1.16.4",
|
||||||
"axios": "^1.10.0",
|
"axios": "^1.10.0",
|
||||||
"quasar": "^2.16.0",
|
"jwt-decode": "^4.0.0",
|
||||||
|
"pinia": "^3.0.3",
|
||||||
|
"quasar": "^2.18.2",
|
||||||
"vue": "^3.4.18",
|
"vue": "^3.4.18",
|
||||||
"vue-router": "^4.0.12"
|
"vue-router": "^4.0.12"
|
||||||
},
|
},
|
||||||
|
@@ -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'],
|
||||||
|
13
src/boot/auth.ts
Normal file
13
src/boot/auth.ts
Normal 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();
|
||||||
|
});
|
@@ -2,20 +2,29 @@ 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,
|
timeout: 30000,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const appApi = axios.create({
|
||||||
|
baseURL: `http://${host}:${portApp}/api`,
|
||||||
|
timeout: 10000,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
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 };
|
||||||
|
@@ -4,11 +4,8 @@ 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;
|
|
||||||
const port = 8100;
|
|
||||||
|
|
||||||
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();
|
||||||
|
@@ -66,18 +66,14 @@ const internalShowDialog = ref(props.showDialog);
|
|||||||
watch(
|
watch(
|
||||||
() => props.showDialog,
|
() => props.showDialog,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
console.log('watch showDialog', newValue);
|
|
||||||
internalShowDialog.value = newValue;
|
internalShowDialog.value = newValue;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
watch(internalShowDialog, (newValue) => {
|
watch(internalShowDialog, (newValue) => {
|
||||||
console.log('watch internalShowDialog', newValue);
|
|
||||||
emit('update:showDialog', newValue);
|
emit('update:showDialog', newValue);
|
||||||
if (!newValue) {
|
if (!newValue) {
|
||||||
console.log('emit cancel');
|
|
||||||
emit('cancel');
|
emit('cancel');
|
||||||
} else {
|
} else {
|
||||||
console.log('emit confirmed');
|
|
||||||
emit('confirmed');
|
emit('confirmed');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
98
src/components/lights/FloodPanel.vue
Normal file
98
src/components/lights/FloodPanel.vue
Normal 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>
|
18
src/components/lights/FloodPanels.vue
Normal file
18
src/components/lights/FloodPanels.vue
Normal 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>
|
@@ -56,10 +56,6 @@
|
|||||||
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>
|
||||||
@@ -67,16 +63,14 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import LightSlider from './LightSlider.vue';
|
import LightSlider from './LightSlider.vue';
|
||||||
import { ref, onMounted, onUnmounted } from 'vue';
|
import { onMounted, onUnmounted } from 'vue';
|
||||||
import { unsubscribe, subscribeToPath } from 'src/vueLib/services/websocket';
|
import { unsubscribe, subscribeToPath } from 'src/vueLib/services/websocket';
|
||||||
import SettingDialog from 'src/components/lights/SettingDomeLight.vue';
|
|
||||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
import { updateValue } from 'src/vueLib/dbm/dbmTree';
|
import { updateValue } from 'src/vueLib/dbm/dbmTree';
|
||||||
import { removeAllSubscriptions } from 'src/vueLib/models/Subscriptions';
|
import { removeAllSubscriptions } from 'src/vueLib/models/Subscriptions';
|
||||||
import { catchError } from 'src/vueLib/models/error';
|
import { catchError } from 'src/vueLib/models/error';
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
const settings = ref(false);
|
|
||||||
const brightness = updateValue(NotifyResponse, 'LightBar:Brightness');
|
const brightness = updateValue(NotifyResponse, 'LightBar:Brightness');
|
||||||
const state = updateValue(NotifyResponse, 'LightBar:State');
|
const state = updateValue(NotifyResponse, 'LightBar:State');
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
@@ -26,7 +26,7 @@ select
|
|||||||
:toggle-high-low="true"
|
:toggle-high-low="true"
|
||||||
dbm-path="MovingHead:Brightness"
|
dbm-path="MovingHead:Brightness"
|
||||||
dbm-path2="MovingHead:BrightnessFine"
|
dbm-path2="MovingHead:BrightnessFine"
|
||||||
dbm-path3="MovingHead:Strobe"
|
dbm-path3="MovingHead:Strobe'"
|
||||||
:dbm-value3="255"
|
:dbm-value3="255"
|
||||||
:opacity="0.5"
|
:opacity="0.5"
|
||||||
class="q-ma-md"
|
class="q-ma-md"
|
||||||
@@ -114,14 +114,13 @@ import { findSubscriptionByPath, removeAllSubscriptions } from 'src/vueLib/model
|
|||||||
import { catchError } from 'src/vueLib/models/error';
|
import { catchError } from 'src/vueLib/models/error';
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
const brightness = updateBrightnessValue('MovingHead:Brightness');
|
|
||||||
const state = updateValue(NotifyResponse, '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;
|
||||||
|
@@ -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,
|
||||||
});
|
});
|
||||||
|
117
src/components/lights/StageLight.vue
Normal file
117
src/components/lights/StageLight.vue
Normal 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>
|
18
src/components/lights/StageLights.vue
Normal file
18
src/components/lights/StageLights.vue
Normal 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>
|
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- new edit scene dialog-->
|
<!-- new edit scene dialog-->
|
||||||
<DialogFrame ref="sceneDialog" width="350px">
|
<DialogFrame ref="sceneDialog" :height="500" :width="350">
|
||||||
<q-card>
|
<q-card>
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
<div class="text-primary text-h6">{{ dialogLabel }}</div>
|
<div class="text-primary text-h6">{{ dialogLabel }}</div>
|
||||||
@@ -27,8 +27,10 @@
|
|||||||
/>
|
/>
|
||||||
<div class="q-py-md">
|
<div class="q-py-md">
|
||||||
<div class="q-gutter-sm">
|
<div class="q-gutter-sm">
|
||||||
<q-checkbox v-model="newScene.movingHead" label="Moving Head" />
|
<q-checkbox v-model="newScene.stageLights" label="Stage Lights" />
|
||||||
<q-checkbox v-model="newScene.lightBar" label="Light Bar" />
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
@@ -52,6 +54,7 @@
|
|||||||
>
|
>
|
||||||
<q-btn
|
<q-btn
|
||||||
rounded
|
rounded
|
||||||
|
no-caps
|
||||||
color="primary"
|
color="primary"
|
||||||
:class="['q-ma-md', 'text-bold', 'text-white']"
|
:class="['q-ma-md', 'text-bold', 'text-white']"
|
||||||
@click="openDialog('add')"
|
@click="openDialog('add')"
|
||||||
@@ -102,6 +105,7 @@
|
|||||||
<div>No scenes available</div>
|
<div>No scenes available</div>
|
||||||
<q-btn
|
<q-btn
|
||||||
rounded
|
rounded
|
||||||
|
no-caps
|
||||||
color="primary"
|
color="primary"
|
||||||
:class="['q-ma-md', 'text-bold', 'text-white']"
|
:class="['q-ma-md', 'text-bold', 'text-white']"
|
||||||
@click="openDialog('add')"
|
@click="openDialog('add')"
|
||||||
@@ -114,13 +118,13 @@
|
|||||||
import { onMounted, reactive, ref } from 'vue';
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
import type { Scene } from 'src/models/Scene';
|
import type { Scene } from 'src/models/Scene';
|
||||||
import type { Set } from 'src/vueLib/models/Set';
|
import type { Set } from 'src/vueLib/models/Set';
|
||||||
import axios from 'axios';
|
import { dbmApi } from 'src/boot/axios';
|
||||||
import { api } from 'src/boot/axios';
|
|
||||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
import Dialog from 'src/components/dialog/OkDialog.vue';
|
import Dialog from 'src/components/dialog/OkDialog.vue';
|
||||||
import { setValues } from 'src/vueLib/services/websocket';
|
import { setValues } from 'src/vueLib/services/websocket';
|
||||||
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
||||||
import { catchError } from 'src/vueLib/models/error';
|
import { catchError } from 'src/vueLib/models/error';
|
||||||
|
import { appApi } from 'src/boot/axios';
|
||||||
|
|
||||||
const { NotifyResponse, NotifyDialog } = useNotify();
|
const { NotifyResponse, NotifyDialog } = useNotify();
|
||||||
const sceneDialog = ref();
|
const sceneDialog = ref();
|
||||||
@@ -130,26 +134,17 @@ const editIndex = ref(-1);
|
|||||||
const dialogLabel = ref('');
|
const dialogLabel = ref('');
|
||||||
const newScene = reactive<Scene>({
|
const newScene = reactive<Scene>({
|
||||||
name: '',
|
name: '',
|
||||||
movingHead: false,
|
stageLights: false,
|
||||||
lightBar: false,
|
lightBar: false,
|
||||||
|
floodPanels: false,
|
||||||
|
movingHead: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const scenes = ref<Scene[]>([]);
|
const scenes = ref<Scene[]>([]);
|
||||||
const host = window.location.hostname;
|
|
||||||
const port = 9500;
|
|
||||||
const baseURL = `http://${host}:${port}`;
|
|
||||||
|
|
||||||
const quasarApi = axios.create({
|
|
||||||
baseURL: baseURL,
|
|
||||||
timeout: 10000,
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
quasarApi
|
appApi
|
||||||
.get('/api/loadScenes')
|
.get('/scenes/all')
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (resp.data) {
|
if (resp.data) {
|
||||||
scenes.value = resp.data;
|
scenes.value = resp.data;
|
||||||
@@ -166,9 +161,8 @@ function removeScene(name: string) {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res) {
|
if (res) {
|
||||||
scenes.value = scenes.value.filter((s) => s.name !== name);
|
scenes.value = scenes.value.filter((s) => s.name !== name);
|
||||||
|
appApi
|
||||||
quasarApi
|
.delete('/scenes', {
|
||||||
.delete('/api/deleteScene', {
|
|
||||||
data: { name },
|
data: { name },
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@@ -190,8 +184,11 @@ function openDialog(dialogType: string, scene?: Scene, index?: number) {
|
|||||||
dialog.value = 'add';
|
dialog.value = 'add';
|
||||||
dialogLabel.value = 'Add Scene';
|
dialogLabel.value = 'Add Scene';
|
||||||
newScene.name = '';
|
newScene.name = '';
|
||||||
newScene.movingHead = true;
|
newScene.stageLights = true;
|
||||||
newScene.lightBar = true;
|
newScene.lightBar = true;
|
||||||
|
newScene.floodPanels = true;
|
||||||
|
newScene.movingHead = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'edit':
|
case 'edit':
|
||||||
if (!scene) return;
|
if (!scene) return;
|
||||||
@@ -205,8 +202,8 @@ function openDialog(dialogType: string, scene?: Scene, index?: number) {
|
|||||||
if (!scene) return;
|
if (!scene) return;
|
||||||
dialog.value = 'load';
|
dialog.value = 'load';
|
||||||
dialogLabel.value = 'Load Scene';
|
dialogLabel.value = 'Load Scene';
|
||||||
quasarApi
|
appApi
|
||||||
.post('/api/loadScene', scene)
|
.post('/scenes/load', scene)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
Object.assign(newScene, JSON.parse(JSON.stringify(res.data)));
|
Object.assign(newScene, JSON.parse(JSON.stringify(res.data)));
|
||||||
@@ -236,9 +233,9 @@ const saveScene = async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newScene.movingHead) {
|
if (newScene.stageLights) {
|
||||||
sendValues.push({
|
sendValues.push({
|
||||||
path: 'MovingHead',
|
path: 'StageLights',
|
||||||
query: { depth: 0 },
|
query: { depth: 0 },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -250,9 +247,23 @@ const saveScene = async () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newScene.floodPanels) {
|
||||||
|
sendValues.push({
|
||||||
|
path: 'FloodPanels',
|
||||||
|
query: { depth: 0 },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newScene.movingHead) {
|
||||||
|
sendValues.push({
|
||||||
|
path: 'MovingHead',
|
||||||
|
query: { depth: 0 },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (sendValues.length > 0) {
|
if (sendValues.length > 0) {
|
||||||
try {
|
try {
|
||||||
const res = await api.post('/json_data', { get: sendValues });
|
const res = await dbmApi.post('/json_data', { get: sendValues });
|
||||||
newScene.values = res.data.get;
|
newScene.values = res.data.get;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
NotifyResponse(err as Error, 'error');
|
NotifyResponse(err as Error, 'error');
|
||||||
@@ -266,8 +277,8 @@ const saveScene = async () => {
|
|||||||
// Sort alphabetically by scene name
|
// Sort alphabetically by scene name
|
||||||
scenes.value.sort((a, b) => a.name.localeCompare(b.name));
|
scenes.value.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
|
|
||||||
quasarApi
|
appApi
|
||||||
.post('/api/saveScene', JSON.stringify(newScene))
|
.post('/scenes/save', JSON.stringify(newScene))
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
NotifyResponse(res.data);
|
NotifyResponse(res.data);
|
||||||
@@ -285,9 +296,9 @@ const saveScene = async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newScene.movingHead) {
|
if (newScene.stageLights) {
|
||||||
sendValues.push({
|
sendValues.push({
|
||||||
path: 'MovingHead',
|
path: 'StageLights',
|
||||||
query: { depth: 0 },
|
query: { depth: 0 },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -299,9 +310,23 @@ const saveScene = async () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newScene.floodPanels) {
|
||||||
|
sendValues.push({
|
||||||
|
path: 'FloodPanels',
|
||||||
|
query: { depth: 0 },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newScene.movingHead) {
|
||||||
|
sendValues.push({
|
||||||
|
path: 'MovingHead',
|
||||||
|
query: { depth: 0 },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (sendValues.length > 0) {
|
if (sendValues.length > 0) {
|
||||||
try {
|
try {
|
||||||
const res = await api.post('/json_data', { get: sendValues });
|
const res = await dbmApi.post('/json_data', { get: sendValues });
|
||||||
newScene.values = res.data.get;
|
newScene.values = res.data.get;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
NotifyResponse(err as Error, 'error');
|
NotifyResponse(err as Error, 'error');
|
||||||
@@ -313,8 +338,8 @@ const saveScene = async () => {
|
|||||||
scenes.value.sort((a, b) => a.name.localeCompare(b.name));
|
scenes.value.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
scenes.value = [...scenes.value];
|
scenes.value = [...scenes.value];
|
||||||
|
|
||||||
quasarApi
|
appApi
|
||||||
.post('/api/saveScene', JSON.stringify(newScene))
|
.post('/scene/save', JSON.stringify(newScene))
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
NotifyResponse(res.data);
|
NotifyResponse(res.data);
|
||||||
@@ -333,11 +358,17 @@ const saveScene = async () => {
|
|||||||
newScene.values?.forEach((element) => {
|
newScene.values?.forEach((element) => {
|
||||||
if (!element.path) return;
|
if (!element.path) return;
|
||||||
|
|
||||||
if (newScene.movingHead && element.path.includes('MovingHead'))
|
if (newScene.stageLights && element.path.includes('StageLights'))
|
||||||
setPaths.push({ uuid: element.uuid, path: element.path, value: element.value });
|
setPaths.push({ uuid: element.uuid, path: element.path, value: element.value });
|
||||||
|
|
||||||
if (newScene.lightBar && element.path.includes('LightBar'))
|
if (newScene.lightBar && element.path.includes('LightBar'))
|
||||||
setPaths.push({ uuid: element.uuid, path: element.path, value: element.value });
|
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)
|
setValues(setPaths)
|
||||||
|
@@ -10,10 +10,11 @@
|
|||||||
/>
|
/>
|
||||||
<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" />
|
<q-btn dense icon="refresh" square class="q-px-md q-ml-md" @click="refresh" />
|
||||||
|
<LoginMenu />
|
||||||
</q-toolbar>
|
</q-toolbar>
|
||||||
</q-header>
|
</q-header>
|
||||||
|
|
||||||
@@ -25,9 +26,12 @@
|
|||||||
<q-item to="/scenes" clickable v-ripple @click="closeDrawer">
|
<q-item to="/scenes" clickable v-ripple @click="closeDrawer">
|
||||||
<q-item-section>Scenes</q-item-section>
|
<q-item-section>Scenes</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item to="/data" clickable v-ripple @click="closeDrawer">
|
<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>
|
||||||
@@ -38,10 +42,14 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import logo from 'src/assets/LOGO_CF-ICON_color.svg';
|
import logo from 'src/assets/LOGO_CF-ICON_color.svg';
|
||||||
import { ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { version } from '../..//package.json';
|
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;
|
||||||
|
@@ -14,5 +14,4 @@ export type Settings = {
|
|||||||
show: boolean;
|
show: boolean;
|
||||||
reversePan: boolean;
|
reversePan: boolean;
|
||||||
reverseTilt: boolean;
|
reverseTilt: boolean;
|
||||||
startAddress: number;
|
|
||||||
};
|
};
|
||||||
|
@@ -3,7 +3,9 @@ import type { Value } from '../vueLib/models/Value';
|
|||||||
export interface Scene {
|
export interface Scene {
|
||||||
name: string;
|
name: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
movingHead: boolean;
|
stageLights: boolean;
|
||||||
lightBar: boolean;
|
lightBar: boolean;
|
||||||
|
floodPanels: boolean;
|
||||||
|
movingHead: boolean;
|
||||||
values?: Value[];
|
values?: Value[];
|
||||||
}
|
}
|
||||||
|
@@ -5,15 +5,15 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import DBMTree from 'src/vueLib/dbm/DBMTree.vue';
|
import DBMTree from 'src/vueLib/dbm/DBMTree.vue';
|
||||||
import { api } from 'src/boot/axios';
|
import { dbmApi } from 'src/boot/axios';
|
||||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
import { catchError } from 'src/vueLib/models/error';
|
import { catchError } from 'src/vueLib/models/error';
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
|
|
||||||
function saveDBM() {
|
function saveDBM() {
|
||||||
api
|
dbmApi
|
||||||
.get('saveData')
|
.get('data/save')
|
||||||
.then((resp) => NotifyResponse(resp.data))
|
.then((resp) => NotifyResponse(resp.data))
|
||||||
.catch((err) => NotifyResponse(catchError(err), 'error'));
|
.catch((err) => NotifyResponse(catchError(err), 'error'));
|
||||||
}
|
}
|
||||||
|
@@ -1,16 +1,20 @@
|
|||||||
<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="movingHead" label="Moving Head" />
|
||||||
<q-tab name="lightBar" label="Light Bar" />
|
<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">
|
|
||||||
<moving-head />
|
|
||||||
</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 +22,7 @@
|
|||||||
<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 { 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';
|
||||||
|
157
src/pages/ServicesPage.vue
Normal file
157
src/pages/ServicesPage.vue
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<q-card>
|
||||||
|
<q-card-section>
|
||||||
|
<div class="text-bold text-primary">Services</div>
|
||||||
|
</q-card-section>
|
||||||
|
<div class="row justify-center">
|
||||||
|
<q-card-section class="col-8">
|
||||||
|
<div class="q-py-md text-grey text-left">
|
||||||
|
<div v-if="driverRows?.length == 0">No services available</div>
|
||||||
|
<q-btn
|
||||||
|
no-caps
|
||||||
|
rounded
|
||||||
|
color="primary"
|
||||||
|
:style="'font-size: 12px;'"
|
||||||
|
:class="[, 'text-bold', 'text-white']"
|
||||||
|
:disable="userStore.user?.role !== 'admin'"
|
||||||
|
@click="addNewDriver"
|
||||||
|
>
|
||||||
|
Add {{ driverRows?.length == 0 ? 'First' : '' }} Service
|
||||||
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
<q-table v-if="driverRows?.length > 0" :rows="driverRows" :columns="columns">
|
||||||
|
<template v-slot:body-cell-settings="props">
|
||||||
|
<q-td :props="props">
|
||||||
|
<q-btn
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
size="md"
|
||||||
|
icon="more_vert"
|
||||||
|
@click="openSubMenu($event, props.row)"
|
||||||
|
></q-btn>
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
|
<template v-slot:body-cell-state="props">
|
||||||
|
<q-td :props="props">
|
||||||
|
<q-badge
|
||||||
|
:color="props.row.stateColor"
|
||||||
|
:text-color="props.row.stateTextColor"
|
||||||
|
:label="props.row.state"
|
||||||
|
/>
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
|
</q-table>
|
||||||
|
</q-card-section>
|
||||||
|
</div>
|
||||||
|
<sub-menu ref="subMenuRef" />
|
||||||
|
</q-card>
|
||||||
|
|
||||||
|
<service-dialog ref="refServiceDialog"></service-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted, reactive, ref, toRef } from 'vue';
|
||||||
|
import { useQuasar, type QTableProps } from 'quasar';
|
||||||
|
import { useUserStore } from 'src/vueLib/login/userStore';
|
||||||
|
import ServiceDialog from 'src/vueLib/services/dialog/ServiceDialog.vue';
|
||||||
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
|
import type { Service, Services, State } from 'src/vueLib/models/Services';
|
||||||
|
import { useServices } from 'src/vueLib/models/Services';
|
||||||
|
import SubMenu from 'src/vueLib/services/dialog/SubMenu.vue';
|
||||||
|
import { useStatusServer } from 'src/vueLib/services/statusServer/useStatusServer';
|
||||||
|
|
||||||
|
const { NotifyResponse } = useNotify();
|
||||||
|
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const refServiceDialog = ref();
|
||||||
|
const { initServices } = useServices();
|
||||||
|
const driverRows = reactive<Services>([]);
|
||||||
|
const { connect, subscribe } = useStatusServer(
|
||||||
|
'127.0.0.1',
|
||||||
|
9500,
|
||||||
|
'api/status',
|
||||||
|
'quasar',
|
||||||
|
(response) => {
|
||||||
|
// normalize topic to service name
|
||||||
|
const serviceName = response.topic.replace('status/', '').replace(' ', '');
|
||||||
|
const driver = driverRows.find((d) => d.name.replace(' ', '') === serviceName);
|
||||||
|
|
||||||
|
if (driver && response.data?.state !== undefined) {
|
||||||
|
// update state reactively
|
||||||
|
driver.state = response.data?.state as State;
|
||||||
|
|
||||||
|
// update colors depending on state
|
||||||
|
switch (driver.state) {
|
||||||
|
case 'Running':
|
||||||
|
driver.stateColor = 'green';
|
||||||
|
driver.stateTextColor = 'white';
|
||||||
|
break;
|
||||||
|
case 'Starting':
|
||||||
|
driver.stateColor = 'orange';
|
||||||
|
driver.stateTextColor = 'black';
|
||||||
|
break;
|
||||||
|
case 'Stopping':
|
||||||
|
driver.stateColor = 'orange';
|
||||||
|
driver.stateTextColor = 'black';
|
||||||
|
break;
|
||||||
|
case 'Error':
|
||||||
|
driver.stateColor = 'red';
|
||||||
|
driver.stateTextColor = 'white';
|
||||||
|
NotifyResponse(response.data?.message, 'error');
|
||||||
|
break;
|
||||||
|
case 'Stopped':
|
||||||
|
default:
|
||||||
|
driver.stateColor = 'grey-4';
|
||||||
|
driver.stateTextColor = 'black';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
useQuasar(),
|
||||||
|
);
|
||||||
|
|
||||||
|
const subMenuRef = ref();
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{ name: 'name', label: 'Name', field: 'name', align: 'left', style: 'font-size:12px;' },
|
||||||
|
{
|
||||||
|
name: 'description',
|
||||||
|
label: 'Description',
|
||||||
|
field: 'description',
|
||||||
|
align: 'center',
|
||||||
|
style: 'font-size:12px;',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'settings',
|
||||||
|
label: '',
|
||||||
|
field: 'settings',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'state',
|
||||||
|
label: 'State',
|
||||||
|
field: 'state',
|
||||||
|
align: 'left',
|
||||||
|
},
|
||||||
|
] as QTableProps['columns'];
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
initServices()
|
||||||
|
.then((resp) => {
|
||||||
|
driverRows.push(...resp);
|
||||||
|
})
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
connect();
|
||||||
|
subscribe('*').catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
});
|
||||||
|
|
||||||
|
function addNewDriver() {
|
||||||
|
refServiceDialog.value.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
function openSubMenu(event: Event, service: Service) {
|
||||||
|
subMenuRef.value?.open(event, toRef(driverRows.find((d) => d.name === service.name)!));
|
||||||
|
}
|
||||||
|
</script>
|
@@ -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;
|
||||||
});
|
});
|
||||||
|
@@ -6,8 +6,16 @@ const routes: RouteRecordRaw[] = [
|
|||||||
component: () => import('layouts/MainLayout.vue'),
|
component: () => import('layouts/MainLayout.vue'),
|
||||||
children: [
|
children: [
|
||||||
{ path: '', component: () => import('pages/MainPage.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: '/scenes', component: () => import('components/scenes/ScenesPage.vue') },
|
||||||
|
{
|
||||||
|
path: '/services',
|
||||||
|
component: () => import('pages/ServicesPage.vue'),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
<div
|
<div
|
||||||
:class="[
|
:class="[
|
||||||
'text-left',
|
'text-left',
|
||||||
!props.row.path.includes('System') && props.row.path !== 'DBM'
|
props.row.path?.split(':')[0] !== 'System' && props.row.path !== 'DBM'
|
||||||
? 'cursor-pointer'
|
? 'cursor-pointer'
|
||||||
: '',
|
: '',
|
||||||
'q-mx-sm',
|
'q-mx-sm',
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<div
|
<div
|
||||||
:class="[
|
:class="[
|
||||||
'text-center',
|
'text-center',
|
||||||
!props.row.path.includes('System') && props.row.path !== 'DBM'
|
props.row.path?.split(':')[0] !== 'System' && props.row.path !== 'DBM'
|
||||||
? 'cursor-pointer'
|
? 'cursor-pointer'
|
||||||
: '',
|
: '',
|
||||||
'q-mx-sm',
|
'q-mx-sm',
|
||||||
@@ -43,24 +43,33 @@
|
|||||||
</q-td>
|
</q-td>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:body-cell-value="props">
|
<template v-slot:body-cell-value="props">
|
||||||
<q-td :props="props" @click="openDialog(props.row)">
|
<q-td :props="props" @click="openDialog(props.row, 'value')">
|
||||||
<div :class="['text-center', 'cursor-pointer', 'q-mx-sm']">
|
<div :class="['text-center', 'cursor-pointer', 'q-mx-sm']">
|
||||||
{{ props.row.value }}
|
{{ props.row.value }}
|
||||||
</div>
|
</div>
|
||||||
</q-td>
|
</q-td>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:body-cell-drivers="props">
|
<template v-slot:body-cell-drivers="props">
|
||||||
<q-td :props="props" @click="openDialog(props.row, 'driver')">
|
<q-td :props="props" @click="openDialog(props.row, 'drivers')">
|
||||||
<div v-if="props.row.type !== 'none'" :class="['cursor-pointer']">
|
<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'" />
|
<q-icon size="sm" name="cell_tower" :color="props.row.drivers ? 'blue-5' : 'grey-4'" />
|
||||||
</div>
|
</div>
|
||||||
</q-td>
|
</q-td>
|
||||||
</template>
|
</template>
|
||||||
</q-table>
|
</q-table>
|
||||||
<RenameDialog width="400px" button-ok-label="Rename" ref="renameDialog" />
|
<RenameDialog
|
||||||
<UpdateDialog width="400px" button-ok-label="Write" ref="updateDialog" />
|
dialogLabel="Rename Datapoint"
|
||||||
|
:width="400"
|
||||||
|
button-ok-label="Rename"
|
||||||
|
ref="renameDialog"
|
||||||
|
/>
|
||||||
|
<UpdateDialog :width="400" button-ok-label="Write" ref="updateDialog" />
|
||||||
|
<UpdateDriver :width="400" ref="updateDriverDialog" />
|
||||||
<UpdateDatatype
|
<UpdateDatatype
|
||||||
width="400px"
|
:width="400"
|
||||||
button-ok-label="Update"
|
button-ok-label="Update"
|
||||||
ref="updateDatatype"
|
ref="updateDatatype"
|
||||||
dialog-label="Update Datatype"
|
dialog-label="Update Datatype"
|
||||||
@@ -72,6 +81,7 @@
|
|||||||
import UpdateDialog from './dialog/UpdateValueDialog.vue';
|
import UpdateDialog from './dialog/UpdateValueDialog.vue';
|
||||||
import RenameDialog from './dialog/RenameDatapoint.vue';
|
import RenameDialog from './dialog/RenameDatapoint.vue';
|
||||||
import UpdateDatatype from './dialog/UpdateDatatype.vue';
|
import UpdateDatatype from './dialog/UpdateDatatype.vue';
|
||||||
|
import UpdateDriver from './dialog/UpdateDriverDialog.vue';
|
||||||
import type { QTableProps } from 'quasar';
|
import type { QTableProps } from 'quasar';
|
||||||
import type { Subscribe } from '../models/Subscribe';
|
import type { Subscribe } from '../models/Subscribe';
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
@@ -80,10 +90,11 @@ import { convertFromType } from './Datapoint';
|
|||||||
|
|
||||||
const renameDialog = ref();
|
const renameDialog = ref();
|
||||||
const updateDialog = ref();
|
const updateDialog = ref();
|
||||||
|
const updateDriverDialog = ref();
|
||||||
const updateDatatype = ref();
|
const updateDatatype = ref();
|
||||||
|
|
||||||
const openDialog = (sub: Subscribe, type?: string) => {
|
const openDialog = (sub: Subscribe, type?: string) => {
|
||||||
if (sub.path?.includes('System') || sub.path === 'DBM') return;
|
if (sub.path?.split(':')[0] === 'System' && sub.path !== 'DBM') return;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'type':
|
case 'type':
|
||||||
updateDatatype.value.open(sub.uuid);
|
updateDatatype.value.open(sub.uuid);
|
||||||
@@ -91,10 +102,14 @@ const openDialog = (sub: Subscribe, type?: string) => {
|
|||||||
case 'rename':
|
case 'rename':
|
||||||
renameDialog.value.open(sub.uuid);
|
renameDialog.value.open(sub.uuid);
|
||||||
break;
|
break;
|
||||||
default:
|
case 'value':
|
||||||
if (sub.type === 'none') return;
|
if (sub.type === 'NONE') return;
|
||||||
updateDialog.value?.open(ref(sub), type);
|
updateDialog.value?.open(ref(sub), type);
|
||||||
break;
|
break;
|
||||||
|
case 'drivers':
|
||||||
|
if (sub.path === 'DBM' || sub.type === 'NONE') return;
|
||||||
|
updateDriverDialog.value?.open(sub);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -101,13 +101,13 @@
|
|||||||
</q-item>
|
</q-item>
|
||||||
</q-list>
|
</q-list>
|
||||||
</q-menu>
|
</q-menu>
|
||||||
<RenameDatapoint :dialogLabel="label" width="700px" button-ok-label="Rename" ref="renameDialog" />
|
<RenameDatapoint :dialogLabel="label" :width="700" button-ok-label="Rename" ref="renameDialog" />
|
||||||
<AddDialog :dialogLabel="label" width="700px" button-ok-label="Add" ref="addDialog" />
|
<AddDialog :dialogLabel="label" :width="750" button-ok-label="Add" ref="addDialog" />
|
||||||
<RemoveDialog :dialogLabel="label" width="350px" button-ok-label="Remove" ref="removeDialog" />
|
<RemoveDialog :dialogLabel="label" :width="350" button-ok-label="Remove" ref="removeDialog" />
|
||||||
<CopyDialog :dialogLabel="label" width="300px" button-ok-label="Copy" ref="copyDialog" />
|
<CopyDialog :dialogLabel="label" :width="300" button-ok-label="Copy" ref="copyDialog" />
|
||||||
<UpdateDatapoint
|
<UpdateDatapoint
|
||||||
:dialogLabel="label"
|
:dialogLabel="label"
|
||||||
width="300px"
|
:width="300"
|
||||||
button-ok-label="Update"
|
button-ok-label="Update"
|
||||||
ref="datatypeDialog"
|
ref="datatypeDialog"
|
||||||
/>
|
/>
|
||||||
|
@@ -1,5 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<DialogFrame ref="Dialog" :width="props.width" :header-title="props.dialogLabel">
|
<DialogFrame
|
||||||
|
ref="Dialog"
|
||||||
|
:width="props.width"
|
||||||
|
:height="props.height"
|
||||||
|
:header-title="props.dialogLabel"
|
||||||
|
>
|
||||||
<q-card-section
|
<q-card-section
|
||||||
v-if="props.dialogLabel"
|
v-if="props.dialogLabel"
|
||||||
class="text-bold text-left q-mb-none q-pb-none"
|
class="text-bold text-left q-mb-none q-pb-none"
|
||||||
@@ -10,7 +15,7 @@
|
|||||||
<q-input
|
<q-input
|
||||||
class="q-mt-lg q-mb-none q-pl-lg q-pr-xl"
|
class="q-mt-lg q-mb-none q-pl-lg q-pr-xl"
|
||||||
filled
|
filled
|
||||||
v-model="path"
|
v-model="addingForm.path"
|
||||||
label=""
|
label=""
|
||||||
:rules="[(val) => !!val || 'Path is required']"
|
:rules="[(val) => !!val || 'Path is required']"
|
||||||
>
|
>
|
||||||
@@ -18,7 +23,7 @@
|
|||||||
<div class="column">
|
<div class="column">
|
||||||
<span class="text-caption text-primary non-editable-prefix">Path *</span>
|
<span class="text-caption text-primary non-editable-prefix">Path *</span>
|
||||||
<span class="text-body2 text-grey-6 non-editable-prefix"
|
<span class="text-body2 text-grey-6 non-editable-prefix"
|
||||||
>{{ prefix }}{{ staticPrefix }}</span
|
>{{ addingForm.prefix }}{{ addingForm.staticPrefix }}</span
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -26,8 +31,8 @@
|
|||||||
<DataTypes class="q-mt-lg q-pl-md q-pr-xl" flat v-model:datatype="datatype"></DataTypes>
|
<DataTypes class="q-mt-lg q-pl-md q-pr-xl" flat v-model:datatype="datatype"></DataTypes>
|
||||||
<div class="q-pl-lg">
|
<div class="q-pl-lg">
|
||||||
<div class="text-grey text-bold">Read Write Access</div>
|
<div class="text-grey text-bold">Read Write Access</div>
|
||||||
<q-checkbox v-model="read">Read</q-checkbox>
|
<q-checkbox v-model="addingForm.read">Read</q-checkbox>
|
||||||
<q-checkbox v-model="write">Write</q-checkbox>
|
<q-checkbox v-model="addingForm.write">Write</q-checkbox>
|
||||||
</div>
|
</div>
|
||||||
<q-input
|
<q-input
|
||||||
:type="valueType"
|
:type="valueType"
|
||||||
@@ -35,17 +40,19 @@
|
|||||||
label="Value"
|
label="Value"
|
||||||
class="q-pl-md q-pr-xl"
|
class="q-pl-md q-pr-xl"
|
||||||
filled
|
filled
|
||||||
v-model="value"
|
v-model="addingForm.value"
|
||||||
></q-input>
|
></q-input>
|
||||||
<q-btn no-caps class="q-mb-xl q-mx-xl q-px-lg" @click="onSubmit" color="primary">{{
|
<div class="row justify-end">
|
||||||
props.buttonOkLabel
|
<q-btn no-caps class="q-mb-xl q-mx-xl q-px-lg" @click="onSubmit" color="primary">{{
|
||||||
}}</q-btn>
|
props.buttonOkLabel
|
||||||
|
}}</q-btn>
|
||||||
|
</div>
|
||||||
</q-form>
|
</q-form>
|
||||||
</DialogFrame>
|
</DialogFrame>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from 'vue';
|
import { reactive, ref, watch } from 'vue';
|
||||||
import DialogFrame from '../../dialog/DialogFrame.vue';
|
import DialogFrame from '../../dialog/DialogFrame.vue';
|
||||||
import { useNotify } from '../../general/useNotify';
|
import { useNotify } from '../../general/useNotify';
|
||||||
import DataTypes from '../../buttons/DataTypes.vue';
|
import DataTypes from '../../buttons/DataTypes.vue';
|
||||||
@@ -56,16 +63,21 @@ import { convertToType } from '../Datapoint';
|
|||||||
import { catchError } from 'src/vueLib/models/error';
|
import { catchError } from 'src/vueLib/models/error';
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
|
|
||||||
|
const addingForm = reactive({
|
||||||
|
path: '',
|
||||||
|
value: '',
|
||||||
|
staticPrefix: '',
|
||||||
|
read: true,
|
||||||
|
write: true,
|
||||||
|
prefix: 'DBM:',
|
||||||
|
});
|
||||||
const Dialog = ref();
|
const Dialog = ref();
|
||||||
const path = ref('');
|
|
||||||
const staticPrefix = ref('');
|
|
||||||
const value = ref('');
|
|
||||||
const valueType = ref<'text' | 'number'>('text');
|
const valueType = ref<'text' | 'number'>('text');
|
||||||
const read = ref(true);
|
|
||||||
const write = ref(true);
|
|
||||||
const datatype = ref('None');
|
const datatype = ref('None');
|
||||||
const addForm = ref();
|
const addForm = ref();
|
||||||
const prefix = 'DBM:';
|
|
||||||
|
|
||||||
const open = (uuid: string) => {
|
const open = (uuid: string) => {
|
||||||
Dialog.value?.open();
|
Dialog.value?.open();
|
||||||
@@ -84,15 +96,15 @@ function onSubmit() {
|
|||||||
if (success) {
|
if (success) {
|
||||||
type = convertToType(datatype.value);
|
type = convertToType(datatype.value);
|
||||||
|
|
||||||
if (read.value) access = 'R';
|
if (addingForm.read) access = 'R';
|
||||||
if (write.value) access += 'W';
|
if (addingForm.write) access += 'W';
|
||||||
if (access == '') access = 'R';
|
if (access == '') access = 'R';
|
||||||
|
|
||||||
setRequest(staticPrefix.value + path.value, type, value.value, access)
|
setRequest(addingForm.staticPrefix + addingForm.path, type, addingForm.value, access)
|
||||||
.then((respond) => {
|
.then((respond) => {
|
||||||
if (respond) {
|
if (respond) {
|
||||||
respond.forEach((set) => {
|
respond.forEach((set) => {
|
||||||
NotifyResponse("Datapoint '" + prefix + set.path + "' added");
|
NotifyResponse("Datapoint '" + addingForm.prefix + set.path + "' added");
|
||||||
});
|
});
|
||||||
addRawSubscription(respond[0]);
|
addRawSubscription(respond[0]);
|
||||||
UpdateTable();
|
UpdateTable();
|
||||||
@@ -102,7 +114,7 @@ function onSubmit() {
|
|||||||
NotifyResponse(catchError(err), 'error');
|
NotifyResponse(catchError(err), 'error');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (path.value === '') {
|
if (addingForm.path === '') {
|
||||||
NotifyResponse("Field 'Path' is requierd", 'error');
|
NotifyResponse("Field 'Path' is requierd", 'error');
|
||||||
return;
|
return;
|
||||||
} else NotifyResponse('Form not validated', 'error');
|
} else NotifyResponse('Form not validated', 'error');
|
||||||
@@ -124,8 +136,12 @@ const props = defineProps({
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
width: {
|
width: {
|
||||||
type: String,
|
type: Number,
|
||||||
default: '300px',
|
default: 300,
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
type: Number,
|
||||||
|
default: 650,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -133,8 +149,8 @@ function getDatapoint(uuid: string) {
|
|||||||
getRequest(uuid, '', 1)
|
getRequest(uuid, '', 1)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (resp[0]) {
|
if (resp[0]) {
|
||||||
staticPrefix.value = resp[0].path ?? '';
|
addingForm.staticPrefix = resp[0].path ?? '';
|
||||||
if (staticPrefix.value !== '') staticPrefix.value += ':';
|
if (addingForm.staticPrefix !== '') addingForm.staticPrefix += ':';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => NotifyResponse(catchError(err), 'error'));
|
.catch((err) => NotifyResponse(catchError(err), 'error'));
|
||||||
|
@@ -1,5 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<DialogFrame ref="Dialog" :width="props.width" :header-title="props.dialogLabel">
|
<DialogFrame
|
||||||
|
ref="Dialog"
|
||||||
|
:width="props.width"
|
||||||
|
:height="props.height"
|
||||||
|
:header-title="props.dialogLabel"
|
||||||
|
>
|
||||||
<q-card-section
|
<q-card-section
|
||||||
v-if="props.dialogLabel"
|
v-if="props.dialogLabel"
|
||||||
class="text-bold text-left q-mb-none q-pb-none"
|
class="text-bold text-left q-mb-none q-pb-none"
|
||||||
@@ -10,7 +15,7 @@
|
|||||||
<q-input
|
<q-input
|
||||||
class="q-mt-lg q-mb-none q-pl-md q-mx-lg"
|
class="q-mt-lg q-mb-none q-pl-md q-mx-lg"
|
||||||
filled
|
filled
|
||||||
v-model="path"
|
v-model="copyData.path"
|
||||||
label="Current Path"
|
label="Current Path"
|
||||||
label-color="primary"
|
label-color="primary"
|
||||||
readonly
|
readonly
|
||||||
@@ -19,7 +24,7 @@
|
|||||||
<q-input
|
<q-input
|
||||||
class="q-mt-lg q-mt-none q-pl-md q-mx-lg"
|
class="q-mt-lg q-mt-none q-pl-md q-mx-lg"
|
||||||
filled
|
filled
|
||||||
v-model="copyPath"
|
v-model="copyData.copyPath"
|
||||||
label="New Path *"
|
label="New Path *"
|
||||||
label-color="primary"
|
label-color="primary"
|
||||||
@keyup.enter="onSubmit"
|
@keyup.enter="onSubmit"
|
||||||
@@ -27,16 +32,18 @@
|
|||||||
>
|
>
|
||||||
</q-input>
|
</q-input>
|
||||||
<div class="q-mx-sm">
|
<div class="q-mx-sm">
|
||||||
<q-btn no-caps class="q-mb-xl q-ml-lg q-px-lg" @click="onSubmit" color="primary">{{
|
<div class="row justify-end">
|
||||||
props.buttonOkLabel
|
<q-btn no-caps class="q-mb-xl q-mr-md q-px-lg" @click="onSubmit" color="primary">{{
|
||||||
}}</q-btn>
|
props.buttonOkLabel
|
||||||
|
}}</q-btn>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</q-form>
|
</q-form>
|
||||||
</DialogFrame>
|
</DialogFrame>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import DialogFrame from '../../dialog/DialogFrame.vue';
|
import DialogFrame from '../../dialog/DialogFrame.vue';
|
||||||
import { useNotify } from '../../general/useNotify';
|
import { useNotify } from '../../general/useNotify';
|
||||||
import { getRequest, setsRequest } from 'src/vueLib/models/Request';
|
import { getRequest, setsRequest } from 'src/vueLib/models/Request';
|
||||||
@@ -44,11 +51,14 @@ import { datapointRequestForCopy } from '../Datapoint';
|
|||||||
import { catchError } from 'src/vueLib/models/error';
|
import { catchError } from 'src/vueLib/models/error';
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
|
const copyData = reactive({
|
||||||
|
path: '',
|
||||||
|
copyPath: '',
|
||||||
|
prefix: 'DBM:',
|
||||||
|
});
|
||||||
|
|
||||||
const Dialog = ref();
|
const Dialog = ref();
|
||||||
const path = ref('');
|
|
||||||
const copyPath = ref('');
|
|
||||||
const copyForm = ref();
|
const copyForm = ref();
|
||||||
const prefix = 'DBM:';
|
|
||||||
|
|
||||||
const open = (uuid: string) => {
|
const open = (uuid: string) => {
|
||||||
Dialog.value?.open();
|
Dialog.value?.open();
|
||||||
@@ -58,18 +68,18 @@ const open = (uuid: string) => {
|
|||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
copyForm.value.validate().then((success: undefined) => {
|
copyForm.value.validate().then((success: undefined) => {
|
||||||
if (success) {
|
if (success) {
|
||||||
if (copyPath.value === path.value) {
|
if (copyData.copyPath === copyData.path) {
|
||||||
NotifyResponse('copy path can not be the same as current path', 'error');
|
NotifyResponse('copy path can not be the same as current path', 'error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const absolutePath = path.value.slice(prefix.length);
|
const absolutePath = copyData.path.slice(copyData.prefix.length);
|
||||||
const absolutecopyPath = copyPath.value.slice(prefix.length);
|
const absolutecopyPath = copyData.copyPath.slice(copyData.prefix.length);
|
||||||
|
|
||||||
getRequest('', absolutecopyPath, 1)
|
getRequest('', absolutecopyPath, 1)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response?.length > 0) {
|
if (response?.length > 0) {
|
||||||
NotifyResponse("path '" + copyPath.value + "' already exists", 'warning');
|
NotifyResponse("path '" + copyData.copyPath + "' already exists", 'warning');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -80,7 +90,7 @@ function onSubmit() {
|
|||||||
setsRequest(
|
setsRequest(
|
||||||
datapointRequestForCopy(response, absolutePath, absolutecopyPath),
|
datapointRequestForCopy(response, absolutePath, absolutecopyPath),
|
||||||
).catch((err) => console.error(err));
|
).catch((err) => console.error(err));
|
||||||
NotifyResponse(copyPath.value + ' copied');
|
NotifyResponse(copyData.copyPath + ' copied');
|
||||||
})
|
})
|
||||||
.catch((err) => NotifyResponse(catchError(err), 'error'));
|
.catch((err) => NotifyResponse(catchError(err), 'error'));
|
||||||
} else {
|
} else {
|
||||||
@@ -89,7 +99,7 @@ function onSubmit() {
|
|||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (copyPath.value === '') {
|
if (copyData.copyPath === '') {
|
||||||
NotifyResponse("Field 'New Path' is requierd", 'error');
|
NotifyResponse("Field 'New Path' is requierd", 'error');
|
||||||
return;
|
return;
|
||||||
} else NotifyResponse('Form not validated', 'error');
|
} else NotifyResponse('Form not validated', 'error');
|
||||||
@@ -111,8 +121,12 @@ const props = defineProps({
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
width: {
|
width: {
|
||||||
type: String,
|
type: Number,
|
||||||
default: '300px',
|
default: 300,
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
type: Number,
|
||||||
|
default: 400,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -120,8 +134,8 @@ function getDatapoint(uuid: string) {
|
|||||||
getRequest(uuid)
|
getRequest(uuid)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (resp[0]) {
|
if (resp[0]) {
|
||||||
path.value = prefix + resp[0].path;
|
copyData.path = copyData.prefix + resp[0].path;
|
||||||
copyPath.value = prefix + resp[0].path;
|
copyData.copyPath = copyData.prefix + resp[0].path;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => NotifyResponse(catchError(err), 'error'));
|
.catch((err) => NotifyResponse(catchError(err), 'error'));
|
||||||
|
258
src/vueLib/dbm/dialog/DriverDialog.vue
Normal file
258
src/vueLib/dbm/dialog/DriverDialog.vue
Normal 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: Number,
|
||||||
|
default: 300,
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
type: Number,
|
||||||
|
default: 480,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
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>
|
@@ -8,12 +8,14 @@
|
|||||||
</q-card-section>
|
</q-card-section>
|
||||||
<div class="text-center text-bold text-primary">
|
<div class="text-center text-bold text-primary">
|
||||||
Do you want to remove Datapoint
|
Do you want to remove Datapoint
|
||||||
<br />
|
<br /><br />
|
||||||
'{{ datapoint.path ?? '' }}'
|
'{{ datapoint.path ?? '' }}'
|
||||||
</div>
|
</div>
|
||||||
<q-btn no-caps class="q-ma-md" filled color="negative" @click="remove">{{
|
<div class="row justify-end">
|
||||||
props.buttonOkLabel
|
<q-btn no-caps class="q-ma-lg q-mr-xl" filled color="negative" @click="remove">{{
|
||||||
}}</q-btn>
|
props.buttonOkLabel
|
||||||
|
}}</q-btn>
|
||||||
|
</div>
|
||||||
</DialogFrame>
|
</DialogFrame>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -84,8 +86,8 @@ const props = defineProps({
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
width: {
|
width: {
|
||||||
type: String,
|
type: Number,
|
||||||
default: '300px',
|
default: 300,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,5 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<DialogFrame ref="Dialog" :width="props.width" :header-title="props.dialogLabel">
|
<DialogFrame
|
||||||
|
ref="Dialog"
|
||||||
|
:width="props.width"
|
||||||
|
:height="props.height"
|
||||||
|
:header-title="props.dialogLabel"
|
||||||
|
>
|
||||||
<q-card-section
|
<q-card-section
|
||||||
v-if="props.dialogLabel"
|
v-if="props.dialogLabel"
|
||||||
class="text-bold text-left q-mb-none q-pb-none"
|
class="text-bold text-left q-mb-none q-pb-none"
|
||||||
@@ -10,7 +15,7 @@
|
|||||||
<q-input
|
<q-input
|
||||||
class="q-mt-lg q-mb-none q-pl-md q-mx-lg"
|
class="q-mt-lg q-mb-none q-pl-md q-mx-lg"
|
||||||
filled
|
filled
|
||||||
v-model="path"
|
v-model="removeData.path"
|
||||||
label="Current Path"
|
label="Current Path"
|
||||||
label-color="primary"
|
label-color="primary"
|
||||||
readonly
|
readonly
|
||||||
@@ -19,14 +24,14 @@
|
|||||||
<q-input
|
<q-input
|
||||||
class="q-mt-lg q-mt-none q-pl-md q-mx-lg"
|
class="q-mt-lg q-mt-none q-pl-md q-mx-lg"
|
||||||
filled
|
filled
|
||||||
v-model="newPath"
|
v-model="removeData.newPath"
|
||||||
label="New Path *"
|
label="New Path *"
|
||||||
label-color="primary"
|
label-color="primary"
|
||||||
@keyup.enter="onSubmit"
|
@keyup.enter="onSubmit"
|
||||||
:rules="[(val) => !!val || 'Path is required']"
|
:rules="[(val) => !!val || 'Path is required']"
|
||||||
>
|
>
|
||||||
</q-input>
|
</q-input>
|
||||||
<div class="q-mx-sm">
|
<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">{{
|
<q-btn no-caps class="q-mb-xl q-ml-lg q-px-lg" @click="onSubmit" color="primary">{{
|
||||||
props.buttonOkLabel
|
props.buttonOkLabel
|
||||||
}}</q-btn>
|
}}</q-btn>
|
||||||
@@ -36,7 +41,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
import DialogFrame from '../../dialog/DialogFrame.vue';
|
import DialogFrame from '../../dialog/DialogFrame.vue';
|
||||||
import { useNotify } from '../../general/useNotify';
|
import { useNotify } from '../../general/useNotify';
|
||||||
import { getRequest, setRequest } from 'src/vueLib/models/Request';
|
import { getRequest, setRequest } from 'src/vueLib/models/Request';
|
||||||
@@ -49,10 +54,13 @@ import { buildTree } from '../dbmTree';
|
|||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
const Dialog = ref();
|
const Dialog = ref();
|
||||||
const datapoint = ref();
|
const datapoint = ref();
|
||||||
const path = ref('');
|
const removeData = reactive({
|
||||||
const newPath = ref('');
|
path: '',
|
||||||
|
newPath: '',
|
||||||
|
prefix: 'DBM:',
|
||||||
|
});
|
||||||
|
|
||||||
const copyForm = ref();
|
const copyForm = ref();
|
||||||
const prefix = 'DBM:';
|
|
||||||
|
|
||||||
const open = (uuid: string) => {
|
const open = (uuid: string) => {
|
||||||
Dialog.value?.open();
|
Dialog.value?.open();
|
||||||
@@ -62,14 +70,13 @@ const open = (uuid: string) => {
|
|||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
copyForm.value.validate().then((success: undefined) => {
|
copyForm.value.validate().then((success: undefined) => {
|
||||||
if (success) {
|
if (success) {
|
||||||
if (newPath.value === path.value) {
|
if (removeData.newPath === removeData.path) {
|
||||||
NotifyResponse('same name', 'warning');
|
NotifyResponse('same name', 'warning');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
getRequest('', newPath.value.slice(prefix.length), 1)
|
getRequest('', removeData.newPath.slice(removeData.prefix.length), 1)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log(10, response);
|
|
||||||
if (response?.length > 0) {
|
if (response?.length > 0) {
|
||||||
NotifyResponse("path '" + response[0]?.path + "' already exists", 'warning');
|
NotifyResponse("path '" + response[0]?.path + "' already exists", 'warning');
|
||||||
return;
|
return;
|
||||||
@@ -83,11 +90,12 @@ function onSubmit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setRequest(
|
setRequest(
|
||||||
newPath.value.slice(prefix.length),
|
removeData.newPath.slice(removeData.prefix.length),
|
||||||
datapoint.value.type,
|
datapoint.value.type,
|
||||||
datapoint.value.value,
|
datapoint.value.value,
|
||||||
datapoint.value.rights,
|
datapoint.value.rights,
|
||||||
datapoint.value.uuid,
|
datapoint.value.uuid,
|
||||||
|
undefined,
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@@ -98,7 +106,7 @@ function onSubmit() {
|
|||||||
.catch((err) => NotifyResponse(err, 'error'));
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (newPath.value === '') {
|
if (removeData.newPath === '') {
|
||||||
NotifyResponse("Field 'New Path' is requierd", 'error');
|
NotifyResponse("Field 'New Path' is requierd", 'error');
|
||||||
return;
|
return;
|
||||||
} else NotifyResponse('Form not validated', 'error');
|
} else NotifyResponse('Form not validated', 'error');
|
||||||
@@ -120,8 +128,12 @@ const props = defineProps({
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
width: {
|
width: {
|
||||||
type: String,
|
type: Number,
|
||||||
default: '300px',
|
default: 300,
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
type: Number,
|
||||||
|
default: 400,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -130,8 +142,8 @@ function getDatapoint(uuid: string) {
|
|||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (resp[0]) {
|
if (resp[0]) {
|
||||||
datapoint.value = resp[0];
|
datapoint.value = resp[0];
|
||||||
path.value = prefix + resp[0].path;
|
removeData.path = removeData.prefix + resp[0].path;
|
||||||
newPath.value = prefix + resp[0].path;
|
removeData.newPath = removeData.prefix + resp[0].path;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => NotifyResponse(catchError(err), 'error'));
|
.catch((err) => NotifyResponse(catchError(err), 'error'));
|
||||||
|
@@ -1,10 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<DialogFrame ref="Dialog" :width="props.width" :header-title="props.dialogLabel">
|
<DialogFrame
|
||||||
|
ref="Dialog"
|
||||||
|
:width="props.width"
|
||||||
|
:height="props.height"
|
||||||
|
:header-title="props.dialogLabel"
|
||||||
|
>
|
||||||
<q-card-section
|
<q-card-section
|
||||||
v-if="props.dialogLabel"
|
v-if="props.dialogLabel"
|
||||||
class="text-bold text-left q-mb-none q-pb-none"
|
class="text-bold text-left q-mb-none q-pb-none"
|
||||||
:class="'text-' + props.labelColor"
|
:class="'text-' + props.labelColor"
|
||||||
>DBM:{{ datapoint.path }}
|
>{{
|
||||||
|
datapoint.uuid === '00000000-0000-0000-0000-000000000000' ? 'DBM' : 'DBM:' + datapoint.path
|
||||||
|
}}
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-form ref="datatypeForm" class="q-gutter-md">
|
<q-form ref="datatypeForm" class="q-gutter-md">
|
||||||
<q-input
|
<q-input
|
||||||
@@ -12,7 +19,7 @@
|
|||||||
filled
|
filled
|
||||||
dense
|
dense
|
||||||
v-model="currentDatatype"
|
v-model="currentDatatype"
|
||||||
label="Current Path"
|
label="Current Datatype"
|
||||||
label-color="primary"
|
label-color="primary"
|
||||||
readonly
|
readonly
|
||||||
>
|
>
|
||||||
@@ -20,6 +27,7 @@
|
|||||||
<q-select
|
<q-select
|
||||||
class="q-mt-lg q-mt-none q-pl-md q-mx-lg"
|
class="q-mt-lg q-mt-none q-pl-md q-mx-lg"
|
||||||
popup-content-class="small-dropdown"
|
popup-content-class="small-dropdown"
|
||||||
|
label="New Datatype"
|
||||||
filled
|
filled
|
||||||
dense
|
dense
|
||||||
v-model="selectedDatatype"
|
v-model="selectedDatatype"
|
||||||
@@ -27,7 +35,7 @@
|
|||||||
option-label="label"
|
option-label="label"
|
||||||
>
|
>
|
||||||
</q-select>
|
</q-select>
|
||||||
<div class="q-mx-sm">
|
<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">{{
|
<q-btn no-caps class="q-mb-xl q-ml-lg q-px-lg" @click="onSubmit" color="primary">{{
|
||||||
props.buttonOkLabel
|
props.buttonOkLabel
|
||||||
}}</q-btn>
|
}}</q-btn>
|
||||||
@@ -111,8 +119,12 @@ const props = defineProps({
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
width: {
|
width: {
|
||||||
type: String,
|
type: Number,
|
||||||
default: '300px',
|
default: 300,
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
type: Number,
|
||||||
|
default: 340,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
212
src/vueLib/dbm/dialog/UpdateDriverDialog.vue
Normal file
212
src/vueLib/dbm/dialog/UpdateDriverDialog.vue
Normal 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: Number,
|
||||||
|
default: 300,
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
type: Number,
|
||||||
|
default: 500,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
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>
|
@@ -1,12 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<DialogFrame ref="Dialog" :width="props.width" :header-title="datapoint?.path">
|
<DialogFrame
|
||||||
|
ref="Dialog"
|
||||||
|
:width="props.width"
|
||||||
|
:height="props.height"
|
||||||
|
:header-title="datapoint?.path"
|
||||||
|
>
|
||||||
<q-card-section
|
<q-card-section
|
||||||
v-if="props.dialogLabel || localDialogLabel"
|
v-if="props.dialogLabel || localDialogLabel"
|
||||||
class="text-bold text-left q-mb-none q-pb-none"
|
class="text-bold text-left q-mb-none q-pb-none"
|
||||||
:class="'text-' + props.labelColor"
|
:class="'text-' + props.labelColor"
|
||||||
>{{ props.dialogLabel ? props.dialogLabel : localDialogLabel }}</q-card-section
|
>{{ props.dialogLabel ? props.dialogLabel : localDialogLabel }}</q-card-section
|
||||||
>
|
>
|
||||||
<q-card-section v-if="drivers && drivers.length == 0">
|
<q-card-section v-if="datapoint.type !== 'BIT'">
|
||||||
<q-input
|
<q-input
|
||||||
class="q-px-md q-ma-sm"
|
class="q-px-md q-ma-sm"
|
||||||
label="current value"
|
label="current value"
|
||||||
@@ -27,24 +32,29 @@
|
|||||||
></q-input>
|
></q-input>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-card-section v-else>
|
<q-card-section v-else>
|
||||||
<q-table
|
<div class="column q-pr-xs q-ma-sm">
|
||||||
flat
|
<div class="row items-center q-gutter-sm">
|
||||||
dense
|
<div>current value</div>
|
||||||
virtual-scroll
|
<div class="row items-left">
|
||||||
:rows-per-page-options="[0]"
|
<q-toggle class="readonly-toggle" left-label v-model="inputValue"></q-toggle>
|
||||||
:rows="drivers"
|
</div>
|
||||||
:columns="columns"
|
</div>
|
||||||
>
|
<div class="row items-center q-gutter-lg">
|
||||||
</q-table>
|
<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>
|
||||||
<q-card-section v-if="props.text" class="text-center" style="white-space: pre-line">{{
|
<q-card-section v-if="props.text" class="text-center" style="white-space: pre-line">{{
|
||||||
props.text
|
props.text
|
||||||
}}</q-card-section>
|
}}</q-card-section>
|
||||||
<q-card-actions align="left" class="text-primary">
|
<q-card-actions align="right" class="text-primary">
|
||||||
<q-btn v-if="props.buttonCancelLabel" flat :label="props.buttonCancelLabel" v-close-popup>
|
<q-btn v-if="props.buttonCancelLabel" flat :label="props.buttonCancelLabel" v-close-popup>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
<q-btn
|
<q-btn
|
||||||
class="q-mb-xl q-ml-lg q-mt-none"
|
class="q-mb-xl q-mr-lg q-mt-none"
|
||||||
v-if="props.buttonOkLabel"
|
v-if="props.buttonOkLabel"
|
||||||
color="primary"
|
color="primary"
|
||||||
no-caps
|
no-caps
|
||||||
@@ -63,15 +73,16 @@ import type { Subscribe } from '../../models/Subscribe';
|
|||||||
import type { Ref } from 'vue';
|
import type { Ref } from 'vue';
|
||||||
import { setValues } from '../../services/websocket';
|
import { setValues } from '../../services/websocket';
|
||||||
import { useNotify } from '../../general/useNotify';
|
import { useNotify } from '../../general/useNotify';
|
||||||
import type { QTableProps } from 'quasar';
|
|
||||||
import type { Driver } from '../../models/Drivers';
|
|
||||||
import { catchError } from 'src/vueLib/models/error';
|
import { catchError } from 'src/vueLib/models/error';
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
const Dialog = ref();
|
const Dialog = ref();
|
||||||
|
const localDialogLabel = ref('');
|
||||||
const writeValue = ref();
|
const writeValue = ref();
|
||||||
const onlyRead = ref(false);
|
const onlyRead = ref(false);
|
||||||
const writeType = ref<'text' | 'number'>('text');
|
const writeType = ref<'text' | 'number'>('text');
|
||||||
|
const datapoint = ref();
|
||||||
|
const inputValue = ref(datapoint?.value);
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
buttonOkLabel: {
|
buttonOkLabel: {
|
||||||
@@ -95,38 +106,23 @@ const props = defineProps({
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
width: {
|
width: {
|
||||||
type: String,
|
type: Number,
|
||||||
default: '300px',
|
default: 300,
|
||||||
|
},
|
||||||
|
height: {
|
||||||
|
type: Number,
|
||||||
|
default: 350,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const datapoint = ref();
|
const open = (sub: Ref<Subscribe>) => {
|
||||||
const inputValue = ref(datapoint?.value);
|
|
||||||
const localDialogLabel = ref('');
|
|
||||||
const drivers = ref<Driver[]>([]);
|
|
||||||
const columns = [
|
|
||||||
{ 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' },
|
|
||||||
] as QTableProps['columns'];
|
|
||||||
|
|
||||||
const open = (sub: Ref<Subscribe>, type?: string) => {
|
|
||||||
datapoint.value = sub.value;
|
datapoint.value = sub.value;
|
||||||
if (datapoint.value.rights == 'R') onlyRead.value = true;
|
if (datapoint.value.rights == 'R') onlyRead.value = true;
|
||||||
drivers.value = [];
|
localDialogLabel.value = 'Update Value';
|
||||||
switch (type) {
|
if (sub.value.type === 'STR') writeType.value = 'text';
|
||||||
case 'driver':
|
else writeType.value = 'number';
|
||||||
localDialogLabel.value = 'Update Drivers';
|
writeValue.value = sub.value.value;
|
||||||
if (sub.value.drivers) drivers.value = Object.values(sub.value.drivers);
|
|
||||||
writeValue.value = sub.value.drivers;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
localDialogLabel.value = 'Update Value';
|
|
||||||
if (sub.value.type === 'STR') writeType.value = 'text';
|
|
||||||
else if (sub.value.type === 'BIT') writeType.value = 'text';
|
|
||||||
else writeType.value = 'number';
|
|
||||||
writeValue.value = sub.value.value;
|
|
||||||
}
|
|
||||||
Dialog.value?.open();
|
Dialog.value?.open();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -156,4 +152,8 @@ defineExpose({ open });
|
|||||||
.outercard {
|
.outercard {
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
|
.readonly-toggle {
|
||||||
|
pointer-events: none;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@@ -7,18 +7,30 @@
|
|||||||
:no-refocus="!minMaxState"
|
:no-refocus="!minMaxState"
|
||||||
:seamless="!minMaxState"
|
:seamless="!minMaxState"
|
||||||
>
|
>
|
||||||
<q-card class="layout" :style="cardStyle" v-touch-pan.mouse.prevent.stop="handlePan">
|
<q-card class="layout" :style="cardStyle">
|
||||||
<div :class="props.headerTitle ? 'row items-center justify-between' : ''">
|
<!-- Draggable Header -->
|
||||||
<div v-if="headerTitle" class="q-mx-sm q-mt-xs text-left text-bold text-caption">
|
<div
|
||||||
{{ props.headerTitle }}
|
class="dialog-header row items-center justify-between bg-grey-1"
|
||||||
|
v-touch-pan.mouse.prevent.stop="handlePan"
|
||||||
|
>
|
||||||
|
<div class="text-left text-bold text-caption q-mx-sm">
|
||||||
|
{{ headerTitle }}
|
||||||
</div>
|
</div>
|
||||||
<div class="row justify-end q-mx-sm q-mt-xs">
|
<div class="row justify-end q-mx-sm">
|
||||||
<q-btn dense flat :icon="minMaxIcon" size="md" @click="minMax()"></q-btn>
|
<q-btn dense flat :icon="minMaxIcon" size="md" @click="minMax" />
|
||||||
<q-btn dense flat icon="close" size="md" v-close-popup></q-btn>
|
<q-btn dense flat icon="close" size="md" v-close-popup />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<q-separator color="black" class="q-my-none" />
|
|
||||||
<div class="scrollArea"><slot /></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-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
</template>
|
</template>
|
||||||
@@ -29,54 +41,107 @@ import { ref, computed } from 'vue';
|
|||||||
const dialogRef = ref();
|
const dialogRef = ref();
|
||||||
const open = () => dialogRef.value?.show();
|
const open = () => dialogRef.value?.show();
|
||||||
const close = () => dialogRef.value?.hide();
|
const close = () => dialogRef.value?.hide();
|
||||||
|
defineExpose({ open, close });
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
headerTitle: { type: String, default: '' },
|
||||||
|
width: { type: Number, default: 400 },
|
||||||
|
height: { type: Number, default: 250 },
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fullscreen toggle
|
||||||
const minMaxIcon = ref('fullscreen');
|
const minMaxIcon = ref('fullscreen');
|
||||||
const minMaxState = ref(false);
|
const minMaxState = ref(false);
|
||||||
function minMax() {
|
function minMax() {
|
||||||
if (minMaxState.value) {
|
|
||||||
minMaxIcon.value = 'fullscreen';
|
|
||||||
} else {
|
|
||||||
minMaxIcon.value = 'fullscreen_exit';
|
|
||||||
}
|
|
||||||
minMaxState.value = !minMaxState.value;
|
minMaxState.value = !minMaxState.value;
|
||||||
|
minMaxIcon.value = minMaxState.value ? 'fullscreen_exit' : 'fullscreen';
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps({
|
// Position and Size
|
||||||
headerTitle: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '300px',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const position = ref({ x: 0, y: 0 });
|
const position = ref({ x: 0, y: 0 });
|
||||||
|
const width = ref(props.width);
|
||||||
|
const height = ref(props.height);
|
||||||
|
|
||||||
// This makes the dialog draggable
|
// Dragging (only from header)
|
||||||
const handlePan = (details: { delta: { x: number; y: number } }) => {
|
const handlePan = (details: { delta: { x: number; y: number } }) => {
|
||||||
position.value.x += details.delta.x;
|
if (!minMaxState.value) {
|
||||||
position.value.y += details.delta.y;
|
position.value.x += details.delta.x;
|
||||||
|
position.value.y += details.delta.y;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const cardStyle = computed(() => ({
|
// Resizing
|
||||||
width: props.width,
|
const isResizing = ref(false);
|
||||||
transform: `translate(${position.value.x}px, ${position.value.y}px)`,
|
function startResizing(e: MouseEvent) {
|
||||||
}));
|
isResizing.value = true;
|
||||||
|
const startX = e.clientX;
|
||||||
|
const startY = e.clientY;
|
||||||
|
const startWidth = width.value;
|
||||||
|
const startHeight = height.value;
|
||||||
|
|
||||||
defineExpose({ open, close });
|
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>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.layout {
|
.layout {
|
||||||
border-radius: 10px;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
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 {
|
.scrollArea {
|
||||||
overflow-y: auto;
|
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
min-height: 0;
|
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>
|
</style>
|
||||||
|
@@ -22,6 +22,19 @@ export function useNotify() {
|
|||||||
break;
|
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) {
|
if (response) {
|
||||||
const message = typeof response === 'string' ? response : (response.message ?? '');
|
const message = typeof response === 'string' ? response : (response.message ?? '');
|
||||||
if (message === '') {
|
if (message === '') {
|
||||||
|
109
src/vueLib/login/LoginForm.vue
Normal file
109
src/vueLib/login/LoginForm.vue
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
<template>
|
||||||
|
<DialogFrame ref="Dialog" :width="300" :height="380" 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>
|
43
src/vueLib/login/LoginMenu.vue
Normal file
43
src/vueLib/login/LoginMenu.vue
Normal 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
31
src/vueLib/login/login.ts
Normal 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 };
|
||||||
|
}
|
80
src/vueLib/login/userStore.ts
Normal file
80
src/vueLib/login/userStore.ts
Normal 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
7
src/vueLib/models/Bus.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import type { Topic } from './Topic';
|
||||||
|
|
||||||
|
export interface Bus {
|
||||||
|
name: string;
|
||||||
|
address?: number[];
|
||||||
|
topic?: Topic;
|
||||||
|
}
|
@@ -1,5 +1,9 @@
|
|||||||
|
import type { Bus } from './Bus';
|
||||||
export interface Driver {
|
export interface Driver {
|
||||||
type: string;
|
type: string;
|
||||||
addess: number;
|
buses?: Bus[];
|
||||||
value: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const driverDefault = <Driver>{
|
||||||
|
type: '',
|
||||||
|
};
|
||||||
|
@@ -1,14 +1,21 @@
|
|||||||
|
import type { Driver } from './Drivers';
|
||||||
export type Publish = {
|
export type Publish = {
|
||||||
event: string;
|
event: string;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
path: string;
|
path: string;
|
||||||
type: string;
|
type: string;
|
||||||
|
drivers?: Record<string, Driver>;
|
||||||
value: string | number | boolean | null;
|
value: string | number | boolean | null;
|
||||||
hasChild: boolean;
|
hasChild: boolean;
|
||||||
};
|
};
|
||||||
export type Pubs = Publish[];
|
export type Pubs = Publish[];
|
||||||
|
|
||||||
import { updateSubscriptionValue, removeRawSubscriptions } from './Subscriptions';
|
import {
|
||||||
|
updateSubscriptionValue,
|
||||||
|
removeRawSubscriptions,
|
||||||
|
addRawSubscription,
|
||||||
|
removeRawSubscription,
|
||||||
|
} from './Subscriptions';
|
||||||
import { buildTree, buildTreeWithRawSubs, removeNodes } from '../dbm/dbmTree';
|
import { buildTree, buildTreeWithRawSubs, removeNodes } from '../dbm/dbmTree';
|
||||||
import type { RawSubs, RawSubscribe } from '../models/Subscribe';
|
import type { RawSubs, RawSubscribe } from '../models/Subscribe';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
@@ -33,6 +40,11 @@ export function publishToSubscriptions(pubs: Pubs) {
|
|||||||
rawSubs.value.push(pub as RawSubscribe);
|
rawSubs.value.push(pub as RawSubscribe);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (pub.drivers) {
|
||||||
|
removeRawSubscription(pub as RawSubscribe);
|
||||||
|
addRawSubscription(pub as RawSubscribe);
|
||||||
|
UpdateTable();
|
||||||
|
}
|
||||||
updateSubscriptionValue(pub.uuid, pub.value);
|
updateSubscriptionValue(pub.uuid, pub.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
|
import type { Driver } from './Drivers';
|
||||||
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 { Subs } from './Subscribe';
|
||||||
import { api } from 'src/boot/axios';
|
import { dbmApi } from 'src/boot/axios';
|
||||||
|
|
||||||
export type Request = {
|
export type Request = {
|
||||||
get?: Gets;
|
get?: Gets;
|
||||||
@@ -24,7 +25,7 @@ export async function getRequest(
|
|||||||
payload = { path: path, query: { depth: depth } };
|
payload = { path: path, query: { depth: depth } };
|
||||||
}
|
}
|
||||||
|
|
||||||
const resp = await api.post(query, {
|
const resp = await dbmApi.post(query, {
|
||||||
get: [payload],
|
get: [payload],
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ export async function getRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getRequests(gets: Gets): Promise<Gets> {
|
export async function getRequests(gets: Gets): Promise<Gets> {
|
||||||
const resp = await api.post(query, {
|
const resp = await dbmApi.post(query, {
|
||||||
get: gets,
|
get: gets,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ export async function getRequests(gets: Gets): Promise<Gets> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function rawSetsRequest(sets: Sets): Promise<Sets> {
|
export async function rawSetsRequest(sets: Sets): Promise<Sets> {
|
||||||
const resp = await api.post(query, {
|
const resp = await dbmApi.post(query, {
|
||||||
set: sets,
|
set: sets,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -61,10 +62,11 @@ export async function rawSetsRequest(sets: Sets): Promise<Sets> {
|
|||||||
|
|
||||||
export async function setRequest(
|
export async function setRequest(
|
||||||
path: string,
|
path: string,
|
||||||
type: string,
|
type?: string,
|
||||||
value: string | number | boolean,
|
value?: string | number | boolean,
|
||||||
rights?: string,
|
rights?: string,
|
||||||
uuid?: string,
|
uuid?: string,
|
||||||
|
driver?: Driver,
|
||||||
rename?: boolean,
|
rename?: boolean,
|
||||||
): Promise<Sets> {
|
): Promise<Sets> {
|
||||||
const payload = {
|
const payload = {
|
||||||
@@ -73,10 +75,11 @@ export async function setRequest(
|
|||||||
value: value,
|
value: value,
|
||||||
rights: rights,
|
rights: rights,
|
||||||
uuid: uuid,
|
uuid: uuid,
|
||||||
|
driver: driver,
|
||||||
rename: rename,
|
rename: rename,
|
||||||
};
|
};
|
||||||
|
|
||||||
const resp = await api.post(query, {
|
const resp = await dbmApi.post(query, {
|
||||||
set: [payload],
|
set: [payload],
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -88,7 +91,7 @@ export async function setRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function setsRequest(sets: Sets): Promise<Sets> {
|
export async function setsRequest(sets: Sets): Promise<Sets> {
|
||||||
const resp = await api.post(query, {
|
const resp = await dbmApi.post(query, {
|
||||||
set: sets,
|
set: sets,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -99,15 +102,19 @@ export async function setsRequest(sets: Sets): Promise<Sets> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteRequest(uuid?: string, path?: string, rename?: boolean): Promise<Sets> {
|
export async function deleteRequest(
|
||||||
|
uuid?: string,
|
||||||
|
path?: string,
|
||||||
|
driver?: Driver,
|
||||||
|
rename?: boolean,
|
||||||
|
): Promise<Sets> {
|
||||||
let payload = {};
|
let payload = {};
|
||||||
if (uuid) {
|
if (uuid) {
|
||||||
payload = { uuid: uuid, rename: rename };
|
payload = { uuid: uuid, driver: driver, rename: rename };
|
||||||
} else if (path) {
|
} else if (path) {
|
||||||
payload = { path: path };
|
payload = { path: path, driver: driver };
|
||||||
}
|
}
|
||||||
|
const resp = await dbmApi.delete('/json_data', {
|
||||||
const resp = await api.delete('/json_data', {
|
|
||||||
data: {
|
data: {
|
||||||
set: [payload],
|
set: [payload],
|
||||||
},
|
},
|
||||||
|
@@ -11,4 +11,10 @@ export type Response = {
|
|||||||
publish?: Pubs;
|
publish?: Pubs;
|
||||||
error?: boolean;
|
error?: boolean;
|
||||||
message?: string;
|
message?: string;
|
||||||
|
response?: {
|
||||||
|
data?: {
|
||||||
|
error?: boolean;
|
||||||
|
message?: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
64
src/vueLib/models/Services.ts
Normal file
64
src/vueLib/models/Services.ts
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
import { appApi } from 'src/boot/axios';
|
||||||
|
//import { ref } from 'vue';
|
||||||
|
|
||||||
|
export interface Service {
|
||||||
|
name: string;
|
||||||
|
workingDirectory: string;
|
||||||
|
executablePath: string;
|
||||||
|
description: string;
|
||||||
|
arguments: string[];
|
||||||
|
state: State;
|
||||||
|
stateColor: string;
|
||||||
|
stateTextColor: string;
|
||||||
|
}
|
||||||
|
export type Services = Service[];
|
||||||
|
export type State = 'Stopped' | 'Stopping' | 'Starting' | 'Running' | 'Error';
|
||||||
|
|
||||||
|
export function useServices() {
|
||||||
|
async function initServices() {
|
||||||
|
return appApi
|
||||||
|
.get('services/load')
|
||||||
|
.then((resp) => {
|
||||||
|
const normalized = resp.data.services.map((item: Service) => {
|
||||||
|
if (!item.state) {
|
||||||
|
item.state = 'Stopped';
|
||||||
|
}
|
||||||
|
|
||||||
|
let stateColor = 'grey-4';
|
||||||
|
let stateTextColor = 'black';
|
||||||
|
|
||||||
|
switch (item.state) {
|
||||||
|
case 'Running':
|
||||||
|
stateColor = 'green';
|
||||||
|
stateTextColor = 'white';
|
||||||
|
break;
|
||||||
|
case 'Starting':
|
||||||
|
case 'Stopping':
|
||||||
|
stateColor = 'green';
|
||||||
|
stateTextColor = 'white';
|
||||||
|
break;
|
||||||
|
case 'Stopped':
|
||||||
|
default:
|
||||||
|
stateColor = 'grey-4';
|
||||||
|
stateTextColor = 'black';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
stateColor,
|
||||||
|
stateTextColor,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return normalized;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
initServices,
|
||||||
|
};
|
||||||
|
}
|
@@ -20,6 +20,7 @@ export type RawSubscribe = {
|
|||||||
path?: string;
|
path?: string;
|
||||||
depth?: number;
|
depth?: number;
|
||||||
value?: string | number | boolean | null;
|
value?: string | number | boolean | null;
|
||||||
|
drivers?: Record<string, Driver>;
|
||||||
rights?: string;
|
rights?: string;
|
||||||
hasChild?: boolean;
|
hasChild?: boolean;
|
||||||
};
|
};
|
||||||
|
4
src/vueLib/models/Topic.ts
Normal file
4
src/vueLib/models/Topic.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export interface Topic {
|
||||||
|
subscribe: string[];
|
||||||
|
publish: string[];
|
||||||
|
}
|
87
src/vueLib/models/driverTable.ts
Normal file
87
src/vueLib/models/driverTable.ts
Normal 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',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
43
src/vueLib/services/dialog/ServiceDialog.vue
Normal file
43
src/vueLib/services/dialog/ServiceDialog.vue
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
<template>
|
||||||
|
<DialogFrame ref="refDialog" :width="250" header-title="Add new Service">
|
||||||
|
<div class="row justify-center">
|
||||||
|
<div>
|
||||||
|
<div class="q-ma-md text-primary text-bold">Choose new service</div>
|
||||||
|
<q-select dense filled class="col-4" :options="opts" v-model="option"></q-select>
|
||||||
|
<div class="row justify-end">
|
||||||
|
<q-btn class="q-mt-md" no-caps color="primary">Add Service</q-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</DialogFrame>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
|
import { appApi } from 'src/boot/axios';
|
||||||
|
|
||||||
|
const { NotifyResponse } = useNotify();
|
||||||
|
|
||||||
|
const refDialog = ref();
|
||||||
|
const driverRows = ref([]);
|
||||||
|
const opts = ref();
|
||||||
|
const option = ref('');
|
||||||
|
|
||||||
|
interface conf {
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
function open() {
|
||||||
|
appApi
|
||||||
|
.get('services/all')
|
||||||
|
.then((resp) => {
|
||||||
|
driverRows.value = resp.data;
|
||||||
|
opts.value = resp.data.services.map((item: conf) => item.name);
|
||||||
|
})
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
refDialog.value.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ open });
|
||||||
|
</script>
|
92
src/vueLib/services/dialog/SubMenu.vue
Normal file
92
src/vueLib/services/dialog/SubMenu.vue
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
<template>
|
||||||
|
<q-menu ref="refMenu" context-menu>
|
||||||
|
<q-list>
|
||||||
|
<q-item :disable="!startEnabled" clickable @click="start">
|
||||||
|
<q-item-section>
|
||||||
|
<q-icon :color="startEnabled ? 'green' : 'green-2'" name="play_arrow" size="sm" />
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
<q-item :disable="!stopEnabled" clickable @click="stop">
|
||||||
|
<q-item-section>
|
||||||
|
<q-icon :color="stopEnabled ? 'red' : 'red-2'" name="stop" size="sm" />
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
<q-item :disable="!restartEnabled" clickable>
|
||||||
|
<q-item-section>
|
||||||
|
<q-icon
|
||||||
|
:color="restartEnabled ? 'orange' : 'orange-3'"
|
||||||
|
name="restart_alt"
|
||||||
|
size="sm"
|
||||||
|
@click="console.log('restart')"
|
||||||
|
/>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</q-menu>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { appApi } from 'src/boot/axios';
|
||||||
|
import type { Service } from 'src/vueLib/models/Services';
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
|
|
||||||
|
const { NotifyResponse } = useNotify();
|
||||||
|
|
||||||
|
const refMenu = ref();
|
||||||
|
const startEnabled = computed(() => localService.value?.state === 'Stopped' || 'Error');
|
||||||
|
const stopEnabled = computed(() => localService.value?.state === 'Running');
|
||||||
|
const restartEnabled = computed(() => localService.value?.state === 'Running');
|
||||||
|
const localService = ref<Service>();
|
||||||
|
|
||||||
|
const open = (event: MouseEvent, service: Service) => {
|
||||||
|
localService.value = service;
|
||||||
|
refMenu.value?.show(event);
|
||||||
|
};
|
||||||
|
|
||||||
|
function start() {
|
||||||
|
if (!localService.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
localService.value.state = 'Starting';
|
||||||
|
localService.value.stateColor = 'yellow';
|
||||||
|
localService.value.stateTextColor = 'black';
|
||||||
|
appApi
|
||||||
|
.get(`/services/${localService.value.name}/start`)
|
||||||
|
.then(() => {
|
||||||
|
if (!localService.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
localService.value.state = 'Running';
|
||||||
|
localService.value.stateColor = 'green';
|
||||||
|
localService.value.stateTextColor = 'white';
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
NotifyResponse(err, 'error');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop() {
|
||||||
|
if (!localService.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
localService.value.state = 'Stopping';
|
||||||
|
localService.value.stateColor = 'yellow';
|
||||||
|
localService.value.stateTextColor = 'black';
|
||||||
|
|
||||||
|
appApi
|
||||||
|
.get(`/services/${localService.value.name}/stop`)
|
||||||
|
.then(() => {
|
||||||
|
if (!localService.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
localService.value.state = 'Stopped';
|
||||||
|
localService.value.stateColor = 'grey-4';
|
||||||
|
localService.value.stateTextColor = 'black';
|
||||||
|
})
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ open });
|
||||||
|
</script>
|
7
src/vueLib/services/statusServer/models.ts
Normal file
7
src/vueLib/services/statusServer/models.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export type Payload = {
|
||||||
|
action?: Action;
|
||||||
|
topic: string;
|
||||||
|
data: { state?: string; message?: string };
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Action = 'subscribe' | 'publish';
|
115
src/vueLib/services/statusServer/useStatusServer.ts
Normal file
115
src/vueLib/services/statusServer/useStatusServer.ts
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
import type { Response } from '../../models/Response';
|
||||||
|
import type { QVueGlobals } from 'quasar';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import type { Payload } from './models';
|
||||||
|
|
||||||
|
let socket: WebSocket | null = null;
|
||||||
|
|
||||||
|
const isConnected = ref(false);
|
||||||
|
|
||||||
|
export function useStatusServer(
|
||||||
|
host: string,
|
||||||
|
port: number = 9500,
|
||||||
|
path: string,
|
||||||
|
id: string,
|
||||||
|
callback: (payload: Payload) => void,
|
||||||
|
$q?: QVueGlobals,
|
||||||
|
) {
|
||||||
|
const connect = () => {
|
||||||
|
socket = new WebSocket(`ws://${host}:${port}/${path}?id=${id}`);
|
||||||
|
|
||||||
|
socket.onopen = () => {
|
||||||
|
console.log('WebSocket connected');
|
||||||
|
isConnected.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
socket.onclose = () => {
|
||||||
|
isConnected.value = false;
|
||||||
|
console.log('WebSocket disconnected');
|
||||||
|
$q?.notify({
|
||||||
|
message: 'WebSocket disconnected',
|
||||||
|
color: 'orange',
|
||||||
|
position: 'bottom-right',
|
||||||
|
icon: 'warning',
|
||||||
|
timeout: 10000,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
socket.onerror = (err) => {
|
||||||
|
console.log(`WebSocket error: ${err.type}`);
|
||||||
|
isConnected.value = false;
|
||||||
|
$q?.notify({
|
||||||
|
message: `WebSocket error: ${err.type}`,
|
||||||
|
color: 'red',
|
||||||
|
position: 'bottom-right',
|
||||||
|
icon: 'error',
|
||||||
|
timeout: 10000,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
socket.onmessage = (event) => {
|
||||||
|
callback(JSON.parse(event.data));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
function subscribe(topic: string): Promise<Response | undefined> {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
waitForSocketConnection()
|
||||||
|
.then(() => {
|
||||||
|
socket?.send('{"action":"subscribe", "topic":"' + topic + '"}');
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.warn('WebSocket send failed:', err);
|
||||||
|
resolve(undefined); // or reject(err) if strict failure is desired
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function publish(topic: string, data: unknown): Promise<Response | undefined> {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
waitForSocketConnection()
|
||||||
|
.then(() => {
|
||||||
|
socket?.send(
|
||||||
|
'{"action":"publish", "topic":"' + topic + '", "data":' + JSON.stringify(data) + '}',
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.warn('WebSocket send failed:', err);
|
||||||
|
resolve(undefined); // or reject(err) if strict failure is desired
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const close = () => {
|
||||||
|
if (socket) {
|
||||||
|
socket.close();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
connect,
|
||||||
|
close,
|
||||||
|
subscribe,
|
||||||
|
publish,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function waitForSocketConnection(): Promise<void> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const maxWait = 5000; // timeout after 5 seconds
|
||||||
|
const interval = 50;
|
||||||
|
let waited = 0;
|
||||||
|
|
||||||
|
const check = () => {
|
||||||
|
if (socket && socket.readyState === WebSocket.OPEN) {
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
waited += interval;
|
||||||
|
if (waited >= maxWait) {
|
||||||
|
reject(new Error('WebSocket connection timeout'));
|
||||||
|
} else {
|
||||||
|
setTimeout(check, interval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
check();
|
||||||
|
});
|
||||||
|
}
|
@@ -12,9 +12,11 @@ export let socket: WebSocket | null = null;
|
|||||||
|
|
||||||
const isConnected = ref(false);
|
const isConnected = ref(false);
|
||||||
|
|
||||||
export function initWebSocket(url: string, $q?: QVueGlobals) {
|
export function initWebSocket(host: string, port: number = 8100, $q?: QVueGlobals) {
|
||||||
|
const randomId = Math.floor(Math.random() * 10001); // random number from 0 to 10000
|
||||||
|
|
||||||
const connect = () => {
|
const connect = () => {
|
||||||
socket = new WebSocket(url);
|
socket = new WebSocket(`ws://${host}:${port}/ws?id=q${randomId}`);
|
||||||
|
|
||||||
socket.onopen = () => {
|
socket.onopen = () => {
|
||||||
console.log('WebSocket connected');
|
console.log('WebSocket connected');
|
||||||
|
Reference in New Issue
Block a user