Compare commits
42 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d4d2e4c54 | ||
|
|
352d0aa4c6 | ||
|
|
76269e7358 | ||
|
|
87297a3b97 | ||
|
|
b12574994c | ||
|
|
66bb7c1942 | ||
|
|
f8b79de6a2 | ||
|
|
c7fe7490f1 | ||
|
|
334c14a307 | ||
|
|
b9f009162d | ||
|
|
b844f487bc | ||
|
|
829dc074e2 | ||
|
|
63c7e89dd4 | ||
|
|
53a6408466 | ||
|
|
0793bb5e31 | ||
|
|
8d243302f0 | ||
|
|
2cce310fc4 | ||
|
|
a9707dc799 | ||
|
|
67dee7a746 | ||
|
|
c7c1b6c7c6 | ||
|
|
f7d5d9d019 | ||
|
|
f1d7d3617d | ||
|
|
df580d98c0 | ||
|
|
06afdf4349 | ||
|
|
db96732a62 | ||
|
|
aba4bafb65 | ||
|
|
d57ee4c1e7 | ||
|
|
9866cc3ffd | ||
| 6ec42c6c75 | |||
|
|
7b760afeb3 | ||
|
|
21dcf1a476 | ||
|
|
35d1a0f734 | ||
|
|
effbb61707 | ||
|
|
7eb5ab9ab2 | ||
|
|
aec741f094 | ||
|
|
632163d751 | ||
|
|
a93f063009 | ||
|
|
cc3a547961 | ||
| fdc8525abe | |||
| 8075d1fe1f | |||
| 8709989fbe | |||
|
|
b0d6bb5512 |
1
.env.development
Normal file
@@ -0,0 +1 @@
|
|||||||
|
VITE_API_URL= https://localhost:9500/api
|
||||||
1
.env.production
Normal file
@@ -0,0 +1 @@
|
|||||||
|
VITE_API_URL= https://members.tecamino.com/api
|
||||||
@@ -117,4 +117,4 @@ jobs:
|
|||||||
name: memberApp-${{ matrix.goos }}-${{ matrix.arch }}
|
name: memberApp-${{ matrix.goos }}-${{ matrix.arch }}
|
||||||
path: |
|
path: |
|
||||||
./dist/spa
|
./dist/spa
|
||||||
server-${{ matrix.goos }}-${{ matrix.arch }}${{ matrix.ext }}
|
memberApp-${{ matrix.goos }}-${{ matrix.arch }}${{ matrix.ext }}
|
||||||
|
|||||||
1
.gitignore
vendored
@@ -36,6 +36,7 @@ yarn-error.log*
|
|||||||
|
|
||||||
# local .db files
|
# local .db files
|
||||||
*.db
|
*.db
|
||||||
|
*.dba
|
||||||
|
|
||||||
# local .log files
|
# local .log files
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
1
backend/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.env
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
package dbRequest
|
|
||||||
|
|
||||||
import (
|
|
||||||
"backend/models"
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
var CreateUserTable string = `CREATE TABLE IF NOT EXISTS users (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
username TEXT NOT NULL,
|
|
||||||
email TEXT NOT NULL,
|
|
||||||
role TEXT NOT NULL,
|
|
||||||
password TEXT NOT NULL,
|
|
||||||
settings TEXT NOT NULL
|
|
||||||
);`
|
|
||||||
|
|
||||||
var CreateRoleTable string = `CREATE TABLE IF NOT EXISTS roles (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
role TEXT NOT NULL,
|
|
||||||
rights TEXT NOT NULL
|
|
||||||
);`
|
|
||||||
|
|
||||||
var NewUser string = `INSERT INTO users (username, email, role, password, settings) VALUES (?, ?, ?, ?, ?)`
|
|
||||||
var NewRole = `INSERT INTO roles (role, rights) VALUES (?, ?)`
|
|
||||||
var DBQueryPassword string = `SELECT id, role, password, settings FROM users WHERE username = ?`
|
|
||||||
var DBUserLookup string = `SELECT EXISTS(SELECT 1 FROM users WHERE username = ?)`
|
|
||||||
var DBRoleLookup string = `SELECT EXISTS(SELECT 1 FROM roles WHERE role = ?)`
|
|
||||||
var DBRemoveUser string = `DELETE FROM users WHERE username = $1`
|
|
||||||
var DBUpdateSettings string = `UPDATE users SET settings = ? WHERE username = ?`
|
|
||||||
var DBUpdateRole string = `UPDATE roles SET rights = ? WHERE role = ?`
|
|
||||||
|
|
||||||
func CheckDBError(c *gin.Context, username string, err error) bool {
|
|
||||||
if err != nil {
|
|
||||||
if err.Error() == "sql: no rows in result set" {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse(fmt.Sprintf("no user '%s' found", username)))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
59
backend/env/env.go
vendored
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
package env
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/joho/godotenv"
|
||||||
|
)
|
||||||
|
|
||||||
|
type EnvKey string
|
||||||
|
|
||||||
|
const (
|
||||||
|
Env EnvKey = "ENV"
|
||||||
|
GinMode EnvKey = "GIN_MODE"
|
||||||
|
Debug EnvKey = "DEBUG"
|
||||||
|
PrivKey EnvKey = "PRIVKEY"
|
||||||
|
Fullchain EnvKey = "FULLCHAIN"
|
||||||
|
Https EnvKey = "HTTPS"
|
||||||
|
Url EnvKey = "URL"
|
||||||
|
Port EnvKey = "PORT"
|
||||||
|
WorkingDir EnvKey = "WORKING_DIR"
|
||||||
|
Spa EnvKey = "SPA"
|
||||||
|
AccessSecret EnvKey = "ACCESS_SECRET"
|
||||||
|
RefreshSecret EnvKey = "REFRESH_SECRET"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
EnvDevelopment = "development"
|
||||||
|
EnvProduction = "Prodction"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (key EnvKey) GetValue() string {
|
||||||
|
return os.Getenv(string(key))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (key EnvKey) GetBoolValue() bool {
|
||||||
|
return strings.ToLower(os.Getenv(string(key))) == "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (key EnvKey) GetUIntValue() uint {
|
||||||
|
value, err := strconv.ParseUint(os.Getenv(string(key)), 10, 32)
|
||||||
|
if err != nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return uint(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Load(file string) error {
|
||||||
|
return godotenv.Load(file)
|
||||||
|
}
|
||||||
|
|
||||||
|
func InDevelopmentMode() bool {
|
||||||
|
return Env.GetValue() == EnvDevelopment
|
||||||
|
}
|
||||||
|
|
||||||
|
func InDebugMode() bool {
|
||||||
|
return strings.ToLower(Debug.GetValue()) == "true"
|
||||||
|
}
|
||||||
12
backend/example/example.env
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
ENV=development
|
||||||
|
GIN_MODE=release
|
||||||
|
DEBUG=false
|
||||||
|
SPA=directory_of_spa_files
|
||||||
|
WORKING_DIR=.
|
||||||
|
URL=your_local_url
|
||||||
|
PORT=your_local_port
|
||||||
|
HTTPS=true
|
||||||
|
PRIVKEY=your_certificate_key_file
|
||||||
|
FULLCHAIN=your_certificate_fullchain_file
|
||||||
|
ACCESS_SECRET=your_32bit_long_access_secret
|
||||||
|
REFRESH_SECRET=your_32bit_long_referesh_secret
|
||||||
@@ -3,29 +3,35 @@ module backend
|
|||||||
go 1.24.5
|
go 1.24.5
|
||||||
|
|
||||||
require (
|
require (
|
||||||
gitea.tecamino.com/paadi/memberDB v1.0.1
|
gitea.tecamino.com/paadi/access-handler v1.0.22
|
||||||
|
gitea.tecamino.com/paadi/memberDB v1.1.2
|
||||||
gitea.tecamino.com/paadi/tecamino-dbm v0.1.1
|
gitea.tecamino.com/paadi/tecamino-dbm v0.1.1
|
||||||
gitea.tecamino.com/paadi/tecamino-logger v0.2.1
|
gitea.tecamino.com/paadi/tecamino-logger v0.2.1
|
||||||
github.com/gin-contrib/cors v1.7.6
|
github.com/gin-contrib/cors v1.7.6
|
||||||
github.com/gin-gonic/gin v1.11.0
|
github.com/gin-gonic/gin v1.11.0
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.2
|
github.com/joho/godotenv v1.5.1
|
||||||
golang.org/x/crypto v0.40.0
|
golang.org/x/crypto v0.43.0
|
||||||
modernc.org/sqlite v1.39.0
|
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
gitea.tecamino.com/paadi/dbHandler v1.0.8 // indirect
|
||||||
github.com/bytedance/sonic v1.14.0 // indirect
|
github.com/bytedance/sonic v1.14.0 // indirect
|
||||||
github.com/bytedance/sonic/loader v0.3.0 // indirect
|
github.com/bytedance/sonic/loader v0.3.0 // indirect
|
||||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
github.com/cloudwego/base64x v0.1.6 // 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.9 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
|
||||||
github.com/gin-contrib/sse v1.1.0 // indirect
|
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||||
|
github.com/glebarez/go-sqlite v1.21.2 // indirect
|
||||||
|
github.com/glebarez/sqlite v1.11.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.27.0 // indirect
|
github.com/go-playground/validator/v10 v10.27.0 // indirect
|
||||||
github.com/goccy/go-json v0.10.5 // indirect
|
github.com/goccy/go-json v0.10.5 // indirect
|
||||||
github.com/goccy/go-yaml v1.18.0 // indirect
|
github.com/goccy/go-yaml v1.18.0 // indirect
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
|
github.com/jinzhu/now v1.1.5 // 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.3.0 // indirect
|
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
@@ -45,15 +51,17 @@ require (
|
|||||||
go.uber.org/zap v1.27.0 // indirect
|
go.uber.org/zap v1.27.0 // indirect
|
||||||
golang.org/x/arch v0.20.0 // indirect
|
golang.org/x/arch v0.20.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
|
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect
|
||||||
golang.org/x/mod v0.25.0 // indirect
|
golang.org/x/mod v0.28.0 // indirect
|
||||||
golang.org/x/net v0.42.0 // indirect
|
golang.org/x/net v0.45.0 // indirect
|
||||||
golang.org/x/sync v0.16.0 // indirect
|
golang.org/x/sync v0.17.0 // indirect
|
||||||
golang.org/x/sys v0.35.0 // indirect
|
golang.org/x/sys v0.37.0 // indirect
|
||||||
golang.org/x/text v0.27.0 // indirect
|
golang.org/x/text v0.30.0 // indirect
|
||||||
golang.org/x/tools v0.34.0 // indirect
|
golang.org/x/tools v0.37.0 // indirect
|
||||||
google.golang.org/protobuf v1.36.9 // indirect
|
google.golang.org/protobuf v1.36.9 // indirect
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
|
||||||
|
gorm.io/gorm v1.31.0 // indirect
|
||||||
modernc.org/libc v1.66.3 // indirect
|
modernc.org/libc v1.66.3 // indirect
|
||||||
modernc.org/mathutil v1.7.1 // indirect
|
modernc.org/mathutil v1.7.1 // indirect
|
||||||
modernc.org/memory v1.11.0 // indirect
|
modernc.org/memory v1.11.0 // indirect
|
||||||
|
modernc.org/sqlite v1.39.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
gitea.tecamino.com/paadi/memberDB v1.0.1 h1:hNnnoCeFRBEOQ+QmizF9nzvrQ8bNed8YrDln5jeRy2Y=
|
gitea.tecamino.com/paadi/access-handler v1.0.22 h1:XFi2PQ1gWqe9YuSye4Ti1o5TpdV0AFpt4Fb58MFMagk=
|
||||||
gitea.tecamino.com/paadi/memberDB v1.0.1/go.mod h1:4tgbjrSZ2FZeJL68R2TFHPH34+aGxx5wtZxRmu6nZv4=
|
gitea.tecamino.com/paadi/access-handler v1.0.22/go.mod h1:wKsB5/Rvaj580gdg3+GbUf5V/0N00XN6cID+C/8135M=
|
||||||
|
gitea.tecamino.com/paadi/dbHandler v1.0.8 h1:ZWSBM/KFtLwTv2cBqwK1mOxWAxAfL0BcWEC3kJ9JALU=
|
||||||
|
gitea.tecamino.com/paadi/dbHandler v1.0.8/go.mod h1:y/xn/POJg1DO++67uKvnO23lJQgh+XFQq7HZCS9Getw=
|
||||||
|
gitea.tecamino.com/paadi/memberDB v1.1.2 h1:j/Tsr7JnzAkdOvgjG77TzTVBWd4vBrmEFzPXNpW7GYk=
|
||||||
|
gitea.tecamino.com/paadi/memberDB v1.1.2/go.mod h1:/Af2OeJIHq+8kE5L5DlJxhSJjB75eWBcKRpkxi+n9bU=
|
||||||
gitea.tecamino.com/paadi/tecamino-dbm v0.1.1 h1:vAq7mwUxlxJuLzCQSDMrZCwo8ky5usWi9Qz+UP+WnkI=
|
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-dbm v0.1.1/go.mod h1:+tmf1rjPaKEoNeUcr1vdtoFIFweNG3aUGevDAl3NMBk=
|
||||||
gitea.tecamino.com/paadi/tecamino-logger v0.2.1 h1:sQTBKYPdzn9mmWX2JXZBtGBvNQH7cuXIwsl4TD0aMgE=
|
gitea.tecamino.com/paadi/tecamino-logger v0.2.1 h1:sQTBKYPdzn9mmWX2JXZBtGBvNQH7cuXIwsl4TD0aMgE=
|
||||||
@@ -23,6 +27,10 @@ github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w
|
|||||||
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
||||||
github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=
|
github.com/gin-gonic/gin v1.11.0 h1:OW/6PLjyusp2PPXtyxKHU0RbX6I/l28FTdDlae5ueWk=
|
||||||
github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls=
|
github.com/gin-gonic/gin v1.11.0/go.mod h1:+iq/FyxlGzII0KHiBGjuNn4UNENUlKbGlNmc+W50Dls=
|
||||||
|
github.com/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo=
|
||||||
|
github.com/glebarez/go-sqlite v1.21.2/go.mod h1:sfxdZyhQjTM2Wry3gVYWaW072Ri1WMdWJi0k6+3382k=
|
||||||
|
github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw=
|
||||||
|
github.com/glebarez/sqlite v1.11.0/go.mod h1:h8/o8j5wiAsqSPoWELDUdJXhjAhsVliSn7bWZjOhrgQ=
|
||||||
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=
|
||||||
@@ -35,8 +43,8 @@ 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/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
|
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
|
||||||
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
||||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
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=
|
||||||
@@ -44,6 +52,12 @@ github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17k
|
|||||||
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/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
|
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||||
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
|
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||||
|
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||||
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.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||||
@@ -94,23 +108,23 @@ 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.20.0 h1:dx1zTU0MAE98U+TQ8BLl7XsJbgze2WnNKF/8tGp/Q6c=
|
golang.org/x/arch v0.20.0 h1:dx1zTU0MAE98U+TQ8BLl7XsJbgze2WnNKF/8tGp/Q6c=
|
||||||
golang.org/x/arch v0.20.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
|
golang.org/x/arch v0.20.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk=
|
||||||
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
|
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
|
||||||
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
|
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
|
||||||
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
|
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
|
||||||
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
|
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
|
||||||
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
|
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
|
||||||
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
|
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
|
||||||
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
|
golang.org/x/net v0.45.0 h1:RLBg5JKixCy82FtLJpeNlVM0nrSqpCRYzVU1n8kj0tM=
|
||||||
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
|
golang.org/x/net v0.45.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
|
||||||
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
||||||
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||||
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.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
|
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
|
||||||
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
|
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
|
||||||
golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU=
|
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
|
||||||
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=
|
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
|
||||||
golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg=
|
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
|
||||||
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
|
google.golang.org/protobuf v1.36.9 h1:w2gp2mA27hUeUzj9Ex9FBjsBm40zfaDtEWow293U7Iw=
|
||||||
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
google.golang.org/protobuf v1.36.9/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
@@ -119,6 +133,8 @@ gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYs
|
|||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gorm.io/gorm v1.31.0 h1:0VlycGreVhK7RF/Bwt51Fk8v0xLiiiFdbGDPIZQ7mJY=
|
||||||
|
gorm.io/gorm v1.31.0/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
|
||||||
modernc.org/cc/v4 v4.26.2 h1:991HMkLjJzYBIfha6ECZdjrIYz2/1ayr+FL8GN+CNzM=
|
modernc.org/cc/v4 v4.26.2 h1:991HMkLjJzYBIfha6ECZdjrIYz2/1ayr+FL8GN+CNzM=
|
||||||
modernc.org/cc/v4 v4.26.2/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
|
modernc.org/cc/v4 v4.26.2/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
|
||||||
modernc.org/ccgo/v4 v4.28.0 h1:rjznn6WWehKq7dG4JtLRKxb52Ecv8OUGah8+Z/SfpNU=
|
modernc.org/ccgo/v4 v4.28.0 h1:rjznn6WWehKq7dG4JtLRKxb52Ecv8OUGah8+Z/SfpNU=
|
||||||
|
|||||||
125
backend/main.go
@@ -1,9 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"backend/env"
|
||||||
"backend/models"
|
"backend/models"
|
||||||
"backend/server"
|
"backend/server"
|
||||||
"backend/user"
|
|
||||||
"backend/utils"
|
"backend/utils"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -14,9 +14,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
AccessHandler "gitea.tecamino.com/paadi/access-handler"
|
||||||
|
dbApi "gitea.tecamino.com/paadi/memberDB/api"
|
||||||
"gitea.tecamino.com/paadi/tecamino-dbm/cert"
|
"gitea.tecamino.com/paadi/tecamino-dbm/cert"
|
||||||
|
|
||||||
dbApi "gitea.tecamino.com/paadi/memberDB/api"
|
|
||||||
"gitea.tecamino.com/paadi/tecamino-logger/logging"
|
"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"
|
||||||
@@ -27,20 +28,27 @@ 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")
|
envFile := flag.String("env", ".env", "enviroment file")
|
||||||
workingDir := flag.String("workingDirectory", ".", "quasar spa files")
|
|
||||||
ip := flag.String("ip", "0.0.0.0", "server listening ip")
|
|
||||||
organization := flag.String("organization", "", "self signed ciertificate organization")
|
organization := flag.String("organization", "", "self signed ciertificate organization")
|
||||||
port := flag.Uint("port", 9500, "server listening port")
|
|
||||||
https := flag.Bool("https", false, "serves as https needs flag -cert and -chain")
|
|
||||||
sslCert := flag.String("cert", "", "ssl certificate path")
|
|
||||||
sslChain := flag.String("chain", "", "ssl chain path")
|
|
||||||
debug := flag.Bool("debug", false, "log debug")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
// load enviroment file if exists
|
||||||
|
if err := env.Load(*envFile); err != nil {
|
||||||
|
fmt.Println("no .env found path: ", *envFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
devMode := env.InDevelopmentMode()
|
||||||
|
// set gin mode
|
||||||
|
if !devMode {
|
||||||
|
gin.SetMode(env.GinMode.GetValue())
|
||||||
|
}
|
||||||
|
|
||||||
|
workingDir := env.WorkingDir.GetValue()
|
||||||
|
spa := env.Spa.GetValue()
|
||||||
|
|
||||||
//change working directory only if value is given
|
//change working directory only if value is given
|
||||||
if *workingDir != "." && *workingDir != "" {
|
if workingDir != "." && workingDir != "" {
|
||||||
os.Chdir(*workingDir)
|
os.Chdir(workingDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
@@ -55,18 +63,18 @@ func main() {
|
|||||||
MaxSize: 1,
|
MaxSize: 1,
|
||||||
MaxBackup: 3,
|
MaxBackup: 3,
|
||||||
MaxAge: 28,
|
MaxAge: 28,
|
||||||
Debug: *debug,
|
Debug: env.InDebugMode(),
|
||||||
TerminalOut: true,
|
TerminalOut: true,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("main new logger", err.Error())
|
logger.Error("main new logger", err)
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//new login manager
|
//new login manager
|
||||||
userManager, err := user.NewUserManager(".")
|
accessHandler, err := AccessHandler.NewAccessHandler(".", logger)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("main login manager", err.Error())
|
logger.Error("main login manager", err)
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,25 +82,30 @@ func main() {
|
|||||||
s := server.NewServer()
|
s := server.NewServer()
|
||||||
|
|
||||||
// initiate Database handler
|
// initiate Database handler
|
||||||
dbHandler := dbApi.NewAPIHandler()
|
dbHandler, err := dbApi.NewAPIHandler(logger)
|
||||||
|
if err != nil {
|
||||||
|
logger.Error("main login manager", err)
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
//get local ip
|
//get local ip
|
||||||
httpString := "http://"
|
httpString := "http://"
|
||||||
if *https {
|
if env.Https.GetBoolValue() {
|
||||||
httpString = "https://"
|
httpString = "https://"
|
||||||
|
|
||||||
}
|
}
|
||||||
allowOrigins = append(allowOrigins, httpString+"localhost:9000", httpString+"localhost:9500", httpString+"127.0.0.1:9500")
|
allowOrigins = append(allowOrigins, httpString+"localhost:9000", httpString+"localhost:9500", httpString+"127.0.0.1:9000", httpString+"0.0.0.0: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))
|
||||||
} else {
|
} else {
|
||||||
allowOrigins = append(allowOrigins, fmt.Sprintf("%s%s:9000", httpString, localIP), fmt.Sprintf("%s%s:9500", httpString, localIP))
|
allowOrigins = append(allowOrigins, fmt.Sprintf("%s%s:9000", httpString, localIP), fmt.Sprintf("%s%s:9500", httpString, localIP))
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Routes.Use(cors.New(cors.Config{
|
s.Routes.Use(cors.New(cors.Config{
|
||||||
AllowOrigins: allowOrigins,
|
AllowOrigins: allowOrigins,
|
||||||
|
//AllowOrigins: []string{"*"},
|
||||||
AllowMethods: []string{"POST", "GET", "DELETE", "OPTIONS"},
|
AllowMethods: []string{"POST", "GET", "DELETE", "OPTIONS"},
|
||||||
AllowHeaders: []string{"Origin", "Content-Type"},
|
AllowHeaders: []string{"Origin", "Content-Type"},
|
||||||
ExposeHeaders: []string{"Content-Length"},
|
ExposeHeaders: []string{"Content-Length"},
|
||||||
@@ -100,86 +113,100 @@ func main() {
|
|||||||
MaxAge: 12 * time.Hour,
|
MaxAge: 12 * time.Hour,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
//set logger for AuthMiddleware
|
||||||
|
accessHandler.SetMiddlewareLogger(s.Routes)
|
||||||
api := s.Routes.Group("/api")
|
api := s.Routes.Group("/api")
|
||||||
//set routes
|
//set routes
|
||||||
|
|
||||||
//public
|
//public
|
||||||
api.GET("/logout", userManager.Logout)
|
api.GET("/logout", accessHandler.Logout)
|
||||||
api.GET("/login/me", userManager.Me)
|
api.GET("/login/me", accessHandler.Me)
|
||||||
|
|
||||||
api.POST("/login", userManager.Login)
|
api.POST("/login", accessHandler.Login)
|
||||||
|
|
||||||
//private
|
//private
|
||||||
auth := api.Group("/secure", user.AuthMiddleware())
|
auth := api.Group("", accessHandler.AuthMiddleware())
|
||||||
|
|
||||||
auth.GET("/users", userManager.GetUserById)
|
role := auth.Group("", accessHandler.AuthorizeRole("/api"))
|
||||||
auth.GET("/members", dbHandler.GetMemberById)
|
role.GET("/members", dbHandler.GetMember)
|
||||||
auth.GET("/roles", userManager.GetRoleById)
|
auth.GET("/events", dbHandler.GetEvent)
|
||||||
|
|
||||||
|
auth.GET("/users", accessHandler.GetUser)
|
||||||
|
auth.GET("/roles", accessHandler.GetRole)
|
||||||
|
|
||||||
auth.POST("database/open", dbHandler.OpenDatabase)
|
auth.POST("database/open", dbHandler.OpenDatabase)
|
||||||
auth.POST("/members/add", dbHandler.AddNewMember)
|
auth.POST("/members/add", dbHandler.AddNewMember)
|
||||||
auth.POST("/members/edit", dbHandler.EditMember)
|
auth.POST("/members/edit", dbHandler.UpdateMember)
|
||||||
auth.POST("/members/delete", dbHandler.DeleteMember)
|
auth.POST("/members/delete", dbHandler.DeleteMember)
|
||||||
auth.POST("/members/import/csv", dbHandler.ImportCSV)
|
auth.POST("/members/import/csv", dbHandler.ImportCSV)
|
||||||
|
|
||||||
auth.POST("/settings/update", userManager.UpdateSettings)
|
auth.POST("/events/add", dbHandler.StartNewEvent)
|
||||||
|
auth.POST("/events/edit", dbHandler.UpdateEvent)
|
||||||
|
auth.POST("/events/add/attendees", dbHandler.AddNewAttendees)
|
||||||
|
auth.POST("/events/delete/attendees", dbHandler.DeleteAttendee)
|
||||||
|
auth.POST("/events/delete", dbHandler.DeleteEvent)
|
||||||
|
|
||||||
auth.POST("/roles/add", userManager.AddRole)
|
auth.GET("/responsible", dbHandler.GetResponsible)
|
||||||
auth.POST("/roles/update", userManager.UpdateRole)
|
auth.POST("/responsible/add", dbHandler.AddNewResponsible)
|
||||||
auth.POST("/roles/delete", userManager.DeleteRole)
|
auth.POST("/responsible/delete", dbHandler.DeleteResponsible)
|
||||||
|
|
||||||
auth.POST("/users/add", userManager.AddUser)
|
auth.POST("/roles/add", accessHandler.AddRole)
|
||||||
auth.POST("/users/delete", userManager.DeleteUser)
|
auth.POST("/roles/update", accessHandler.UpdateRole)
|
||||||
|
auth.POST("/roles/delete", accessHandler.DeleteRole)
|
||||||
|
|
||||||
auth.POST("/login/refresh", userManager.Refresh)
|
auth.POST("/users/add", accessHandler.AddUser)
|
||||||
|
auth.POST("/users/update", accessHandler.UpdateUser)
|
||||||
|
auth.POST("/users/delete", accessHandler.DeleteUser)
|
||||||
|
|
||||||
|
api.POST("/login/refresh", accessHandler.Refresh)
|
||||||
|
|
||||||
// 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, models.NewJsonErrorMessageResponse("API endpoint not found"))
|
c.JSON(http.StatusNotFound, models.NewJsonMessageResponse("API endpoint not found"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Try to serve file from SPA directory
|
// Try to serve file from SPA directory
|
||||||
filePath := filepath.Join(*spa, c.Request.URL.Path)
|
filePath := filepath.Join(spa, c.Request.URL.Path)
|
||||||
if _, err := os.Stat(filePath); err == nil {
|
if _, err := os.Stat(filePath); err == nil {
|
||||||
c.File(filePath)
|
c.File(filePath)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Fallback to index.html for SPA routing
|
// Fallback to index.html for SPA routing
|
||||||
c.File(filepath.Join(*spa, "index.html"))
|
c.File(filepath.Join(spa, "index.html"))
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
if err := utils.OpenBrowser(fmt.Sprintf("%slocalhost:%d", httpString, *port), logger); err != nil {
|
if err := utils.OpenBrowser(fmt.Sprintf("%slocalhost:%s", httpString, env.Port.GetValue()), logger); err != nil {
|
||||||
logger.Error("main", fmt.Sprintf("starting browser error : %s", err.Error()))
|
logger.Error("main", fmt.Sprintf("starting browser error : %s", err))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if *https {
|
if env.Https.GetBoolValue() {
|
||||||
if *sslCert == "" {
|
if env.Fullchain.GetValue() == "" {
|
||||||
logger.Error("ssl certificate", "-cert flag not given for https server")
|
logger.Error("ssl certificate", "-cert flag not given for https server")
|
||||||
log.Fatal("-cert flag not given for https server")
|
log.Fatal("-cert flag not given for https server")
|
||||||
}
|
}
|
||||||
if *sslChain == "" {
|
if env.PrivKey.GetValue() == "" {
|
||||||
logger.Error("ssl key", "-chain flag not given for https server")
|
logger.Error("ssl key", "-chain flag not given for https server")
|
||||||
log.Fatal("-chain flag not given for https server")
|
log.Fatal("-chain flag not given for https server")
|
||||||
}
|
}
|
||||||
|
|
||||||
// start https server
|
// start https server
|
||||||
logger.Info("main", fmt.Sprintf("https listen on ip: %s port: %d", *ip, *port))
|
logger.Info("main", fmt.Sprintf("https listen on ip: %s port: %s", env.Url.GetValue(), env.Port.GetValue()))
|
||||||
if err := s.ServeHttps(*ip, *port, cert.Cert{Organization: *organization, CertFile: *sslCert, KeyFile: *sslChain}); err != nil {
|
if err := s.ServeHttps(env.Url.GetValue(), env.Port.GetUIntValue(), cert.Cert{Organization: *organization, CertFile: env.Fullchain.GetValue(), KeyFile: env.PrivKey.GetValue()}); err != nil {
|
||||||
logger.Error("main", "error https server "+err.Error())
|
logger.Error("main", "error https server "+err.Error())
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// start http server
|
// start http server
|
||||||
logger.Info("main", fmt.Sprintf("http listen on ip: %s port: %d", *ip, *port))
|
logger.Info("main", fmt.Sprintf("http listen on ip: %s port: %s", env.Url.GetValue(), env.Port.GetValue()))
|
||||||
if err := s.ServeHttp(*ip, *port); err != nil {
|
if err := s.ServeHttp(env.Url.GetValue(), env.Port.GetUIntValue()); err != nil {
|
||||||
logger.Error("main", "error http server "+err.Error())
|
logger.Error("main", "error http server "+err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,16 +5,14 @@ type JsonResponse struct {
|
|||||||
Message string `json:"message,omitempty"`
|
Message string `json:"message,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewJsonErrorMessageResponse(msg string) JsonResponse {
|
func NewJsonMessageResponse(msg string) JsonResponse {
|
||||||
return JsonResponse{
|
return JsonResponse{
|
||||||
Error: true,
|
|
||||||
Message: msg,
|
Message: msg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewJsonErrorResponse(err error) JsonResponse {
|
func NewJsonErrorResponse(err error) JsonResponse {
|
||||||
return JsonResponse{
|
return JsonResponse{
|
||||||
Error: true,
|
|
||||||
Message: err.Error(),
|
Message: err.Error(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
package models
|
|
||||||
|
|
||||||
type Rights struct {
|
|
||||||
Name string `json:"name,omitempty"`
|
|
||||||
Read bool `json:"read,omitempty"`
|
|
||||||
Write bool `json:"write,omitempty"`
|
|
||||||
Delete bool `json:"delete,omitempty"`
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package models
|
|
||||||
|
|
||||||
type Role struct {
|
|
||||||
Id int `json:"id"`
|
|
||||||
Role string `json:"role"`
|
|
||||||
Rights []Rights `json:"rights"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Role) IsValid() bool {
|
|
||||||
return r.Role != ""
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package models
|
|
||||||
|
|
||||||
type Settings struct {
|
|
||||||
PrimaryColor string `json:"primaryColor,omitempty"`
|
|
||||||
SecondaryColor string `json:"secondaryColor,omitempty"`
|
|
||||||
Icon string `json:"icon,omitempty"`
|
|
||||||
DatabaseName string `json:"databaseName,omitempty"`
|
|
||||||
DatabaseToken string `json:"databaseToken,omitempty"`
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
package models
|
|
||||||
|
|
||||||
type User struct {
|
|
||||||
Id int `json:"id"`
|
|
||||||
Name string `json:"user"`
|
|
||||||
Email string `json:"email"`
|
|
||||||
Role string `json:"role"`
|
|
||||||
Password string `json:"password,omitempty"`
|
|
||||||
Settings Settings `json:"settings"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u *User) IsValid() bool {
|
|
||||||
return u.Name != ""
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package user
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"github.com/golang-jwt/jwt/v5"
|
|
||||||
)
|
|
||||||
|
|
||||||
func AuthMiddleware() gin.HandlerFunc {
|
|
||||||
return func(c *gin.Context) {
|
|
||||||
// Read access token from cookie
|
|
||||||
cookie, err := c.Cookie("access_token")
|
|
||||||
if err != nil {
|
|
||||||
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"message": "not logged in"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
token, err := jwt.Parse(cookie, func(t *jwt.Token) (any, error) {
|
|
||||||
return JWT_SECRET, nil
|
|
||||||
})
|
|
||||||
if err != nil || !token.Valid {
|
|
||||||
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"message": "invalid token"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.Next()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func AuthorizeRole(roles ...string) gin.HandlerFunc {
|
|
||||||
return func(c *gin.Context) {
|
|
||||||
userRole := c.GetString("role")
|
|
||||||
for _, role := range roles {
|
|
||||||
if userRole == role {
|
|
||||||
c.Next()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"message": "Forbidden"})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,181 +0,0 @@
|
|||||||
package user
|
|
||||||
|
|
||||||
import (
|
|
||||||
"backend/dbRequest"
|
|
||||||
"backend/models"
|
|
||||||
"backend/utils"
|
|
||||||
"encoding/json"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"github.com/golang-jwt/jwt/v5"
|
|
||||||
_ "modernc.org/sqlite"
|
|
||||||
)
|
|
||||||
|
|
||||||
var JWT_SECRET = []byte("4h5Jza1Fn_zuzu&417%8nH*UH100+55-")
|
|
||||||
var DOMAIN = "localhost"
|
|
||||||
var ACCESS_TOKEN_TIME = 15 * time.Minute
|
|
||||||
var REFRESH_TOKEN_TIME = 72 * time.Hour
|
|
||||||
|
|
||||||
func (um *UserManager) Login(c *gin.Context) {
|
|
||||||
if !um.databaseOpened(c) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
body, err := io.ReadAll(c.Request.Body)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
user := models.User{}
|
|
||||||
err = json.Unmarshal(body, &user)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !user.IsValid() {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse("user empty"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var storedPassword, settingsJsonString string
|
|
||||||
if err := um.database.QueryRow(dbRequest.DBQueryPassword, user.Name).Scan(&user.Id, &user.Role, &storedPassword, &settingsJsonString); dbRequest.CheckDBError(c, user.Name, err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err = json.Unmarshal([]byte(settingsJsonString), &user.Settings)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse(err.Error()))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !utils.CheckPassword(user.Password, storedPassword) {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse("wrong password"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- Create JWT tokens ----
|
|
||||||
accessTokenExp := time.Now().Add(ACCESS_TOKEN_TIME)
|
|
||||||
refreshTokenExp := time.Now().Add(REFRESH_TOKEN_TIME)
|
|
||||||
|
|
||||||
// Create token
|
|
||||||
accessToken := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
|
|
||||||
"id": user.Id,
|
|
||||||
"username": user.Name,
|
|
||||||
"role": user.Role,
|
|
||||||
"type": "access",
|
|
||||||
"exp": accessTokenExp.Unix(),
|
|
||||||
})
|
|
||||||
|
|
||||||
refreshToken := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
|
|
||||||
"id": user.Id,
|
|
||||||
"username": user.Name,
|
|
||||||
"role": user.Role,
|
|
||||||
"type": "refresh",
|
|
||||||
"exp": refreshTokenExp.Unix(),
|
|
||||||
})
|
|
||||||
|
|
||||||
accessString, err := accessToken.SignedString(JWT_SECRET)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, models.NewJsonErrorMessageResponse("could not create access token"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
refreshString, err := refreshToken.SignedString(JWT_SECRET)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusInternalServerError, models.NewJsonErrorMessageResponse("could not create refresh token"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- Set secure cookies ----
|
|
||||||
secure := gin.Mode() == gin.ReleaseMode
|
|
||||||
c.SetCookie("access_token", accessString, int(time.Until(accessTokenExp).Seconds()),
|
|
||||||
"/", "", secure, true) // Path=/, Secure=true (only HTTPS), HttpOnly=true
|
|
||||||
c.SetCookie("refresh_token", refreshString, int(time.Until(refreshTokenExp).Seconds()),
|
|
||||||
"/", "", secure, true)
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"message": "login successful",
|
|
||||||
"id": user.Id,
|
|
||||||
"user": user.Name,
|
|
||||||
"role": user.Role,
|
|
||||||
"settings": user.Settings,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (um *UserManager) Refresh(c *gin.Context) {
|
|
||||||
refreshCookie, err := c.Cookie("refresh_token")
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusUnauthorized, gin.H{"message": "no refresh token"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
token, err := jwt.Parse(refreshCookie, func(token *jwt.Token) (any, error) {
|
|
||||||
return JWT_SECRET, nil
|
|
||||||
})
|
|
||||||
if err != nil || !token.Valid {
|
|
||||||
c.JSON(http.StatusUnauthorized, gin.H{"message": "invalid refresh token"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
claims, ok := token.Claims.(jwt.MapClaims)
|
|
||||||
if !ok || claims["type"] != "refresh" {
|
|
||||||
c.JSON(http.StatusUnauthorized, gin.H{"message": "invalid token type"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
username := claims["username"].(string)
|
|
||||||
id := claims["id"].(float64)
|
|
||||||
role := claims["role"].(string)
|
|
||||||
|
|
||||||
// new access token
|
|
||||||
accessExp := time.Now().Add(ACCESS_TOKEN_TIME)
|
|
||||||
newAccess := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{
|
|
||||||
"id": id,
|
|
||||||
"username": username,
|
|
||||||
"role": role,
|
|
||||||
"exp": accessExp.Unix(),
|
|
||||||
})
|
|
||||||
accessString, _ := newAccess.SignedString(JWT_SECRET)
|
|
||||||
|
|
||||||
c.SetCookie("access_token", accessString, int(time.Until(accessExp).Seconds()), "/", DOMAIN, gin.Mode() == gin.ReleaseMode, true)
|
|
||||||
c.JSON(http.StatusOK, gin.H{"message": "token refreshed"})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (um *UserManager) Me(c *gin.Context) {
|
|
||||||
// Read access token from cookie
|
|
||||||
cookie, err := c.Cookie("access_token")
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusUnauthorized, gin.H{"message": "not logged in"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify token
|
|
||||||
token, err := jwt.Parse(cookie, func(t *jwt.Token) (any, error) {
|
|
||||||
return JWT_SECRET, nil
|
|
||||||
})
|
|
||||||
if err != nil || !token.Valid {
|
|
||||||
c.JSON(http.StatusUnauthorized, gin.H{"message": "invalid token"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
claims := token.Claims.(jwt.MapClaims)
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"id": claims["id"],
|
|
||||||
"user": claims["username"],
|
|
||||||
"role": claims["role"],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (um *UserManager) Logout(c *gin.Context) {
|
|
||||||
secure := gin.Mode() == gin.ReleaseMode
|
|
||||||
|
|
||||||
c.SetCookie("access_token", "", -1, "/", DOMAIN, secure, true)
|
|
||||||
c.SetCookie("refresh_token", "", -1, "/", DOMAIN, secure, true)
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{"message": "logged out"})
|
|
||||||
}
|
|
||||||
@@ -1,261 +0,0 @@
|
|||||||
package user
|
|
||||||
|
|
||||||
import (
|
|
||||||
"backend/dbRequest"
|
|
||||||
"backend/models"
|
|
||||||
"backend/utils"
|
|
||||||
"database/sql"
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
type UserManager struct {
|
|
||||||
database *sql.DB
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewUserManager(dir string) (*UserManager, error) {
|
|
||||||
if dir == "" {
|
|
||||||
dir = "."
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
|
||||||
var um UserManager
|
|
||||||
file := fmt.Sprintf("%s/user.db", dir)
|
|
||||||
|
|
||||||
um.database, err = sql.Open("sqlite", file)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := os.Stat(file); err != nil {
|
|
||||||
_, err = um.database.Exec(dbRequest.CreateUserTable)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
hash, err := utils.HashPassword("tecamino@2025")
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
_, err = um.database.Exec(dbRequest.NewUser, "admin", "", "admin", hash, `{"databaseName":"members.dba","primaryColor":"#1976d2", "secondaryColor":"#26a69a"}`)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return &um, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (um *UserManager) databaseOpened(c *gin.Context) bool {
|
|
||||||
if um.database == nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": "no database opened",
|
|
||||||
})
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (um *UserManager) AddUser(c *gin.Context) {
|
|
||||||
if !um.databaseOpened(c) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
body, err := io.ReadAll(c.Request.Body)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
user := models.User{}
|
|
||||||
err = json.Unmarshal(body, &user)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !user.IsValid() {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse("user empty"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var exists bool
|
|
||||||
|
|
||||||
if err := um.database.QueryRow(dbRequest.DBUserLookup, user.Name).Scan(&exists); dbRequest.CheckDBError(c, user.Name, err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if exists {
|
|
||||||
c.JSON(http.StatusOK, models.NewJsonErrorMessageResponse(fmt.Sprintf("user '%s' exists already", user.Name)))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
hash, err := utils.HashPassword(user.Password)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !utils.IsValidEmail(user.Email) {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(errors.New("not valid email address")))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := um.database.Exec(dbRequest.NewUser, user.Name, user.Email, user.Role, hash, "{}"); dbRequest.CheckDBError(c, user.Name, err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"message": fmt.Sprintf("user '%s' successfully added", user.Name),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (um *UserManager) GetUserById(c *gin.Context) {
|
|
||||||
if !um.databaseOpened(c) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var i int
|
|
||||||
var err error
|
|
||||||
|
|
||||||
id := c.Query("id")
|
|
||||||
if id != "" {
|
|
||||||
i, err = strconv.Atoi(id)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
query := `SELECT id, username, email, role, settings FROM users`
|
|
||||||
var args any
|
|
||||||
if i > 0 {
|
|
||||||
query = `
|
|
||||||
SELECT id, username, email, role, settings FROM users
|
|
||||||
WHERE id = ?
|
|
||||||
`
|
|
||||||
args = i
|
|
||||||
}
|
|
||||||
|
|
||||||
rows, err := um.database.Query(query, args)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
var users []models.User
|
|
||||||
|
|
||||||
for rows.Next() {
|
|
||||||
var id int
|
|
||||||
var name, email, role, settingsString string
|
|
||||||
if err = rows.Scan(&id, &name, &email, &role, &settingsString); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var settings models.Settings
|
|
||||||
err := json.Unmarshal([]byte(settingsString), &settings)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
users = append(users, models.User{
|
|
||||||
Id: id,
|
|
||||||
Name: name,
|
|
||||||
Email: email,
|
|
||||||
Role: role,
|
|
||||||
Settings: settings,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.JSON(http.StatusOK, users)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (um *UserManager) DeleteUser(c *gin.Context) {
|
|
||||||
if !um.databaseOpened(c) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
queryId := c.Query("id")
|
|
||||||
|
|
||||||
if queryId == "" || queryId == "null" || queryId == "undefined" {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": "id query missing or wrong value: " + queryId,
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var request struct {
|
|
||||||
Ids []int `json:"ids"`
|
|
||||||
}
|
|
||||||
|
|
||||||
err := c.BindJSON(&request)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(request.Ids) == 0 {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": "no ids given to be deleted",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var ownId string
|
|
||||||
placeholders := make([]string, len(request.Ids))
|
|
||||||
args := make([]any, len(request.Ids))
|
|
||||||
for i, id := range request.Ids {
|
|
||||||
if queryId == fmt.Sprint(id) {
|
|
||||||
ownId = queryId
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
placeholders[i] = "?"
|
|
||||||
args[i] = id
|
|
||||||
}
|
|
||||||
|
|
||||||
query := fmt.Sprintf("DELETE FROM users WHERE id IN (%s)", strings.Join(placeholders, ","))
|
|
||||||
|
|
||||||
_, err = um.database.Exec(query, args...)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if ownId != "" {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": "can not delete logged in member id: " + queryId,
|
|
||||||
"id": queryId,
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"message": "member(s) deleted",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,245 +0,0 @@
|
|||||||
package user
|
|
||||||
|
|
||||||
import (
|
|
||||||
"backend/dbRequest"
|
|
||||||
"backend/models"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (um *UserManager) AddRole(c *gin.Context) {
|
|
||||||
if !um.databaseOpened(c) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
body, err := io.ReadAll(c.Request.Body)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
role := models.Role{}
|
|
||||||
err = json.Unmarshal(body, &role)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !role.IsValid() {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorMessageResponse("user empty"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var exists bool
|
|
||||||
|
|
||||||
if err := um.database.QueryRow(dbRequest.DBRoleLookup, role.Role).Scan(&exists); dbRequest.CheckDBError(c, role.Role, err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if exists {
|
|
||||||
c.JSON(http.StatusOK, models.NewJsonErrorMessageResponse(fmt.Sprintf("role '%s' exists already", role.Role)))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonBytes, err := json.Marshal(role.Rights)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusOK, models.NewJsonErrorMessageResponse(err.Error()))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := um.database.Exec(dbRequest.NewRole, role.Role, string(jsonBytes)); dbRequest.CheckDBError(c, role.Role, err) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"message": fmt.Sprintf("role '%s' successfully added", role.Role),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (um *UserManager) GetRoleById(c *gin.Context) {
|
|
||||||
if !um.databaseOpened(c) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := um.database.Exec(dbRequest.CreateRoleTable); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var i int
|
|
||||||
var err error
|
|
||||||
|
|
||||||
id := c.Query("id")
|
|
||||||
if id != "" {
|
|
||||||
i, err = strconv.Atoi(id)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
query := `SELECT id, role, rights FROM roles`
|
|
||||||
var args any
|
|
||||||
if i > 0 {
|
|
||||||
query = `
|
|
||||||
SELECT id, role, rights FROM users
|
|
||||||
WHERE id = ?
|
|
||||||
`
|
|
||||||
args = i
|
|
||||||
}
|
|
||||||
|
|
||||||
rows, err := um.database.Query(query, args)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
var roles []models.Role
|
|
||||||
|
|
||||||
for rows.Next() {
|
|
||||||
var id int
|
|
||||||
var role, rightsString string
|
|
||||||
if err = rows.Scan(&id, &role, &rightsString); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var data struct {
|
|
||||||
Rights []models.Rights `json:"rights"`
|
|
||||||
}
|
|
||||||
err := json.Unmarshal([]byte(rightsString), &data)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
roles = append(roles, models.Role{
|
|
||||||
Id: id,
|
|
||||||
Role: role,
|
|
||||||
Rights: data.Rights,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.JSON(http.StatusOK, roles)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (um *UserManager) UpdateRole(c *gin.Context) {
|
|
||||||
if !um.databaseOpened(c) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
body, err := io.ReadAll(c.Request.Body)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
role := models.Role{}
|
|
||||||
err = json.Unmarshal(body, &role)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonBytes, err := json.Marshal(role)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusOK, models.NewJsonErrorMessageResponse(err.Error()))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := um.database.Exec(dbRequest.DBUpdateRole, string(jsonBytes), role.Role); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"message": fmt.Sprintf("role rights '%s' successfully updated", role.Role),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (um *UserManager) DeleteRole(c *gin.Context) {
|
|
||||||
if !um.databaseOpened(c) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
queryRole := c.Query("role")
|
|
||||||
|
|
||||||
if queryRole == "" || queryRole == "null" || queryRole == "undefined" {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": "role query missing or wrong value: " + queryRole,
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var request struct {
|
|
||||||
Roles []string `json:"roles"`
|
|
||||||
}
|
|
||||||
|
|
||||||
err := c.BindJSON(&request)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(request.Roles) == 0 {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": "no roles given to be deleted",
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var ownRole string
|
|
||||||
placeholders := make([]string, len(request.Roles))
|
|
||||||
args := make([]any, len(request.Roles))
|
|
||||||
for i, role := range request.Roles {
|
|
||||||
if ownRole == role {
|
|
||||||
ownRole = queryRole
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
placeholders[i] = "?"
|
|
||||||
args[i] = role
|
|
||||||
}
|
|
||||||
|
|
||||||
query := fmt.Sprintf("DELETE FROM roles WHERE role IN (%s)", strings.Join(placeholders, ","))
|
|
||||||
|
|
||||||
_, err = um.database.Exec(query, args...)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": err.Error(),
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if ownRole != "" {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{
|
|
||||||
"message": "can not delete logged in role id: " + ownRole,
|
|
||||||
"role": ownRole,
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"message": "role(s) deleted",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package user
|
|
||||||
|
|
||||||
import (
|
|
||||||
"backend/dbRequest"
|
|
||||||
"backend/models"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (um *UserManager) UpdateSettings(c *gin.Context) {
|
|
||||||
if !um.databaseOpened(c) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
body, err := io.ReadAll(c.Request.Body)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
user := models.User{}
|
|
||||||
err = json.Unmarshal(body, &user)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonBytes, err := json.Marshal(user.Settings)
|
|
||||||
if err != nil {
|
|
||||||
c.JSON(http.StatusOK, models.NewJsonErrorMessageResponse(err.Error()))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := um.database.Exec(dbRequest.DBUpdateSettings, string(jsonBytes), user.Name); err != nil {
|
|
||||||
c.JSON(http.StatusBadRequest, models.NewJsonErrorResponse(err))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
c.JSON(http.StatusOK, gin.H{
|
|
||||||
"message": fmt.Sprintf("user settings '%s' successfully updated", user.Name),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"gitea.tecamino.com/paadi/tecamino-logger/logging"
|
"gitea.tecamino.com/paadi/tecamino-logger/logging"
|
||||||
@@ -64,8 +63,3 @@ func FindAllFiles(rootDir, fileExtention string) (files []string, err error) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsValidEmail(email string) bool {
|
|
||||||
re := regexp.MustCompile(`^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$`)
|
|
||||||
return re.MatchString(email)
|
|
||||||
}
|
|
||||||
|
|||||||
25
index.html
@@ -1,19 +1,22 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title><%= productName %></title>
|
<title><%= productName %></title>
|
||||||
|
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8" />
|
||||||
<meta name="description" content="<%= productDescription %>">
|
<meta name="description" content="<%= productDescription %>" />
|
||||||
<meta name="format-detection" content="telephone=no">
|
<meta name="format-detection" content="telephone=no" />
|
||||||
<meta name="msapplication-tap-highlight" content="no">
|
<meta name="msapplication-tap-highlight" content="no" />
|
||||||
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width<% if (ctx.mode.cordova || ctx.mode.capacitor) { %>, viewport-fit=cover<% } %>">
|
<meta
|
||||||
|
name="viewport"
|
||||||
|
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width<% if (ctx.mode.cordova || ctx.mode.capacitor) { %>, viewport-fit=cover<% } %>"
|
||||||
|
/>
|
||||||
|
|
||||||
<link rel="icon" type="image/png" sizes="128x128" href="icons/favicon-128x128.png">
|
<link rel="icon" type="image/png" sizes="128x128" href="icons/favicon-128x128.png" />
|
||||||
<link rel="icon" type="image/png" sizes="96x96" href="icons/favicon-96x96.png">
|
<link rel="icon" type="image/png" sizes="96x96" href="icons/favicon-96x96.png" />
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="icons/favicon-32x32.png">
|
<link rel="icon" type="image/png" sizes="32x32" href="icons/favicon-32x32.png" />
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="icons/favicon-16x16.png">
|
<link rel="icon" type="image/png" sizes="16x16" href="icons/favicon-16x16.png" />
|
||||||
<link rel="icon" type="image/ico" href="favicon.ico">
|
<link rel="icon" type="image/ico" href="favicon.ico" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- quasar:entry-point -->
|
<!-- quasar:entry-point -->
|
||||||
|
|||||||
31
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "lightcontrol",
|
"name": "lightcontrol",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "lightcontrol",
|
"name": "lightcontrol",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capacitor-community/sqlite": "^7.0.1",
|
"@capacitor-community/sqlite": "^7.0.1",
|
||||||
@@ -19,12 +19,15 @@
|
|||||||
"vue": "^3.4.18",
|
"vue": "^3.4.18",
|
||||||
"vue-i18n": "^11.1.12",
|
"vue-i18n": "^11.1.12",
|
||||||
"vue-router": "^4.0.12",
|
"vue-router": "^4.0.12",
|
||||||
"vuedraggable": "^4.1.0"
|
"vue3-touch-events": "^5.0.13",
|
||||||
|
"vuedraggable": "^4.1.0",
|
||||||
|
"zxcvbn": "^4.4.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.14.0",
|
"@eslint/js": "^9.14.0",
|
||||||
"@quasar/app-vite": "^2.1.0",
|
"@quasar/app-vite": "^2.1.0",
|
||||||
"@types/node": "^20.5.9",
|
"@types/node": "^20.5.9",
|
||||||
|
"@types/zxcvbn": "^4.4.5",
|
||||||
"@vue/eslint-config-prettier": "^10.1.0",
|
"@vue/eslint-config-prettier": "^10.1.0",
|
||||||
"@vue/eslint-config-typescript": "^14.4.0",
|
"@vue/eslint-config-typescript": "^14.4.0",
|
||||||
"autoprefixer": "^10.4.2",
|
"autoprefixer": "^10.4.2",
|
||||||
@@ -1883,6 +1886,13 @@
|
|||||||
"@types/send": "*"
|
"@types/send": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/zxcvbn": {
|
||||||
|
"version": "4.4.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/zxcvbn/-/zxcvbn-4.4.5.tgz",
|
||||||
|
"integrity": "sha512-FZJgC5Bxuqg7Rhsm/bx6gAruHHhDQ55r+s0JhDh8CQ16fD7NsJJ+p8YMMQDhSQoIrSmjpqqYWA96oQVMNkjRyA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||||
"version": "8.31.1",
|
"version": "8.31.1",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.31.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.31.1.tgz",
|
||||||
@@ -8222,6 +8232,15 @@
|
|||||||
"typescript": ">=5.0.0"
|
"typescript": ">=5.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/vue3-touch-events": {
|
||||||
|
"version": "5.0.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/vue3-touch-events/-/vue3-touch-events-5.0.13.tgz",
|
||||||
|
"integrity": "sha512-VOprVhKsL5DaistDFU0+oLJz/LaFzVENeUzs4Hp3PeD0TVx1vNEgNgS/9WehUHlUIUuCdnmLm0TkmITjwVmUBQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"vue": "^3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/vuedraggable": {
|
"node_modules/vuedraggable": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/vuedraggable/-/vuedraggable-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/vuedraggable/-/vuedraggable-4.1.0.tgz",
|
||||||
@@ -8415,6 +8434,12 @@
|
|||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 14"
|
"node": ">= 14"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"node_modules/zxcvbn": {
|
||||||
|
"version": "4.4.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/zxcvbn/-/zxcvbn-4.4.2.tgz",
|
||||||
|
"integrity": "sha512-Bq0B+ixT/DMyG8kgX2xWcI5jUvCwqrMxSFam7m0lAf78nf04hv6lNCsyLYdyYTrCVMqNDY/206K7eExYCeSyUQ==",
|
||||||
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "lightcontrol",
|
"name": "lightcontrol",
|
||||||
"version": "1.0.1",
|
"version": "1.1.0",
|
||||||
"description": "A Tecamino App",
|
"description": "A Tecamino App",
|
||||||
"productName": "Member Database",
|
"productName": "Attendence Records",
|
||||||
"author": "A. Zuercher",
|
"author": "A. Zuercher",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
@@ -25,12 +25,15 @@
|
|||||||
"vue": "^3.4.18",
|
"vue": "^3.4.18",
|
||||||
"vue-i18n": "^11.1.12",
|
"vue-i18n": "^11.1.12",
|
||||||
"vue-router": "^4.0.12",
|
"vue-router": "^4.0.12",
|
||||||
"vuedraggable": "^4.1.0"
|
"vue3-touch-events": "^5.0.13",
|
||||||
|
"vuedraggable": "^4.1.0",
|
||||||
|
"zxcvbn": "^4.4.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^9.14.0",
|
"@eslint/js": "^9.14.0",
|
||||||
"@quasar/app-vite": "^2.1.0",
|
"@quasar/app-vite": "^2.1.0",
|
||||||
"@types/node": "^20.5.9",
|
"@types/node": "^20.5.9",
|
||||||
|
"@types/zxcvbn": "^4.4.5",
|
||||||
"@vue/eslint-config-prettier": "^10.1.0",
|
"@vue/eslint-config-prettier": "^10.1.0",
|
||||||
"@vue/eslint-config-typescript": "^14.4.0",
|
"@vue/eslint-config-typescript": "^14.4.0",
|
||||||
"autoprefixer": "^10.4.2",
|
"autoprefixer": "^10.4.2",
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 859 B After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 6.9 KiB |
@@ -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: ['auth', 'axios', 'lang', 'quasar-global'],
|
boot: ['auth', 'axios', 'lang', 'quasar-global', 'restore-route'],
|
||||||
|
|
||||||
// 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'],
|
||||||
@@ -109,7 +109,7 @@ export default defineConfig((/* ctx */) => {
|
|||||||
// you can manually specify Quasar components/directives to be available everywhere:
|
// you can manually specify Quasar components/directives to be available everywhere:
|
||||||
//
|
//
|
||||||
// components: [],
|
// components: [],
|
||||||
// directives: [],
|
//directives: [],
|
||||||
|
|
||||||
// Quasar plugins
|
// Quasar plugins
|
||||||
plugins: ['Notify', 'Dialog'],
|
plugins: ['Notify', 'Dialog'],
|
||||||
|
|||||||
@@ -32,12 +32,15 @@ settings: Iistellige
|
|||||||
databaseName: Datebank Name
|
databaseName: Datebank Name
|
||||||
token: Schlüssu
|
token: Schlüssu
|
||||||
login: Amäude
|
login: Amäude
|
||||||
|
logout: Abmäude
|
||||||
user: Benutzer
|
user: Benutzer
|
||||||
password: Passwort
|
password: Passwort
|
||||||
isRequired: isch erforderlich
|
isRequired: isch erforderlich
|
||||||
colors: Farbe
|
colors: Farbe
|
||||||
primaryColor: Primär Farb
|
primaryColor: Primär Farb
|
||||||
|
primaryColorText: Primär Text Farb
|
||||||
secondaryColor: Sekondär Farb
|
secondaryColor: Sekondär Farb
|
||||||
|
secondaryColorText: Sekondär Text Farb
|
||||||
database: Datebank
|
database: Datebank
|
||||||
general: Augemein
|
general: Augemein
|
||||||
setColors: Setz Farbe
|
setColors: Setz Farbe
|
||||||
@@ -51,12 +54,67 @@ role: Rolle
|
|||||||
addNewUser: Füeg neue Benutzer hinzue
|
addNewUser: Füeg neue Benutzer hinzue
|
||||||
expires: Ablouf
|
expires: Ablouf
|
||||||
selectUserOptions: Wähle Benutzer Optione
|
selectUserOptions: Wähle Benutzer Optione
|
||||||
prenameIsRequired: Vorname ist erforderlich
|
prenameIsRequired: Vorname isch erforderlich
|
||||||
lastNameIsRequired: Nachname ist erforderlich
|
lastNameIsRequired: Nachname isch erforderlich
|
||||||
birthdayIsRequired: Geburtstag ist erforderlich
|
birthdayIsRequired: Geburtstag isch erforderlich
|
||||||
userIsRequired: Benutzer ist erforderlich
|
userIsRequired: Benutzer isch erforderlich
|
||||||
emailIsRequired: Email ist erforderlich
|
emailIsRequired: Email isch erforderlich
|
||||||
roleIsRequired: Rolle ist erforderlich
|
roleIsRequired: Rolle isch erforderlich
|
||||||
rights: Recht
|
permissions: Recht
|
||||||
selectRoleOptions: Wähle Roue Optione
|
selectRoleOptions: Wähle Roue Optione
|
||||||
|
selectEventOptions: Wähle Verastautigs Optione
|
||||||
addNewRole: Füeg neui Roue hinzue
|
addNewRole: Füeg neui Roue hinzue
|
||||||
|
addNewEvent: Füeg neui Verastautig hinzue
|
||||||
|
veryWeak: sehr Schwach
|
||||||
|
weak: Schwach
|
||||||
|
fair: So so
|
||||||
|
good: Guet
|
||||||
|
strong: Stark
|
||||||
|
passwordIsRequired: Password isch erforderlich
|
||||||
|
passwordTooShort: Ds Passwort mues mindestens 8 Zeiche läng si
|
||||||
|
passwordNeedsUppercase: Ds Passwort mues mindestens ei Grossbuechstabe enthaute
|
||||||
|
passwordNeedsLowercase: Ds Passwort mues mindestens ei Chlibuechstabe enthaute
|
||||||
|
passwordNeedsNumber: Ds Passwort mues mindestens ei Zau enthaute
|
||||||
|
passwordNeedsSpecial: Ds Passwort mues mindestens eis Sonderzeiche enthaute
|
||||||
|
passwordDoNotMatch: Passwörter stimme nid überei
|
||||||
|
read: Lese
|
||||||
|
write: Schribe
|
||||||
|
userSettings: Benutzer Istellige
|
||||||
|
members: Mitglider
|
||||||
|
attendanceTable: Anweseheits Tabelle
|
||||||
|
excursionTable: Usflugs Tabelle
|
||||||
|
updated: aktualisiert
|
||||||
|
events: Veranstalige
|
||||||
|
eventNameIsRequired: Verastatigsname isch erforderlich
|
||||||
|
eventName: Verastatigsname
|
||||||
|
attendees: Teilnähmer
|
||||||
|
now: Jetzt
|
||||||
|
addToEvent: Füge zu Veranstautig
|
||||||
|
add: Hinzuefüege
|
||||||
|
event: Verastautig
|
||||||
|
dateAndTime: Datum und Zyt
|
||||||
|
count: Anzau
|
||||||
|
selectAttendeesOptions: Wähle Teilnehmer Optionen
|
||||||
|
addNewAttendees: Füeg neue Teilnehmer hinzue
|
||||||
|
notAllRequiredFieldsFilled: Nid aui erforderliche Felder usgfüet
|
||||||
|
memberUpdated: Mitglied aktualisiert
|
||||||
|
membersUpdated: Mitglieder aktualisiert
|
||||||
|
deleteAttendee: Teilnehmer entfernt
|
||||||
|
deleteAttendees: Teilnehmer entfernt
|
||||||
|
deleteRoles: Rolen entfernt
|
||||||
|
attendeeAdded: Teilnämer hinzuegfüegt
|
||||||
|
attendeesAdded: Teilnämer hinzuegfüegt
|
||||||
|
eventAdded: Verastautig hinzuegfüegt
|
||||||
|
userUpdated: Benutzer aktualisiert
|
||||||
|
selectResponsibleOptions: Wähle Verantwortliche Optionen
|
||||||
|
addNewResponsible: Füeg neue Verantwortliche hinzue
|
||||||
|
responsibleAdded: Veratwortläche hinzuegfüegt
|
||||||
|
responsiblesAdded: Veratwortläche hinzuegfüegt
|
||||||
|
deleteResponsible: Veratwortläche entfernt
|
||||||
|
deleteResponsibles: Veratwortläche entfernt
|
||||||
|
expiration: Ablauf
|
||||||
|
never: Nie
|
||||||
|
responsibles: Verantwortliche
|
||||||
|
comment: Bemerkung
|
||||||
|
dark_mode: Dunkel-Modus
|
||||||
|
light_mode: Hell-Modus
|
||||||
|
|||||||
@@ -32,12 +32,15 @@ settings: Einstellungen
|
|||||||
databaseName: Datenbank Name
|
databaseName: Datenbank Name
|
||||||
token: Schlüssel
|
token: Schlüssel
|
||||||
login: Anmelden
|
login: Anmelden
|
||||||
|
logout: Abmelden
|
||||||
user: Benutzer
|
user: Benutzer
|
||||||
password: Passwort
|
password: Passwort
|
||||||
isRequired: ist erforderlich
|
isRequired: ist erforderlich
|
||||||
colors: Farben
|
colors: Farben
|
||||||
primaryColor: Primär Farbe
|
primaryColor: Primär Farbe
|
||||||
|
primaryColorText: Primär Text Farbe
|
||||||
secondaryColor: Sekondär Farbe
|
secondaryColor: Sekondär Farbe
|
||||||
|
secondaryColorText: Sekondär Text Farbe
|
||||||
database: Datenbank
|
database: Datenbank
|
||||||
general: Allgemein
|
general: Allgemein
|
||||||
setColors: Setze Farben
|
setColors: Setze Farben
|
||||||
@@ -57,6 +60,61 @@ birthdayIsRequired: Geburtstag ist erforderlich
|
|||||||
userIsRequired: Benutzer ist erforderlich
|
userIsRequired: Benutzer ist erforderlich
|
||||||
emailIsRequired: Email ist erforderlich
|
emailIsRequired: Email ist erforderlich
|
||||||
roleIsRequired: Rolle ist erforderlich
|
roleIsRequired: Rolle ist erforderlich
|
||||||
rights: Rechte
|
permissions: Rechte
|
||||||
selectRoleOptions: Wähle Rollen Option
|
selectRoleOptions: Wähle Rollen Optionen
|
||||||
|
selectEventOptions: Wähle Veranstaltungs Optionen
|
||||||
addNewRole: Füge neue Rolle hinzu
|
addNewRole: Füge neue Rolle hinzu
|
||||||
|
addNewEvent: Füeg neue Veranstaltung hinzu
|
||||||
|
veryWeak: sehr Schwach
|
||||||
|
weak: Schwach
|
||||||
|
fair: Ausreichend
|
||||||
|
good: Gut
|
||||||
|
strong:
|
||||||
|
passwordIsRequired: Password ist erforderlich
|
||||||
|
passwordTooShort: Das Passwort muss mindestens 8 Zeichen lang sein
|
||||||
|
passwordNeedsUppercase: Das Passwort muss mindestens einen Großbuchstaben enthalten
|
||||||
|
passwordNeedsLowercase: Das Passwort muss mindestens einen Kleinbuchstaben enthalten
|
||||||
|
passwordNeedsNumber: Das Passwort muss mindestens eine Zahl enthalten
|
||||||
|
passwordNeedsSpecial: Das Passwort muss mindestens ein Sonderzeichen enthalten
|
||||||
|
passwordDoNotMatch: Passwörter stimmen nicht überein
|
||||||
|
read: Lesen
|
||||||
|
write: Schreiben
|
||||||
|
userSettings: Benutzer Einstellungen
|
||||||
|
members: Mitglieder
|
||||||
|
attendanceTable: Anwesenheits Tabelle
|
||||||
|
excursionTable: Ausflugs Tabelle
|
||||||
|
updated: aktualisiert
|
||||||
|
events: Veranstaltungen
|
||||||
|
eventNameIsRequired: Veranstaltungsname ist erforderlich
|
||||||
|
eventName: Veranstaltungsname
|
||||||
|
attendees: Teilnehmer
|
||||||
|
now: Jetzt
|
||||||
|
addToEvent: Füge zu Veranstaltung
|
||||||
|
add: Hinzufügen
|
||||||
|
event: Veranstaltung
|
||||||
|
dateAndTime: Datum und Zeit
|
||||||
|
count: Anzahl
|
||||||
|
selectAttendeesOptions: Wähle Teilnehmer Optionen
|
||||||
|
addNewAttendees: Füge neuen Teilnehmer hinzu
|
||||||
|
notAllRequiredFieldsFilled: Nicht alle erforderlichen Felder ausgefüllt
|
||||||
|
memberUpdated: Mitglied aktualisiert
|
||||||
|
membersUpdated: Mitglieder aktualisiert
|
||||||
|
deleteAttendee: Teilnehmer entfernt
|
||||||
|
deleteAttendees: Teilnehmer entfernt
|
||||||
|
deleteRoles: Rolen entfernt
|
||||||
|
attendeeAdded: Teilnehmer hinzugefügt
|
||||||
|
attendeesAdded: Teilnehmer hinzugefügt
|
||||||
|
eventAdded: Veranstaltung hinzugefügt
|
||||||
|
userUpdated: Benutzer aktualisiert
|
||||||
|
selectResponsibleOptions: Wähle Verantwortliche Optionen
|
||||||
|
addNewResponsible: Füge neuen Verantwortlichen hinzu
|
||||||
|
responsibleAdded: Veratwortläche hinzuegfüegt
|
||||||
|
responsiblesAdded: Verantwortliche hinzuegfüegt
|
||||||
|
deleteResponsible: Verantwortliche entfernt
|
||||||
|
deleteResponsibles: Verantwortliche entfernt
|
||||||
|
expiration: Ablauf
|
||||||
|
never: Nie
|
||||||
|
responsibles: Verantwortliche
|
||||||
|
comment: Bemerkung
|
||||||
|
dark_mode: Dunkel-Modus
|
||||||
|
light_mode: Hell-Modus
|
||||||
|
|||||||
@@ -32,12 +32,15 @@ settings: Settings
|
|||||||
databaseName: Database Name
|
databaseName: Database Name
|
||||||
token: Token
|
token: Token
|
||||||
login: Login
|
login: Login
|
||||||
|
logout: Logout
|
||||||
user: User
|
user: User
|
||||||
password: Password
|
password: Password
|
||||||
isRequired: is required
|
isRequired: is required
|
||||||
colors: Colors
|
colors: Colors
|
||||||
primaryColor: Primary Color
|
primaryColor: Primary Color
|
||||||
|
primaryColorText: Primary Text Color
|
||||||
secondaryColor: Secondary Color
|
secondaryColor: Secondary Color
|
||||||
|
secondaryColorText: Secondary Text Color
|
||||||
database: Database
|
database: Database
|
||||||
general: General
|
general: General
|
||||||
setColors: Set Colors
|
setColors: Set Colors
|
||||||
@@ -57,6 +60,61 @@ birthdayIsRequired: Birthday is required
|
|||||||
userIsRequired: User is required
|
userIsRequired: User is required
|
||||||
emailIsRequired: Email is required
|
emailIsRequired: Email is required
|
||||||
roleIsRequired: Role is required
|
roleIsRequired: Role is required
|
||||||
rights: Rights
|
permissions: Permissions
|
||||||
selectRoleOptions: Select Role Options
|
selectRoleOptions: Select Role Options
|
||||||
|
selectEventOptions: Select Event Options
|
||||||
addNewRole: Add new Role
|
addNewRole: Add new Role
|
||||||
|
addNewEvent: Add new Event
|
||||||
|
veryWeak: very Weak
|
||||||
|
weak: Weak
|
||||||
|
fair: Fair
|
||||||
|
good: Good
|
||||||
|
strong: Strong
|
||||||
|
passwordIsRequired: Password is required
|
||||||
|
passwordTooShort: Password must be at least 8 characters long
|
||||||
|
passwordNeedsUppercase: Password must contain at least one uppercase letter
|
||||||
|
passwordNeedsLowercase: Password must contain at least one lowercase letter
|
||||||
|
passwordNeedsNumber: Password must contain at least one number
|
||||||
|
passwordNeedsSpecial: Password must contain at least one special character
|
||||||
|
passwordDoNotMatch: Password do not match
|
||||||
|
read: Read
|
||||||
|
write: Write
|
||||||
|
userSettings: User Settings
|
||||||
|
members: Members
|
||||||
|
attendanceTable: Attendance Table
|
||||||
|
excursionTable: Excursion Table
|
||||||
|
updated: updated
|
||||||
|
events: Events
|
||||||
|
eventNameIsRequired: Eventname is required
|
||||||
|
eventName: Eventname
|
||||||
|
attendees: Attendees
|
||||||
|
now: Now
|
||||||
|
addToEvent: Add to event
|
||||||
|
add: Add
|
||||||
|
event: Event
|
||||||
|
dateAndTime: Date and Time
|
||||||
|
count: Count
|
||||||
|
selectAttendeesOptions: Select Attendees Options
|
||||||
|
addNewAttendees: Add new Attendee
|
||||||
|
notAllRequiredFieldsFilled: Not all required fields are filled in
|
||||||
|
memberUpdated: Member updated
|
||||||
|
membersUpdated: Members updated
|
||||||
|
deleteAttendee: Attendee deleted
|
||||||
|
deleteAttendees: Attendees deleted
|
||||||
|
deleteRoles: Roles deleted
|
||||||
|
attendeeAdded: Attendee added
|
||||||
|
attendeesAdded: Attendees added
|
||||||
|
eventAdded: Event added
|
||||||
|
userUpdated: User updated
|
||||||
|
selectResponsibleOptions: Select Responsible Options
|
||||||
|
addNewResponsible: Add Responsible
|
||||||
|
responsibleAdded: Responsible hinzuegfüegt
|
||||||
|
responsiblesAdded: Responsibles hinzuegfüegt
|
||||||
|
deleteResponsible: Responsible deleted
|
||||||
|
deleteResponsibles: Responsibles deleted
|
||||||
|
expiration: Expiration
|
||||||
|
never: Never
|
||||||
|
responsibles: Responsibles
|
||||||
|
comment: Comment
|
||||||
|
dark_mode: Dark-Mode
|
||||||
|
light_mode: Light-Mode
|
||||||
|
|||||||
@@ -14,7 +14,9 @@ export default boot(async ({ app }) => {
|
|||||||
await appApi
|
await appApi
|
||||||
.get('/login/me')
|
.get('/login/me')
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
useStore.setUser({ id: resp.data.id, username: resp.data.username, role: resp.data.role });
|
useStore
|
||||||
|
.setUser({ id: resp.data.id, username: resp.data.username, role: resp.data.role })
|
||||||
|
.catch((err) => console.error(err));
|
||||||
login.refresh().catch((err) => console.error(err));
|
login.refresh().catch((err) => console.error(err));
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|||||||
@@ -3,12 +3,11 @@ import type { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } fro
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useLogin } from 'src/vueLib/login/useLogin';
|
import { useLogin } from 'src/vueLib/login/useLogin';
|
||||||
|
|
||||||
const host = window.location.hostname;
|
const host = import.meta.env.VITE_API_URL;
|
||||||
export const portApp = 9500;
|
|
||||||
|
|
||||||
// Create axios instance
|
// Create axios instance
|
||||||
export const appApi: AxiosInstance = axios.create({
|
export const appApi: AxiosInstance = axios.create({
|
||||||
baseURL: `https://${host}:${portApp}/api`,
|
baseURL: host,
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
});
|
});
|
||||||
@@ -17,7 +16,7 @@ interface RetryRequestConfig extends AxiosRequestConfig {
|
|||||||
_retry?: boolean;
|
_retry?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const noRefreshEndpoints = ['/login', '/secure/login/refresh', '/logout'];
|
const noRefreshEndpoints = ['/login', '/login/refresh', '/logout'];
|
||||||
|
|
||||||
// ========= Refresh Queue Handling ========= //
|
// ========= Refresh Queue Handling ========= //
|
||||||
let isRefreshing = false;
|
let isRefreshing = false;
|
||||||
@@ -56,6 +55,21 @@ appApi.interceptors.response.use(
|
|||||||
|
|
||||||
// Handle unauthorized responses
|
// Handle unauthorized responses
|
||||||
if (error.response?.status === 401 && !originalRequest._retry) {
|
if (error.response?.status === 401 && !originalRequest._retry) {
|
||||||
|
const data = error.response?.data;
|
||||||
|
const serverMessage =
|
||||||
|
typeof data === 'object' && data !== null && 'message' in data
|
||||||
|
? (data as { message: string }).message
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
if (['no refresh token', 'is expired'].some((msg) => serverMessage?.includes(msg))) {
|
||||||
|
console.warn('[Axios] No refresh token — logging out');
|
||||||
|
try {
|
||||||
|
await logout();
|
||||||
|
} catch (logoutErr) {
|
||||||
|
console.error('[Axios] Logout failed:', logoutErr);
|
||||||
|
}
|
||||||
|
throw new Error('Session expired: no refresh token');
|
||||||
|
}
|
||||||
if (isRefreshing) {
|
if (isRefreshing) {
|
||||||
// Wait until refresh completes
|
// Wait until refresh completes
|
||||||
return new Promise<AxiosResponse>((resolve, reject) => {
|
return new Promise<AxiosResponse>((resolve, reject) => {
|
||||||
|
|||||||
@@ -24,10 +24,27 @@ for (const path in modules) {
|
|||||||
messages[locale] = parsed;
|
messages[locale] = parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveLocale(desiredLocale) {
|
||||||
|
if (messages[desiredLocale]) return desiredLocale;
|
||||||
|
|
||||||
|
const baseLang = desiredLocale.split('-')[0];
|
||||||
|
// exact base match (e.g. en)
|
||||||
|
if (messages[baseLang]) return baseLang;
|
||||||
|
|
||||||
|
// first locale starting with that base (e.g. en-US, en-GB)
|
||||||
|
const partialMatch = Object.keys(messages).find((l) => l.startsWith(baseLang));
|
||||||
|
if (partialMatch) return partialMatch;
|
||||||
|
|
||||||
|
// fallback to English or the first available
|
||||||
|
return messages['en'] ? 'en' : Object.keys(messages)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectedLocale = resolveLocale(savedLang || systemLocale);
|
||||||
|
|
||||||
const i18n = createI18n({
|
const i18n = createI18n({
|
||||||
legacy: false, // Composition API mode
|
legacy: false, // Composition API mode
|
||||||
locale: savedLang || systemLocale,
|
locale: selectedLocale,
|
||||||
fallbackLocale: systemLocale,
|
fallbackLocale: resolveLocale(selectedLocale),
|
||||||
messages,
|
messages,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,46 @@
|
|||||||
import { boot } from 'quasar/wrappers';
|
import { boot } from 'quasar/wrappers';
|
||||||
import { setQuasarInstance } from 'src/utils/globalQ';
|
import { setQuasarInstance } from 'src/vueLib/utils/globalQ';
|
||||||
import { setRouterInstance } from 'src/utils/globalRouter';
|
import { setRouterInstance } from 'src/vueLib/utils/globalRouter';
|
||||||
import { databaseName } from 'src/vueLib/tables/members/MembersTable';
|
import { databaseName, logo, appName } from 'src/vueLib/models/settings';
|
||||||
import { Logo } from 'src/vueLib/models/logo';
|
import { Dark } from 'quasar';
|
||||||
|
|
||||||
export default boot(({ app, router }) => {
|
export default boot(({ app, router }) => {
|
||||||
setRouterInstance(router); // store router for global access
|
setRouterInstance(router); // store router for global access
|
||||||
const $q = app.config.globalProperties.$q;
|
const $q = app.config.globalProperties.$q;
|
||||||
setQuasarInstance($q);
|
setQuasarInstance($q);
|
||||||
|
|
||||||
Logo.value = localStorage.getItem('icon') ?? Logo.value;
|
Dark.set(localStorage.getItem('mode') === 'true');
|
||||||
|
|
||||||
|
logo.value = localStorage.getItem('icon') ?? logo.value;
|
||||||
|
appName.value = localStorage.getItem('appName') ?? appName.value;
|
||||||
databaseName.value = localStorage.getItem('databaseName') ?? databaseName.value;
|
databaseName.value = localStorage.getItem('databaseName') ?? databaseName.value;
|
||||||
let primaryColor = localStorage.getItem('primaryColor');
|
let primaryColor = localStorage.getItem('primaryColor');
|
||||||
if (primaryColor == null || primaryColor === 'undefined' || primaryColor.trim() === '') {
|
if (primaryColor == null || primaryColor === 'undefined' || primaryColor.trim() === '') {
|
||||||
primaryColor = null;
|
primaryColor = null;
|
||||||
}
|
}
|
||||||
|
let primaryColorText = localStorage.getItem('primaryColorText');
|
||||||
|
if (
|
||||||
|
primaryColorText == null ||
|
||||||
|
primaryColorText === 'undefined' ||
|
||||||
|
primaryColorText.trim() === ''
|
||||||
|
) {
|
||||||
|
primaryColorText = null;
|
||||||
|
}
|
||||||
let secondaryColor = localStorage.getItem('secondaryColor');
|
let secondaryColor = localStorage.getItem('secondaryColor');
|
||||||
if (secondaryColor == null || secondaryColor === 'undefined' || secondaryColor.trim() === '') {
|
if (secondaryColor == null || secondaryColor === 'undefined' || secondaryColor.trim() === '') {
|
||||||
secondaryColor = null;
|
secondaryColor = null;
|
||||||
}
|
}
|
||||||
|
let secondaryColorText = localStorage.getItem('secondaryColorText');
|
||||||
|
if (
|
||||||
|
secondaryColorText == null ||
|
||||||
|
secondaryColorText === 'undefined' ||
|
||||||
|
secondaryColorText.trim() === ''
|
||||||
|
) {
|
||||||
|
secondaryColorText = null;
|
||||||
|
}
|
||||||
|
|
||||||
document.documentElement.style.setProperty('--q-primary', primaryColor ?? '#1976d2');
|
document.documentElement.style.setProperty('--q-primary', primaryColor ?? '#1976d2');
|
||||||
|
document.documentElement.style.setProperty('--q-primary-text', primaryColorText ?? '#ffffff');
|
||||||
document.documentElement.style.setProperty('--q-secondary', secondaryColor ?? '#26a69a');
|
document.documentElement.style.setProperty('--q-secondary', secondaryColor ?? '#26a69a');
|
||||||
|
document.documentElement.style.setProperty('--q-secondary-text', secondaryColorText ?? '#ffffff');
|
||||||
});
|
});
|
||||||
|
|||||||
40
src/boot/restore-route.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import { boot } from 'quasar/wrappers';
|
||||||
|
import { useUserStore } from 'src/vueLib/login/userStore';
|
||||||
|
import { appApi } from './axios';
|
||||||
|
|
||||||
|
export default boot(async ({ router }) => {
|
||||||
|
const userStore = useUserStore();
|
||||||
|
// load user
|
||||||
|
try {
|
||||||
|
const { data } = await appApi.get('/login/me');
|
||||||
|
await userStore.setUser(data);
|
||||||
|
} catch {
|
||||||
|
/* ignore error */
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore logic after router is ready but before navigation
|
||||||
|
router.isReady().then(() => {
|
||||||
|
const lastRoute = localStorage.getItem('lastRoute');
|
||||||
|
const currentPath = router.currentRoute.value.fullPath;
|
||||||
|
|
||||||
|
// Restore only if:
|
||||||
|
// - we’re on root ("/" or "/#/"), and
|
||||||
|
// - a last route exists, and
|
||||||
|
// - the user is authenticated
|
||||||
|
if (
|
||||||
|
lastRoute &&
|
||||||
|
['/', '/#/', '/#/index.html'].includes(currentPath) &&
|
||||||
|
userStore.isAuthenticated
|
||||||
|
) {
|
||||||
|
router.replace(lastRoute).catch(() => {});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Save the route after every successful navigation
|
||||||
|
router.afterEach((to) => {
|
||||||
|
// Don't save login page as "last route"
|
||||||
|
if (to.path !== '/login' && to.path !== '/') {
|
||||||
|
localStorage.setItem('lastRoute', to.fullPath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
121
src/components/AddToEvent.vue
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
<template>
|
||||||
|
<DialogFrame ref="dialog" :header-title="localTitle">
|
||||||
|
<div class="row justify-center">
|
||||||
|
<q-select
|
||||||
|
autofocus
|
||||||
|
:label="$t('event')"
|
||||||
|
filled
|
||||||
|
:options="events"
|
||||||
|
option-label="name"
|
||||||
|
option-value="id"
|
||||||
|
v-model="selected"
|
||||||
|
@keyup.enter="addAttendees"
|
||||||
|
map-options
|
||||||
|
emit-value
|
||||||
|
></q-select>
|
||||||
|
</div>
|
||||||
|
<div class="row justify-center">
|
||||||
|
<q-btn class="q-ma-md" color="primary" no-caps @click="addAttendees">{{ localTitle }}</q-btn>
|
||||||
|
</div>
|
||||||
|
</DialogFrame>
|
||||||
|
<EditAllDialog
|
||||||
|
ref="newEventRef"
|
||||||
|
v-on:update="
|
||||||
|
(val) => {
|
||||||
|
resolveNewEvent(val);
|
||||||
|
NotifyResponse($t('memberUpdated'));
|
||||||
|
}
|
||||||
|
"
|
||||||
|
></EditAllDialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { appApi } from 'src/boot/axios';
|
||||||
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
|
import { i18n } from 'src/boot/lang';
|
||||||
|
import type { Event, Events } from 'src/vueLib/models/event';
|
||||||
|
import type { Members } from 'src/vueLib/models/member';
|
||||||
|
import EditAllDialog from 'src/components/EventEditAllDialog.vue';
|
||||||
|
import { useAttendeesTable } from 'src/vueLib/tables/attendees/AttendeesTable';
|
||||||
|
import { useEventTable } from 'src/vueLib/tables/events/EventsTable';
|
||||||
|
|
||||||
|
const dialog = ref();
|
||||||
|
const newEventRef = ref();
|
||||||
|
const localTitle = ref('');
|
||||||
|
const events = ref<Events>([{ id: -1, name: i18n.global.t('addNewEvent'), attendees: [] }]);
|
||||||
|
const selected = ref<Event>({ id: -1, name: i18n.global.t('addNewEvent'), attendees: [] });
|
||||||
|
const localMembers = ref<Members>([]);
|
||||||
|
const { updateAttendees } = useAttendeesTable();
|
||||||
|
const { updateEvents } = useEventTable();
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
endpoint: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
queryId: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['update-event']);
|
||||||
|
const { NotifyResponse } = useNotify();
|
||||||
|
|
||||||
|
function open(title: string, members: Members) {
|
||||||
|
localTitle.value = title;
|
||||||
|
localMembers.value = members;
|
||||||
|
|
||||||
|
events.value = [{ id: -1, name: i18n.global.t('addNewEvent'), attendees: [] }];
|
||||||
|
appApi
|
||||||
|
.get('events')
|
||||||
|
.then((resp) => {
|
||||||
|
events.value.push(...resp.data);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
NotifyResponse(err, 'error');
|
||||||
|
});
|
||||||
|
dialog.value?.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function addAttendees() {
|
||||||
|
const payload = {
|
||||||
|
id: Number(selected.value),
|
||||||
|
attendees: localMembers.value,
|
||||||
|
};
|
||||||
|
if (selected.value.id == -1) {
|
||||||
|
const event = await addNewEvent();
|
||||||
|
NotifyResponse(i18n.global.t('eventAdded') + ': ' + event.name);
|
||||||
|
payload.id = event.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
await appApi
|
||||||
|
.post(props.endpoint, payload)
|
||||||
|
.then(() => {
|
||||||
|
emit('update-event', localMembers.value);
|
||||||
|
if (localMembers.value.length > 1) {
|
||||||
|
NotifyResponse(i18n.global.t('attendeesAdded'));
|
||||||
|
} else {
|
||||||
|
NotifyResponse(i18n.global.t('attendeeAdded'));
|
||||||
|
}
|
||||||
|
dialog.value.close();
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
NotifyResponse(err, 'error');
|
||||||
|
});
|
||||||
|
|
||||||
|
await updateAttendees();
|
||||||
|
updateEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
let resolveNewEvent!: (value: Event) => void;
|
||||||
|
function addNewEvent(): Promise<Event> {
|
||||||
|
newEventRef.value?.open(null);
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
resolveNewEvent = resolve;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ open });
|
||||||
|
</script>
|
||||||
@@ -1,17 +1,57 @@
|
|||||||
<template>
|
<template>
|
||||||
<DialogFrame ref="dialog" :header-title="'Edit ' + localTitle">
|
<DialogFrame ref="dialog" :header-title="'Edit ' + localTitle">
|
||||||
<div class="row justify-center">
|
<div class="row justify-center">
|
||||||
<q-input
|
<q-input autofocus :label="localTitle" filled v-model="value" @keyup.enter="save">
|
||||||
autofocus
|
<template
|
||||||
class="q-ml-md col-6"
|
v-if="['firstVisit', 'lastVisit', 'date', 'expiration'].includes(localField)"
|
||||||
:label="localTitle"
|
v-slot:prepend
|
||||||
filled
|
>
|
||||||
v-model="value"
|
<q-icon name="event" class="cursor-pointer">
|
||||||
@keyup.enter="save"
|
<q-popup-proxy cover transition-show="scale" transition-hide="scale">
|
||||||
></q-input>
|
<q-date v-model="value" mask="YYYY-MM-DD HH:mm:ss">
|
||||||
|
<div class="row items-center justify-end">
|
||||||
|
<q-btn :label="$t('now')" color="primary" no-caps flat @click="setTimeNow" />
|
||||||
|
<q-btn
|
||||||
|
v-if="localField"
|
||||||
|
:label="$t('never')"
|
||||||
|
color="primary"
|
||||||
|
no-caps
|
||||||
|
flat
|
||||||
|
@click="value = 'never'"
|
||||||
|
/>
|
||||||
|
<q-btn no-caps v-close-popup :label="$t('close')" color="primary" flat />
|
||||||
|
</div>
|
||||||
|
</q-date>
|
||||||
|
</q-popup-proxy>
|
||||||
|
</q-icon>
|
||||||
|
</template>
|
||||||
|
<template
|
||||||
|
v-if="['firstVisit', 'lastVisit', 'date', 'expiration'].includes(localField)"
|
||||||
|
v-slot:append
|
||||||
|
>
|
||||||
|
<q-icon name="access_time" class="cursor-pointer">
|
||||||
|
<q-popup-proxy cover transition-show="scale" transition-hide="scale">
|
||||||
|
<q-time with-seconds v-model="value" mask="YYYY-MM-DD HH:mm:ss" format24h>
|
||||||
|
<div class="row items-center justify-end">
|
||||||
|
<q-btn :label="$t('now')" color="primary" no-caps flat @click="setTimeNow" />
|
||||||
|
<q-btn
|
||||||
|
v-if="localField"
|
||||||
|
:label="$t('never')"
|
||||||
|
color="primary"
|
||||||
|
no-caps
|
||||||
|
flat
|
||||||
|
@click="value = 'never'"
|
||||||
|
/>
|
||||||
|
<q-btn no-caps v-close-popup :label="$t('close')" color="primary" flat />
|
||||||
|
</div>
|
||||||
|
</q-time>
|
||||||
|
</q-popup-proxy>
|
||||||
|
</q-icon>
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
</div>
|
</div>
|
||||||
<div class="row justify-center">
|
<div class="row justify-center">
|
||||||
<q-btn class="q-ma-md" color="primary" no-caps @click="save">Save</q-btn>
|
<q-btn class="q-ma-md" color="primary" no-caps @click="save">{{ $t('save') }}</q-btn>
|
||||||
</div>
|
</div>
|
||||||
</DialogFrame>
|
</DialogFrame>
|
||||||
</template>
|
</template>
|
||||||
@@ -29,6 +69,12 @@ const localTitle = ref('');
|
|||||||
const localField = ref('');
|
const localField = ref('');
|
||||||
const value = ref('');
|
const value = ref('');
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
endpoint: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['update']);
|
const emit = defineEmits(['update']);
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
|
|
||||||
@@ -42,21 +88,29 @@ function open(label: string, field: string, member: Member) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
const query = 'secure/members/edit?id=' + localMember.value.id;
|
|
||||||
let payload = {};
|
let payload = {};
|
||||||
|
|
||||||
if (value.value === localMember.value[localField.value]) {
|
if (value.value === localMember.value[localField.value]) {
|
||||||
dialog.value.close();
|
dialog.value.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
payload = {
|
|
||||||
[localField.value]: value.value,
|
if (!props.endpoint) {
|
||||||
};
|
localMember.value[localField.value] = value.value;
|
||||||
|
emit('update', localMember.value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
payload = [
|
||||||
|
{
|
||||||
|
id: localMember.value.id,
|
||||||
|
[localField.value]: value.value,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
appApi
|
appApi
|
||||||
.post(query, payload)
|
.post(props.endpoint, payload)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
emit('update', '');
|
emit('update');
|
||||||
dialog.value.close();
|
dialog.value.close();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@@ -64,5 +118,18 @@ function save() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setTimeNow() {
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
|
const year = now.getFullYear();
|
||||||
|
const month = String(now.getMonth() + 1).padStart(2, '0'); // Months are 0-based
|
||||||
|
const day = String(now.getDate()).padStart(2, '0');
|
||||||
|
const hours = String(now.getHours()).padStart(2, '0');
|
||||||
|
const minutes = String(now.getMinutes()).padStart(2, '0');
|
||||||
|
const seconds = String(now.getSeconds()).padStart(2, '0');
|
||||||
|
|
||||||
|
value.value = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||||
|
}
|
||||||
|
|
||||||
defineExpose({ open });
|
defineExpose({ open });
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
95
src/components/EventEditAllDialog.vue
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
<template>
|
||||||
|
<DialogFrame
|
||||||
|
ref="dialog"
|
||||||
|
:header-title="newEvent ? $t('addNewEvent') : 'Edit ' + localEvent.name"
|
||||||
|
:height="250"
|
||||||
|
:width="500"
|
||||||
|
>
|
||||||
|
<q-form ref="form">
|
||||||
|
<div class="row justify-center q-gutter-md">
|
||||||
|
<q-input
|
||||||
|
class="q-ml-md col-5 required"
|
||||||
|
:label="$t('eventName')"
|
||||||
|
filled
|
||||||
|
:rules="[(val) => !!val || $t('eventNameIsRequired')]"
|
||||||
|
v-model="localEvent.name"
|
||||||
|
autofocus
|
||||||
|
@keyup.enter="save"
|
||||||
|
></q-input>
|
||||||
|
</div>
|
||||||
|
</q-form>
|
||||||
|
<div class="row justify-center">
|
||||||
|
<q-btn class="q-ma-md" color="primary" no-caps @click="save">{{ $t('save') }}</q-btn>
|
||||||
|
</div>
|
||||||
|
</DialogFrame>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { appApi } from 'src/boot/axios';
|
||||||
|
import type { Event } from 'src/vueLib/models/event';
|
||||||
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
|
|
||||||
|
const { NotifyResponse } = useNotify();
|
||||||
|
const dialog = ref();
|
||||||
|
const form = ref();
|
||||||
|
const newEvent = ref(false);
|
||||||
|
const localEvent = ref<Event>({
|
||||||
|
id: 0,
|
||||||
|
name: '',
|
||||||
|
attendees: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['update']);
|
||||||
|
|
||||||
|
function open(Event: Event | null) {
|
||||||
|
if (Event === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Event !== null) {
|
||||||
|
localEvent.value = { ...Event };
|
||||||
|
newEvent.value = Event.id === 0;
|
||||||
|
} else {
|
||||||
|
localEvent.value = {
|
||||||
|
id: 0,
|
||||||
|
name: '',
|
||||||
|
attendees: [],
|
||||||
|
};
|
||||||
|
newEvent.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog.value?.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
const valid = await form.value.validate();
|
||||||
|
|
||||||
|
if (!valid) return;
|
||||||
|
|
||||||
|
let query = 'events/edit';
|
||||||
|
let payload = JSON.stringify([localEvent.value]);
|
||||||
|
if (newEvent.value) {
|
||||||
|
query = 'events/add?name=' + localEvent.value.name;
|
||||||
|
payload = JSON.stringify(localEvent.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
appApi
|
||||||
|
.post(query, payload)
|
||||||
|
.then((resp) => {
|
||||||
|
emit('update', resp.data.data);
|
||||||
|
dialog.value.close();
|
||||||
|
})
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ open });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.required .q-field__label::after {
|
||||||
|
content: ' *';
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -25,9 +25,8 @@
|
|||||||
v-model="localMember.lastName"
|
v-model="localMember.lastName"
|
||||||
></q-input>
|
></q-input>
|
||||||
<q-input
|
<q-input
|
||||||
class="q-ml-md col-5 required"
|
class="q-ml-md col-5"
|
||||||
:label="$t('birthday')"
|
:label="$t('birthday')"
|
||||||
:rules="[(val) => !!val || $t('birthdayIsRequired')]"
|
|
||||||
filled
|
filled
|
||||||
v-model="localMember.birthday"
|
v-model="localMember.birthday"
|
||||||
></q-input>
|
></q-input>
|
||||||
@@ -67,12 +66,14 @@
|
|||||||
filled
|
filled
|
||||||
v-model="localMember.group"
|
v-model="localMember.group"
|
||||||
></q-input>
|
></q-input>
|
||||||
<q-input
|
<q-select
|
||||||
class="q-ml-md col-5"
|
class="q-ml-md col-5"
|
||||||
:label="$t('responsible')"
|
:label="$t('responsible')"
|
||||||
filled
|
filled
|
||||||
|
:options="props.responsibles"
|
||||||
|
:option-label="(opt) => opt.firstName + ' ' + opt.lastName"
|
||||||
v-model="localMember.responsiblePerson"
|
v-model="localMember.responsiblePerson"
|
||||||
></q-input>
|
></q-select>
|
||||||
<q-input
|
<q-input
|
||||||
v-if="!newMember"
|
v-if="!newMember"
|
||||||
class="q-ml-md col-11"
|
class="q-ml-md col-11"
|
||||||
@@ -90,17 +91,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</q-form>
|
</q-form>
|
||||||
<div class="row justify-center">
|
<div class="row justify-center">
|
||||||
<q-btn class="q-ma-md" color="primary" no-caps @click="save">Save</q-btn>
|
<q-btn class="q-ma-md" color="primary" no-caps @click="save">{{ $t('save') }}</q-btn>
|
||||||
</div>
|
</div>
|
||||||
</DialogFrame>
|
</DialogFrame>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
||||||
import { ref } from 'vue';
|
import { type PropType, ref } from 'vue';
|
||||||
import { appApi } from 'src/boot/axios';
|
import { appApi } from 'src/boot/axios';
|
||||||
import type { Member } from 'src/vueLib/models/member';
|
import type { Member, Members } from 'src/vueLib/models/member';
|
||||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
|
import { i18n } from 'src/boot/lang';
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
const dialog = ref();
|
const dialog = ref();
|
||||||
@@ -110,20 +112,15 @@ const localMember = ref<Member>({
|
|||||||
id: 0,
|
id: 0,
|
||||||
firstName: '',
|
firstName: '',
|
||||||
lastName: '',
|
lastName: '',
|
||||||
birthday: '',
|
|
||||||
age: '',
|
|
||||||
address: '',
|
|
||||||
town: '',
|
|
||||||
zip: '',
|
|
||||||
phone: '',
|
|
||||||
email: '',
|
|
||||||
group: '',
|
|
||||||
responsiblePerson: '',
|
|
||||||
firstVisit: '',
|
|
||||||
lastVisit: '',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['update-member']);
|
const props = defineProps({
|
||||||
|
responsibles: {
|
||||||
|
type: Object as PropType<Members>,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['update']);
|
||||||
|
|
||||||
function open(member: Member | null) {
|
function open(member: Member | null) {
|
||||||
if (member === undefined) {
|
if (member === undefined) {
|
||||||
@@ -131,24 +128,13 @@ function open(member: Member | null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (member !== null) {
|
if (member !== null) {
|
||||||
localMember.value = member;
|
localMember.value = { ...member };
|
||||||
newMember.value = false;
|
newMember.value = false;
|
||||||
} else {
|
} else {
|
||||||
localMember.value = {
|
localMember.value = {
|
||||||
id: 0,
|
id: 0,
|
||||||
firstName: '',
|
firstName: '',
|
||||||
lastName: '',
|
lastName: '',
|
||||||
birthday: '',
|
|
||||||
age: '',
|
|
||||||
address: '',
|
|
||||||
town: '',
|
|
||||||
zip: '',
|
|
||||||
phone: '',
|
|
||||||
email: '',
|
|
||||||
group: '',
|
|
||||||
responsiblePerson: '',
|
|
||||||
firstVisit: '',
|
|
||||||
lastVisit: '',
|
|
||||||
};
|
};
|
||||||
newMember.value = true;
|
newMember.value = true;
|
||||||
}
|
}
|
||||||
@@ -158,18 +144,23 @@ function open(member: Member | null) {
|
|||||||
|
|
||||||
async function save() {
|
async function save() {
|
||||||
const valid = await form.value.validate();
|
const valid = await form.value.validate();
|
||||||
|
if (!valid) {
|
||||||
if (!valid) return;
|
NotifyResponse(i18n.global.t('notAllRequiredFieldsFilled'), 'error');
|
||||||
|
return;
|
||||||
let query = 'secure/members/edit?id=' + localMember.value.id;
|
|
||||||
if (newMember.value) {
|
|
||||||
query = 'secure/members/add';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
appApi
|
let query = 'members/edit';
|
||||||
.post(query, JSON.stringify(localMember.value))
|
let payload = JSON.stringify([localMember.value]);
|
||||||
|
if (newMember.value) {
|
||||||
|
query = 'members/add';
|
||||||
|
payload = JSON.stringify(localMember.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
await appApi
|
||||||
|
.post(query, payload)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
emit('update-member');
|
emit('update');
|
||||||
|
NotifyResponse(i18n.global.t('memberUpdated'));
|
||||||
dialog.value.close();
|
dialog.value.close();
|
||||||
})
|
})
|
||||||
.catch((err) => NotifyResponse(err, 'error'));
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
|||||||
@@ -2,21 +2,32 @@
|
|||||||
<DialogFrame
|
<DialogFrame
|
||||||
ref="dialog"
|
ref="dialog"
|
||||||
:header-title="newRole ? $t('addNewRole') : 'Edit ' + localRole.role"
|
:header-title="newRole ? $t('addNewRole') : 'Edit ' + localRole.role"
|
||||||
:height="600"
|
:height="700"
|
||||||
:width="500"
|
:width="500"
|
||||||
>
|
>
|
||||||
<div class="row justify-center q-gutter-md">
|
<div class="row justify-center">
|
||||||
<q-input
|
<q-input
|
||||||
class="q-ml-md col-5 required"
|
v-if="showRoleField"
|
||||||
|
class="q-my-lg col-5 required"
|
||||||
:label="$t('role')"
|
:label="$t('role')"
|
||||||
filled
|
filled
|
||||||
:rules="[(val) => !!val || $t('roleIsRequired')]"
|
:rules="[(val) => !!val || $t('roleIsRequired')]"
|
||||||
v-model="localRole.role"
|
v-model="localRole.role"
|
||||||
autofocus
|
autofocus
|
||||||
></q-input>
|
></q-input>
|
||||||
|
<q-card>
|
||||||
|
<q-card-section class="text-h5 text-bold text-primary flex justify-center">{{
|
||||||
|
$t('permissions')
|
||||||
|
}}</q-card-section>
|
||||||
|
<q-separator color="black" />
|
||||||
|
<PermissionsCheckBoxGroup
|
||||||
|
:permissions="localRole.permissions || []"
|
||||||
|
v-on:update="(val) => (localRole.permissions = val)"
|
||||||
|
/>
|
||||||
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
<div class="row justify-center">
|
<div class="row justify-center">
|
||||||
<q-btn class="q-ma-md" color="primary" no-caps @click="save">Save</q-btn>
|
<q-btn class="q-ma-md" color="primary" no-caps @click="save">{{ $t('save') }}</q-btn>
|
||||||
</div>
|
</div>
|
||||||
</DialogFrame>
|
</DialogFrame>
|
||||||
</template>
|
</template>
|
||||||
@@ -27,29 +38,35 @@ import { ref } from 'vue';
|
|||||||
import { appApi } from 'src/boot/axios';
|
import { appApi } from 'src/boot/axios';
|
||||||
import type { Role } from 'src/vueLib/models/roles';
|
import type { Role } from 'src/vueLib/models/roles';
|
||||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
|
import PermissionsCheckBoxGroup from 'src/vueLib/checkboxes/CheckBoxGroupPermissions.vue';
|
||||||
|
import { defaultPermissions } from 'src/vueLib/checkboxes/permissions';
|
||||||
|
import { i18n } from 'src/boot/lang';
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
const dialog = ref();
|
const dialog = ref();
|
||||||
const newRole = ref(false);
|
const newRole = ref(false);
|
||||||
|
const showRoleField = ref(true);
|
||||||
const localRole = ref<Role>({
|
const localRole = ref<Role>({
|
||||||
role: '',
|
role: '',
|
||||||
rights: null,
|
permissions: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['update-role']);
|
const emit = defineEmits(['update']);
|
||||||
|
|
||||||
function open(role: Role | null) {
|
function open(role: Role | null, typ?: 'permissions') {
|
||||||
if (role === undefined) {
|
if (role === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showRoleField.value = typ !== 'permissions';
|
||||||
if (role !== null) {
|
if (role !== null) {
|
||||||
localRole.value = role;
|
localRole.value = { ...role };
|
||||||
|
localRole.value.permissions = role.permissions || defaultPermissions;
|
||||||
newRole.value = false;
|
newRole.value = false;
|
||||||
} else {
|
} else {
|
||||||
localRole.value = {
|
localRole.value = {
|
||||||
role: '',
|
role: '',
|
||||||
rights: null,
|
permissions: defaultPermissions,
|
||||||
};
|
};
|
||||||
newRole.value = true;
|
newRole.value = true;
|
||||||
}
|
}
|
||||||
@@ -58,15 +75,23 @@ function open(role: Role | null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
let query = 'secure/roles/edit?id=' + localRole.value.id;
|
let query = 'roles/update?id=' + localRole.value.id;
|
||||||
|
let update = true;
|
||||||
if (newRole.value) {
|
if (newRole.value) {
|
||||||
query = 'secure/roles/add';
|
query = 'roles/add';
|
||||||
|
update = false;
|
||||||
|
localRole.value.permissions = localRole.value.permissions ?? defaultPermissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
appApi
|
appApi
|
||||||
.post(query, JSON.stringify(localRole.value))
|
.post(query, JSON.stringify(localRole.value))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
emit('update-role');
|
if (update) {
|
||||||
|
NotifyResponse(
|
||||||
|
i18n.global.t('role') + " '" + localRole.value.role + "' " + i18n.global.t('updated'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
emit('update');
|
||||||
dialog.value.close();
|
dialog.value.close();
|
||||||
})
|
})
|
||||||
.catch((err) => NotifyResponse(err, 'error'));
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
|||||||
@@ -4,9 +4,10 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<q-uploader
|
<q-uploader
|
||||||
style="max-width: 300px"
|
style="max-width: 300px"
|
||||||
:url="`https://0.0.0.0:` + portApp + `/api/members/import/csv`"
|
url="/api/members/import/csv"
|
||||||
label="Import CSV"
|
label="Import CSV"
|
||||||
multiple
|
multiple
|
||||||
|
:with-credentials="true"
|
||||||
accept=".csv"
|
accept=".csv"
|
||||||
field-name="file"
|
field-name="file"
|
||||||
method="POST"
|
method="POST"
|
||||||
@@ -127,7 +128,6 @@ import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
|||||||
import { ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
import type { MetaData } from 'src/vueLib/models/metaData';
|
import type { MetaData } from 'src/vueLib/models/metaData';
|
||||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
import { portApp } from 'src/boot/axios';
|
|
||||||
|
|
||||||
const dialogHeight = ref(300);
|
const dialogHeight = ref(300);
|
||||||
const dialogWidth = ref(500);
|
const dialogWidth = ref(500);
|
||||||
|
|||||||
@@ -5,38 +5,103 @@
|
|||||||
:height="600"
|
:height="600"
|
||||||
:width="500"
|
:width="500"
|
||||||
>
|
>
|
||||||
<div class="row justify-center q-gutter-md">
|
<q-form ref="form">
|
||||||
<q-input
|
<div class="row justify-center q-gutter-md">
|
||||||
class="q-ml-md col-5 required"
|
<q-input
|
||||||
:label="$t('user')"
|
class="col-5 required"
|
||||||
filled
|
:label="$t('user')"
|
||||||
:rules="[(val) => !!val || $t('userIsRequired')]"
|
filled
|
||||||
v-model="localUser.user"
|
:lazy-rules="false"
|
||||||
autofocus
|
:rules="[(val) => !!val || $t('userIsRequired')]"
|
||||||
></q-input>
|
v-model="localUser.user"
|
||||||
<q-input
|
autofocus
|
||||||
class="q-ml-md col-5 required"
|
></q-input>
|
||||||
:label="$t('email')"
|
<q-input
|
||||||
filled
|
class="col-5 required"
|
||||||
:rules="[(val) => !!val || $t('emailIsRequired')]"
|
:label="$t('email')"
|
||||||
v-model="localUser.email"
|
filled
|
||||||
></q-input>
|
:lazy-rules="false"
|
||||||
<q-input
|
:rules="[(val) => !!val || $t('emailIsRequired')]"
|
||||||
class="q-ml-md col-5 required"
|
v-model="localUser.email"
|
||||||
:label="$t('role')"
|
></q-input>
|
||||||
filled
|
<div class="col-5">
|
||||||
:rules="[(val) => !!val || $t('roleIsRequired')]"
|
<q-input
|
||||||
v-model="localUser.role"
|
class="col-5 required"
|
||||||
></q-input>
|
:label="$t('password')"
|
||||||
<q-input
|
filled
|
||||||
class="q-ml-md col-5"
|
:lazy-rules="false"
|
||||||
:label="$t('expires')"
|
:rules="[validatePassword]"
|
||||||
filled
|
v-model="localUser.password"
|
||||||
v-model="localUser.expires"
|
@update:model-value="checkStrength"
|
||||||
></q-input>
|
:type="showPassword1 ? 'text' : 'password'"
|
||||||
</div>
|
>
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
:icon="showPassword1 ? 'visibility_off' : 'visibility'"
|
||||||
|
@mousedown.prevent="showPassword1 = true"
|
||||||
|
@mouseup.prevent="showPassword1 = false"
|
||||||
|
@mouseleave.prevent="showPassword1 = false"
|
||||||
|
@touchstart.prevent="showPassword1 = true"
|
||||||
|
@touchend.prevent="showPassword1 = false"
|
||||||
|
@touchcancel.prevent="showPassword1 = false"
|
||||||
|
></q-btn>
|
||||||
|
<q-icon :name="strengthIcon" :color="strengthColor"></q-icon>
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
|
||||||
|
<div class="q-mt-md q-px-xl">
|
||||||
|
<q-linear-progress :value="strengthValue" :color="strengthColor" size="8px" rounded />
|
||||||
|
<div class="text-caption text-center q-mt-xs">
|
||||||
|
{{ strengthLabel }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<q-input
|
||||||
|
class="col-5 required"
|
||||||
|
:label="$t('password')"
|
||||||
|
filled
|
||||||
|
:type="showPassword2 ? 'text' : 'password'"
|
||||||
|
:rules="[checkSamePassword]"
|
||||||
|
v-model="passwordCheck"
|
||||||
|
>
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-btn
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
:icon="showPassword2 ? 'visibility_off' : 'visibility'"
|
||||||
|
@mousedown.prevent="showPassword2 = true"
|
||||||
|
@mouseup.prevent="showPassword2 = false"
|
||||||
|
@mouseleave.prevent="showPassword2 = false"
|
||||||
|
@touchstart.prevent="showPassword2 = true"
|
||||||
|
@touchend.prevent="showPassword2 = false"
|
||||||
|
@touchcancel.prevent="showPassword2 = false"
|
||||||
|
></q-btn>
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-5">
|
||||||
|
<q-select
|
||||||
|
class="col-5 required"
|
||||||
|
:label="$t('role')"
|
||||||
|
filled
|
||||||
|
:options="props.roles"
|
||||||
|
:rules="[(val) => !!val || $t('roleIsRequired')]"
|
||||||
|
v-model="localUser.role"
|
||||||
|
></q-select>
|
||||||
|
<q-input
|
||||||
|
class="col-5 q-mt-xl"
|
||||||
|
:label="$t('expires')"
|
||||||
|
filled
|
||||||
|
type="datetime-local"
|
||||||
|
v-model="localUser.expiration"
|
||||||
|
></q-input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</q-form>
|
||||||
<div class="row justify-center">
|
<div class="row justify-center">
|
||||||
<q-btn class="q-ma-md" color="primary" no-caps @click="save">Save</q-btn>
|
<q-btn class="q-ma-md" color="primary" no-caps @click="save">{{ $t('save') }}</q-btn>
|
||||||
</div>
|
</div>
|
||||||
</DialogFrame>
|
</DialogFrame>
|
||||||
</template>
|
</template>
|
||||||
@@ -44,53 +109,117 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
import zxcvbn from 'zxcvbn';
|
||||||
import { appApi } from 'src/boot/axios';
|
import { appApi } from 'src/boot/axios';
|
||||||
import type { User } from 'src/vueLib/models/users';
|
import type { User } from 'src/vueLib/models/users';
|
||||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
|
import { validateQForm } from 'src/vueLib/utils/validation';
|
||||||
|
import { i18n } from 'src/boot/lang';
|
||||||
|
import { DefaultSettings } from 'src/vueLib/models/settings';
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
const dialog = ref();
|
const dialog = ref();
|
||||||
|
const form = ref();
|
||||||
const newUser = ref(false);
|
const newUser = ref(false);
|
||||||
|
const showPassword1 = ref(false);
|
||||||
|
const showPassword2 = ref(false);
|
||||||
|
const passwordCheck = ref('');
|
||||||
|
const strengthValue = ref(0);
|
||||||
|
const strengthLabel = ref('Enter a password');
|
||||||
|
const strengthColor = ref('grey');
|
||||||
|
const strengthIcon = ref('lock');
|
||||||
const localUser = ref<User>({
|
const localUser = ref<User>({
|
||||||
user: '',
|
user: '',
|
||||||
email: '',
|
email: '',
|
||||||
role: '',
|
role: '',
|
||||||
expires: '',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['update-user']);
|
const props = defineProps({
|
||||||
|
roles: {
|
||||||
|
type: Array,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
function open(user: User | null) {
|
const emit = defineEmits(['update']);
|
||||||
|
|
||||||
|
async function open(user: User | null) {
|
||||||
if (user === undefined) {
|
if (user === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user !== null) {
|
if (user !== null) {
|
||||||
localUser.value = user;
|
localUser.value = { ...user };
|
||||||
newUser.value = false;
|
newUser.value = false;
|
||||||
} else {
|
} else {
|
||||||
localUser.value = {
|
localUser.value = {
|
||||||
user: '',
|
user: '',
|
||||||
email: '',
|
email: '',
|
||||||
role: '',
|
role: '',
|
||||||
expires: '',
|
|
||||||
};
|
};
|
||||||
newUser.value = true;
|
newUser.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.value?.open();
|
await dialog.value?.open();
|
||||||
|
await validateQForm(form.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function checkStrength() {
|
||||||
let query = 'secure/users/edit?id=' + localUser.value.id;
|
const result = zxcvbn(localUser.value.password || '');
|
||||||
|
strengthValue.value = (result.score + 1) / 5;
|
||||||
|
const levels = [
|
||||||
|
i18n.global.t('veryWeak'),
|
||||||
|
i18n.global.t('weak'),
|
||||||
|
i18n.global.t('fair'),
|
||||||
|
i18n.global.t('good'),
|
||||||
|
i18n.global.t('strong'),
|
||||||
|
];
|
||||||
|
const colors = ['red', 'orange', 'yellow', 'light-green', 'green'];
|
||||||
|
const icon = ['lock', 'warning', 'error_outline', 'check_circle_outline', 'verified_user'];
|
||||||
|
|
||||||
|
strengthLabel.value = levels[result.score] || i18n.global.t('veryWeak');
|
||||||
|
strengthColor.value = colors[result.score] || 'grey';
|
||||||
|
strengthIcon.value = icon[result.score] || 'lock';
|
||||||
|
}
|
||||||
|
|
||||||
|
function validatePassword(): string | boolean {
|
||||||
|
if (!localUser.value.password) return i18n.global.t('passwordIsRequired');
|
||||||
|
|
||||||
|
if (localUser.value.password.length < 8) {
|
||||||
|
return i18n.global.t('passwordTooShort');
|
||||||
|
} else if (!/[A-Z]/.test(localUser.value.password)) {
|
||||||
|
return i18n.global.t('passwordNeedsUppercase');
|
||||||
|
} else if (!/[a-z]/.test(localUser.value.password)) {
|
||||||
|
return i18n.global.t('passwordNeedsLowercase');
|
||||||
|
} else if (!/[0-9]/.test(localUser.value.password)) {
|
||||||
|
return i18n.global.t('passwordNeedsNumber');
|
||||||
|
} else if (!/[!@#$%^&*(),.?":{}|<>]/.test(localUser.value.password)) {
|
||||||
|
return i18n.global.t('passwordNeedsSpecial');
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkSamePassword(): string | boolean {
|
||||||
|
if (localUser.value.password === passwordCheck.value) return true;
|
||||||
|
return i18n.global.t('passwordDoNotMatch');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save() {
|
||||||
|
if (!(await validateQForm(form.value))) {
|
||||||
|
NotifyResponse(i18n.global.t('notAllRequiredFieldsFilled'), 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let query = 'users/edit?id=' + localUser.value.id;
|
||||||
if (newUser.value) {
|
if (newUser.value) {
|
||||||
query = 'secure/users/add';
|
query = 'users/add';
|
||||||
|
localUser.value.settings = DefaultSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
appApi
|
appApi
|
||||||
.post(query, JSON.stringify(localUser.value))
|
.post(query, JSON.stringify(localUser.value))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
emit('update-user');
|
emit('update');
|
||||||
dialog.value.close();
|
dialog.value.close();
|
||||||
})
|
})
|
||||||
.catch((err) => NotifyResponse(err, 'error'));
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
|||||||
@@ -13,7 +13,9 @@
|
|||||||
// Tip: Use the "Theme Builder" on Quasar's documentation website.
|
// Tip: Use the "Theme Builder" on Quasar's documentation website.
|
||||||
|
|
||||||
$primary: #1976d2;
|
$primary: #1976d2;
|
||||||
|
$primary-text: #ffffff;
|
||||||
$secondary: #26a69a;
|
$secondary: #26a69a;
|
||||||
|
$secondary-text: #ffffff;
|
||||||
$accent: #9c27b0;
|
$accent: #9c27b0;
|
||||||
|
|
||||||
$dark: #1d1d1d;
|
$dark: #1d1d1d;
|
||||||
@@ -23,3 +25,16 @@ $positive: #21ba45;
|
|||||||
$negative: #c10015;
|
$negative: #c10015;
|
||||||
$info: #31ccec;
|
$info: #31ccec;
|
||||||
$warning: #f2c037;
|
$warning: #f2c037;
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--q-primary-text: #ffffff;
|
||||||
|
--q-secondary-text: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-primary-text {
|
||||||
|
color: var(--q-primary-text) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-secondary-text {
|
||||||
|
color: var(--q-secondary-text) !important;
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
/>
|
/>
|
||||||
<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> {{ productName }} </q-toolbar-title>
|
<q-toolbar-title class="text-primary-text"> {{ $t(appName) }} </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" />
|
||||||
@@ -18,13 +18,40 @@
|
|||||||
</q-toolbar>
|
</q-toolbar>
|
||||||
</q-header>
|
</q-header>
|
||||||
|
|
||||||
<q-drawer v-model="leftDrawerOpen" bordered>
|
<q-drawer v-model="leftDrawerOpen" bordered :width="drawerWidth" :overlay="$q.screen.lt.sm">
|
||||||
<q-list>
|
<q-list>
|
||||||
<q-item v-if="!autorized" to="/login" exact clickable v-ripple @click="closeDrawer">
|
<q-item v-if="!autorized" to="/login" exact clickable v-ripple @click="closeDrawer">
|
||||||
<q-item-section>{{ $t('login') }}</q-item-section>
|
<q-item-section>{{ $t('login') }}</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item v-if="autorized" to="/members" exact clickable v-ripple @click="closeDrawer">
|
<q-item
|
||||||
<q-item-section>Members</q-item-section>
|
v-if="autorized || user.isPermittedTo('members', 'read')"
|
||||||
|
to="/members"
|
||||||
|
exact
|
||||||
|
clickable
|
||||||
|
v-ripple
|
||||||
|
@click="closeDrawer"
|
||||||
|
>
|
||||||
|
<q-item-section> {{ $t('members') }}</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
<q-item
|
||||||
|
v-if="autorized || user.isPermittedTo('events', 'read')"
|
||||||
|
to="/events"
|
||||||
|
exact
|
||||||
|
clickable
|
||||||
|
v-ripple
|
||||||
|
@click="closeDrawer"
|
||||||
|
>
|
||||||
|
<q-item-section>{{ $t('events') }}</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
<q-item
|
||||||
|
v-if="autorized || user.isPermittedTo('responsible', 'read')"
|
||||||
|
to="/responsible"
|
||||||
|
exact
|
||||||
|
clickable
|
||||||
|
v-ripple
|
||||||
|
@click="closeDrawer"
|
||||||
|
>
|
||||||
|
<q-item-section>{{ $t('responsible') }}</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
</q-list>
|
</q-list>
|
||||||
</q-drawer>
|
</q-drawer>
|
||||||
@@ -36,16 +63,19 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { version, productName } from '../../package.json';
|
import { version } from '../../package.json';
|
||||||
import LoginMenu from 'src/vueLib/login/LoginMenu.vue';
|
import LoginMenu from 'src/vueLib/login/LoginMenu.vue';
|
||||||
import { useUserStore } from 'src/vueLib/login/userStore';
|
import { useUserStore } from 'src/vueLib/login/userStore';
|
||||||
import { Logo } from 'src/vueLib/models/logo';
|
import { logo, appName } from 'src/vueLib/models/settings';
|
||||||
|
import { useQuasar } from 'quasar';
|
||||||
|
|
||||||
const localLogo = ref(Logo);
|
const localLogo = ref(logo);
|
||||||
|
|
||||||
const leftDrawerOpen = ref(false);
|
const leftDrawerOpen = ref(false);
|
||||||
const user = useUserStore();
|
const user = useUserStore();
|
||||||
const autorized = computed(() => !!user.isAuthorizedAs(['admin']));
|
const autorized = computed(
|
||||||
|
() => user.isAuthorizedAs(['admin']) || user.isPermittedTo('settings', 'read'),
|
||||||
|
);
|
||||||
|
|
||||||
function toggleLeftDrawer() {
|
function toggleLeftDrawer() {
|
||||||
leftDrawerOpen.value = !leftDrawerOpen.value;
|
leftDrawerOpen.value = !leftDrawerOpen.value;
|
||||||
@@ -58,4 +88,10 @@ function closeDrawer() {
|
|||||||
function refresh() {
|
function refresh() {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Change width based on screen size
|
||||||
|
const drawerWidth = computed(() => {
|
||||||
|
const $q = useQuasar();
|
||||||
|
return $q.screen.lt.sm ? 220 : 300; // phone: 220px, desktop: 300px
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
21
src/pages/EventsTable.vue
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<template>
|
||||||
|
<q-page>
|
||||||
|
<EventsTable />
|
||||||
|
<DialogFrame ref="dialog" header-title="Test Frame">
|
||||||
|
<EventsTable ref="EventDialog" />
|
||||||
|
</DialogFrame>
|
||||||
|
<DialogFrame ref="uploadDialog" header-title="Test Frame">
|
||||||
|
<EventsTable ref="EventDialog" />
|
||||||
|
</DialogFrame>
|
||||||
|
</q-page>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import EventsTable from 'src/vueLib/tables/events/EventsTable.vue';
|
||||||
|
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import type { EventDialog } from 'src/vueLib/tables/events/EventsTable.vue';
|
||||||
|
|
||||||
|
const dialog = ref();
|
||||||
|
const EventDialog = ref<EventDialog>();
|
||||||
|
</script>
|
||||||
@@ -7,18 +7,21 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import LoginForm from 'src/vueLib/login/LoginForm.vue';
|
import LoginForm from 'src/vueLib/login/LoginForm.vue';
|
||||||
import { useUserStore } from 'src/vueLib/login/userStore';
|
import { useUserStore } from 'src/vueLib/login/userStore';
|
||||||
import { onMounted } from 'vue';
|
import { nextTick, onMounted } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const user = userStore.getUser();
|
if (userStore.user?.username !== '' && userStore.user?.role !== '') {
|
||||||
if (user?.username !== '' && user?.role !== '') {
|
|
||||||
forwardToPage().catch((err) => console.error(err));
|
forwardToPage().catch((err) => console.error(err));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const forwardToPage = () => router.push('/members');
|
const forwardToPage = async () => {
|
||||||
|
await nextTick();
|
||||||
|
const lastRoute = localStorage.getItem('lastRoute') || '/members';
|
||||||
|
await router.push(lastRoute);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,34 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<q-page>
|
<q-page>
|
||||||
<MembersTable />
|
<MembersTable />
|
||||||
<DialogFrame ref="dialog" header-title="Test Frame">
|
|
||||||
<MembersTable ref="memberDialog" />
|
|
||||||
<q-btn @click="getSelection">Get Selected</q-btn>
|
|
||||||
</DialogFrame>
|
|
||||||
<DialogFrame ref="uploadDialog" header-title="Test Frame">
|
|
||||||
<MembersTable ref="memberDialog" />
|
|
||||||
<q-btn @click="getSelection">Get Selected</q-btn>
|
|
||||||
</DialogFrame>
|
|
||||||
<div class="row">
|
|
||||||
<q-btn @click="open">Click Me</q-btn>
|
|
||||||
</div>
|
|
||||||
</q-page>
|
</q-page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import MembersTable from 'src/vueLib/tables/members/MembersTable.vue';
|
import MembersTable from 'src/vueLib/tables/members/MembersTable.vue';
|
||||||
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
|
||||||
import { ref } from 'vue';
|
|
||||||
import type { MemberDialog } from 'src/vueLib/tables/members/MembersTable.vue';
|
|
||||||
|
|
||||||
const dialog = ref();
|
|
||||||
const memberDialog = ref<MemberDialog>();
|
|
||||||
|
|
||||||
const open = () => dialog.value?.open();
|
|
||||||
|
|
||||||
function getSelection() {
|
|
||||||
const selected = memberDialog.value?.getSelected();
|
|
||||||
if (selected === undefined) return;
|
|
||||||
console.log(65, selected[0]?.id);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
28
src/pages/ResponsibleTable.vue
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<template>
|
||||||
|
<q-page>
|
||||||
|
<ResponsibleTable />
|
||||||
|
<DialogFrame ref="dialog" header-title="Test Frame">
|
||||||
|
<ResponsibleTable ref="memberDialog" />
|
||||||
|
<q-btn @click="getSelection">Get Selected</q-btn>
|
||||||
|
</DialogFrame>
|
||||||
|
<DialogFrame ref="uploadDialog" header-title="Test Frame">
|
||||||
|
<ResponsibleTable ref="memberDialog" />
|
||||||
|
<q-btn @click="getSelection">Get Selected</q-btn>
|
||||||
|
</DialogFrame>
|
||||||
|
</q-page>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import ResponsibleTable from 'src/vueLib/tables/responsible/ResponsibleTable.vue';
|
||||||
|
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import type { MemberDialog } from 'src/vueLib/tables/members/MembersTable.vue';
|
||||||
|
import type { Members } from 'src/vueLib/models/member';
|
||||||
|
|
||||||
|
const dialog = ref();
|
||||||
|
const memberDialog = ref<MemberDialog>();
|
||||||
|
|
||||||
|
function getSelection(): Members {
|
||||||
|
return memberDialog.value?.getSelected() || [];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -8,6 +8,19 @@
|
|||||||
<p class="text-bold text-h6 text-primary q-pa-md">{{ $t('general') }}</p>
|
<p class="text-bold text-h6 text-primary q-pa-md">{{ $t('general') }}</p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<q-input
|
<q-input
|
||||||
|
:readonly="!user.isPermittedTo('settings', 'write')"
|
||||||
|
:class="[
|
||||||
|
colorGroup ? 'col-md-4' : 'col-md-3',
|
||||||
|
colorGroup ? 'col-md-6' : 'col-md-6',
|
||||||
|
colorGroup ? 'col-md-4' : 'col-md-12',
|
||||||
|
'q-pa-md',
|
||||||
|
]"
|
||||||
|
filled
|
||||||
|
:label="$t('appName')"
|
||||||
|
v-model="settings.appName"
|
||||||
|
></q-input>
|
||||||
|
<q-input
|
||||||
|
:readonly="!user.isPermittedTo('settings', 'write')"
|
||||||
:class="[
|
:class="[
|
||||||
colorGroup ? 'col-md-4' : 'col-md-3',
|
colorGroup ? 'col-md-4' : 'col-md-3',
|
||||||
colorGroup ? 'col-md-6' : 'col-md-6',
|
colorGroup ? 'col-md-6' : 'col-md-6',
|
||||||
@@ -24,6 +37,7 @@
|
|||||||
<p class="text-bold text-h6 text-primary q-pa-md">{{ $t('database') }}</p>
|
<p class="text-bold text-h6 text-primary q-pa-md">{{ $t('database') }}</p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<q-input
|
<q-input
|
||||||
|
:readonly="!user.isPermittedTo('settings', 'write')"
|
||||||
:class="[
|
:class="[
|
||||||
colorGroup ? 'col-md-4' : 'col-md-3',
|
colorGroup ? 'col-md-4' : 'col-md-3',
|
||||||
colorGroup ? 'col-md-6' : 'col-md-6',
|
colorGroup ? 'col-md-6' : 'col-md-6',
|
||||||
@@ -52,18 +66,72 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-sm-6 col-md-3 q-px-md">
|
<div class="col-12 col-sm-6 col-md-3 q-px-md">
|
||||||
<p class="text-center text-bold text-h6 text-primary">{{ $t('primaryColor') }}</p>
|
<p class="text-center text-bold text-h6 text-primary">{{ $t('primaryColor') }}</p>
|
||||||
<q-color bordered class="q-mx-md" v-model="settings.primaryColor"></q-color>
|
<q-color
|
||||||
|
:disable="!user.isPermittedTo('settings', 'write')"
|
||||||
|
bordered
|
||||||
|
class="q-mx-md"
|
||||||
|
v-model="settings.primaryColor"
|
||||||
|
></q-color>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-sm-6 col-md-3 q-px-md">
|
||||||
|
<p
|
||||||
|
:class="[
|
||||||
|
'text-center',
|
||||||
|
'text-bold',
|
||||||
|
'text-h6',
|
||||||
|
'text-primary-text',
|
||||||
|
settings.primaryColorText === '#ffffff' ? 'bg-black' : '',
|
||||||
|
]"
|
||||||
|
:style="settings.primaryColorText === '#ffffff' ? 'opacity: 0.2;' : ''"
|
||||||
|
>
|
||||||
|
{{ $t('primaryColorText') }}
|
||||||
|
</p>
|
||||||
|
<q-color
|
||||||
|
:disable="!user.isPermittedTo('settings', 'write')"
|
||||||
|
bordered
|
||||||
|
class="q-mx-md"
|
||||||
|
v-model="settings.primaryColorText"
|
||||||
|
></q-color>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-sm-6 col-md-3 q-px-md">
|
<div class="col-12 col-sm-6 col-md-3 q-px-md">
|
||||||
<p class="text-center text-bold text-h6 text-secondary">
|
<p class="text-center text-bold text-h6 text-secondary">
|
||||||
{{ $t('secondaryColor') }}
|
{{ $t('secondaryColor') }}
|
||||||
</p>
|
</p>
|
||||||
<q-color class="q-mx-md" v-model="settings.secondaryColor"></q-color>
|
<q-color
|
||||||
|
:disable="!user.isPermittedTo('settings', 'write')"
|
||||||
|
class="q-mx-md"
|
||||||
|
v-model="settings.secondaryColor"
|
||||||
|
></q-color>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-sm-6 col-md-3 q-px-md">
|
||||||
|
<p
|
||||||
|
:class="[
|
||||||
|
'text-center',
|
||||||
|
'text-bold',
|
||||||
|
'text-h6',
|
||||||
|
'text-secondary-text',
|
||||||
|
settings.secondaryColorText === '#ffffff' ? 'bg-black' : '',
|
||||||
|
]"
|
||||||
|
:style="settings.secondaryColorText === '#ffffff' ? 'opacity: 0.2;' : ''"
|
||||||
|
>
|
||||||
|
{{ $t('secondaryColorText') }}
|
||||||
|
</p>
|
||||||
|
<q-color
|
||||||
|
:disable="!user.isPermittedTo('settings', 'write')"
|
||||||
|
class="q-mx-md"
|
||||||
|
v-model="settings.secondaryColorText"
|
||||||
|
></q-color>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<q-btn class="q-my-md q-mx-md" color="secondary" dense no-caps @click="resetColors">{{
|
<q-btn
|
||||||
$t('resetColors')
|
:disable="!user.isPermittedTo('settings', 'write')"
|
||||||
}}</q-btn>
|
class="q-my-md q-mx-md"
|
||||||
|
color="secondary"
|
||||||
|
dense
|
||||||
|
no-caps
|
||||||
|
@click="resetColors"
|
||||||
|
>{{ $t('resetColors') }}</q-btn
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</q-card>
|
</q-card>
|
||||||
<div class="row justify-end">
|
<div class="row justify-end">
|
||||||
@@ -77,44 +145,65 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { databaseName } from 'src/vueLib/tables/members/MembersTable';
|
import { logo, appName, databaseName } from 'src/vueLib/models/settings';
|
||||||
import { Logo } from 'src/vueLib/models/logo';
|
|
||||||
import { reactive, ref, watch } from 'vue';
|
import { reactive, ref, watch } from 'vue';
|
||||||
import { appApi } from 'src/boot/axios';
|
import { appApi } from 'src/boot/axios';
|
||||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
import { type Settings } from 'src/vueLib/models/settings';
|
import { type Settings } from 'src/vueLib/models/settings';
|
||||||
|
import { useUserStore } from 'src/vueLib/login/userStore';
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
const colorGroup = ref(false);
|
const colorGroup = ref(false);
|
||||||
|
const user = useUserStore();
|
||||||
|
|
||||||
const settings = reactive<Settings>({
|
const settings = reactive<Settings>({
|
||||||
icon: Logo.value,
|
appName: appName.value,
|
||||||
|
icon: logo.value,
|
||||||
databaseName: databaseName.value,
|
databaseName: databaseName.value,
|
||||||
primaryColor: document.documentElement.style.getPropertyValue('--q-primary'),
|
primaryColor: document.documentElement.style.getPropertyValue('--q-primary'),
|
||||||
|
primaryColorText: document.documentElement.style.getPropertyValue('--q-primary-text'),
|
||||||
secondaryColor: document.documentElement.style.getPropertyValue('--q-secondary'),
|
secondaryColor: document.documentElement.style.getPropertyValue('--q-secondary'),
|
||||||
|
secondaryColorText: document.documentElement.style.getPropertyValue('--q-secondary-text'),
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(settings, (newSettings) => {
|
watch(settings, (newSettings) => {
|
||||||
Logo.value = newSettings.icon;
|
logo.value = newSettings.icon;
|
||||||
|
appName.value = newSettings.appName;
|
||||||
databaseName.value = newSettings.databaseName;
|
databaseName.value = newSettings.databaseName;
|
||||||
});
|
});
|
||||||
|
|
||||||
function resetColors() {
|
function resetColors() {
|
||||||
document.documentElement.style.setProperty('--q-primary', '#1976d2');
|
document.documentElement.style.setProperty('--q-primary', '#1976d2');
|
||||||
|
settings.primaryColor = '#1976d2';
|
||||||
|
document.documentElement.style.setProperty('--q-primary-text', '#ffffff');
|
||||||
|
settings.primaryColorText = '#ffffff';
|
||||||
document.documentElement.style.setProperty('--q-secondary', '#26a69a');
|
document.documentElement.style.setProperty('--q-secondary', '#26a69a');
|
||||||
|
settings.secondaryColor = '#26a69a';
|
||||||
|
document.documentElement.style.setProperty('--q-secondary-text', '#ffffff');
|
||||||
|
settings.secondaryColorText = '#ffffff';
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
document.documentElement.style.setProperty('--q-primary', settings.primaryColor);
|
document.documentElement.style.setProperty('--q-primary', settings.primaryColor);
|
||||||
|
document.documentElement.style.setProperty('--q-primary-text', settings.primaryColorText);
|
||||||
document.documentElement.style.setProperty('--q-secondary', settings.secondaryColor);
|
document.documentElement.style.setProperty('--q-secondary', settings.secondaryColor);
|
||||||
Logo.value = settings.icon;
|
document.documentElement.style.setProperty('--q-secondary-text', settings.secondaryColorText);
|
||||||
|
appName.value = settings.appName;
|
||||||
|
logo.value = settings.icon;
|
||||||
localStorage.setItem('icon', settings.icon);
|
localStorage.setItem('icon', settings.icon);
|
||||||
|
localStorage.setItem('appName', settings.appName);
|
||||||
localStorage.setItem('databaseName', settings.databaseName);
|
localStorage.setItem('databaseName', settings.databaseName);
|
||||||
localStorage.setItem('primaryColor', settings.primaryColor);
|
localStorage.setItem('primaryColor', settings.primaryColor);
|
||||||
|
localStorage.setItem('primaryColorText', settings.primaryColorText);
|
||||||
localStorage.setItem('secondaryColor', settings.secondaryColor);
|
localStorage.setItem('secondaryColor', settings.secondaryColor);
|
||||||
|
localStorage.setItem('secondaryColorText', settings.secondaryColorText);
|
||||||
|
|
||||||
|
const tempuser = user.user;
|
||||||
|
if (tempuser) {
|
||||||
|
tempuser.settings = settings;
|
||||||
|
}
|
||||||
appApi
|
appApi
|
||||||
.post('secure/settings/update', { user: 'admin', settings })
|
.post('users/update', tempuser)
|
||||||
.then((resp) => NotifyResponse(resp.data.message))
|
.then((resp) => NotifyResponse(resp.data.message))
|
||||||
.catch((err) => NotifyResponse(err, 'error'));
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,13 +36,13 @@ export default defineRouter(function (/* { store, ssrContext } */) {
|
|||||||
|
|
||||||
Router.beforeEach((to, from, next) => {
|
Router.beforeEach((to, from, next) => {
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
const isLoggedIn = userStore.isAuthenticated;
|
const isLoggedIn = userStore.isAuthenticated;
|
||||||
const isAdmin = userStore.user?.role === 'admin';
|
|
||||||
|
|
||||||
if (to.meta.requiresAuth && !isLoggedIn) {
|
if (to.meta.requiresAuth && !isLoggedIn) {
|
||||||
next('/login');
|
next('/login');
|
||||||
} else if (to.meta.requiresAdmin && !isAdmin) {
|
} else if (
|
||||||
|
to.meta.requiresAdmin &&
|
||||||
|
!userStore.isPermittedTo(to.path.replace('/', ''), 'read')
|
||||||
|
) {
|
||||||
next('/');
|
next('/');
|
||||||
} else {
|
} else {
|
||||||
next();
|
next();
|
||||||
|
|||||||
@@ -10,21 +10,31 @@ const routes: RouteRecordRaw[] = [
|
|||||||
component: () => import('pages/LoginPage.vue'),
|
component: () => import('pages/LoginPage.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/login',
|
path: 'login',
|
||||||
component: () => import('pages/LoginPage.vue'),
|
component: () => import('pages/LoginPage.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/members',
|
path: 'members',
|
||||||
component: () => import('pages/MembersTable.vue'),
|
component: () => import('pages/MembersTable.vue'),
|
||||||
meta: { requiresAuth: true, requiresAdmin: true },
|
meta: { requiresAuth: true, requiresAdmin: true },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/settings',
|
path: 'events',
|
||||||
|
component: () => import('pages/EventsTable.vue'),
|
||||||
|
meta: { requiresAuth: true, requiresAdmin: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'responsible',
|
||||||
|
component: () => import('pages/ResponsibleTable.vue'),
|
||||||
|
meta: { requiresAuth: true, requiresAdmin: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'settings',
|
||||||
component: () => import('pages/SettingsPage.vue'),
|
component: () => import('pages/SettingsPage.vue'),
|
||||||
meta: { requiresAuth: true, requiresAdmin: true },
|
meta: { requiresAuth: true, requiresAdmin: true },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/usersSettings',
|
path: 'userSettings',
|
||||||
component: () => import('pages/UserSettings.vue'),
|
component: () => import('pages/UserSettings.vue'),
|
||||||
meta: { requiresAuth: true, requiresAdmin: true },
|
meta: { requiresAuth: true, requiresAdmin: true },
|
||||||
},
|
},
|
||||||
|
|||||||
67
src/vueLib/checkboxes/CheckBoxGroupPermissions.vue
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<template>
|
||||||
|
<q-card>
|
||||||
|
<q-card bordered v-for="(permission, index) in localPermission" v-bind:key="index">
|
||||||
|
<q-card-section class="text-center">
|
||||||
|
<div class="text-h7 text-bold text-primary">{{ $t(permission.name) }}</div>
|
||||||
|
</q-card-section>
|
||||||
|
<q-separator></q-separator>
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<q-checkbox
|
||||||
|
class="q-mx-md"
|
||||||
|
:model-value="isFlagSet(permission.permission, 1 << 0)"
|
||||||
|
@update:model-value="(val) => toggleBit(index, 0, val)"
|
||||||
|
>{{ i18n.global.t('read') }}</q-checkbox
|
||||||
|
>
|
||||||
|
<q-checkbox
|
||||||
|
class="q-mx-md"
|
||||||
|
:model-value="isFlagSet(permission.permission, 1 << 1)"
|
||||||
|
@update:model-value="(val) => toggleBit(index, 1, val)"
|
||||||
|
>{{ i18n.global.t('write') }}</q-checkbox
|
||||||
|
>
|
||||||
|
<q-checkbox
|
||||||
|
class="q-mx-md"
|
||||||
|
:model-value="isFlagSet(permission.permission, 1 << 2)"
|
||||||
|
@update:model-value="(val) => toggleBit(index, 2, val)"
|
||||||
|
>{{ i18n.global.t('delete') }}</q-checkbox
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</q-card>
|
||||||
|
</q-card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, type PropType } from 'vue';
|
||||||
|
import type { Permissions } from './permissions';
|
||||||
|
import { i18n } from 'src/boot/lang';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
permissions: {
|
||||||
|
type: Object as PropType<Permissions>,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['update']);
|
||||||
|
|
||||||
|
const localPermission = ref(
|
||||||
|
props.permissions.map((e) => ({
|
||||||
|
name: e.name,
|
||||||
|
permission: e.permission ?? 0,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
|
||||||
|
function isFlagSet(mask: number, flag: number) {
|
||||||
|
return (mask & flag) !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleBit(index: number, bit: number, value: boolean) {
|
||||||
|
const item = localPermission.value[index];
|
||||||
|
if (!item) return; // guard against undefined index
|
||||||
|
|
||||||
|
const mask = 1 << bit;
|
||||||
|
const current = item.permission ?? 0;
|
||||||
|
|
||||||
|
item.permission = value ? current | mask : current & ~mask;
|
||||||
|
emit('update', localPermission.value);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
45
src/vueLib/checkboxes/permissions.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import { i18n } from 'src/boot/lang';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
export interface Permission {
|
||||||
|
name: string;
|
||||||
|
label: string;
|
||||||
|
permission: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Permissions = Permission[];
|
||||||
|
|
||||||
|
export const defaultPermissions = [
|
||||||
|
{
|
||||||
|
name: 'settings',
|
||||||
|
label: i18n.global.t('settings'),
|
||||||
|
permission: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'userSettings',
|
||||||
|
label: i18n.global.t('userSettings'),
|
||||||
|
permission: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'members',
|
||||||
|
label: i18n.global.t('members'),
|
||||||
|
permission: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'events',
|
||||||
|
label: i18n.global.t('events'),
|
||||||
|
permission: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'responsible',
|
||||||
|
label: i18n.global.t('responsible'),
|
||||||
|
permission: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'excursionTable',
|
||||||
|
label: i18n.global.t('excursionTable'),
|
||||||
|
permission: 0,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const permissions = ref<Permissions>(defaultPermissions);
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
import { CapacitorSQLite, SQLiteConnection } from '@capacitor-community/sqlite';
|
|
||||||
import type { Settings } from '../models/settings';
|
|
||||||
|
|
||||||
const sqlite = new SQLiteConnection(CapacitorSQLite);
|
|
||||||
|
|
||||||
export async function initDB() {
|
|
||||||
const db = await sqlite.createConnection('membersDB', true, 'secreto_passwordo', 1, false);
|
|
||||||
await db.open();
|
|
||||||
await db.execute(`CREATE TABLE IF NOT EXISTS users (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
username TEXT NOT NULL,
|
|
||||||
role TEXT NOT NULL,
|
|
||||||
password TEXT NOT NULL,
|
|
||||||
settings TEXT NOT NULL
|
|
||||||
);`);
|
|
||||||
|
|
||||||
const result = await db.query(`SELECT * FROM users WHERE username = ?`, ['admin']);
|
|
||||||
if (result.values?.length === 0) {
|
|
||||||
await db.run(`INSERT INTO users (username, role, password, settings) VALUES (?, ?, ?, ?)`, [
|
|
||||||
'admin',
|
|
||||||
'admin',
|
|
||||||
'tecamino@2023',
|
|
||||||
{},
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
return db;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function addUser(user: string, role: string, password: string, settings: Settings) {
|
|
||||||
const db = await initDB();
|
|
||||||
await db.run(`INSERT INTO users (username, role, password, settings) VALUES (?, ?, ?, ?)`, [
|
|
||||||
user,
|
|
||||||
role,
|
|
||||||
password,
|
|
||||||
settings,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getUsers() {
|
|
||||||
const db = await initDB();
|
|
||||||
const resp = await db.query(`SELECT * FROM users`);
|
|
||||||
return resp.values;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getUser(user: string) {
|
|
||||||
const db = await initDB();
|
|
||||||
const resp = await db.query(`SELECT EXISTS(SELECT 1 FROM users WHERE username = ?)`, [user]);
|
|
||||||
return resp.values;
|
|
||||||
}
|
|
||||||
@@ -7,10 +7,10 @@
|
|||||||
:no-refocus="!minMaxState"
|
:no-refocus="!minMaxState"
|
||||||
:seamless="!minMaxState"
|
:seamless="!minMaxState"
|
||||||
>
|
>
|
||||||
<q-card class="layout" :style="cardStyle">
|
<q-card class="layout bg-surface text-on-surface" :style="cardStyle">
|
||||||
<!-- Draggable Header -->
|
<!-- Draggable Header -->
|
||||||
<div
|
<div
|
||||||
class="dialog-header row items-center justify-between bg-grey-1"
|
class="dialog-header row items-center justify-between bg-transparent"
|
||||||
v-touch-pan.mouse.prevent.stop="handlePan"
|
v-touch-pan.mouse.prevent.stop="handlePan"
|
||||||
>
|
>
|
||||||
<div v-if="headerTitle" class="text-left text-bold text-caption q-mx-sm">
|
<div v-if="headerTitle" class="text-left text-bold text-caption q-mx-sm">
|
||||||
@@ -139,13 +139,11 @@ const cardStyle = computed(() => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
background-color: white;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draggable header */
|
/* Draggable header */
|
||||||
.dialog-header {
|
.dialog-header {
|
||||||
padding: 8px 0;
|
padding: 8px 0;
|
||||||
background: #f5f5f5;
|
|
||||||
cursor: move;
|
cursor: move;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,9 +48,20 @@ export function useNotify() {
|
|||||||
$q?.notify({
|
$q?.notify({
|
||||||
message: message,
|
message: message,
|
||||||
color: color,
|
color: color,
|
||||||
position: 'bottom-right',
|
position: 'top',
|
||||||
icon: icon,
|
icon: icon,
|
||||||
timeout: timeout,
|
timeout: timeout,
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
icon: 'close',
|
||||||
|
color: 'white',
|
||||||
|
dense: true,
|
||||||
|
round: true,
|
||||||
|
handler: () => {
|
||||||
|
/* just closes */
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,12 @@
|
|||||||
<q-form ref="refForm">
|
<q-form ref="refForm">
|
||||||
<q-item-section class="q-gutter-md q-pa-md">
|
<q-item-section class="q-gutter-md q-pa-md">
|
||||||
<q-card :class="['q-gutter-xs q-items-center q-pa-lg', { shake: shake }]">
|
<q-card :class="['q-gutter-xs q-items-center q-pa-lg', { shake: shake }]">
|
||||||
<div class="text-h5 text-primary text-center">{{ productName }}</div>
|
<div class="text-h5 text-primary text-center">{{ $t(appName) }}</div>
|
||||||
<q-input
|
<q-input
|
||||||
ref="refUserInput"
|
ref="refUserInput"
|
||||||
dense
|
dense
|
||||||
filled
|
filled
|
||||||
|
autocomplete="username"
|
||||||
type="text"
|
type="text"
|
||||||
:label="$t('user')"
|
:label="$t('user')"
|
||||||
v-model="user"
|
v-model="user"
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
<q-input
|
<q-input
|
||||||
dense
|
dense
|
||||||
filled
|
filled
|
||||||
|
autocomplete="current-password"
|
||||||
:type="showPassword ? 'text' : 'password'"
|
:type="showPassword ? 'text' : 'password'"
|
||||||
:label="$t('password')"
|
:label="$t('password')"
|
||||||
v-model="password"
|
v-model="password"
|
||||||
@@ -27,14 +29,17 @@
|
|||||||
flat
|
flat
|
||||||
dense
|
dense
|
||||||
:icon="showPassword ? 'visibility_off' : 'visibility'"
|
:icon="showPassword ? 'visibility_off' : 'visibility'"
|
||||||
@mousedown.left="showPassword = true"
|
@mousedown.prevent="showPassword = true"
|
||||||
@mouseup.left="showPassword = false"
|
@mouseup.prevent="showPassword = false"
|
||||||
@mouseleave="showPassword = false"
|
@mouseleave.prevent="showPassword = false"
|
||||||
|
@touchstart.prevent="showPassword = true"
|
||||||
|
@touchend.prevent="showPassword = false"
|
||||||
|
@touchcancel.prevent="showPassword = false"
|
||||||
></q-btn>
|
></q-btn>
|
||||||
</template>
|
</template>
|
||||||
</q-input>
|
</q-input>
|
||||||
<div class="q-pt-sm q-mr-md row justify-end">
|
<div class="q-pt-sm q-mr-md row justify-end">
|
||||||
<q-btn color="primary" :label="$t('login')" @click="onSubmit"></q-btn>
|
<q-btn no-caps color="primary" :label="$t('login')" @click="onSubmit"></q-btn>
|
||||||
</div>
|
</div>
|
||||||
</q-card>
|
</q-card>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
@@ -42,7 +47,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { productName } from '../../../package.json';
|
import { appName } from '../models/settings';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useNotify } from '../general/useNotify';
|
import { useNotify } from '../general/useNotify';
|
||||||
import { useLogin } from './useLogin';
|
import { useLogin } from './useLogin';
|
||||||
@@ -59,25 +64,24 @@ const { login } = useLogin();
|
|||||||
|
|
||||||
const emit = defineEmits(['update-close']);
|
const emit = defineEmits(['update-close']);
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = async () => {
|
||||||
refForm.value?.validate().then((success: boolean) => {
|
const valid = refForm.value?.validate();
|
||||||
if (success) {
|
if (!valid) {
|
||||||
login(user.value, password.value)
|
NotifyResponse('error submitting login form', 'error');
|
||||||
.then(() => {
|
return;
|
||||||
NotifyResponse("logged in as '" + user.value + "'");
|
}
|
||||||
emit('update-close');
|
await login(user.value, password.value)
|
||||||
})
|
.then(() => {
|
||||||
.catch((err) => {
|
NotifyResponse("logged in as '" + user.value + "'");
|
||||||
NotifyResponse(err, 'error');
|
})
|
||||||
shake.value = true;
|
.catch((err) => {
|
||||||
setTimeout(() => {
|
NotifyResponse(err, 'error');
|
||||||
shake.value = false;
|
shake.value = true;
|
||||||
}, 500);
|
setTimeout(() => {
|
||||||
});
|
shake.value = false;
|
||||||
} else {
|
}, 500);
|
||||||
NotifyResponse('error submitting login form', 'error');
|
});
|
||||||
}
|
emit('update-close');
|
||||||
});
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,15 @@
|
|||||||
<q-btn dense flat round icon="person" :color="currentUser ? 'green' : ''">
|
<q-btn dense flat round icon="person" :color="currentUser ? 'green' : ''">
|
||||||
<q-menu ref="refLoginMenu">
|
<q-menu ref="refLoginMenu">
|
||||||
<q-list style="min-width: 120px">
|
<q-list style="min-width: 120px">
|
||||||
<q-item v-if="userLogin.getUser()" class="text-primary">{{
|
<q-item v-if="user.user" class="text-primary">{{ currentUser?.username }}</q-item>
|
||||||
currentUser?.username
|
|
||||||
}}</q-item>
|
|
||||||
<q-item v-if="showLogin" clickable v-close-popup @click="openLogin">
|
<q-item v-if="showLogin" clickable v-close-popup @click="openLogin">
|
||||||
<q-item-section class="text-primary">{{ loginText }}</q-item-section>
|
<q-item-section class="text-primary">{{ loginText }}</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
|
<q-item>
|
||||||
|
<q-btn flat :icon="darkMode" @click="toggleDarkMode"
|
||||||
|
><q-tooltip>{{ $t(darkMode) }}</q-tooltip></q-btn
|
||||||
|
>
|
||||||
|
</q-item>
|
||||||
<q-item>
|
<q-item>
|
||||||
<q-select
|
<q-select
|
||||||
:label="$t('language')"
|
:label="$t('language')"
|
||||||
@@ -17,13 +20,23 @@
|
|||||||
dense
|
dense
|
||||||
v-model="langSelected"
|
v-model="langSelected"
|
||||||
:options="langSelection"
|
:options="langSelection"
|
||||||
></q-select>
|
><q-tooltip>{{ $t('language') }}</q-tooltip></q-select
|
||||||
|
>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item v-if="autorized">
|
<q-item
|
||||||
|
v-if="
|
||||||
|
(autorized || user.isPermittedTo('settings', 'read')) && route.path !== '/settings'
|
||||||
|
"
|
||||||
|
>
|
||||||
<q-btn flat color="secondary" icon="settings" to="/settings"></q-btn>
|
<q-btn flat color="secondary" icon="settings" to="/settings"></q-btn>
|
||||||
</q-item>
|
</q-item>
|
||||||
<q-item v-if="autorized">
|
<q-item
|
||||||
<q-btn flat color="secondary" icon="group" to="/usersSettings"></q-btn>
|
v-if="
|
||||||
|
(autorized || user.isPermittedTo('userSettings', 'read')) &&
|
||||||
|
route.path !== '/userSettings'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<q-btn flat color="secondary" icon="group" to="/userSettings"></q-btn>
|
||||||
</q-item>
|
</q-item>
|
||||||
</q-list>
|
</q-list>
|
||||||
</q-menu>
|
</q-menu>
|
||||||
@@ -35,29 +48,43 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import LoginDialog from './LoginDialog.vue';
|
import LoginDialog from './LoginDialog.vue';
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { useLogin } from './useLogin';
|
|
||||||
import { useNotify } from '../general/useNotify';
|
import { useNotify } from '../general/useNotify';
|
||||||
import { lang, i18n } from 'src/boot/lang';
|
import { lang, i18n } from 'src/boot/lang';
|
||||||
import { useUserStore } from './userStore';
|
import { useUserStore } from './userStore';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
import { Dark } from 'quasar';
|
||||||
|
import { useLogin } from './useLogin';
|
||||||
|
|
||||||
|
const userLogin = useLogin();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const refLoginDialog = ref();
|
||||||
|
const user = useUserStore();
|
||||||
|
const { NotifyResponse } = useNotify();
|
||||||
|
const currentUser = computed(() => user.user);
|
||||||
|
const darkMode = computed(() => {
|
||||||
|
if (Dark.mode) {
|
||||||
|
return 'light_mode';
|
||||||
|
}
|
||||||
|
return 'dark_mode';
|
||||||
|
});
|
||||||
const showLogin = computed(
|
const showLogin = computed(
|
||||||
() => (route.path !== '/' && route.path !== '/login') || currentUser.value?.username === '',
|
() => (route.path !== '/' && route.path !== '/login') || currentUser.value?.username === '',
|
||||||
);
|
);
|
||||||
|
|
||||||
const userLogin = useLogin();
|
|
||||||
const user = useUserStore();
|
|
||||||
const autorized = computed(() => !!user.isAuthorizedAs(['admin']));
|
const autorized = computed(() => !!user.isAuthorizedAs(['admin']));
|
||||||
const { NotifyResponse } = useNotify();
|
|
||||||
const currentUser = computed(() => userLogin.getUser());
|
|
||||||
|
|
||||||
|
// switch between logged in or logged out text
|
||||||
const loginText = computed(() => {
|
const loginText = computed(() => {
|
||||||
return currentUser.value ? 'Logout' : 'Login';
|
return currentUser.value ? i18n.global.t('logout') : i18n.global.t('login');
|
||||||
});
|
});
|
||||||
|
|
||||||
const refLoginDialog = ref();
|
//switch between dark and light mode and save it in localStorage
|
||||||
|
function toggleDarkMode() {
|
||||||
|
Dark.toggle();
|
||||||
|
localStorage.setItem('mode', String(Dark.mode));
|
||||||
|
}
|
||||||
|
|
||||||
|
// opens login page if no user is logged in otherwise it serves as logout
|
||||||
function openLogin() {
|
function openLogin() {
|
||||||
if (currentUser.value) {
|
if (currentUser.value) {
|
||||||
userLogin.logout().catch((err) => NotifyResponse(err, 'error'));
|
userLogin.logout().catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { appApi } from 'src/boot/axios';
|
|||||||
import { useUserStore } from './userStore';
|
import { useUserStore } from './userStore';
|
||||||
import { useNotify } from '../general/useNotify';
|
import { useNotify } from '../general/useNotify';
|
||||||
import type { Settings } from '../models/settings';
|
import type { Settings } from '../models/settings';
|
||||||
import { Logo } from '../models/logo';
|
import { appName, logo } from '../models/settings';
|
||||||
|
|
||||||
const refreshTime = 10000;
|
const refreshTime = 10000;
|
||||||
let intervalId: ReturnType<typeof setInterval> | null = null;
|
let intervalId: ReturnType<typeof setInterval> | null = null;
|
||||||
@@ -16,17 +16,24 @@ export function useLogin() {
|
|||||||
await appApi.post('/login', { user, password }).then((resp) => {
|
await appApi.post('/login', { user, password }).then((resp) => {
|
||||||
const sets = resp.data.settings as Settings;
|
const sets = resp.data.settings as Settings;
|
||||||
|
|
||||||
Logo.value = sets.icon;
|
logo.value = sets.icon;
|
||||||
|
appName.value = sets.appName;
|
||||||
document.documentElement.style.setProperty('--q-primary', sets.primaryColor);
|
document.documentElement.style.setProperty('--q-primary', sets.primaryColor);
|
||||||
|
document.documentElement.style.setProperty('--q-primary-text', sets.primaryColorText);
|
||||||
document.documentElement.style.setProperty('--q-secondary', sets.secondaryColor);
|
document.documentElement.style.setProperty('--q-secondary', sets.secondaryColor);
|
||||||
|
document.documentElement.style.setProperty('--q-secondary-text', sets.secondaryColorText);
|
||||||
localStorage.setItem('icon', sets.icon);
|
localStorage.setItem('icon', sets.icon);
|
||||||
localStorage.setItem('databaseName', sets.databaseName);
|
localStorage.setItem('databaseName', sets.databaseName);
|
||||||
localStorage.setItem('primaryColor', sets.primaryColor);
|
localStorage.setItem('primaryColor', sets.primaryColor);
|
||||||
|
localStorage.setItem('primaryColorText', sets.primaryColorText);
|
||||||
localStorage.setItem('secondaryColor', sets.secondaryColor);
|
localStorage.setItem('secondaryColor', sets.secondaryColor);
|
||||||
|
localStorage.setItem('secondaryColorText', sets.secondaryColorText);
|
||||||
});
|
});
|
||||||
|
|
||||||
const resp = await appApi.get('/login/me');
|
const resp = await appApi.get('/login/me');
|
||||||
userStore.setUser({ id: resp.data.id, username: resp.data.user, role: resp.data.role });
|
await userStore
|
||||||
|
.setUser({ id: resp.data.id, username: resp.data.user, role: resp.data.role })
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
|
||||||
startRefreshInterval();
|
startRefreshInterval();
|
||||||
return true;
|
return true;
|
||||||
@@ -42,17 +49,20 @@ export function useLogin() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
userStore.clearUser();
|
userStore.clearUser();
|
||||||
|
localStorage.clear();
|
||||||
stopRefreshInterval();
|
stopRefreshInterval();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function refresh() {
|
async function refresh() {
|
||||||
await appApi
|
await appApi
|
||||||
.post('secure/login/refresh', {}, { withCredentials: true })
|
.post('login/refresh', {}, { withCredentials: true })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
appApi
|
appApi
|
||||||
.get('/login/me')
|
.get('/login/me')
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
userStore.setUser({ id: resp.data.id, username: resp.data.user, role: resp.data.role });
|
userStore
|
||||||
|
.setUser({ id: resp.data.id, username: resp.data.user, role: resp.data.role })
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
if (!intervalId) {
|
if (!intervalId) {
|
||||||
startRefreshInterval();
|
startRefreshInterval();
|
||||||
}
|
}
|
||||||
@@ -66,9 +76,6 @@ export function useLogin() {
|
|||||||
stopRefreshInterval();
|
stopRefreshInterval();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function getUser() {
|
|
||||||
return userStore.getUser();
|
|
||||||
}
|
|
||||||
|
|
||||||
function startRefreshInterval() {
|
function startRefreshInterval() {
|
||||||
intervalId = setInterval(() => {
|
intervalId = setInterval(() => {
|
||||||
@@ -82,5 +89,5 @@ export function useLogin() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { login, logout, refresh, getUser };
|
return { login, logout, refresh };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,52 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { useGlobalRouter } from 'src/utils/globalRouter';
|
import { useGlobalRouter } from 'src/vueLib/utils/globalRouter';
|
||||||
import { useGlobalQ } from 'src/utils/globalQ';
|
import { useGlobalQ } from 'src/vueLib/utils/globalQ';
|
||||||
|
import { appApi } from 'src/boot/axios';
|
||||||
|
import { useNotify } from '../general/useNotify';
|
||||||
|
import type { Role } from '../models/roles';
|
||||||
|
import type { UserState, User } from '../models/user';
|
||||||
|
import type { Permission } from '../checkboxes/permissions';
|
||||||
|
|
||||||
interface User {
|
const { NotifyResponse } = useNotify();
|
||||||
id: number;
|
|
||||||
username: string;
|
|
||||||
role: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface UserState {
|
|
||||||
user: User | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useUserStore = defineStore('user', {
|
export const useUserStore = defineStore('user', {
|
||||||
state: (): UserState => ({
|
state: (): UserState => ({
|
||||||
user: null,
|
user: null,
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
isAuthenticated: (state): boolean => !!state.user,
|
isAuthenticated: (state: UserState): boolean => {
|
||||||
|
return !!state.user;
|
||||||
|
},
|
||||||
|
|
||||||
|
isAuthorizedAs: (state: UserState) => {
|
||||||
|
return (roles: string[]) => {
|
||||||
|
return state.user !== null && roles.includes(state.user.role);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
isPermittedTo: (state: UserState) => {
|
||||||
|
return (name: string, type: 'read' | 'write' | 'delete'): boolean => {
|
||||||
|
const permission = state.user?.permissions?.find((r: Permission) => r.name === name);
|
||||||
|
switch (type) {
|
||||||
|
case 'read':
|
||||||
|
return permission?.permission ? (permission.permission & (1 << 0)) === 1 : false;
|
||||||
|
case 'write':
|
||||||
|
return permission?.permission ? (permission.permission & (1 << 1)) === 2 : false;
|
||||||
|
case 'delete':
|
||||||
|
return permission?.permission ? (permission.permission & (1 << 2)) === 4 : false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setUser(user: User) {
|
async setUser(user: User) {
|
||||||
this.user = user;
|
await appApi
|
||||||
},
|
.get('roles?role=' + user.role)
|
||||||
getUser() {
|
.then((resp) => {
|
||||||
return this.user;
|
const roleData = resp.data.find((role: Role) => role.role === user.role);
|
||||||
|
user.permissions = roleData?.permissions || [];
|
||||||
|
this.user = user;
|
||||||
|
})
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
},
|
},
|
||||||
clearUser() {
|
clearUser() {
|
||||||
const $q = useGlobalQ();
|
const $q = useGlobalQ();
|
||||||
@@ -34,9 +56,20 @@ export const useUserStore = defineStore('user', {
|
|||||||
$q?.notify({
|
$q?.notify({
|
||||||
message: "user '" + this.user?.username + "' logged out",
|
message: "user '" + this.user?.username + "' logged out",
|
||||||
color: 'orange',
|
color: 'orange',
|
||||||
position: 'bottom-right',
|
position: 'top',
|
||||||
icon: 'warning',
|
icon: 'warning',
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
icon: 'close',
|
||||||
|
color: 'white',
|
||||||
|
dense: true,
|
||||||
|
round: true,
|
||||||
|
handler: () => {
|
||||||
|
/* just closes */
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.error("user '" + this.user?.username + "' logged out");
|
console.error("user '" + this.user?.username + "' logged out");
|
||||||
@@ -51,18 +84,25 @@ export const useUserStore = defineStore('user', {
|
|||||||
$q?.notify({
|
$q?.notify({
|
||||||
message: err,
|
message: err,
|
||||||
color: 'orange',
|
color: 'orange',
|
||||||
position: 'bottom-right',
|
position: 'top',
|
||||||
icon: 'warning',
|
icon: 'warning',
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
icon: 'close',
|
||||||
|
color: 'white',
|
||||||
|
dense: true,
|
||||||
|
round: true,
|
||||||
|
handler: () => {
|
||||||
|
/* just closes */
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.error("user '" + this.user?.username + "' logged out");
|
console.error("user '" + this.user?.username + "' logged out");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
isAuthorizedAs(roles: string[]) {
|
|
||||||
return this.user !== null && roles.includes(this.user.role);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
9
src/vueLib/models/event.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import type { Members } from './member';
|
||||||
|
|
||||||
|
export interface Event {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
attendees: Members;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Events = Event[];
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { ref } from 'vue';
|
|
||||||
|
|
||||||
export const Logo = ref('');
|
|
||||||
@@ -2,17 +2,18 @@ export interface Member {
|
|||||||
id: number;
|
id: number;
|
||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
birthday: string;
|
birthday?: string;
|
||||||
age: string;
|
age?: string;
|
||||||
address: string;
|
comment?: string;
|
||||||
town: string;
|
address?: string;
|
||||||
zip: string;
|
town?: string;
|
||||||
phone: string;
|
zip?: string;
|
||||||
email: string;
|
phone?: string;
|
||||||
group: string;
|
email?: string;
|
||||||
responsiblePerson: string;
|
group?: string;
|
||||||
firstVisit: string;
|
responsiblePerson?: Member;
|
||||||
lastVisit: string;
|
firstVisit?: string;
|
||||||
|
lastVisit?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Members = Member[];
|
export type Members = Member[];
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
export interface Right {
|
|
||||||
name: string;
|
|
||||||
read: boolean;
|
|
||||||
write: boolean;
|
|
||||||
delete: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Rights = Right[];
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
import type { Rights } from './rights';
|
import type { Permissions } from '../checkboxes/permissions';
|
||||||
|
|
||||||
export interface Role {
|
export interface Role {
|
||||||
id?: number;
|
id?: number;
|
||||||
role: string;
|
role: string;
|
||||||
rights: Rights | null;
|
permissions: Permissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Roles = Role[];
|
export type Roles = Role[];
|
||||||
|
|||||||
@@ -1,6 +1,27 @@
|
|||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
export const logo = ref('');
|
||||||
|
export const appName = ref('Attendance Records');
|
||||||
|
export const databaseName = ref('members.dba');
|
||||||
|
|
||||||
export type Settings = {
|
export type Settings = {
|
||||||
|
appName: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
databaseName: string;
|
databaseName: string;
|
||||||
primaryColor: string;
|
primaryColor: string;
|
||||||
|
primaryColorText: string;
|
||||||
secondaryColor: string;
|
secondaryColor: string;
|
||||||
|
secondaryColorText: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function DefaultSettings(): Settings {
|
||||||
|
return {
|
||||||
|
appName: 'Attendance Records',
|
||||||
|
icon: '',
|
||||||
|
databaseName: 'members.dba',
|
||||||
|
primaryColor: document.documentElement.style.getPropertyValue('--q-primary-text'),
|
||||||
|
primaryColorText: document.documentElement.style.getPropertyValue('--q-primary'),
|
||||||
|
secondaryColor: document.documentElement.style.getPropertyValue('--q-secondary'),
|
||||||
|
secondaryColorText: document.documentElement.style.getPropertyValue('--q-secondary-text'),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
14
src/vueLib/models/user.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import type { Permissions } from '../checkboxes/permissions';
|
||||||
|
import type { Settings } from './settings';
|
||||||
|
|
||||||
|
export interface User {
|
||||||
|
id: number;
|
||||||
|
username: string;
|
||||||
|
role: string;
|
||||||
|
permissions?: Permissions;
|
||||||
|
settings?: Settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserState {
|
||||||
|
user: User | null;
|
||||||
|
}
|
||||||
@@ -1,9 +1,13 @@
|
|||||||
|
import type { Settings } from './settings';
|
||||||
|
|
||||||
export interface User {
|
export interface User {
|
||||||
id?: number;
|
id?: number;
|
||||||
user: string;
|
user: string;
|
||||||
email: string;
|
email: string;
|
||||||
role: string;
|
role: string;
|
||||||
expires: string;
|
expiration?: string;
|
||||||
|
password?: string;
|
||||||
|
settings?: Settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Users = User[];
|
export type Users = User[];
|
||||||
|
|||||||
77
src/vueLib/tables/attendees/AttendeesTable.ts
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
import { appApi } from 'src/boot/axios';
|
||||||
|
import { ref, computed } from 'vue';
|
||||||
|
import type { Members } from 'src/vueLib/models/member';
|
||||||
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
|
import { i18n } from 'boot/lang';
|
||||||
|
import type { Events } from 'src/vueLib/models/event';
|
||||||
|
|
||||||
|
export function useAttendeesTable() {
|
||||||
|
const attendees = ref<Members>([]);
|
||||||
|
|
||||||
|
const pagination = ref({
|
||||||
|
sortBy: 'firstName',
|
||||||
|
descending: false,
|
||||||
|
page: 1,
|
||||||
|
rowsPerPage: 20,
|
||||||
|
});
|
||||||
|
|
||||||
|
const columns = computed(() => [
|
||||||
|
{
|
||||||
|
name: 'firstName',
|
||||||
|
align: 'left' as const,
|
||||||
|
label: i18n.global.t('prename'),
|
||||||
|
field: 'firstName',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'lastName',
|
||||||
|
align: 'left' as const,
|
||||||
|
label: i18n.global.t('lastName'),
|
||||||
|
field: 'lastName',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{ name: 'option', align: 'center' as const, label: '', field: 'option', icon: 'option' },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const { NotifyResponse } = useNotify();
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
//updates Attendees list from database
|
||||||
|
async function updateAttendees() {
|
||||||
|
loading.value = true;
|
||||||
|
|
||||||
|
let events: Events | undefined;
|
||||||
|
|
||||||
|
await appApi
|
||||||
|
.get('events')
|
||||||
|
.then((resp) => {
|
||||||
|
if (resp.data === null) {
|
||||||
|
attendees.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
events = resp.data as Events;
|
||||||
|
})
|
||||||
|
|
||||||
|
.catch((err) => {
|
||||||
|
NotifyResponse(err, 'error');
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!events || events.length === 0 || !events[0]?.attendees || events[0].attendees === null) {
|
||||||
|
attendees.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
attendees.value = events[0].attendees ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
attendees,
|
||||||
|
pagination,
|
||||||
|
columns,
|
||||||
|
loading,
|
||||||
|
updateAttendees,
|
||||||
|
};
|
||||||
|
}
|
||||||
234
src/vueLib/tables/attendees/AttendeesTable.vue
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
<template>
|
||||||
|
<DialogFrame ref="dialog" :header-title="$t('attendees')" :width="600" :height="600">
|
||||||
|
<div class="q-pa-md">
|
||||||
|
<q-table
|
||||||
|
flat
|
||||||
|
bordered
|
||||||
|
ref="tableRef"
|
||||||
|
:title="$t('attendees')"
|
||||||
|
title-class="text-bold text-blue-9"
|
||||||
|
:no-data-label="$t('noDataAvailable')"
|
||||||
|
:loading-label="$t('loading')"
|
||||||
|
:rows-per-page-label="$t('recordsPerPage')"
|
||||||
|
:selected-rows-label="(val) => val + ' ' + $t('recordSelected')"
|
||||||
|
:rows="attendees"
|
||||||
|
:columns="columns"
|
||||||
|
row-key="id"
|
||||||
|
v-model:pagination="pagination"
|
||||||
|
:loading="loading"
|
||||||
|
:filter="filter"
|
||||||
|
:selection="selectOption ? 'multiple' : 'none'"
|
||||||
|
v-model:selected="selected"
|
||||||
|
binary-state-sort
|
||||||
|
class="bigger-table-text"
|
||||||
|
>
|
||||||
|
<template v-slot:top-left>
|
||||||
|
<q-btn-group push flat style="color: grey">
|
||||||
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('events', 'write')"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
icon="person"
|
||||||
|
@click="openAllValueDialog"
|
||||||
|
><q-badge floating transparent color="primary" text-color="primary-text">+</q-badge>
|
||||||
|
<q-tooltip>{{ $t('addNewAttendees') }}</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('events', 'write')"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
style="color: grey"
|
||||||
|
:icon="selectOption ? 'check_box' : 'check_box_outline_blank'"
|
||||||
|
@click="selectOption = !selectOption"
|
||||||
|
>
|
||||||
|
<q-tooltip>{{ $t('selectAttendeesOptions') }}</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
</q-btn-group>
|
||||||
|
<div v-if="selectOption && selected.length > 0">
|
||||||
|
<q-btn flat dense icon="more_vert" @click="openSubmenu = true" />
|
||||||
|
<q-menu v-if="openSubmenu" anchor="bottom middle" self="top middle">
|
||||||
|
<q-item
|
||||||
|
clickable
|
||||||
|
v-close-popup
|
||||||
|
@click="openRemoveDialog(...selected)"
|
||||||
|
class="text-negative"
|
||||||
|
>{{ $t('delete') }}</q-item
|
||||||
|
>
|
||||||
|
</q-menu>
|
||||||
|
</div>
|
||||||
|
<div v-if="selectOption && selected.length > 0" class="q-ml-md text-weight-bold">
|
||||||
|
{{ $t('selected') }}: {{ selected.length }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-slot:top-right>
|
||||||
|
<q-input filled dense debounce="300" v-model="filter" :placeholder="$t('search')">
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-icon name="search" />
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
</template>
|
||||||
|
<template v-slot:body-cell="props">
|
||||||
|
<q-td v-if="props.col.field === 'attendees'" :props="props">
|
||||||
|
<q-btn v-if="props.value !== null && props.value.length > 0" dense flat icon="people"
|
||||||
|
><q-badge color="primary" text-color="primary-text" floating transparent>{{
|
||||||
|
props.row.count
|
||||||
|
}}</q-badge></q-btn
|
||||||
|
>
|
||||||
|
</q-td>
|
||||||
|
<q-td v-else :props="props">
|
||||||
|
{{ props.value }}
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
|
<template v-slot:body-cell-option="props">
|
||||||
|
<q-td :props="props">
|
||||||
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('events', 'delete')"
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
@click="openRemoveDialog(props.row)"
|
||||||
|
color="negative"
|
||||||
|
icon="delete"
|
||||||
|
/>
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
|
</q-table>
|
||||||
|
</div>
|
||||||
|
<DialogFrame ref="memberTableDialog" :header-title="$t('members')" :width="700" :height="500">
|
||||||
|
<MembersTable
|
||||||
|
add-attendees
|
||||||
|
:compare-members="attendees"
|
||||||
|
v-on:update-event="updateTable"
|
||||||
|
:event-id="localEvent?.id ?? 0"
|
||||||
|
/>
|
||||||
|
</DialogFrame>
|
||||||
|
|
||||||
|
<OkDialog
|
||||||
|
ref="okDialog"
|
||||||
|
:dialog-label="$t('delete')"
|
||||||
|
:text="$t('doYouWantToDelete') + ' ' + deleteText"
|
||||||
|
label-color="red"
|
||||||
|
:button-cancel-label="$t('cancel')"
|
||||||
|
:button-ok-label="$t('confirm')"
|
||||||
|
:button-ok-flat="false"
|
||||||
|
button-ok-color="red"
|
||||||
|
v-on:update-confirm="(val) => removeAttendees(...val)"
|
||||||
|
></OkDialog>
|
||||||
|
</DialogFrame>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { appApi } from 'src/boot/axios';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import type { Members } from 'src/vueLib/models/member';
|
||||||
|
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
||||||
|
import OkDialog from 'src/components/dialog/OkDialog.vue';
|
||||||
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
|
import { useAttendeesTable } from '../attendees/AttendeesTable';
|
||||||
|
import { useUserStore } from 'src/vueLib/login/userStore';
|
||||||
|
import type { Event } from 'src/vueLib/models/event';
|
||||||
|
import MembersTable from '../members/MembersTable.vue';
|
||||||
|
import { i18n } from 'src/boot/lang';
|
||||||
|
|
||||||
|
export interface AttendeesDialog {
|
||||||
|
getSelected: () => Members;
|
||||||
|
}
|
||||||
|
|
||||||
|
const emit = defineEmits(['update']);
|
||||||
|
|
||||||
|
const { NotifyResponse } = useNotify();
|
||||||
|
const memberTableDialog = ref();
|
||||||
|
const dialog = ref();
|
||||||
|
const okDialog = ref();
|
||||||
|
const deleteText = ref('');
|
||||||
|
const selectOption = ref(false);
|
||||||
|
const localEvent = ref<Event>();
|
||||||
|
const selected = ref<Members>([]);
|
||||||
|
const openSubmenu = ref(false);
|
||||||
|
const filter = ref('');
|
||||||
|
const user = useUserStore();
|
||||||
|
|
||||||
|
const { attendees, pagination, loading, columns, updateAttendees } = useAttendeesTable();
|
||||||
|
|
||||||
|
const open = (event: Event) => {
|
||||||
|
localEvent.value = event;
|
||||||
|
attendees.value = event.attendees ?? [];
|
||||||
|
dialog.value.open();
|
||||||
|
};
|
||||||
|
|
||||||
|
//opens dialog for one value
|
||||||
|
function openAllValueDialog() {
|
||||||
|
memberTableDialog.value?.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
//opens remove dialog
|
||||||
|
function openRemoveDialog(...attendees: Members) {
|
||||||
|
if (attendees.length === 1) {
|
||||||
|
deleteText.value = "'";
|
||||||
|
if (attendees[0]?.firstName && attendees[0]?.lastName) {
|
||||||
|
deleteText.value += attendees[0]?.firstName + ' ' + attendees[0]?.lastName;
|
||||||
|
}
|
||||||
|
deleteText.value += "'";
|
||||||
|
} else {
|
||||||
|
deleteText.value = String(attendees.length) + ' ' + i18n.global.t('attendees');
|
||||||
|
}
|
||||||
|
okDialog.value?.open(attendees);
|
||||||
|
}
|
||||||
|
|
||||||
|
//remove Attendees from database
|
||||||
|
async function removeAttendees(...removeAttendees: Members) {
|
||||||
|
if (!localEvent.value) {
|
||||||
|
console.error('event is empty');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
localEvent.value.attendees = removeAttendees;
|
||||||
|
|
||||||
|
await appApi
|
||||||
|
.post('events/delete/attendees', localEvent.value)
|
||||||
|
.then(() => {
|
||||||
|
selected.value = [];
|
||||||
|
if (localEvent.value?.attendees !== undefined && localEvent.value?.attendees.length > 1) {
|
||||||
|
NotifyResponse(i18n.global.t('deleteAttendees'), 'warning');
|
||||||
|
} else {
|
||||||
|
NotifyResponse(i18n.global.t('deleteAttendee'), 'warning');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'))
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
emit('update');
|
||||||
|
await updateAttendees();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function updateTable() {
|
||||||
|
await updateAttendees();
|
||||||
|
emit('update');
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
open,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@keyframes blink-yellow {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
background-color: yellow;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bigger-table-text .q-table__middle td {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bigger-table-text .q-table__top,
|
||||||
|
.bigger-table-text .q-table__bottom,
|
||||||
|
.bigger-table-text th {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
79
src/vueLib/tables/events/EventsTable.ts
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import { appApi } from 'src/boot/axios';
|
||||||
|
import { ref, computed } from 'vue';
|
||||||
|
import type { Events } from 'src/vueLib/models/event';
|
||||||
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
|
import { i18n } from 'boot/lang';
|
||||||
|
|
||||||
|
export function useEventTable() {
|
||||||
|
const Events = ref<Events>([]);
|
||||||
|
|
||||||
|
const pagination = ref({
|
||||||
|
sortBy: 'firstName',
|
||||||
|
descending: false,
|
||||||
|
page: 1,
|
||||||
|
rowsPerPage: 20,
|
||||||
|
});
|
||||||
|
|
||||||
|
const columns = computed(() => [
|
||||||
|
{
|
||||||
|
name: 'name',
|
||||||
|
align: 'left' as const,
|
||||||
|
label: i18n.global.t('name'),
|
||||||
|
field: 'name',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'attendees',
|
||||||
|
align: 'center' as const,
|
||||||
|
label: i18n.global.t('attendees'),
|
||||||
|
field: 'attendees',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'date',
|
||||||
|
align: 'left' as const,
|
||||||
|
label: i18n.global.t('dateAndTime'),
|
||||||
|
field: 'date',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{ name: 'option', align: 'center' as const, label: '', field: 'option', icon: 'option' },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const { NotifyResponse } = useNotify();
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
//updates Event list from database
|
||||||
|
function updateEvents() {
|
||||||
|
loading.value = true;
|
||||||
|
|
||||||
|
appApi
|
||||||
|
.get('events')
|
||||||
|
.then((resp) => {
|
||||||
|
if (resp.data === null) {
|
||||||
|
Events.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Events.value = resp.data as Events;
|
||||||
|
if (Events.value === null) {
|
||||||
|
Events.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
.catch((err) => {
|
||||||
|
NotifyResponse(err, 'error');
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
Events,
|
||||||
|
pagination,
|
||||||
|
columns,
|
||||||
|
loading,
|
||||||
|
updateEvents,
|
||||||
|
};
|
||||||
|
}
|
||||||
269
src/vueLib/tables/events/EventsTable.vue
Normal file
@@ -0,0 +1,269 @@
|
|||||||
|
<template>
|
||||||
|
<div class="q-pa-md">
|
||||||
|
<q-table
|
||||||
|
flat
|
||||||
|
bordered
|
||||||
|
ref="tableRef"
|
||||||
|
title="Events"
|
||||||
|
title-class="text-bold text-blue-9"
|
||||||
|
:no-data-label="$t('noDataAvailable')"
|
||||||
|
:loading-label="$t('loading')"
|
||||||
|
:rows-per-page-label="$t('recordsPerPage')"
|
||||||
|
:selected-rows-label="(val) => val + ' ' + $t('recordSelected')"
|
||||||
|
:rows="Events"
|
||||||
|
:columns="columns"
|
||||||
|
row-key="id"
|
||||||
|
v-model:pagination="pagination"
|
||||||
|
:loading="loading"
|
||||||
|
:filter="filter"
|
||||||
|
:selection="selectOption ? 'multiple' : 'none'"
|
||||||
|
v-model:selected="selected"
|
||||||
|
binary-state-sort
|
||||||
|
class="bigger-table-text"
|
||||||
|
>
|
||||||
|
<template v-slot:top-left>
|
||||||
|
<q-btn-group push flat style="color: grey">
|
||||||
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('events', 'write')"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
icon="add"
|
||||||
|
@click="openAllValueDialog(null)"
|
||||||
|
>
|
||||||
|
<q-tooltip>{{ $t('addNewEvent') }}</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('events', 'write')"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
style="color: grey"
|
||||||
|
:icon="selectOption ? 'check_box' : 'check_box_outline_blank'"
|
||||||
|
@click="selectOption = !selectOption"
|
||||||
|
>
|
||||||
|
<q-tooltip>{{ $t('selectEventOptions') }}</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
</q-btn-group>
|
||||||
|
<div v-if="selectOption && selected.length > 0">
|
||||||
|
<q-btn flat dense icon="more_vert" @click="openSubmenu = true" />
|
||||||
|
<q-menu v-if="openSubmenu" anchor="bottom middle" self="top middle">
|
||||||
|
<q-item
|
||||||
|
clickable
|
||||||
|
v-close-popup
|
||||||
|
@click="openRemoveDialog(...selected)"
|
||||||
|
class="text-negative"
|
||||||
|
>{{ $t('delete') }}</q-item
|
||||||
|
>
|
||||||
|
</q-menu>
|
||||||
|
</div>
|
||||||
|
<div v-if="selectOption && selected.length > 0" class="q-ml-md text-weight-bold">
|
||||||
|
{{ $t('selected') }}: {{ selected.length }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-slot:top-right>
|
||||||
|
<q-input filled dense debounce="300" v-model="filter" :placeholder="$t('search')">
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-icon name="search" />
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
</template>
|
||||||
|
<template v-slot:body-cell="props">
|
||||||
|
<q-td v-if="props.col.field === 'attendees'" :props="props">
|
||||||
|
<q-btn dense flat icon="people" @click="openAttendees(props.row)"
|
||||||
|
><q-badge color="primary" text-color="primary-text" floating transparent>{{
|
||||||
|
props.row.count
|
||||||
|
}}</q-badge></q-btn
|
||||||
|
>
|
||||||
|
</q-td>
|
||||||
|
<q-td
|
||||||
|
v-else
|
||||||
|
:props="props"
|
||||||
|
:style="
|
||||||
|
user.isPermittedTo('events', 'write') && props.col.field !== 'count'
|
||||||
|
? 'cursor: pointer'
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
@click="
|
||||||
|
user.isPermittedTo('events', 'write') &&
|
||||||
|
props.col.field !== 'count' &&
|
||||||
|
openSingleValueDialog(props.col.label, props.col.name, props.row)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{ props.value }}
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
|
<template v-slot:body-cell-option="props">
|
||||||
|
<q-td :props="props">
|
||||||
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('events', 'write') || user.isPermittedTo('events', 'delete')"
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
icon="more_vert"
|
||||||
|
@click="openSubmenu = true"
|
||||||
|
/>
|
||||||
|
<q-menu v-if="openSubmenu" anchor="top right" self="top left">
|
||||||
|
<q-item
|
||||||
|
v-if="user.isPermittedTo('events', 'write')"
|
||||||
|
clickable
|
||||||
|
v-close-popup
|
||||||
|
@click="openAllValueDialog(props.row)"
|
||||||
|
class="text-primary"
|
||||||
|
>{{ $t('edit') }}</q-item
|
||||||
|
>
|
||||||
|
<q-item
|
||||||
|
v-if="user.isPermittedTo('events', 'delete')"
|
||||||
|
clickable
|
||||||
|
v-close-popup
|
||||||
|
@click="openRemoveDialog(props.row)"
|
||||||
|
class="text-negative"
|
||||||
|
title="zu"
|
||||||
|
>{{ $t('delete') }}</q-item
|
||||||
|
>
|
||||||
|
</q-menu>
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
|
</q-table>
|
||||||
|
</div>
|
||||||
|
<EditOneDialog
|
||||||
|
ref="editOneDialog"
|
||||||
|
endpoint="events/edit"
|
||||||
|
query-id
|
||||||
|
v-on:update="updateEvents"
|
||||||
|
></EditOneDialog>
|
||||||
|
<EditAllDialog ref="editAllDialog" v-on:update="updateEvents"></EditAllDialog>
|
||||||
|
<AttendeesTable ref="attendeesDialog" v-on:update="updateEvents" />
|
||||||
|
<OkDialog
|
||||||
|
ref="okDialog"
|
||||||
|
:dialog-label="$t('delete')"
|
||||||
|
:text="$t('doYouWantToDelete') + ' ' + deleteText"
|
||||||
|
label-color="red"
|
||||||
|
:button-cancel-label="$t('cancel')"
|
||||||
|
:button-ok-label="$t('confirm')"
|
||||||
|
:button-ok-flat="false"
|
||||||
|
button-ok-color="red"
|
||||||
|
v-on:update-confirm="(val) => removeEvent(...val)"
|
||||||
|
></OkDialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { appApi } from 'src/boot/axios';
|
||||||
|
import { ref, onMounted } from 'vue';
|
||||||
|
import type { Event, Events } from 'src/vueLib/models/event';
|
||||||
|
import EditOneDialog from 'src/components/EditOneDialog.vue';
|
||||||
|
import EditAllDialog from 'src/components/EventEditAllDialog.vue';
|
||||||
|
import OkDialog from 'src/components/dialog/OkDialog.vue';
|
||||||
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
|
import { useEventTable } from './EventsTable';
|
||||||
|
import { databaseName } from 'src/vueLib/models/settings';
|
||||||
|
import { useUserStore } from 'src/vueLib/login/userStore';
|
||||||
|
import AttendeesTable from '../attendees/AttendeesTable.vue';
|
||||||
|
import type { Members } from 'src/vueLib/models/member';
|
||||||
|
import { i18n } from 'src/boot/lang';
|
||||||
|
|
||||||
|
export interface EventDialog {
|
||||||
|
getSelected: () => Events;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { NotifyResponse } = useNotify();
|
||||||
|
const editOneDialog = ref();
|
||||||
|
const editAllDialog = ref();
|
||||||
|
const attendeesDialog = ref();
|
||||||
|
const okDialog = ref();
|
||||||
|
const deleteText = ref('');
|
||||||
|
const selectOption = ref(false);
|
||||||
|
const selected = ref<Events>([]);
|
||||||
|
const openSubmenu = ref(false);
|
||||||
|
const filter = ref('');
|
||||||
|
const user = useUserStore();
|
||||||
|
|
||||||
|
const { Events, pagination, loading, columns, updateEvents } = useEventTable();
|
||||||
|
|
||||||
|
//load on mounting page
|
||||||
|
onMounted(() => {
|
||||||
|
loading.value = true;
|
||||||
|
|
||||||
|
appApi
|
||||||
|
.post('database/open', { dbPath: databaseName.value, create: true })
|
||||||
|
.then(() => {
|
||||||
|
updateEvents();
|
||||||
|
})
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'))
|
||||||
|
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// opens dialog for all Event values
|
||||||
|
function openSingleValueDialog(label: string, field: string, Event: Event) {
|
||||||
|
editOneDialog.value?.open(label, field, Event);
|
||||||
|
}
|
||||||
|
|
||||||
|
//opens dialog for one value
|
||||||
|
function openAllValueDialog(Event: Event | null) {
|
||||||
|
editAllDialog.value?.open(Event);
|
||||||
|
}
|
||||||
|
|
||||||
|
//opens remove dialog
|
||||||
|
function openRemoveDialog(...Events: Events) {
|
||||||
|
if (Events.length === 1) {
|
||||||
|
deleteText.value = "'";
|
||||||
|
if (Events[0]?.name !== undefined) {
|
||||||
|
deleteText.value += Events[0]?.name + ' ';
|
||||||
|
}
|
||||||
|
deleteText.value += "'";
|
||||||
|
} else {
|
||||||
|
deleteText.value = String(Events.length) + ' ' + i18n.global.t('events');
|
||||||
|
}
|
||||||
|
okDialog.value?.open(Events);
|
||||||
|
}
|
||||||
|
|
||||||
|
function openAttendees(attendees: Members | null) {
|
||||||
|
attendeesDialog.value.open(attendees);
|
||||||
|
}
|
||||||
|
|
||||||
|
//remove Event from database
|
||||||
|
function removeEvent(...removeEvents: Events) {
|
||||||
|
const EventIds: number[] = [];
|
||||||
|
|
||||||
|
removeEvents.forEach((Event: Event) => {
|
||||||
|
EventIds.push(Event.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
appApi
|
||||||
|
.post('events/delete', { ids: EventIds })
|
||||||
|
.then(() => {
|
||||||
|
updateEvents();
|
||||||
|
selected.value = [];
|
||||||
|
})
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'))
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@keyframes blink-yellow {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
background-color: yellow;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.blink-yellow {
|
||||||
|
animation: blink-yellow 1.5s step-start 6 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bigger-table-text .q-table__middle td {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bigger-table-text .q-table__top,
|
||||||
|
.bigger-table-text .q-table__bottom,
|
||||||
|
.bigger-table-text th {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -3,114 +3,143 @@ import { ref, computed } from 'vue';
|
|||||||
import type { Member, Members } from 'src/vueLib/models/member';
|
import type { Member, Members } from 'src/vueLib/models/member';
|
||||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
import { i18n } from 'boot/lang';
|
import { i18n } from 'boot/lang';
|
||||||
|
import { useResponsibleTable } from '../responsible/ResponsibleTable';
|
||||||
export const databaseName = ref('members.dba');
|
|
||||||
|
|
||||||
export function useMemberTable() {
|
export function useMemberTable() {
|
||||||
const members = ref<Members>([]);
|
const members = ref<Members>([]);
|
||||||
|
const { responsibles, updateResponsibles } = useResponsibleTable();
|
||||||
|
|
||||||
const pagination = ref({
|
const pagination = ref({
|
||||||
sortBy: 'firstName',
|
sortBy: 'firstName',
|
||||||
descending: false,
|
descending: false,
|
||||||
page: 1,
|
page: 1,
|
||||||
rowsPerPage: 10,
|
rowsPerPage: 20,
|
||||||
});
|
});
|
||||||
|
|
||||||
const columns = computed(() => [
|
//add enabling of each columns
|
||||||
{ name: 'cake', align: 'center' as const, label: '', field: 'cake', icon: 'cake' },
|
const enabledColumns = ref<Record<string, boolean>>({
|
||||||
{
|
cake: true,
|
||||||
name: 'firstName',
|
firstName: true,
|
||||||
align: 'left' as const,
|
lastName: true,
|
||||||
label: i18n.global.t('prename'),
|
birthday: true,
|
||||||
field: 'firstName',
|
age: true,
|
||||||
sortable: true,
|
address: true,
|
||||||
},
|
comment: true,
|
||||||
{
|
town: true,
|
||||||
name: 'lastName',
|
zip: true,
|
||||||
align: 'left' as const,
|
phone: true,
|
||||||
label: i18n.global.t('lastName'),
|
email: true,
|
||||||
field: 'lastName',
|
group: true,
|
||||||
sortable: true,
|
responsiblePerson: true,
|
||||||
},
|
firstVisit: true,
|
||||||
{
|
lastVisit: true,
|
||||||
name: 'birthday',
|
option: true,
|
||||||
align: 'left' as const,
|
});
|
||||||
label: i18n.global.t('birthday'),
|
|
||||||
field: 'birthday',
|
const columns = computed(() =>
|
||||||
sortable: true,
|
[
|
||||||
},
|
{ name: 'cake', align: 'center' as const, label: '', field: 'cake', icon: 'cake' },
|
||||||
{
|
{
|
||||||
name: 'age',
|
name: 'firstName',
|
||||||
align: 'left' as const,
|
align: 'left' as const,
|
||||||
label: i18n.global.t('age'),
|
label: i18n.global.t('prename'),
|
||||||
field: 'age',
|
field: 'firstName',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'address',
|
name: 'lastName',
|
||||||
align: 'left' as const,
|
align: 'left' as const,
|
||||||
label: i18n.global.t('address'),
|
label: i18n.global.t('lastName'),
|
||||||
field: 'address',
|
field: 'lastName',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'town',
|
name: 'birthday',
|
||||||
align: 'left' as const,
|
align: 'left' as const,
|
||||||
label: i18n.global.t('town'),
|
label: i18n.global.t('birthday'),
|
||||||
field: 'town',
|
field: 'birthday',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'zip',
|
name: 'age',
|
||||||
align: 'left' as const,
|
align: 'left' as const,
|
||||||
label: i18n.global.t('zipCode'),
|
label: i18n.global.t('age'),
|
||||||
field: 'zip',
|
field: 'age',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'phone',
|
name: 'comment',
|
||||||
align: 'left' as const,
|
align: 'left' as const,
|
||||||
label: i18n.global.t('phone'),
|
label: i18n.global.t('comment'),
|
||||||
field: 'phone',
|
field: 'comment',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'email',
|
name: 'address',
|
||||||
align: 'left' as const,
|
align: 'left' as const,
|
||||||
label: i18n.global.t('email'),
|
label: i18n.global.t('address'),
|
||||||
field: 'email',
|
field: 'address',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'group',
|
name: 'town',
|
||||||
align: 'left' as const,
|
align: 'left' as const,
|
||||||
label: i18n.global.t('group'),
|
label: i18n.global.t('town'),
|
||||||
field: 'group',
|
field: 'town',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'responsiblePerson',
|
name: 'zip',
|
||||||
align: 'left' as const,
|
align: 'left' as const,
|
||||||
label: i18n.global.t('responsible'),
|
label: i18n.global.t('zipCode'),
|
||||||
field: 'responsiblePerson',
|
field: 'zip',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'firstVisit',
|
name: 'phone',
|
||||||
align: 'left' as const,
|
align: 'left' as const,
|
||||||
label: i18n.global.t('firstVisit'),
|
label: i18n.global.t('phone'),
|
||||||
field: 'firstVisit',
|
field: 'phone',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'lastVisit',
|
name: 'email',
|
||||||
align: 'left' as const,
|
align: 'left' as const,
|
||||||
label: i18n.global.t('lastVisit'),
|
label: i18n.global.t('email'),
|
||||||
field: 'lastVisit',
|
field: 'email',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{ name: 'option', align: 'center' as const, label: '', field: 'option', icon: 'option' },
|
{
|
||||||
]);
|
name: 'group',
|
||||||
|
align: 'left' as const,
|
||||||
|
label: i18n.global.t('group'),
|
||||||
|
field: 'group',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'responsiblePerson',
|
||||||
|
align: 'left' as const,
|
||||||
|
label: i18n.global.t('responsible'),
|
||||||
|
field: 'responsiblePerson',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'firstVisit',
|
||||||
|
align: 'left' as const,
|
||||||
|
label: i18n.global.t('firstVisit'),
|
||||||
|
field: 'firstVisit',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'lastVisit',
|
||||||
|
align: 'left' as const,
|
||||||
|
label: i18n.global.t('lastVisit'),
|
||||||
|
field: 'lastVisit',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{ name: 'option', align: 'center' as const, label: '', field: 'option', icon: 'option' },
|
||||||
|
].filter((c) => enabledColumns.value[c.name]),
|
||||||
|
);
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
|
|
||||||
@@ -156,6 +185,7 @@ export function useMemberTable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getRowClass(row: Member) {
|
function getRowClass(row: Member) {
|
||||||
|
if (!row.birthday) return '';
|
||||||
if (isXDaysBeforeAnnualDate(row.birthday, 1)) {
|
if (isXDaysBeforeAnnualDate(row.birthday, 1)) {
|
||||||
return 'bg-red-2 text-red-10';
|
return 'bg-red-2 text-red-10';
|
||||||
} else if (isXDaysBeforeAnnualDate(row.birthday, 4)) {
|
} else if (isXDaysBeforeAnnualDate(row.birthday, 4)) {
|
||||||
@@ -167,11 +197,13 @@ export function useMemberTable() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//updates member list from database
|
//updates member list from database
|
||||||
function updateMembers() {
|
async function updateMembers(filter?: Members, filterbyName?: boolean) {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
|
await updateResponsibles().catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
|
||||||
appApi
|
appApi
|
||||||
.get('secure/members')
|
.get('members')
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (resp.data === null) {
|
if (resp.data === null) {
|
||||||
members.value = [];
|
members.value = [];
|
||||||
@@ -183,6 +215,10 @@ export function useMemberTable() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
members.value.forEach((member) => {
|
members.value.forEach((member) => {
|
||||||
|
if (!responsibles.value.some((r) => r.id === member.responsiblePerson?.id)) {
|
||||||
|
delete member.responsiblePerson;
|
||||||
|
}
|
||||||
|
|
||||||
if (member.birthday !== undefined) {
|
if (member.birthday !== undefined) {
|
||||||
member.age = String(calculateAge(member.birthday));
|
member.age = String(calculateAge(member.birthday));
|
||||||
}
|
}
|
||||||
@@ -194,16 +230,38 @@ export function useMemberTable() {
|
|||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
//filter same members out so list is shorter
|
||||||
|
if (filter) {
|
||||||
|
members.value = members.value.filter(
|
||||||
|
(m1) =>
|
||||||
|
!filter.some((m2) => {
|
||||||
|
if (filterbyName) {
|
||||||
|
return m1.firstName === m2.firstName && m1.lastName === m2.lastName;
|
||||||
|
}
|
||||||
|
return m1.id === m2.id;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function disableColumns(...columns: string[]) {
|
||||||
|
columns.forEach((col) => {
|
||||||
|
if (col in enabledColumns.value) {
|
||||||
|
enabledColumns.value[col] = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
members,
|
members,
|
||||||
|
responsibles,
|
||||||
pagination,
|
pagination,
|
||||||
columns,
|
columns,
|
||||||
loading,
|
loading,
|
||||||
getRowClass,
|
getRowClass,
|
||||||
updateMembers,
|
updateMembers,
|
||||||
isXDaysBeforeAnnualDate,
|
isXDaysBeforeAnnualDate,
|
||||||
|
disableColumns,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
:no-data-label="$t('noDataAvailable')"
|
:no-data-label="$t('noDataAvailable')"
|
||||||
:loading-label="$t('loading')"
|
:loading-label="$t('loading')"
|
||||||
:rows-per-page-label="$t('recordsPerPage')"
|
:rows-per-page-label="$t('recordsPerPage')"
|
||||||
:selected-rows-label="(val) => val + $t('recordSelected')"
|
:selected-rows-label="(val) => val + ' ' + $t('recordSelected')"
|
||||||
:rows="members"
|
:rows="members"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
@@ -23,10 +23,17 @@
|
|||||||
>
|
>
|
||||||
<template v-slot:top-left>
|
<template v-slot:top-left>
|
||||||
<q-btn-group push flat style="color: grey">
|
<q-btn-group push flat style="color: grey">
|
||||||
<q-btn dense flat icon="add" @click="openAllValueDialog(null)">
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('members', 'write')"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
icon="add"
|
||||||
|
@click="openAllValueDialog(null)"
|
||||||
|
>
|
||||||
<q-tooltip>{{ $t('addNewMember') }}</q-tooltip>
|
<q-tooltip>{{ $t('addNewMember') }}</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
<q-btn
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('members', 'write') || user.isPermittedTo('members', 'delete')"
|
||||||
dense
|
dense
|
||||||
flat
|
flat
|
||||||
style="color: grey"
|
style="color: grey"
|
||||||
@@ -35,14 +42,35 @@
|
|||||||
>
|
>
|
||||||
<q-tooltip>{{ $t('selectMemberOptions') }}</q-tooltip>
|
<q-tooltip>{{ $t('selectMemberOptions') }}</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
<q-btn dense flat icon="upload" @click="openUploadDialog">
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('members', 'write')"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
icon="upload"
|
||||||
|
@click="openUploadDialog"
|
||||||
|
>
|
||||||
<q-tooltip>{{ $t('importCSV') }}</q-tooltip>
|
<q-tooltip>{{ $t('importCSV') }}</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</q-btn-group>
|
</q-btn-group>
|
||||||
<div v-if="selectOption && selected.length > 0">
|
<div v-if="selectOption && selected.length > 0">
|
||||||
<q-btn flat dense icon="more_vert" @click="openSubmenu = true" />
|
<q-btn
|
||||||
|
v-if="inProps.addAttendees || inProps.addResponsible"
|
||||||
|
dense
|
||||||
|
color="grey-7"
|
||||||
|
flat
|
||||||
|
icon="person"
|
||||||
|
@click="addMemberTo"
|
||||||
|
>
|
||||||
|
<q-badge floating transparent color="primary" text-color="primary-text">+</q-badge>
|
||||||
|
</q-btn>
|
||||||
|
<q-btn v-else flat dense icon="more_vert" @click="openSubmenu = true" />
|
||||||
|
|
||||||
<q-menu v-if="openSubmenu" anchor="bottom middle" self="top middle">
|
<q-menu v-if="openSubmenu" anchor="bottom middle" self="top middle">
|
||||||
|
<q-item clickable v-close-popup @click="addToEvent" class="text-primary">{{
|
||||||
|
$t('addToEvent')
|
||||||
|
}}</q-item>
|
||||||
<q-item
|
<q-item
|
||||||
|
v-if="user.isPermittedTo('members', 'delete')"
|
||||||
clickable
|
clickable
|
||||||
v-close-popup
|
v-close-popup
|
||||||
@click="openRemoveDialog(...selected)"
|
@click="openRemoveDialog(...selected)"
|
||||||
@@ -51,7 +79,7 @@
|
|||||||
>
|
>
|
||||||
</q-menu>
|
</q-menu>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="selectOption && selected.length > 0" class="q-ml-md text-weight-bold">
|
<div v-if="selectOption && selected.length > 0" class="text-weight-bold">
|
||||||
{{ $t('selected') }}: {{ selected.length }}
|
{{ $t('selected') }}: {{ selected.length }}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -66,7 +94,11 @@
|
|||||||
<q-td
|
<q-td
|
||||||
:props="props"
|
:props="props"
|
||||||
:class="getRowClass(props.row)"
|
:class="getRowClass(props.row)"
|
||||||
@click="openSingleValueDialog(props.col.label, props.col.name, props.row)"
|
:style="user.isPermittedTo('members', 'write') ? 'cursor: pointer' : ''"
|
||||||
|
@click="
|
||||||
|
user.isPermittedTo('members', 'write') &&
|
||||||
|
openSingleValueDialog(props.col.label, props.col.name, props.row)
|
||||||
|
"
|
||||||
>
|
>
|
||||||
{{ props.value }}
|
{{ props.value }}
|
||||||
</q-td>
|
</q-td>
|
||||||
@@ -80,11 +112,30 @@
|
|||||||
/>
|
/>
|
||||||
</q-td>
|
</q-td>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-slot:body-cell-responsiblePerson="props">
|
||||||
|
<q-td :props="props">
|
||||||
|
<q-select
|
||||||
|
v-if="responsibles.length > 0"
|
||||||
|
:readonly="!user.isPermittedTo('members', 'write')"
|
||||||
|
:options="responsibles"
|
||||||
|
:option-label="(opt) => opt.firstName + ' ' + opt.lastName"
|
||||||
|
v-model="props.row.responsiblePerson"
|
||||||
|
@update:model-value="updateMember(props.row)"
|
||||||
|
></q-select>
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
<template v-slot:body-cell-option="props">
|
<template v-slot:body-cell-option="props">
|
||||||
<q-td :props="props">
|
<q-td :props="props">
|
||||||
<q-btn flat dense icon="more_vert" @click="openSubmenu = true" />
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('members', 'write') || user.isPermittedTo('members', 'delete')"
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
icon="more_vert"
|
||||||
|
@click="openSubmenu = true"
|
||||||
|
/>
|
||||||
<q-menu v-if="openSubmenu" anchor="top right" self="top left">
|
<q-menu v-if="openSubmenu" anchor="top right" self="top left">
|
||||||
<q-item
|
<q-item
|
||||||
|
v-if="user.isPermittedTo('members', 'write')"
|
||||||
clickable
|
clickable
|
||||||
v-close-popup
|
v-close-popup
|
||||||
@click="openAllValueDialog(props.row)"
|
@click="openAllValueDialog(props.row)"
|
||||||
@@ -92,6 +143,11 @@
|
|||||||
>{{ $t('edit') }}</q-item
|
>{{ $t('edit') }}</q-item
|
||||||
>
|
>
|
||||||
<q-item
|
<q-item
|
||||||
|
v-if="
|
||||||
|
user.isPermittedTo('members', 'delete') &&
|
||||||
|
!inProps.addAttendees &&
|
||||||
|
!inProps.addResponsible
|
||||||
|
"
|
||||||
clickable
|
clickable
|
||||||
v-close-popup
|
v-close-popup
|
||||||
@click="openRemoveDialog(props.row)"
|
@click="openRemoveDialog(props.row)"
|
||||||
@@ -104,8 +160,17 @@
|
|||||||
</template>
|
</template>
|
||||||
</q-table>
|
</q-table>
|
||||||
</div>
|
</div>
|
||||||
<EditOneDialog ref="editOneDialog" v-on:update="updateMembers"></EditOneDialog>
|
<EditOneDialog
|
||||||
<EditAllDialog ref="editAllDialog" v-on:update="updateMembers"></EditAllDialog>
|
ref="editOneDialog"
|
||||||
|
endpoint="members/edit"
|
||||||
|
query-id
|
||||||
|
v-on:update="updateMember"
|
||||||
|
></EditOneDialog>
|
||||||
|
<EditAllDialog
|
||||||
|
ref="editAllDialog"
|
||||||
|
:responsibles="responsibles"
|
||||||
|
v-on:update="updateMember"
|
||||||
|
></EditAllDialog>
|
||||||
<OkDialog
|
<OkDialog
|
||||||
ref="okDialog"
|
ref="okDialog"
|
||||||
:dialog-label="$t('delete')"
|
:dialog-label="$t('delete')"
|
||||||
@@ -118,11 +183,16 @@
|
|||||||
v-on:update-confirm="(val) => removeMember(...val)"
|
v-on:update-confirm="(val) => removeMember(...val)"
|
||||||
></OkDialog>
|
></OkDialog>
|
||||||
<UploadDialog ref="uploadDialog" @update-upload="updateMembers"> </UploadDialog>
|
<UploadDialog ref="uploadDialog" @update-upload="updateMembers"> </UploadDialog>
|
||||||
|
<AddToEvent
|
||||||
|
ref="addToEventDialog"
|
||||||
|
endpoint="events/add/attendees"
|
||||||
|
v-on:update-event="(val) => updateMemberLastVisit(val)"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { appApi } from 'src/boot/axios';
|
import { appApi } from 'src/boot/axios';
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted, type PropType } from 'vue';
|
||||||
import type { Member, Members } from 'src/vueLib/models/member';
|
import type { Member, Members } from 'src/vueLib/models/member';
|
||||||
import EditOneDialog from 'src/components/EditOneDialog.vue';
|
import EditOneDialog from 'src/components/EditOneDialog.vue';
|
||||||
import EditAllDialog from 'src/components/MemberEditAllDialog.vue';
|
import EditAllDialog from 'src/components/MemberEditAllDialog.vue';
|
||||||
@@ -130,15 +200,27 @@ import OkDialog from 'src/components/dialog/OkDialog.vue';
|
|||||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
import { useMemberTable } from './MembersTable';
|
import { useMemberTable } from './MembersTable';
|
||||||
import UploadDialog from 'src/components/UploadDialog.vue';
|
import UploadDialog from 'src/components/UploadDialog.vue';
|
||||||
import { databaseName } from './MembersTable';
|
import AddToEvent from 'src/components/AddToEvent.vue';
|
||||||
|
import { databaseName } from 'src/vueLib/models/settings';
|
||||||
|
import { useUserStore } from 'src/vueLib/login/userStore';
|
||||||
|
import { i18n } from 'src/boot/lang';
|
||||||
|
|
||||||
|
const inProps = defineProps({
|
||||||
|
addAttendees: { type: Boolean },
|
||||||
|
addResponsible: { type: Boolean },
|
||||||
|
eventId: { type: Number },
|
||||||
|
compareMembers: { type: Object as PropType<Members> },
|
||||||
|
});
|
||||||
export interface MemberDialog {
|
export interface MemberDialog {
|
||||||
getSelected: () => Members;
|
getSelected: () => Members;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const emit = defineEmits(['update-event']);
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
const editOneDialog = ref();
|
const editOneDialog = ref();
|
||||||
const editAllDialog = ref();
|
const editAllDialog = ref();
|
||||||
|
const addToEventDialog = ref();
|
||||||
const uploadDialog = ref();
|
const uploadDialog = ref();
|
||||||
const okDialog = ref();
|
const okDialog = ref();
|
||||||
const deleteText = ref('');
|
const deleteText = ref('');
|
||||||
@@ -146,25 +228,48 @@ const selectOption = ref(false);
|
|||||||
const selected = ref<Members>([]);
|
const selected = ref<Members>([]);
|
||||||
const openSubmenu = ref(false);
|
const openSubmenu = ref(false);
|
||||||
const filter = ref('');
|
const filter = ref('');
|
||||||
|
const user = useUserStore();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
members,
|
members,
|
||||||
|
responsibles,
|
||||||
pagination,
|
pagination,
|
||||||
loading,
|
loading,
|
||||||
columns,
|
columns,
|
||||||
getRowClass,
|
getRowClass,
|
||||||
updateMembers,
|
updateMembers,
|
||||||
isXDaysBeforeAnnualDate,
|
isXDaysBeforeAnnualDate,
|
||||||
|
disableColumns,
|
||||||
} = useMemberTable();
|
} = useMemberTable();
|
||||||
|
|
||||||
//load on mounting page
|
//load on mounting page
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
if (inProps.addAttendees || inProps.addResponsible) {
|
||||||
|
selectOption.value = true;
|
||||||
|
disableColumns(
|
||||||
|
'birthday',
|
||||||
|
'age',
|
||||||
|
'comment',
|
||||||
|
'town',
|
||||||
|
'zip',
|
||||||
|
'email',
|
||||||
|
'address',
|
||||||
|
'phone',
|
||||||
|
'group',
|
||||||
|
'responsiblePerson',
|
||||||
|
'firstVisit',
|
||||||
|
'lastVisit',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
appApi
|
appApi
|
||||||
.post('secure/database/open', { dbPath: databaseName.value, create: true })
|
.post('database/open', { dbPath: databaseName.value, create: true })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
updateMembers();
|
updateMembers(inProps.compareMembers, inProps.addResponsible).catch((err) =>
|
||||||
|
NotifyResponse(err, 'error'),
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.catch((err) => NotifyResponse(err, 'error'))
|
.catch((err) => NotifyResponse(err, 'error'))
|
||||||
|
|
||||||
@@ -195,7 +300,7 @@ function openRemoveDialog(...members: Members) {
|
|||||||
}
|
}
|
||||||
deleteText.value += "'";
|
deleteText.value += "'";
|
||||||
} else {
|
} else {
|
||||||
deleteText.value = String(members.length) + ' members';
|
deleteText.value = String(members.length) + ' ' + i18n.global.t('members');
|
||||||
}
|
}
|
||||||
okDialog.value?.open(members);
|
okDialog.value?.open(members);
|
||||||
}
|
}
|
||||||
@@ -214,9 +319,9 @@ function removeMember(...removeMembers: Members) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
appApi
|
appApi
|
||||||
.post('secure/members/delete', { ids: memberIds })
|
.post('members/delete', { ids: memberIds })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
updateMembers();
|
updateMembers().catch((err) => NotifyResponse(err, 'error'));
|
||||||
selected.value = [];
|
selected.value = [];
|
||||||
})
|
})
|
||||||
.catch((err) => NotifyResponse(err, 'error'))
|
.catch((err) => NotifyResponse(err, 'error'))
|
||||||
@@ -225,24 +330,83 @@ function removeMember(...removeMembers: Members) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//const blinkingId = ref<number | null>(null);
|
function updateMember(member: Member | null) {
|
||||||
|
if (!member) NotifyResponse(i18n.global.t('memberUpdated'));
|
||||||
// function triggerBlink(id: number) {
|
appApi
|
||||||
// blinkingId.value = id;
|
.post('/members/edit', [member])
|
||||||
|
.then(() => NotifyResponse(i18n.global.t('memberUpdated')))
|
||||||
// // Optional: stop blinking after 3 seconds
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
// setTimeout(() => {
|
updateMembers().catch((err) => NotifyResponse(err, 'error'));
|
||||||
// blinkingId.value = null;
|
}
|
||||||
// }, 3000);
|
|
||||||
// }
|
function addToEvent() {
|
||||||
|
addToEventDialog.value?.open(i18n.global.t('addToEvent'), selected.value);
|
||||||
function getSelected(): Members {
|
}
|
||||||
if (selected.value.length === 0) return [];
|
|
||||||
return selected.value;
|
async function addMemberTo() {
|
||||||
|
let query = '';
|
||||||
|
let payload = {};
|
||||||
|
let notificationSingular = '';
|
||||||
|
let notificationPlural = '';
|
||||||
|
if (inProps.addAttendees) {
|
||||||
|
query = 'events/add/attendees';
|
||||||
|
payload = {
|
||||||
|
id: inProps.eventId,
|
||||||
|
attendees: [...selected.value],
|
||||||
|
};
|
||||||
|
notificationSingular = 'attendeeAdded';
|
||||||
|
notificationPlural = 'attendeesAdded';
|
||||||
|
} else if (inProps.addResponsible) {
|
||||||
|
query = 'responsible/add';
|
||||||
|
payload = selected.value;
|
||||||
|
notificationSingular = 'responsibleAdded';
|
||||||
|
notificationPlural = 'responsiblesAdded';
|
||||||
|
}
|
||||||
|
|
||||||
|
await appApi
|
||||||
|
.post(query, payload)
|
||||||
|
.then(() => {
|
||||||
|
if (selected.value.length > 1) {
|
||||||
|
NotifyResponse(i18n.global.t(notificationSingular));
|
||||||
|
} else {
|
||||||
|
NotifyResponse(i18n.global.t(notificationPlural));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
NotifyResponse(err, 'error');
|
||||||
|
});
|
||||||
|
|
||||||
|
if (inProps.addAttendees) {
|
||||||
|
await updateMemberLastVisit(selected.value);
|
||||||
|
}
|
||||||
|
emit('update-event');
|
||||||
|
}
|
||||||
|
async function updateMemberLastVisit(members: Members) {
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
|
const year = now.getFullYear();
|
||||||
|
const month = String(now.getMonth() + 1).padStart(2, '0'); // Months are 0-based
|
||||||
|
const day = String(now.getDate()).padStart(2, '0');
|
||||||
|
const hours = String(now.getHours()).padStart(2, '0');
|
||||||
|
const minutes = String(now.getMinutes()).padStart(2, '0');
|
||||||
|
const seconds = String(now.getSeconds()).padStart(2, '0');
|
||||||
|
|
||||||
|
const dateTimeNow = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||||
|
members.forEach((mem) => {
|
||||||
|
mem.lastVisit = dateTimeNow;
|
||||||
|
});
|
||||||
|
|
||||||
|
await appApi
|
||||||
|
.post('members/edit', members)
|
||||||
|
.then(() => {
|
||||||
|
if (members.length > 1) {
|
||||||
|
NotifyResponse(i18n.global.t('membersUpdated'));
|
||||||
|
} else {
|
||||||
|
NotifyResponse(i18n.global.t('memberUpdated'));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
}
|
}
|
||||||
defineExpose({
|
|
||||||
getSelected,
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
68
src/vueLib/tables/responsible/ResponsibleTable.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import { appApi } from 'src/boot/axios';
|
||||||
|
import { ref, computed } from 'vue';
|
||||||
|
import type { Members } from 'src/vueLib/models/member';
|
||||||
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
|
import { i18n } from 'boot/lang';
|
||||||
|
|
||||||
|
export function useResponsibleTable() {
|
||||||
|
const responsibles = ref<Members>([]);
|
||||||
|
|
||||||
|
const pagination = ref({
|
||||||
|
sortBy: 'firstName',
|
||||||
|
descending: false,
|
||||||
|
page: 1,
|
||||||
|
rowsPerPage: 20,
|
||||||
|
});
|
||||||
|
|
||||||
|
const columns = computed(() => [
|
||||||
|
{
|
||||||
|
name: 'firstName',
|
||||||
|
align: 'left' as const,
|
||||||
|
label: i18n.global.t('prename'),
|
||||||
|
field: 'firstName',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'lastName',
|
||||||
|
align: 'left' as const,
|
||||||
|
label: i18n.global.t('lastName'),
|
||||||
|
field: 'lastName',
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{ name: 'option', align: 'center' as const, label: '', field: 'option', icon: 'option' },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const { NotifyResponse } = useNotify();
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
//updates responsible list from database
|
||||||
|
async function updateResponsibles() {
|
||||||
|
loading.value = true;
|
||||||
|
|
||||||
|
await appApi
|
||||||
|
.get('responsible')
|
||||||
|
.then((resp) => {
|
||||||
|
if (resp.data === null) {
|
||||||
|
responsibles.value = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
responsibles.value = resp.data as Members;
|
||||||
|
})
|
||||||
|
|
||||||
|
.catch((err) => {
|
||||||
|
NotifyResponse(err, 'error');
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
responsibles,
|
||||||
|
pagination,
|
||||||
|
columns,
|
||||||
|
loading,
|
||||||
|
updateResponsibles,
|
||||||
|
};
|
||||||
|
}
|
||||||
242
src/vueLib/tables/responsible/ResponsibleTable.vue
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
<template>
|
||||||
|
<div class="q-pa-md">
|
||||||
|
<q-table
|
||||||
|
flat
|
||||||
|
bordered
|
||||||
|
ref="tableRef"
|
||||||
|
title="Responsibles"
|
||||||
|
title-class="text-bold text-blue-9"
|
||||||
|
:no-data-label="$t('noDataAvailable')"
|
||||||
|
:loading-label="$t('loading')"
|
||||||
|
:rows-per-page-label="$t('recordsPerPage')"
|
||||||
|
:selected-rows-label="(val) => val + ' ' + $t('recordSelected')"
|
||||||
|
:rows="responsibles"
|
||||||
|
:columns="columns"
|
||||||
|
row-key="id"
|
||||||
|
v-model:pagination="pagination"
|
||||||
|
:loading="loading"
|
||||||
|
:filter="filter"
|
||||||
|
:selection="selectOption ? 'multiple' : 'none'"
|
||||||
|
v-model:selected="selected"
|
||||||
|
binary-state-sort
|
||||||
|
class="bigger-table-text"
|
||||||
|
>
|
||||||
|
<template v-slot:top-left>
|
||||||
|
<q-btn-group push flat style="color: grey">
|
||||||
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('responsible', 'write')"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
icon="add"
|
||||||
|
@click="openResponsibleDialog"
|
||||||
|
>
|
||||||
|
<q-tooltip>{{ $t('addNewResponsible') }}</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
<q-btn
|
||||||
|
v-if="
|
||||||
|
user.isPermittedTo('responsible', 'write') ||
|
||||||
|
user.isPermittedTo('responsible', 'delete')
|
||||||
|
"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
style="color: grey"
|
||||||
|
:icon="selectOption ? 'check_box' : 'check_box_outline_blank'"
|
||||||
|
@click="selectOption = !selectOption"
|
||||||
|
>
|
||||||
|
<q-tooltip>{{ $t('selectResponsibleOptions') }}</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
</q-btn-group>
|
||||||
|
<div v-if="selectOption && selected.length > 0">
|
||||||
|
<q-btn flat dense icon="more_vert" @click="openSubmenu = true" />
|
||||||
|
<q-menu v-if="openSubmenu" anchor="bottom middle" self="top middle">
|
||||||
|
<q-item
|
||||||
|
v-if="user.isPermittedTo('responsible', 'delete')"
|
||||||
|
clickable
|
||||||
|
v-close-popup
|
||||||
|
@click="openRemoveDialog(...selected)"
|
||||||
|
class="text-negative"
|
||||||
|
>{{ $t('delete') }}</q-item
|
||||||
|
>
|
||||||
|
</q-menu>
|
||||||
|
</div>
|
||||||
|
<div v-if="selectOption && selected.length > 0" class="text-weight-bold">
|
||||||
|
{{ $t('selected') }}: {{ selected.length }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-slot:top-right>
|
||||||
|
<q-input filled dense debounce="300" v-model="filter" :placeholder="$t('search')">
|
||||||
|
<template v-slot:append>
|
||||||
|
<q-icon name="search" />
|
||||||
|
</template>
|
||||||
|
</q-input>
|
||||||
|
</template>
|
||||||
|
<template v-slot:body-cell="props">
|
||||||
|
<q-td :props="props">
|
||||||
|
{{ props.value }}
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
|
<template v-slot:body-cell-option="props">
|
||||||
|
<q-td :props="props">
|
||||||
|
<q-btn
|
||||||
|
v-if="
|
||||||
|
user.isPermittedTo('responsible', 'write') ||
|
||||||
|
user.isPermittedTo('responsible', 'delete')
|
||||||
|
"
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
icon="more_vert"
|
||||||
|
@click="openSubmenu = true"
|
||||||
|
/>
|
||||||
|
<q-menu v-if="openSubmenu" anchor="top right" self="top left">
|
||||||
|
<q-item
|
||||||
|
v-if="user.isPermittedTo('responsible', 'delete')"
|
||||||
|
clickable
|
||||||
|
v-close-popup
|
||||||
|
@click="openRemoveDialog(props.row)"
|
||||||
|
class="text-negative"
|
||||||
|
title="zu"
|
||||||
|
>{{ $t('delete') }}</q-item
|
||||||
|
>
|
||||||
|
</q-menu>
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
|
</q-table>
|
||||||
|
</div>
|
||||||
|
<DialogFrame
|
||||||
|
ref="responsibleDialog"
|
||||||
|
:header-title="$t('addNewResponsible')"
|
||||||
|
:height="600"
|
||||||
|
:width="500"
|
||||||
|
>
|
||||||
|
<MembersTable
|
||||||
|
add-responsible
|
||||||
|
:compare-members="responsibles"
|
||||||
|
v-on:update-event="updateResponsibles"
|
||||||
|
/>
|
||||||
|
</DialogFrame>
|
||||||
|
<OkDialog
|
||||||
|
ref="okDialog"
|
||||||
|
:dialog-label="$t('delete')"
|
||||||
|
:text="$t('doYouWantToDelete') + ' ' + deleteText"
|
||||||
|
label-color="red"
|
||||||
|
:button-cancel-label="$t('cancel')"
|
||||||
|
:button-ok-label="$t('confirm')"
|
||||||
|
:button-ok-flat="false"
|
||||||
|
button-ok-color="red"
|
||||||
|
v-on:update-confirm="(val) => removeResponsible(...val)"
|
||||||
|
></OkDialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { appApi } from 'src/boot/axios';
|
||||||
|
import { ref, onMounted } from 'vue';
|
||||||
|
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
||||||
|
import MembersTable from '../members/MembersTable.vue';
|
||||||
|
import type { Member, Members } from 'src/vueLib/models/member';
|
||||||
|
import OkDialog from 'src/components/dialog/OkDialog.vue';
|
||||||
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
|
import { useResponsibleTable } from './ResponsibleTable';
|
||||||
|
import { databaseName } from 'src/vueLib/models/settings';
|
||||||
|
import { useUserStore } from 'src/vueLib/login/userStore';
|
||||||
|
import { i18n } from 'src/boot/lang';
|
||||||
|
|
||||||
|
export interface ResponsibleDialog {
|
||||||
|
getSelected: () => Members;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { NotifyResponse } = useNotify();
|
||||||
|
const responsibleDialog = ref();
|
||||||
|
const okDialog = ref();
|
||||||
|
const deleteText = ref('');
|
||||||
|
const selectOption = ref(false);
|
||||||
|
const selected = ref<Members>([]);
|
||||||
|
const openSubmenu = ref(false);
|
||||||
|
const filter = ref('');
|
||||||
|
const user = useUserStore();
|
||||||
|
|
||||||
|
const { responsibles, pagination, loading, columns, updateResponsibles } = useResponsibleTable();
|
||||||
|
|
||||||
|
//load on mounting page
|
||||||
|
onMounted(() => {
|
||||||
|
loading.value = true;
|
||||||
|
|
||||||
|
appApi
|
||||||
|
.post('database/open', { dbPath: databaseName.value, create: true })
|
||||||
|
.then(() => {
|
||||||
|
updateResponsibles().catch((err) => {
|
||||||
|
NotifyResponse(err, 'error');
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'))
|
||||||
|
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//opens dialog for one value
|
||||||
|
function openResponsibleDialog() {
|
||||||
|
responsibleDialog.value?.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
//opens remove dialog
|
||||||
|
function openRemoveDialog(...Responsibles: Members) {
|
||||||
|
if (Responsibles.length === 1) {
|
||||||
|
deleteText.value = "'";
|
||||||
|
if (Responsibles[0]?.firstName !== undefined) {
|
||||||
|
deleteText.value += Responsibles[0]?.firstName + ' ';
|
||||||
|
}
|
||||||
|
if (Responsibles[0]?.lastName !== undefined) {
|
||||||
|
deleteText.value += Responsibles[0]?.lastName;
|
||||||
|
}
|
||||||
|
deleteText.value += "'";
|
||||||
|
} else {
|
||||||
|
deleteText.value = String(Responsibles.length) + ' ' + i18n.global.t('responsibles');
|
||||||
|
}
|
||||||
|
okDialog.value?.open(Responsibles);
|
||||||
|
}
|
||||||
|
|
||||||
|
//remove Responsible from database
|
||||||
|
function removeResponsible(...removeResponsibles: Members) {
|
||||||
|
const ResponsibleIds: number[] = [];
|
||||||
|
|
||||||
|
removeResponsibles.forEach((Responsible: Member) => {
|
||||||
|
ResponsibleIds.push(Responsible.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
appApi
|
||||||
|
.post('responsible/delete', { ids: ResponsibleIds })
|
||||||
|
.then(() => {
|
||||||
|
updateResponsibles().catch((err) => {
|
||||||
|
NotifyResponse(err, 'error');
|
||||||
|
});
|
||||||
|
selected.value = [];
|
||||||
|
})
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'))
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@keyframes blink-yellow {
|
||||||
|
0%,
|
||||||
|
100% {
|
||||||
|
background-color: yellow;
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bigger-table-text .q-table__middle td {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bigger-table-text .q-table__top,
|
||||||
|
.bigger-table-text .q-table__bottom,
|
||||||
|
.bigger-table-text th {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -3,6 +3,8 @@ import { ref, computed } from 'vue';
|
|||||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
import { i18n } from 'boot/lang';
|
import { i18n } from 'boot/lang';
|
||||||
import type { Roles } from 'src/vueLib/models/roles';
|
import type { Roles } from 'src/vueLib/models/roles';
|
||||||
|
import { useUserStore } from 'src/vueLib/login/userStore';
|
||||||
|
import { useLogin } from 'src/vueLib/login/useLogin';
|
||||||
|
|
||||||
export const roles = ref<Roles>([]);
|
export const roles = ref<Roles>([]);
|
||||||
|
|
||||||
@@ -15,14 +17,6 @@ export function useRoleTable() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
align: 'left' as const,
|
|
||||||
label: 'Id',
|
|
||||||
field: 'id',
|
|
||||||
sortable: true,
|
|
||||||
style: 'width: 50px; max-width: 50px;',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'role',
|
name: 'role',
|
||||||
align: 'left' as const,
|
align: 'left' as const,
|
||||||
@@ -31,11 +25,10 @@ export function useRoleTable() {
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'rights',
|
name: 'permissions',
|
||||||
align: 'left' as const,
|
align: 'left' as const,
|
||||||
label: i18n.global.t('rights'),
|
label: i18n.global.t('permissions'),
|
||||||
field: 'rights',
|
field: '',
|
||||||
sortable: true,
|
|
||||||
style: 'width: 120px; max-width: 120px;',
|
style: 'width: 120px; max-width: 120px;',
|
||||||
},
|
},
|
||||||
{ name: 'option', align: 'center' as const, label: '', field: 'option', icon: 'option' },
|
{ name: 'option', align: 'center' as const, label: '', field: 'option', icon: 'option' },
|
||||||
@@ -44,18 +37,21 @@ export function useRoleTable() {
|
|||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const login = useLogin();
|
||||||
|
|
||||||
//updates user list from database
|
//updates user list from database
|
||||||
function updateRoles() {
|
async function updateRoles() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
appApi
|
await appApi
|
||||||
.get('secure/roles')
|
.get('roles?id=0')
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (resp.data === null) {
|
if (resp.data === null) {
|
||||||
roles.value = [];
|
roles.value = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
roles.value = resp.data as Roles;
|
roles.value = resp.data as Roles;
|
||||||
|
|
||||||
if (roles.value === null) {
|
if (roles.value === null) {
|
||||||
roles.value = [];
|
roles.value = [];
|
||||||
return;
|
return;
|
||||||
@@ -68,6 +64,17 @@ export function useRoleTable() {
|
|||||||
.finally(() => {
|
.finally(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
|
await appApi
|
||||||
|
.get('/login/me')
|
||||||
|
.then((resp) => {
|
||||||
|
userStore
|
||||||
|
.setUser({ id: resp.data.id, username: resp.data.username, role: resp.data.role })
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
login.refresh().catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
login.logout().catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
roles,
|
roles,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
:no-data-label="$t('noDataAvailable')"
|
:no-data-label="$t('noDataAvailable')"
|
||||||
:loading-label="$t('loading')"
|
:loading-label="$t('loading')"
|
||||||
:rows-per-page-label="$t('recordsPerPage')"
|
:rows-per-page-label="$t('recordsPerPage')"
|
||||||
:selected-rows-label="(val) => val + $t('recordSelected')"
|
:selected-rows-label="(val) => val + ' ' + $t('recordSelected')"
|
||||||
:rows="roles"
|
:rows="roles"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
@@ -23,10 +23,17 @@
|
|||||||
>
|
>
|
||||||
<template v-slot:top-left>
|
<template v-slot:top-left>
|
||||||
<q-btn-group push flat style="color: grey">
|
<q-btn-group push flat style="color: grey">
|
||||||
<q-btn dense flat icon="add" @click="openAllValueDialog(null)">
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('userSettings', 'write')"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
icon="add"
|
||||||
|
@click="openAllValueDialog(null)"
|
||||||
|
>
|
||||||
<q-tooltip>{{ $t('addNewRole') }}</q-tooltip>
|
<q-tooltip>{{ $t('addNewRole') }}</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
<q-btn
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('userSettings', 'write')"
|
||||||
dense
|
dense
|
||||||
flat
|
flat
|
||||||
style="color: grey"
|
style="color: grey"
|
||||||
@@ -62,21 +69,65 @@
|
|||||||
<template v-slot:body-cell="props">
|
<template v-slot:body-cell="props">
|
||||||
<q-td
|
<q-td
|
||||||
:props="props"
|
:props="props"
|
||||||
@click="openSingleValueDialog(props.col.label, props.col.name, props.row)"
|
:disable="!autorized(props.row)"
|
||||||
|
:style="
|
||||||
|
autorized(props.row) && user.isPermittedTo('userSettings', 'write')
|
||||||
|
? 'cursor: pointer'
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
@click="
|
||||||
|
autorized(props.row) && user.isPermittedTo('userSettings', 'write')
|
||||||
|
? openSingleValueDialog(props.col.label, props.col.name, props.row)
|
||||||
|
: ''
|
||||||
|
"
|
||||||
>
|
>
|
||||||
{{ props.value }}
|
{{ props.value }}
|
||||||
</q-td>
|
</q-td>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-slot:body-cell-permissions="props">
|
||||||
|
<q-td :props="props">
|
||||||
|
<q-btn
|
||||||
|
:disable="!autorized(props.row) || !user.isPermittedTo('userSettings', 'write')"
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
icon="rule"
|
||||||
|
:color="
|
||||||
|
autorized(props.row) && user.isPermittedTo('userSettings', 'write')
|
||||||
|
? 'secondary'
|
||||||
|
: 'grey'
|
||||||
|
"
|
||||||
|
@click="
|
||||||
|
user.isPermittedTo('userSettings', 'write') &&
|
||||||
|
openAllValueDialog(props.row, 'permissions')
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<q-tooltip> {{ $t('permissions') }} </q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
<template v-slot:body-cell-option="props">
|
<template v-slot:body-cell-option="props">
|
||||||
<q-td :props="props">
|
<q-td :props="props">
|
||||||
<q-btn flat dense icon="delete" color="negative" @click="openRemoveDialog(props.row)">
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('userSettings', 'delete')"
|
||||||
|
:disable="!autorized(props.row)"
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
icon="delete"
|
||||||
|
color="negative"
|
||||||
|
@click="openRemoveDialog(props.row)"
|
||||||
|
>
|
||||||
<q-tooltip> {{ $t('delete') }} </q-tooltip>
|
<q-tooltip> {{ $t('delete') }} </q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</q-td>
|
</q-td>
|
||||||
</template>
|
</template>
|
||||||
</q-table>
|
</q-table>
|
||||||
</div>
|
</div>
|
||||||
<EditOneDialog ref="editOneDialog" v-on:update="updateRoles"></EditOneDialog>
|
<EditOneDialog
|
||||||
|
ref="editOneDialog"
|
||||||
|
endpoint="roles/update"
|
||||||
|
query-id
|
||||||
|
v-on:update="updateRoles"
|
||||||
|
></EditOneDialog>
|
||||||
<EditAllDialog ref="editAllDialog" v-on:update="updateRoles"></EditAllDialog>
|
<EditAllDialog ref="editAllDialog" v-on:update="updateRoles"></EditAllDialog>
|
||||||
<OkDialog
|
<OkDialog
|
||||||
ref="okDialog"
|
ref="okDialog"
|
||||||
@@ -100,7 +151,9 @@ import EditAllDialog from 'src/components/RoleEditAllDialog.vue';
|
|||||||
import OkDialog from 'src/components/dialog/OkDialog.vue';
|
import OkDialog from 'src/components/dialog/OkDialog.vue';
|
||||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
import { useRoleTable } from './RoleTable';
|
import { useRoleTable } from './RoleTable';
|
||||||
import { useLogin } from 'src/vueLib/login/useLogin';
|
import { i18n } from 'src/boot/lang';
|
||||||
|
import { QTable } from 'quasar';
|
||||||
|
import { useUserStore } from 'src/vueLib/login/userStore';
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
const editOneDialog = ref();
|
const editOneDialog = ref();
|
||||||
@@ -110,24 +163,32 @@ const deleteText = ref('');
|
|||||||
const selectOption = ref(false);
|
const selectOption = ref(false);
|
||||||
const selected = ref<Roles>([]);
|
const selected = ref<Roles>([]);
|
||||||
const openSubmenu = ref(false);
|
const openSubmenu = ref(false);
|
||||||
|
const currentUser = ref();
|
||||||
const filter = ref('');
|
const filter = ref('');
|
||||||
|
const user = useUserStore();
|
||||||
|
|
||||||
const { roles, pagination, loading, columns, updateRoles } = useRoleTable();
|
const { roles, pagination, loading, columns, updateRoles } = useRoleTable();
|
||||||
|
|
||||||
//load on mounting page
|
//load on mounting page
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
updateRoles();
|
currentUser.value = user.user;
|
||||||
|
updateRoles().catch((err) => NotifyResponse(err, 'error'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function autorized(role: Role): boolean {
|
||||||
|
if (role.id !== 1) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// opens dialog for all role values
|
// opens dialog for all role values
|
||||||
function openSingleValueDialog(label: string, field: string, role: Role) {
|
function openSingleValueDialog(label: string, field: string, role: Role) {
|
||||||
editOneDialog.value?.open(label, field, role);
|
editOneDialog.value?.open(label, field, role);
|
||||||
}
|
}
|
||||||
|
|
||||||
//opens dialog for one value
|
//opens dialog for one value
|
||||||
function openAllValueDialog(role: Role | null) {
|
function openAllValueDialog(role: Role | null, typ?: 'permissions') {
|
||||||
editAllDialog.value?.open(role);
|
editAllDialog.value?.open(role, typ);
|
||||||
}
|
}
|
||||||
|
|
||||||
//opens remove dialog
|
//opens remove dialog
|
||||||
@@ -135,7 +196,7 @@ function openRemoveDialog(...roles: Roles) {
|
|||||||
if (roles.length === 1) {
|
if (roles.length === 1) {
|
||||||
deleteText.value = "'" + roles[0]?.role + "'";
|
deleteText.value = "'" + roles[0]?.role + "'";
|
||||||
} else {
|
} else {
|
||||||
deleteText.value = String(roles.length) + ' roles';
|
deleteText.value = String(roles.length) + ' ' + i18n.global.t('roles');
|
||||||
}
|
}
|
||||||
okDialog.value?.open(roles);
|
okDialog.value?.open(roles);
|
||||||
}
|
}
|
||||||
@@ -145,18 +206,22 @@ function removeRole(...removeRoles: Roles) {
|
|||||||
const roles: string[] = [];
|
const roles: string[] = [];
|
||||||
|
|
||||||
removeRoles.forEach((role: Role) => {
|
removeRoles.forEach((role: Role) => {
|
||||||
if (role.role) {
|
if (role.role === currentUser.value.role) {
|
||||||
|
NotifyResponse(i18n.global.t('notPossibleToDeleteLoggedInRole'), 'error');
|
||||||
|
} else if (role.role) {
|
||||||
roles.push(role.role);
|
roles.push(role.role);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const login = useLogin();
|
|
||||||
const user = login.getUser();
|
|
||||||
|
|
||||||
appApi
|
appApi
|
||||||
.post('secure/roles/delete?role=' + user?.role, { roles: roles })
|
.post('roles/delete?role=' + currentUser.value.role, { roles: roles })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
updateRoles();
|
updateRoles().catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
if (roles.length === 1) {
|
||||||
|
NotifyResponse("'" + roles[0] + "' " + i18n.global.t('deleted'), 'warning');
|
||||||
|
} else {
|
||||||
|
NotifyResponse(i18n.global.t('deleteRoles'), 'warning');
|
||||||
|
}
|
||||||
selected.value = [];
|
selected.value = [];
|
||||||
})
|
})
|
||||||
.catch((err) => NotifyResponse(err, 'error'))
|
.catch((err) => NotifyResponse(err, 'error'))
|
||||||
@@ -164,14 +229,6 @@ function removeRole(...removeRoles: Roles) {
|
|||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelected(): Roles {
|
|
||||||
if (selected.value.length === 0) return [];
|
|
||||||
return selected.value;
|
|
||||||
}
|
|
||||||
defineExpose({
|
|
||||||
getSelected,
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -15,14 +15,6 @@ export function useUserTable() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
align: 'left' as const,
|
|
||||||
label: 'Id',
|
|
||||||
field: 'id',
|
|
||||||
sortable: true,
|
|
||||||
style: 'width: 50px; max-width: 50px;',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'user',
|
name: 'user',
|
||||||
align: 'left' as const,
|
align: 'left' as const,
|
||||||
@@ -45,6 +37,14 @@ export function useUserTable() {
|
|||||||
sortable: true,
|
sortable: true,
|
||||||
style: 'width: 120px; max-width: 120px;',
|
style: 'width: 120px; max-width: 120px;',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'expiration',
|
||||||
|
align: 'left' as const,
|
||||||
|
label: i18n.global.t('expiration'),
|
||||||
|
field: 'expiration',
|
||||||
|
sortable: true,
|
||||||
|
style: 'width: 120px; max-width: 120px;',
|
||||||
|
},
|
||||||
{ name: 'option', align: 'center' as const, label: '', field: 'option', icon: 'option' },
|
{ name: 'option', align: 'center' as const, label: '', field: 'option', icon: 'option' },
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -55,9 +55,8 @@ export function useUserTable() {
|
|||||||
//updates user list from database
|
//updates user list from database
|
||||||
function updateUsers() {
|
function updateUsers() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
|
||||||
appApi
|
appApi
|
||||||
.get('secure/users')
|
.get('users')
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (resp.data === null) {
|
if (resp.data === null) {
|
||||||
users.value = [];
|
users.value = [];
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
:no-data-label="$t('noDataAvailable')"
|
:no-data-label="$t('noDataAvailable')"
|
||||||
:loading-label="$t('loading')"
|
:loading-label="$t('loading')"
|
||||||
:rows-per-page-label="$t('recordsPerPage')"
|
:rows-per-page-label="$t('recordsPerPage')"
|
||||||
:selected-rows-label="(val) => val + $t('recordSelected')"
|
:selected-rows-label="(val) => val + ' ' + $t('recordSelected')"
|
||||||
:rows="users"
|
:rows="users"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
@@ -23,10 +23,17 @@
|
|||||||
>
|
>
|
||||||
<template v-slot:top-left>
|
<template v-slot:top-left>
|
||||||
<q-btn-group push flat style="color: grey">
|
<q-btn-group push flat style="color: grey">
|
||||||
<q-btn dense flat icon="add" @click="openAllValueDialog(null)">
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('userSettings', 'write')"
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
icon="add"
|
||||||
|
@click="openAllValueDialog(null)"
|
||||||
|
>
|
||||||
<q-tooltip>{{ $t('addNewUser') }}</q-tooltip>
|
<q-tooltip>{{ $t('addNewUser') }}</q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
<q-btn
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('userSettings', 'write')"
|
||||||
dense
|
dense
|
||||||
flat
|
flat
|
||||||
style="color: grey"
|
style="color: grey"
|
||||||
@@ -60,28 +67,73 @@
|
|||||||
</q-input>
|
</q-input>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:body-cell="props">
|
<template v-slot:body-cell="props">
|
||||||
<q-td v-if="props.col.name === 'role'" :props="props">
|
|
||||||
<q-select dense v-model="props.row.role" :options="localRoles"></q-select>
|
|
||||||
</q-td>
|
|
||||||
<q-td
|
<q-td
|
||||||
v-else
|
|
||||||
:props="props"
|
:props="props"
|
||||||
@click="openSingleValueDialog(props.col.label, props.col.name, props.row)"
|
:style="
|
||||||
|
autorized(props.row) && user.isPermittedTo('userSettings', 'write')
|
||||||
|
? 'cursor: pointer'
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
@click="
|
||||||
|
autorized(props.row) && user.isPermittedTo('userSettings', 'write')
|
||||||
|
? openSingleValueDialog(props.col.label, props.col.name, props.row)
|
||||||
|
: ''
|
||||||
|
"
|
||||||
>
|
>
|
||||||
{{ props.value }}
|
{{ props.value }}
|
||||||
</q-td>
|
</q-td>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-slot:body-cell-role="props">
|
||||||
|
<q-td :props="props">
|
||||||
|
<q-select
|
||||||
|
:readonly="!user.isPermittedTo('userSettings', 'write') || !autorized(props.row)"
|
||||||
|
dense
|
||||||
|
v-model="props.row.role"
|
||||||
|
:options="localRoles"
|
||||||
|
@update:model-value="updateUser(props.row)"
|
||||||
|
></q-select>
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
|
<template v-slot:body-cell-expiration="props">
|
||||||
|
<q-td
|
||||||
|
:props="props"
|
||||||
|
:style="
|
||||||
|
autorized(props.row) && user.isPermittedTo('userSettings', 'write')
|
||||||
|
? 'cursor: pointer'
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
@click="
|
||||||
|
autorized(props.row) && user.isPermittedTo('userSettings', 'write')
|
||||||
|
? openSingleValueDialog(props.col.label, props.col.name, props.row)
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{ props.value === 'never' ? $t('never') : props.value }}
|
||||||
|
</q-td>
|
||||||
|
</template>
|
||||||
<template v-slot:body-cell-option="props">
|
<template v-slot:body-cell-option="props">
|
||||||
<q-td :props="props">
|
<q-td :props="props">
|
||||||
<q-btn flat dense icon="delete" color="negative" @click="openRemoveDialog(props.row)">
|
<q-btn
|
||||||
|
v-if="user.isPermittedTo('userSettings', 'delete')"
|
||||||
|
:disable="!autorized(props.row)"
|
||||||
|
flat
|
||||||
|
dense
|
||||||
|
icon="delete"
|
||||||
|
color="negative"
|
||||||
|
@click="openRemoveDialog(props.row)"
|
||||||
|
>
|
||||||
<q-tooltip> {{ $t('delete') }} </q-tooltip>
|
<q-tooltip> {{ $t('delete') }} </q-tooltip>
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</q-td>
|
</q-td>
|
||||||
</template>
|
</template>
|
||||||
</q-table>
|
</q-table>
|
||||||
</div>
|
</div>
|
||||||
<EditOneDialog ref="editOneDialog" v-on:update="updateUsers"></EditOneDialog>
|
<EditOneDialog
|
||||||
<EditAllDialog ref="editAllDialog" v-on:update="updateUsers"></EditAllDialog>
|
ref="editOneDialog"
|
||||||
|
query-id
|
||||||
|
v-on:update="(val) => updateUser(val)"
|
||||||
|
></EditOneDialog>
|
||||||
|
<EditAllDialog ref="editAllDialog" :roles="localRoles" v-on:update="updateUsers"></EditAllDialog>
|
||||||
<OkDialog
|
<OkDialog
|
||||||
ref="okDialog"
|
ref="okDialog"
|
||||||
:dialog-label="$t('delete')"
|
:dialog-label="$t('delete')"
|
||||||
@@ -104,28 +156,41 @@ import EditAllDialog from 'src/components/UserEditAllDialog.vue';
|
|||||||
import OkDialog from 'src/components/dialog/OkDialog.vue';
|
import OkDialog from 'src/components/dialog/OkDialog.vue';
|
||||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
import { useUserTable } from './UserTable';
|
import { useUserTable } from './UserTable';
|
||||||
import { useLogin } from 'src/vueLib/login/useLogin';
|
import { roles, useRoleTable } from '../roles/RoleTable';
|
||||||
import { roles } from '../roles/RoleTable';
|
import { i18n } from 'src/boot/lang';
|
||||||
|
import { useUserStore } from 'src/vueLib/login/userStore';
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
const editOneDialog = ref();
|
const editOneDialog = ref();
|
||||||
const editAllDialog = ref();
|
const editAllDialog = ref();
|
||||||
const okDialog = ref();
|
const okDialog = ref();
|
||||||
const deleteText = ref('');
|
const deleteText = ref('');
|
||||||
const localRoles = computed(() => roles.value.map((role) => role.role));
|
const localRoles = computed(() => {
|
||||||
|
return roles.value.map((role) => role.role);
|
||||||
|
});
|
||||||
const selectOption = ref(false);
|
const selectOption = ref(false);
|
||||||
const selected = ref<Users>([]);
|
const selected = ref<Users>([]);
|
||||||
const openSubmenu = ref(false);
|
const openSubmenu = ref(false);
|
||||||
const filter = ref('');
|
const filter = ref('');
|
||||||
|
const currentUser = ref();
|
||||||
const { users, pagination, loading, columns, updateUsers } = useUserTable();
|
const { users, pagination, loading, columns, updateUsers } = useUserTable();
|
||||||
|
const { updateRoles } = useRoleTable();
|
||||||
|
const user = useUserStore();
|
||||||
|
|
||||||
//load on mounting page
|
//load on mounting page
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
currentUser.value = user.user;
|
||||||
updateUsers();
|
updateUsers();
|
||||||
|
updateRoles().catch((err) => NotifyResponse(err, 'error'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//check authorization
|
||||||
|
function autorized(user: User): boolean {
|
||||||
|
if (user.id !== 1) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// opens dialog for all user values
|
// opens dialog for all user values
|
||||||
function openSingleValueDialog(label: string, field: string, user: User) {
|
function openSingleValueDialog(label: string, field: string, user: User) {
|
||||||
editOneDialog.value?.open(label, field, user);
|
editOneDialog.value?.open(label, field, user);
|
||||||
@@ -141,7 +206,7 @@ function openRemoveDialog(...users: Users) {
|
|||||||
if (users.length === 1) {
|
if (users.length === 1) {
|
||||||
deleteText.value = "'" + users[0]?.user + "'";
|
deleteText.value = "'" + users[0]?.user + "'";
|
||||||
} else {
|
} else {
|
||||||
deleteText.value = String(users.length) + ' users';
|
deleteText.value = String(users.length) + ' ' + i18n.global.t('users');
|
||||||
}
|
}
|
||||||
okDialog.value?.open(users);
|
okDialog.value?.open(users);
|
||||||
}
|
}
|
||||||
@@ -151,16 +216,15 @@ function removeUser(...removeUsers: Users) {
|
|||||||
const userIds: number[] = [];
|
const userIds: number[] = [];
|
||||||
|
|
||||||
removeUsers.forEach((user: User) => {
|
removeUsers.forEach((user: User) => {
|
||||||
if (user.id) {
|
if (user.id === currentUser.value.id) {
|
||||||
|
NotifyResponse(i18n.global.t('notPossibleToDeleteLoggedInUser'), 'error');
|
||||||
|
} else if (user.id) {
|
||||||
userIds.push(user.id);
|
userIds.push(user.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const login = useLogin();
|
|
||||||
const user = login.getUser();
|
|
||||||
|
|
||||||
appApi
|
appApi
|
||||||
.post('secure/users/delete?id=' + user?.id, { ids: userIds })
|
.post('users/delete?id=' + currentUser.value.id, { ids: userIds })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
updateUsers();
|
updateUsers();
|
||||||
selected.value = [];
|
selected.value = [];
|
||||||
@@ -171,13 +235,13 @@ function removeUser(...removeUsers: Users) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelected(): Users {
|
// update role select
|
||||||
if (selected.value.length === 0) return [];
|
function updateUser(user: User) {
|
||||||
return selected.value;
|
appApi
|
||||||
|
.post('/users/update', user)
|
||||||
|
.then(() => NotifyResponse(i18n.global.t('userUpdated')))
|
||||||
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
}
|
}
|
||||||
defineExpose({
|
|
||||||
getSelected,
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
21
src/vueLib/utils/validation.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import type { QForm } from 'quasar';
|
||||||
|
import { nextTick } from 'vue';
|
||||||
|
|
||||||
|
export async function validateQForm(formRef: QForm | null | undefined): Promise<boolean> {
|
||||||
|
await nextTick(); // wait until all inputs are rendered
|
||||||
|
const components = formRef?.getValidationComponents?.();
|
||||||
|
|
||||||
|
if (!components) {
|
||||||
|
console.warn('No validation components found in form');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
let allValid = true;
|
||||||
|
|
||||||
|
for (const comp of components) {
|
||||||
|
const valid = await comp.validate();
|
||||||
|
if (!valid) allValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return allValid;
|
||||||
|
}
|
||||||