Compare commits
257 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 69acc57ed2 | |||
| c9bc0c8f38 | |||
| fee9d605f1 | |||
| 8bedcbf88a | |||
| 95946d7cc2 | |||
| c125afdfc7 | |||
| 80fb1a6127 | |||
| 92a66fc8a4 | |||
| 8c52952a1e | |||
| ac16e982ea | |||
| 604c7201e9 | |||
| 2c48ee7610 | |||
| ce42d060ff | |||
| 4d24e7ac2b | |||
| 543424a978 | |||
| 66cc629d57 | |||
| 3c0ec6310f | |||
| ce98a34d5a | |||
| a13678578d | |||
| cbf8e8dcab | |||
| 76c6797495 | |||
| 681d75d0dc | |||
| f008efbd47 | |||
| 88f69ee99b | |||
| b779ca34a3 | |||
| 583bf2181a | |||
| 7d5cfff62f | |||
| e182f1b857 | |||
| f2bcf0d77f | |||
| 40226c2984 | |||
| 7b8947656a | |||
| f13e1270c1 | |||
| b7811dbe27 | |||
| 4060ee4ad3 | |||
| 3dcc3fb64b | |||
| 59926b8c28 | |||
| ebe28b45c0 | |||
| 697e9fe07f | |||
| 08892f5afa | |||
| 5f2ff2d773 | |||
| 2e64e85d4b | |||
| 07f9bb5c77 | |||
| f53b93a3a5 | |||
| 33c56016f6 | |||
| c6f8beda54 | |||
| 8d6f5daba8 | |||
| aba417b1bc | |||
| 3095c7bbb4 | |||
| 3be50f138b | |||
| 58a55e2cbc | |||
| ed1360428d | |||
| 184d9335d7 | |||
| 163f9c8af5 | |||
| 75d47fcd9c | |||
| cbbd187214 | |||
| edd7689887 | |||
| fe406c59a1 | |||
| 87312e5a89 | |||
| 99e897b35f | |||
| 07c6788c2c | |||
| 4a9c010db8 | |||
| edc8022dc6 | |||
| 2021dc58af | |||
| dc056789d2 | |||
| 59647c66a6 | |||
| bd0519df1b | |||
| 8c19e13cda | |||
| f8230f1c5b | |||
| 0563c7ccc3 | |||
| 596b41c35d | |||
| ea0236efc0 | |||
| b35beeb8c3 | |||
| 6c5e09c986 | |||
| d381145bd1 | |||
| 40b01fafa3 | |||
| 54aefadf8e | |||
| 2a69725f15 | |||
| e21cb3e315 | |||
| a3a0dcd585 | |||
| 86a616bcc3 | |||
| a8181eeb8b | |||
| 9c56c17ebc | |||
| a5b9761537 | |||
| 9534fe21e2 | |||
| c2e44761c4 | |||
| 9741037e96 | |||
| 41b7c08bce | |||
| be1db1fc1d | |||
| ee1c5132b7 | |||
| 31fb7c6fff | |||
| fb4ae2daa5 | |||
| 930295ec71 | |||
| f82747d435 | |||
| ce1283cc68 | |||
| b62e73ac03 | |||
| c0bef1b6db | |||
| 85b9bc00af | |||
| 31d246e61f | |||
| 5ebbc336f2 | |||
| de4a46995c | |||
| c2f574426f | |||
| cee1669a0e | |||
| bba23e1f7a | |||
| 01911874d1 | |||
| 052d69a2ca | |||
| f83d23ce23 | |||
| d24eabfb3e | |||
| 83dfa54fbd | |||
| d7ba7d812d | |||
| 540278bb67 | |||
| 3626319a0e | |||
| 2a3c426d21 | |||
| 00f82f2b71 | |||
| 0eaff40b51 | |||
| efe3b03c34 | |||
| 77147f04c1 | |||
| fa040c3442 | |||
| b8df1d89b1 | |||
| 4c6aafaec7 | |||
| 494413405c | |||
| 08741d0f5c | |||
| f149c25268 | |||
| 60d509309f | |||
| 56e7c230b3 | |||
| 169ecf5773 | |||
| f410caaa54 | |||
| e4a12c5d3c | |||
| cef361232d | |||
| b22ca4525e | |||
| 9107e4f252 | |||
| 957ad71108 | |||
| f88b7a4bf6 | |||
| d1158df2ed | |||
| 65be53bd3c | |||
| c70efd082f | |||
| 0c68342c11 | |||
| 8906b2b6ce | |||
| d36da86fb7 | |||
| c926eb792e | |||
| 09d856e8eb | |||
| 0e42758513 | |||
| 973a1b80d0 | |||
| 558e6484d0 | |||
| 8cb100552d | |||
| ef58ce188a | |||
| 5189a2cbf2 | |||
| 567fa46e77 | |||
| 4f015fbeee | |||
| 9cd8cb21c9 | |||
| eea7ff492b | |||
| 42d35dfbd6 | |||
| 22c16cc455 | |||
| 7764ccc65f | |||
| 62cb0e8f73 | |||
| 2d8fce32d3 | |||
| 3746d71c2d | |||
| 34a0ae5c65 | |||
| 3e7eb6cbf9 | |||
| 9da93677bf | |||
| 71319f0497 | |||
| 74326f3436 | |||
| db8eaab3db | |||
| 8da9b15b5e | |||
| 641095b1bd | |||
| 14a9841218 | |||
| 1f0818b5ed | |||
| 84f7a792cf | |||
| c9bb412729 | |||
| 1216702203 | |||
| 7e30943015 | |||
| 7c91f02606 | |||
| 743da5c4f3 | |||
| d1a0457702 | |||
| 48ad232b50 | |||
| e0431509e2 | |||
| 8372d52212 | |||
| 1c07638b9f | |||
| 19acedeea0 | |||
| e98b9ba75d | |||
| 46016ff5fa | |||
| bc3cd9b77f | |||
| 0d6d94b455 | |||
| e124f5b86e | |||
| 322c1ccc50 | |||
| 4540d8b851 | |||
| c6a9af4086 | |||
| 61980c62d7 | |||
| abe7b446be | |||
| 47b81553be | |||
| 9ebe092b9d | |||
| 6d06e5ae9b | |||
| 69bb334b20 | |||
| 885b69ff03 | |||
| 27e6bf01d3 | |||
| ecce74795d | |||
| 44a2a91e9d | |||
| 2f1acee092 | |||
| 2c92334884 | |||
| 652924e8cd | |||
| bd24ddde74 | |||
| b56c69108b | |||
| 6b9a942b14 | |||
| af84e91bfa | |||
| ac0f9096da | |||
| 71b49adf44 | |||
| e523400551 | |||
| 7e07210ad3 | |||
| 9485351e63 | |||
| bc379d3888 | |||
| 7a4a0d5049 | |||
| d09d1620f3 | |||
| ff46a9ac80 | |||
| 7110be01c6 | |||
| a08a39cbdd | |||
| fba43d919a | |||
| f36e03ef32 | |||
| d3e88bc2dd | |||
| d03f1b220b | |||
| a1ee1e5d27 | |||
| f86a24606f | |||
| 79317fec30 | |||
| fd7ab53b75 | |||
| b0988fc20e | |||
| e3f14e90f7 | |||
| a41495ccb7 | |||
| 1d5cea4620 | |||
| bcd34bdf38 | |||
| 6f512fbc1b | |||
| 78f0375566 | |||
| 6f9039474d | |||
| bf69134e7c | |||
| aef9db57ae | |||
| 6b50d6a0f7 | |||
| 888ddb1c56 | |||
| c4e02fab7a | |||
| 5ffec52b89 | |||
| 20d98f6628 | |||
| f0d7715aca | |||
| f4a1990462 | |||
| 6cbaedebc9 | |||
| 70709024ae | |||
| b870627f86 | |||
| 9b19a114df | |||
| eb9bb9d92f | |||
| 60142488a6 | |||
| 0d15ade648 | |||
| 5b48d924ae | |||
| 96158ce2d8 | |||
| 6707a5bd95 | |||
| 688d05eda9 | |||
| 7ae27a94b0 | |||
| 62c3de819a | |||
| a8f997d0f6 | |||
| dabc97fd49 | |||
| 3e54cdd8f8 | |||
| 6532eb48f8 | |||
| 72d36e297a |
@@ -8,6 +8,9 @@ updates:
|
||||
open-pull-requests-limit: 10
|
||||
commit-message:
|
||||
prefix: go-dep
|
||||
ignore:
|
||||
- dependency-name: "*"
|
||||
update-types: ["version-update:semver-major"]
|
||||
- package-ecosystem: npm
|
||||
directory: "/frontend"
|
||||
schedule:
|
||||
@@ -15,6 +18,9 @@ updates:
|
||||
open-pull-requests-limit: 10
|
||||
commit-message:
|
||||
prefix: npm-dep
|
||||
ignore:
|
||||
- dependency-name: "*"
|
||||
update-types: ["version-update:semver-major"]
|
||||
- package-ecosystem: github-actions
|
||||
directory: "/"
|
||||
schedule:
|
||||
|
||||
@@ -234,3 +234,5 @@ backend/pb_public/*
|
||||
|
||||
dist/
|
||||
vite.config.js.timestamp*
|
||||
|
||||
frontend/src/lib/paraglide
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM alpine:3 as downloader
|
||||
FROM alpine:3 AS downloader
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
ARG TARGETVARIANT
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
FROM node:alpine as node
|
||||
FROM node:alpine AS node
|
||||
WORKDIR /app
|
||||
COPY frontend/ .
|
||||
RUN npm i -g pnpm &&\
|
||||
pnpm i &&\
|
||||
pnpm run build
|
||||
|
||||
FROM golang:alpine as go
|
||||
FROM golang:alpine AS go
|
||||
WORKDIR /app
|
||||
COPY backend/ .
|
||||
COPY --from=node /app/build ./pb_public
|
||||
|
||||
@@ -26,27 +26,21 @@
|
||||
- 🔌 Ping Any Port You Choose
|
||||
- 🔍 Discover Devices with Network Scanning (nmap required)
|
||||
- 👤 Secured User Management
|
||||
- 🌐 i18n support for [these](https://github.com/seriousm4x/UpSnap/tree/master/frontend/src/lib/i18n) languages
|
||||
- 🎨 29 Themes
|
||||
- 🌐 i18n support for [these](/frontend/translations) languages
|
||||
- 🎨 35 Themes
|
||||
- 🐳 [Docker images](https://github.com/seriousm4x/UpSnap/pkgs/container/upsnap) for amd64, arm64, arm/v7, arm/v6
|
||||
- 🏠 Self-Hostable
|
||||
|
||||
## 📸 Screenshots
|
||||
|
||||
| Dark | Light |
|
||||
| --------------------------------- | ---------------------------------- |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
||||
## 🐧 Install from the [AUR](https://aur.archlinux.org/packages/upsnap-bin)
|
||||
|
||||
```bash
|
||||
yay -Sy upsnap-bin
|
||||
```
|
||||
| Silk | Dim |
|
||||
| ---------------------------------- | --------------------------------- |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
||||
## 🚀 Run the binary
|
||||
|
||||
@@ -75,6 +69,8 @@ You can use the [docker-compose](docker-compose.yml) example. See the comments i
|
||||
|
||||
### Non-root docker user:
|
||||
|
||||
You will loose the ability to add network devices via the scan page.
|
||||
|
||||
Create the mount point first:
|
||||
|
||||
```bash
|
||||
@@ -111,6 +107,12 @@ upsnap.example.com {
|
||||
}
|
||||
```
|
||||
|
||||
## 🐧 Install from the [AUR](https://aur.archlinux.org/packages/upsnap-bin)
|
||||
|
||||
```bash
|
||||
yay -Sy upsnap-bin
|
||||
```
|
||||
|
||||
## 🔒 User permissions
|
||||
|
||||
UpSnap offers unique access for each user, per device. While admins have all permissions, they can assign specific rights to users such as displaying/hiding a device, accessing device editing, deleting and powering devices on/off. See the last screenshot in the [📸 Screenshots section](#-screenshots).
|
||||
@@ -127,12 +129,15 @@ Although UpSnap has user authorisation, it is **not recommended to expose it to
|
||||
|
||||
UpSnap is available in the following languages so far:
|
||||
|
||||
- 🇺🇸 **English** (en-US)
|
||||
- 🇩🇪 **German** (de-DE)
|
||||
- 🇺🇸 **English** (en-US)
|
||||
- 🇪🇸 **Spanish** (es-ES)
|
||||
- 🇫🇷 **French** (fr-FR)
|
||||
- 🇮🇩 **Bahasa Indonesia** (id-ID)
|
||||
- 🇮🇹 **Italian** (it-IT)
|
||||
- 🇯🇵 **Japanese** (ja-JP)
|
||||
- 🇳🇱 **Dutch** (nl-NL)
|
||||
- 🇵🇱 **Polish** (pl-PL)
|
||||
- 🇵🇹 **Portuguese** (pt-PT)
|
||||
- 🇨🇳 **Chinese** (zh-CN)
|
||||
- 🇹🇼 **Chinese (Taiwan)** (zh-TW)
|
||||
|
||||
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 124 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 212 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 206 KiB |
|
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 212 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 97 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 101 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 93 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 70 KiB |
@@ -15,20 +15,21 @@ builds:
|
||||
- linux
|
||||
- windows
|
||||
- darwin
|
||||
- freebsd
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
- arm
|
||||
goarm:
|
||||
- 6
|
||||
- 7
|
||||
- "6"
|
||||
- "7"
|
||||
ignore:
|
||||
- goos: windows
|
||||
goarch: arm
|
||||
- goos: darwin
|
||||
goarch: arm
|
||||
archives:
|
||||
- format: zip
|
||||
- formats: [ 'zip' ]
|
||||
checksum:
|
||||
name_template: "checksums.txt"
|
||||
snapshot:
|
||||
@@ -56,7 +57,7 @@ changelog:
|
||||
order: 2
|
||||
git:
|
||||
ignore_tags:
|
||||
- "{{ if not .Prerelease}}beta{{ end }}"
|
||||
- "{{ if not .Prerelease}}*beta*{{ end }}"
|
||||
aurs:
|
||||
- name: upsnap-bin
|
||||
homepage: https://github.com/seriousm4x/UpSnap
|
||||
|
||||
@@ -2,7 +2,7 @@ package cronjobs
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/robfig/cron/v3"
|
||||
"github.com/seriousm4x/upsnap/logger"
|
||||
"github.com/seriousm4x/upsnap/networking"
|
||||
@@ -11,8 +11,12 @@ import (
|
||||
var (
|
||||
PingRunning = false
|
||||
WakeShutdownRunning = false
|
||||
CronPing = cron.New()
|
||||
CronWakeShutdown = cron.New()
|
||||
CronPing = cron.New(cron.WithParser(cron.NewParser(
|
||||
cron.SecondOptional | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow,
|
||||
)))
|
||||
CronWakeShutdown = cron.New(cron.WithParser(cron.NewParser(
|
||||
cron.SecondOptional | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow,
|
||||
)))
|
||||
)
|
||||
|
||||
func SetPingJobs(app *pocketbase.PocketBase) {
|
||||
@@ -21,7 +25,7 @@ func SetPingJobs(app *pocketbase.PocketBase) {
|
||||
CronPing.Remove(job.ID)
|
||||
}
|
||||
|
||||
settingsPrivateRecords, err := app.Dao().FindRecordsByExpr("settings_private")
|
||||
settingsPrivateRecords, err := app.FindAllRecords("settings_private")
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
}
|
||||
@@ -33,34 +37,38 @@ func SetPingJobs(app *pocketbase.PocketBase) {
|
||||
return
|
||||
}
|
||||
|
||||
devices, err := app.Dao().FindRecordsByExpr("devices")
|
||||
devices, err := app.FindAllRecords("devices")
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
// expand ports field
|
||||
expandFetchFunc := func(c *models.Collection, ids []string) ([]*models.Record, error) {
|
||||
return app.Dao().FindRecordsByIds(c.Id, ids, nil)
|
||||
expandFetchFunc := func(c *core.Collection, ids []string) ([]*core.Record, error) {
|
||||
return app.FindRecordsByIds(c.Id, ids, nil)
|
||||
}
|
||||
merr := app.Dao().ExpandRecords(devices, []string{"ports"}, expandFetchFunc)
|
||||
merr := app.ExpandRecords(devices, []string{"ports"}, expandFetchFunc)
|
||||
if len(merr) > 0 {
|
||||
return
|
||||
}
|
||||
|
||||
for _, device := range devices {
|
||||
// ping device
|
||||
go func(d *models.Record) {
|
||||
go func(d *core.Record) {
|
||||
status := d.GetString("status")
|
||||
if status == "pending" {
|
||||
return
|
||||
}
|
||||
if networking.PingDevice(d) {
|
||||
isUp, err := networking.PingDevice(d)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
}
|
||||
if isUp {
|
||||
if status == "online" {
|
||||
return
|
||||
}
|
||||
d.Set("status", "online")
|
||||
if err := app.Dao().SaveRecord(d); err != nil {
|
||||
if err := app.Save(d); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
} else {
|
||||
@@ -68,23 +76,26 @@ func SetPingJobs(app *pocketbase.PocketBase) {
|
||||
return
|
||||
}
|
||||
d.Set("status", "offline")
|
||||
if err := app.Dao().SaveRecord(d); err != nil {
|
||||
if err := app.Save(d); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
}
|
||||
}(device)
|
||||
|
||||
// ping ports
|
||||
go func(d *models.Record) {
|
||||
ports, err := app.Dao().FindRecordsByIds("ports", d.GetStringSlice("ports"))
|
||||
go func(d *core.Record) {
|
||||
ports, err := app.FindRecordsByIds("ports", d.GetStringSlice("ports"))
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
}
|
||||
for _, port := range ports {
|
||||
isUp := networking.CheckPort(d.GetString("ip"), port.GetString("number"))
|
||||
isUp, err := networking.CheckPort(d.GetString("ip"), port.GetString("number"))
|
||||
if err != nil {
|
||||
logger.Error.Println("Failed to check port:", err)
|
||||
}
|
||||
if isUp != port.GetBool("status") {
|
||||
port.Set("status", isUp)
|
||||
if err := app.Dao().SaveRecord(port); err != nil {
|
||||
if err := app.Save(port); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
}
|
||||
@@ -100,7 +111,7 @@ func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
|
||||
CronWakeShutdown.Remove(job.ID)
|
||||
}
|
||||
|
||||
devices, err := app.Dao().FindRecordsByExpr("devices")
|
||||
devices, err := app.FindAllRecords("devices")
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
return
|
||||
@@ -113,17 +124,24 @@ func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
|
||||
|
||||
if wake_cron_enabled && wake_cron != "" {
|
||||
_, err := CronWakeShutdown.AddFunc(wake_cron, func() {
|
||||
isOnline := networking.PingDevice(dev)
|
||||
if isOnline {
|
||||
return
|
||||
}
|
||||
d, err := app.Dao().FindRecordById("devices", dev.Id)
|
||||
d, err := app.FindRecordById("devices", dev.Id)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
return
|
||||
}
|
||||
if d.GetString("status") == "pending" {
|
||||
return
|
||||
}
|
||||
isOnline, err := networking.PingDevice(dev)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
return
|
||||
}
|
||||
if isOnline {
|
||||
return
|
||||
}
|
||||
d.Set("status", "pending")
|
||||
if err := app.Dao().SaveRecord(d); err != nil {
|
||||
if err := app.Save(d); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
return
|
||||
}
|
||||
@@ -133,32 +151,39 @@ func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
|
||||
} else {
|
||||
d.Set("status", "online")
|
||||
}
|
||||
if err := app.Dao().SaveRecord(d); err != nil {
|
||||
if err := app.Save(d); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
logger.Error.Printf("device %s: %+v", dev.GetString("name"), err)
|
||||
}
|
||||
}
|
||||
|
||||
if shutdown_cron_enabled && shutdown_cron != "" {
|
||||
_, err := CronWakeShutdown.AddFunc(shutdown_cron, func() {
|
||||
isOnline := networking.PingDevice(dev)
|
||||
if !isOnline {
|
||||
return
|
||||
}
|
||||
d, err := app.Dao().FindRecordById("devices", dev.Id)
|
||||
d, err := app.FindRecordById("devices", dev.Id)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
return
|
||||
}
|
||||
if d.GetString("status") == "pending" {
|
||||
return
|
||||
}
|
||||
isOnline, err := networking.PingDevice(dev)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
return
|
||||
}
|
||||
if !isOnline {
|
||||
return
|
||||
}
|
||||
status := d.GetString("status")
|
||||
if status != "online" {
|
||||
return
|
||||
}
|
||||
d.Set("status", "pending")
|
||||
if err := app.Dao().SaveRecord(d); err != nil {
|
||||
if err := app.Save(d); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
if err := networking.ShutdownDevice(d); err != nil {
|
||||
@@ -167,12 +192,12 @@ func SetWakeShutdownJobs(app *pocketbase.PocketBase) {
|
||||
} else {
|
||||
d.Set("status", "offline")
|
||||
}
|
||||
if err := app.Dao().SaveRecord(d); err != nil {
|
||||
if err := app.Save(d); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
logger.Error.Printf("device %s: %+v", dev.GetString("name"), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,8 +212,7 @@ func StartWakeShutdown() {
|
||||
func StopWakeShutdown() {
|
||||
if WakeShutdownRunning {
|
||||
logger.Info.Println("Stopping wake/shutdown cronjob")
|
||||
ctx := CronWakeShutdown.Stop()
|
||||
<-ctx.Done()
|
||||
CronWakeShutdown.Stop()
|
||||
}
|
||||
WakeShutdownRunning = false
|
||||
}
|
||||
@@ -201,8 +225,7 @@ func StartPing() {
|
||||
func StopPing() {
|
||||
if PingRunning {
|
||||
logger.Info.Println("Stopping wake/shutdown cronjob")
|
||||
ctx := CronPing.Stop()
|
||||
<-ctx.Done()
|
||||
CronPing.Stop()
|
||||
}
|
||||
PingRunning = false
|
||||
}
|
||||
|
||||
@@ -1,90 +1,51 @@
|
||||
module github.com/seriousm4x/upsnap
|
||||
|
||||
go 1.23.0
|
||||
go 1.24
|
||||
|
||||
require (
|
||||
github.com/labstack/echo/v5 v5.0.0-20230722203903-ec5b858dab61
|
||||
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a
|
||||
github.com/pocketbase/dbx v1.10.1
|
||||
github.com/pocketbase/pocketbase v0.22.25
|
||||
github.com/prometheus-community/pro-bing v0.4.1
|
||||
github.com/pocketbase/dbx v1.11.0
|
||||
github.com/pocketbase/pocketbase v0.26.1
|
||||
github.com/prometheus-community/pro-bing v0.6.1
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
golang.org/x/sys v0.27.0
|
||||
golang.org/x/sys v0.31.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/AlecAivazis/survey/v2 v2.3.7 // indirect
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2 v1.32.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.6 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/config v1.28.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.17.44 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.19 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.37 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.23 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.23 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.23 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.66.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.24.5 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.32.4 // indirect
|
||||
github.com/aws/smithy-go v1.22.0 // indirect
|
||||
github.com/disintegration/imaging v1.6.2 // indirect
|
||||
github.com/domodwyer/mailyak/v3 v3.6.2 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/fatih/color v1.18.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.6 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
|
||||
github.com/ganigeorgiev/fexpr v0.4.1 // indirect
|
||||
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect
|
||||
github.com/goccy/go-json v0.10.3 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.5.1 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
|
||||
github.com/google/go-cmp v0.7.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/googleapis/gax-go/v2 v2.14.0 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/josharian/native v1.1.0 // indirect
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.24 // indirect
|
||||
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118 // indirect
|
||||
github.com/mdlayher/packet v1.1.2 // indirect
|
||||
github.com/mdlayher/socket v0.5.1 // indirect
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
|
||||
github.com/ncruces/go-strftime v0.1.9 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/spf13/cast v1.7.0 // indirect
|
||||
github.com/spf13/cobra v1.8.1 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
gocloud.dev v0.40.0 // indirect
|
||||
golang.org/x/crypto v0.29.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
|
||||
golang.org/x/image v0.22.0 // indirect
|
||||
golang.org/x/net v0.31.0 // indirect
|
||||
golang.org/x/oauth2 v0.24.0 // indirect
|
||||
golang.org/x/sync v0.9.0 // indirect
|
||||
golang.org/x/term v0.26.0 // indirect
|
||||
golang.org/x/text v0.20.0 // indirect
|
||||
golang.org/x/time v0.8.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
|
||||
google.golang.org/api v0.205.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f // indirect
|
||||
google.golang.org/grpc v1.68.0 // indirect
|
||||
google.golang.org/protobuf v1.35.2 // indirect
|
||||
modernc.org/gc/v3 v3.0.0-20241004144649-1aea3fae8852 // indirect
|
||||
modernc.org/libc v1.61.0 // indirect
|
||||
modernc.org/mathutil v1.6.0 // indirect
|
||||
modernc.org/memory v1.8.0 // indirect
|
||||
modernc.org/sqlite v1.33.1 // indirect
|
||||
modernc.org/strutil v1.2.0 // indirect
|
||||
modernc.org/token v1.1.0 // indirect
|
||||
github.com/spf13/cast v1.7.1 // indirect
|
||||
github.com/spf13/cobra v1.9.1 // indirect
|
||||
github.com/spf13/pflag v1.0.6 // indirect
|
||||
github.com/stretchr/testify v1.8.1 // indirect
|
||||
golang.org/x/crypto v0.36.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
|
||||
golang.org/x/image v0.25.0 // indirect
|
||||
golang.org/x/net v0.37.0 // indirect
|
||||
golang.org/x/oauth2 v0.28.0 // indirect
|
||||
golang.org/x/sync v0.12.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
modernc.org/libc v1.61.13 // indirect
|
||||
modernc.org/mathutil v1.7.1 // indirect
|
||||
modernc.org/memory v1.8.2 // indirect
|
||||
modernc.org/sqlite v1.36.1 // indirect
|
||||
)
|
||||
|
||||
@@ -1,72 +1,9 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.116.0 h1:B3fRrSDkLRt5qSHWe40ERJvhvnQwdZiHu0bJOpldweE=
|
||||
cloud.google.com/go v0.116.0/go.mod h1:cEPSRWPzZEswwdr9BxE6ChEn01dWlTaF05LiC2Xs70U=
|
||||
cloud.google.com/go/auth v0.10.1 h1:TnK46qldSfHWt2a0b/hciaiVJsmDXWy9FqyUan0uYiI=
|
||||
cloud.google.com/go/auth v0.10.1/go.mod h1:xxA5AqpDrvS+Gkmo9RqrGGRh6WSNKKOXhY3zNOr38tI=
|
||||
cloud.google.com/go/auth/oauth2adapt v0.2.5 h1:2p29+dePqsCHPP1bqDJcKj4qxRyYCcbzKpFyKGt3MTk=
|
||||
cloud.google.com/go/auth/oauth2adapt v0.2.5/go.mod h1:AlmsELtlEBnaNTL7jCj8VQFLy6mbZv0s4Q7NGBeQ5E8=
|
||||
cloud.google.com/go/compute/metadata v0.5.2 h1:UxK4uu/Tn+I3p2dYWTfiX4wva7aYlKixAHn3fyqngqo=
|
||||
cloud.google.com/go/compute/metadata v0.5.2/go.mod h1:C66sj2AluDcIqakBq/M8lw8/ybHgOZqin2obFxa/E5k=
|
||||
cloud.google.com/go/iam v1.1.13 h1:7zWBXG9ERbMLrzQBRhFliAV+kjcRToDTgQT3CTwYyv4=
|
||||
cloud.google.com/go/iam v1.1.13/go.mod h1:K8mY0uSXwEXS30KrnVb+j54LB/ntfZu1dr+4zFMNbus=
|
||||
cloud.google.com/go/storage v1.43.0 h1:CcxnSohZwizt4LCzQHWvBf1/kvtHUn7gk9QERXPyXFs=
|
||||
cloud.google.com/go/storage v1.43.0/go.mod h1:ajvxEa7WmZS1PxvKRq4bq0tFT3vMd502JwstCcYv0Q0=
|
||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ=
|
||||
github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s=
|
||||
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
|
||||
github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg=
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
|
||||
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
|
||||
github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU=
|
||||
github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
|
||||
github.com/aws/aws-sdk-go-v2 v1.32.4 h1:S13INUiTxgrPueTmrm5DZ+MiAo99zYzHEFh1UNkOxNE=
|
||||
github.com/aws/aws-sdk-go-v2 v1.32.4/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo=
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.6 h1:pT3hpW0cOHRJx8Y0DfJUEQuqPild8jRGmSFmBgvydr0=
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.6/go.mod h1:j/I2++U0xX+cr44QjHay4Cvxj6FUbnxrgmqN3H1jTZA=
|
||||
github.com/aws/aws-sdk-go-v2/config v1.28.3 h1:kL5uAptPcPKaJ4q0sDUjUIdueO18Q7JDzl64GpVwdOM=
|
||||
github.com/aws/aws-sdk-go-v2/config v1.28.3/go.mod h1:SPEn1KA8YbgQnwiJ/OISU4fz7+F6Fe309Jf0QTsRCl4=
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.17.44 h1:qqfs5kulLUHUEXlHEZXLJkgGoF3kkUeFUTVA585cFpU=
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.17.44/go.mod h1:0Lm2YJ8etJdEdw23s+q/9wTpOeo2HhNE97XcRa7T8MA=
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.19 h1:woXadbf0c7enQ2UGCi8gW/WuKmE0xIzxBF/eD94jMKQ=
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.19/go.mod h1:zminj5ucw7w0r65bP6nhyOd3xL6veAUMc3ElGMoLVb4=
|
||||
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.37 h1:jHKR76E81sZvz1+x1vYYrHMxphG5LFBJPhSqEr4CLlE=
|
||||
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.37/go.mod h1:iMkyPkmoJWQKzSOtaX+8oEJxAuqr7s8laxcqGDSHeII=
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.23 h1:A2w6m6Tmr+BNXjDsr7M90zkWjsu4JXHwrzPg235STs4=
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.23/go.mod h1:35EVp9wyeANdujZruvHiQUAo9E3vbhnIO1mTCAxMlY0=
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.23 h1:pgYW9FCabt2M25MoHYCfMrVY2ghiiBKYWUVXfwZs+sU=
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.23/go.mod h1:c48kLgzO19wAu3CPkDWC28JbaJ+hfQlsdl7I2+oqIbk=
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ=
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc=
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.23 h1:1SZBDiRzzs3sNhOMVApyWPduWYGAX0imGy06XiBnCAM=
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.23/go.mod h1:i9TkxgbZmHVh2S0La6CAXtnyFhlCX/pJ0JsOvBAS6Mk=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 h1:TToQNkvGguu209puTojY/ozlqy2d/SFNcoLIqTFi42g=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0/go.mod h1:0jp+ltwkf+SwG2fm/PKo8t4y8pJSgOCO4D8Lz3k0aHQ=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.4 h1:aaPpoG15S2qHkWm4KlEyF01zovK1nW4BBbyXuHNSE90=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.4/go.mod h1:eD9gS2EARTKgGr/W5xwgY/ik9z/zqpW+m/xOQbVxrMk=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.4 h1:tHxQi/XHPK0ctd/wdOw0t7Xrc2OxcRCnVzv8lwWPu0c=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.4/go.mod h1:4GQbF1vJzG60poZqWatZlhP31y8PGCCVTvIGPdaaYJ0=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.4 h1:E5ZAVOmI2apR8ADb72Q63KqwwwdW1XcMeXIlrZ1Psjg=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.4/go.mod h1:wezzqVUOVVdk+2Z/JzQT4NxAU0NbhRe5W8pIE72jsWI=
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.66.3 h1:neNOYJl72bHrz9ikAEED4VqWyND/Po0DnEx64RW6YM4=
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.66.3/go.mod h1:TMhLIyRIyoGVlaEMAt+ITMbwskSTpcGsCPDq91/ihY0=
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.24.5 h1:HJwZwRt2Z2Tdec+m+fPjvdmkq2s9Ra+VR0hjF7V2o40=
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.24.5/go.mod h1:wrMCEwjFPms+V86TCQQeOxQF/If4vT44FGIOFiMC2ck=
|
||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4 h1:zcx9LiGWZ6i6pjdcoE9oXAB6mUdeyC36Ia/QEiIvYdg=
|
||||
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4/go.mod h1:Tp/ly1cTjRLGBBmNccFumbZ8oqpZlpdhFf80SrRh4is=
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.32.4 h1:yDxvkz3/uOKfxnv8YhzOi9m+2OGIxF+on3KOISbK5IU=
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.32.4/go.mod h1:9XEUty5v5UAsMiFOBJrNibZgwCeOma73jgGwwhgffa8=
|
||||
github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM=
|
||||
github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
|
||||
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@@ -76,101 +13,44 @@ github.com/domodwyer/mailyak/v3 v3.6.2 h1:x3tGMsyFhTCaxp6ycgR0FE/bu5QiNp+hetUuCO
|
||||
github.com/domodwyer/mailyak/v3 v3.6.2/go.mod h1:lOm/u9CyCVWHeaAmHIdF4RiKVxKUT/H5XX10lIKAL6c=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
||||
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc=
|
||||
github.com/gabriel-vasile/mimetype v1.4.6/go.mod h1:JX1qVKqZd40hUPpAfiNTe0Sne7hdfKSbOqqmkq8GCXc=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
||||
github.com/ganigeorgiev/fexpr v0.4.1 h1:hpUgbUEEWIZhSDBtf4M9aUNfQQ0BZkGRaMePy7Gcx5k=
|
||||
github.com/ganigeorgiev/fexpr v0.4.1/go.mod h1:RyGiGqmeXhEQ6+mlGdnUleLHgtzzu/VGO2WtJkF5drE=
|
||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 h1:byhDUpfEwjsVQb1vBunvIjh2BHQ9ead57VkAEY4V+Es=
|
||||
github.com/go-ozzo/ozzo-validation/v4 v4.3.0/go.mod h1:2NKgrcHl3z6cJs+3Oo940FPRiTzuqKbvfrL2RxCj6Ew=
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
|
||||
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
|
||||
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
|
||||
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA=
|
||||
github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
|
||||
github.com/google/s2a-go v0.1.8 h1:zZDs9gcbt9ZPLV0ndSyQk6Kacx2g/X+SKYovpnz3SMM=
|
||||
github.com/google/s2a-go v0.1.8/go.mod h1:6iNWHTpQ+nfNRN5E00MSdfDwVesa8hhS32PhPO8deJA=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
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/pprof v0.0.0-20250315033105-103756e64e1d h1:tx51Lf+wdE+aavqH8TcPJoCjTf4cE8hrMzROghCely0=
|
||||
github.com/google/pprof v0.0.0-20250315033105-103756e64e1d/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
|
||||
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/wire v0.6.0 h1:HBkoIh4BdSxoyo9PveV8giw7ZsaBOvzWKfcg/6MrVwI=
|
||||
github.com/google/wire v0.6.0/go.mod h1:F4QhpQ9EDIdJ1Mbop/NZBRB+5yrR6qg3BnctaoUk6NA=
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.3.4 h1:XYIDZApgAnrN1c855gTgghdIA6Stxb52D5RnLI1SLyw=
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.3.4/go.mod h1:YKe7cfqYXjKGpGvmSg28/fFvhNzinZQm8DGnaburhGA=
|
||||
github.com/googleapis/gax-go/v2 v2.14.0 h1:f+jMrjBPl+DL9nI4IQzLUxMq7XrAqFYB7hBPqMNIe8o=
|
||||
github.com/googleapis/gax-go/v2 v2.14.0/go.mod h1:lhBCnjdLrWRaPvLWhmc8IS24m9mr07qSYnHncrgo+zk=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog=
|
||||
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/josharian/native v1.0.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
||||
github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA=
|
||||
github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/labstack/echo/v5 v5.0.0-20230722203903-ec5b858dab61 h1:FwuzbVh87iLiUQj1+uQUsuw9x5t9m5n5g7rG7o4svW4=
|
||||
github.com/labstack/echo/v5 v5.0.0-20230722203903-ec5b858dab61/go.mod h1:paQfF1YtHe+GrGg5fOgjsjoCX/UKDr9bc1DoWpZfns8=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM=
|
||||
github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/mdlayher/ethernet v0.0.0-20190313224307-5b5fc417d966/go.mod h1:5s5p/sMJ6sNsFl6uCh85lkFGV8kLuIYJCRJLavVJwvg=
|
||||
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118 h1:2oDp6OOhLxQ9JBoUuysVz9UZ9uI6oLUbvAZu0x8o+vE=
|
||||
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118/go.mod h1:ZFUnHIVchZ9lJoWoEGUg8Q3M4U8aNNWA3CVSUTkW4og=
|
||||
@@ -183,20 +63,16 @@ github.com/mdlayher/socket v0.5.1 h1:VZaqt6RkGkt2OE9l3GcC6nZkqD3xKeQLyfleW/uBcos
|
||||
github.com/mdlayher/socket v0.5.1/go.mod h1:TjPLHI1UgwEv5J1B5q0zTZq12A/6H7nKmtTanQE37IQ=
|
||||
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a h1:fpQi42PM6HzbHwNg6a7OvLbh5l49Rgr7GCARozjHwio=
|
||||
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a/go.mod h1:XX6nvyQpGc8E4KaQm62FyexOYd36ilpyfYf8wjgMDV8=
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
|
||||
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
||||
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
|
||||
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pocketbase/dbx v1.10.1 h1:cw+vsyfCJD8YObOVeqb93YErnlxwYMkNZ4rwN0G0AaA=
|
||||
github.com/pocketbase/dbx v1.10.1/go.mod h1:xXRCIAKTHMgUCyCKZm55pUOdvFziJjQfXaWKhu2vhMs=
|
||||
github.com/pocketbase/pocketbase v0.22.25 h1:ewn97JQu0izpge+a57YZYPhOOqdTmHao8kUOtpxj7AQ=
|
||||
github.com/pocketbase/pocketbase v0.22.25/go.mod h1:h2ojT2pqBWH9LLl1aiawkwXiICKtzZA/kjM/8VhydR4=
|
||||
github.com/prometheus-community/pro-bing v0.4.1 h1:aMaJwyifHZO0y+h8+icUz0xbToHbia0wdmzdVZ+Kl3w=
|
||||
github.com/prometheus-community/pro-bing v0.4.1/go.mod h1:aLsw+zqCaDoa2RLVVSX3+UiCkBBXTMtZC3c7EkfWnAE=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/pocketbase/dbx v1.11.0 h1:LpZezioMfT3K4tLrqA55wWFw1EtH1pM4tzSVa7kgszU=
|
||||
github.com/pocketbase/dbx v1.11.0/go.mod h1:xXRCIAKTHMgUCyCKZm55pUOdvFziJjQfXaWKhu2vhMs=
|
||||
github.com/pocketbase/pocketbase v0.26.1 h1:0WBqIRKKPCqp+xHPVLB4fevkoT9HVlR4BSuNwAt5oJ0=
|
||||
github.com/pocketbase/pocketbase v0.26.1/go.mod h1:t5y5pfnhrEg//RuSzSg0a926OLZ0oQj66jYs3BzDJwA=
|
||||
github.com/prometheus-community/pro-bing v0.6.1 h1:EQukUOma9YFZRPe4DGSscxUf9LH07rpqwisNWjSZrgU=
|
||||
github.com/prometheus-community/pro-bing v0.6.1/go.mod h1:jNCOI3D7pmTCeaoF41cNS6uaxeFY/Gmc3ffwbuJVzAQ=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
@@ -204,186 +80,82 @@ github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzG
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
|
||||
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
|
||||
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/cast v1.7.1 h1:cuNEagBQEHWN1FnbGEjCXL2szYEXqfJPbP2HNUaca9Y=
|
||||
github.com/spf13/cast v1.7.1/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
|
||||
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
|
||||
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
||||
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
|
||||
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 h1:r6I7RJCN86bpD/FQwedZ0vSixDpwuWREjW9oRMsmqDc=
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0/go.mod h1:B9yO6b04uB80CzjedvewuqDhxJxi11s7/GtiGa8bAjI=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8=
|
||||
go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw=
|
||||
go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8=
|
||||
go.opentelemetry.io/otel/metric v1.29.0 h1:vPf/HFWTNkPu1aYeIsc98l4ktOQaL6LeSoeV2g+8YLc=
|
||||
go.opentelemetry.io/otel/metric v1.29.0/go.mod h1:auu/QWieFVWx+DmQOUMgj0F8LHWdgalxXqvp7BII/W8=
|
||||
go.opentelemetry.io/otel/trace v1.29.0 h1:J/8ZNK4XgR7a21DZUAsbF8pZ5Jcw1VhACmnYt39JTi4=
|
||||
go.opentelemetry.io/otel/trace v1.29.0/go.mod h1:eHl3w0sp3paPkYstJOmAimxhiFXPg+MMTlEh3nsQgWQ=
|
||||
gocloud.dev v0.40.0 h1:f8LgP+4WDqOG/RXoUcyLpeIAGOcAbZrZbDQCUee10ng=
|
||||
gocloud.dev v0.40.0/go.mod h1:drz+VyYNBvrMTW0KZiBAYEdl8lbNZx+OQ7oQvdrFmSQ=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
|
||||
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
|
||||
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
|
||||
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
||||
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
||||
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw=
|
||||
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM=
|
||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/image v0.22.0 h1:UtK5yLUzilVrkjMAZAZ34DXGpASN8i8pj8g+O+yd10g=
|
||||
golang.org/x/image v0.22.0/go.mod h1:9hPFhljd4zZ1GNSIZJ49sqbp45GKK9t6w+iXvGqZUz4=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
|
||||
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/image v0.25.0 h1:Y6uW6rH1y5y/LK1J8BPWZtr6yZ7hrsy6hFrXjgsc2fQ=
|
||||
golang.org/x/image v0.25.0/go.mod h1:tCAmOEGthTtkalusGp1g3xa2gke8J6c2N565dTyl9Rs=
|
||||
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
|
||||
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
|
||||
golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
|
||||
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
|
||||
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c=
|
||||
golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=
|
||||
golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
|
||||
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw=
|
||||
golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
|
||||
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU=
|
||||
golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
|
||||
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
|
||||
golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg=
|
||||
golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
|
||||
golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU=
|
||||
golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY=
|
||||
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
|
||||
google.golang.org/api v0.205.0 h1:LFaxkAIpDb/GsrWV20dMMo5MR0h8UARTbn24LmD+0Pg=
|
||||
google.golang.org/api v0.205.0/go.mod h1:NrK1EMqO8Xk6l6QwRAmrXXg2v6dzukhlOyvkYtnvUuc=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20241021214115-324edc3d5d38 h1:Q3nlH8iSQSRUwOskjbcSMcF2jiYMNiQYZ0c2KEJLKKU=
|
||||
google.golang.org/genproto v0.0.0-20241021214115-324edc3d5d38/go.mod h1:xBI+tzfqGGN2JBeSebfKXFSdBpWVQ7sLW40PTupVRm4=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 h1:M0KvPgPmDZHPlbRbaNU1APr28TvwvvdUPlSv7PUvy8g=
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28/go.mod h1:dguCy7UOdZhTvLzDyt15+rOrawrpM4q7DD9dQ1P11P4=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f h1:C1QccEa9kUwvMgEUORqQD9S17QesQijxjZ84sO82mfo=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||
google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0=
|
||||
google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
|
||||
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
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/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
modernc.org/cc/v4 v4.21.4 h1:3Be/Rdo1fpr8GrQ7IVw9OHtplU4gWbb+wNgeoBMmGLQ=
|
||||
modernc.org/cc/v4 v4.21.4/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ=
|
||||
modernc.org/ccgo/v4 v4.21.0 h1:kKPI3dF7RIag8YcToh5ZwDcVMIv6VGa0ED5cvh0LMW4=
|
||||
modernc.org/ccgo/v4 v4.21.0/go.mod h1:h6kt6H/A2+ew/3MW/p6KEoQmrq/i3pr0J/SiwiaF/g0=
|
||||
modernc.org/cc/v4 v4.24.4 h1:TFkx1s6dCkQpd6dKurBNmpo+G8Zl4Sq/ztJ+2+DEsh0=
|
||||
modernc.org/cc/v4 v4.24.4/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0=
|
||||
modernc.org/ccgo/v4 v4.23.16 h1:Z2N+kk38b7SfySC1ZkpGLN2vthNJP1+ZzGZIlH7uBxo=
|
||||
modernc.org/ccgo/v4 v4.23.16/go.mod h1:nNma8goMTY7aQZQNTyN9AIoJfxav4nvTnvKThAeMDdo=
|
||||
modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE=
|
||||
modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ=
|
||||
modernc.org/gc/v2 v2.5.0 h1:bJ9ChznK1L1mUtAQtxi0wi5AtAs5jQuw4PrPHO5pb6M=
|
||||
modernc.org/gc/v2 v2.5.0/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU=
|
||||
modernc.org/gc/v3 v3.0.0-20241004144649-1aea3fae8852 h1:IYXPPTTjjoSHvUClZIYexDiO7g+4x+XveKT4gCIAwiY=
|
||||
modernc.org/gc/v3 v3.0.0-20241004144649-1aea3fae8852/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4=
|
||||
modernc.org/libc v1.61.0 h1:eGFcvWpqlnoGwzZeZe3PWJkkKbM/3SUGyk1DVZQ0TpE=
|
||||
modernc.org/libc v1.61.0/go.mod h1:DvxVX89wtGTu+r72MLGhygpfi3aUGgZRdAYGCAVVud0=
|
||||
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
|
||||
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
|
||||
modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
|
||||
modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU=
|
||||
modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
|
||||
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
|
||||
modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc=
|
||||
modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss=
|
||||
modernc.org/sqlite v1.33.1 h1:trb6Z3YYoeM9eDL1O8do81kP+0ejv+YzgyFo+Gwy0nM=
|
||||
modernc.org/sqlite v1.33.1/go.mod h1:pXV2xHxhzXZsgT/RtTFAPY6JJDEvOTcTdwADQCCWD4k=
|
||||
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
|
||||
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
|
||||
modernc.org/gc/v2 v2.6.3 h1:aJVhcqAte49LF+mGveZ5KPlsp4tdGdAOT4sipJXADjw=
|
||||
modernc.org/gc/v2 v2.6.3/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=
|
||||
modernc.org/libc v1.61.13 h1:3LRd6ZO1ezsFiX1y+bHd1ipyEHIJKvuprv0sLTBwLW8=
|
||||
modernc.org/libc v1.61.13/go.mod h1:8F/uJWL/3nNil0Lgt1Dpz+GgkApWh04N3el3hxJcA6E=
|
||||
modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=
|
||||
modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=
|
||||
modernc.org/memory v1.8.2 h1:cL9L4bcoAObu4NkxOlKWBWtNHIsnnACGF/TbqQ6sbcI=
|
||||
modernc.org/memory v1.8.2/go.mod h1:ZbjSvMO5NQ1A2i3bWeDiVMxIorXwdClKE/0SZ+BMotU=
|
||||
modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8=
|
||||
modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=
|
||||
modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=
|
||||
modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=
|
||||
modernc.org/sqlite v1.36.1 h1:bDa8BJUH4lg6EGkLbahKe/8QqoF8p9gArSc6fTqYhyQ=
|
||||
modernc.org/sqlite v1.36.1/go.mod h1:7MPwH7Z6bREicF9ZVUR78P1IKuxfZ8mRIDHD0iD+8TU=
|
||||
modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
|
||||
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
|
||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||
|
||||
@@ -3,13 +3,13 @@ package main
|
||||
import (
|
||||
"embed"
|
||||
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/pocketbase/pocketbase/apis"
|
||||
"github.com/seriousm4x/upsnap/pb"
|
||||
)
|
||||
|
||||
//go:embed all:pb_public
|
||||
var distDir embed.FS
|
||||
var distDirFS = echo.MustSubFS(distDir, "pb_public")
|
||||
var distDirFS = apis.MustSubFS(distDir, "pb_public")
|
||||
|
||||
func main() {
|
||||
pb.StartPocketBase(distDirFS)
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
jsonData := `{
|
||||
"id": "z5lghx2r3tm45n1",
|
||||
"created": "2023-01-28 19:10:29.223Z",
|
||||
"updated": "2023-01-28 19:10:29.223Z",
|
||||
"name": "devices",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "tiqcmnjo",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "1si6ajha",
|
||||
"name": "ip",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "fyqmpon6",
|
||||
"name": "mac",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "s8c5z7n0",
|
||||
"name": "netmask",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "qqvyfrex",
|
||||
"name": "status",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "ilrwvlev",
|
||||
"name": "ports",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": null,
|
||||
"collectionId": "cti4l8f4mz8df3r",
|
||||
"cascadeDelete": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "gdctb8hj",
|
||||
"name": "link",
|
||||
"type": "url",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"exceptDomains": null,
|
||||
"onlyDomains": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "kzvdbbws",
|
||||
"name": "wake_cron",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "dcd3vuc3",
|
||||
"name": "wake_cron_enabled",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "91bs6clw",
|
||||
"name": "shutdown_cron",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "vnlymcuw",
|
||||
"name": "shutdown_cron_enabled",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "1a7yrwo9",
|
||||
"name": "shutdown_cmd",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "iarksm3l",
|
||||
"name": "password",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": "",
|
||||
"updateRule": "",
|
||||
"deleteRule": "",
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &models.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return daos.New(db).SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dao.DeleteCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
jsonData := `{
|
||||
"id": "cti4l8f4mz8df3r",
|
||||
"created": "2023-01-28 19:10:29.223Z",
|
||||
"updated": "2023-01-28 19:10:29.223Z",
|
||||
"name": "ports",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "8nwuncgg",
|
||||
"name": "number",
|
||||
"type": "number",
|
||||
"required": true,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": 65535
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "o0he3pu6",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "w0bh39gv",
|
||||
"name": "status",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
}
|
||||
],
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": "",
|
||||
"updateRule": "",
|
||||
"deleteRule": "",
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &models.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return daos.New(db).SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("cti4l8f4mz8df3r")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dao.DeleteCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
jsonData := `{
|
||||
"id": "nmj3ko20gzkg8n3",
|
||||
"created": "2023-01-28 19:10:29.223Z",
|
||||
"updated": "2023-01-28 19:10:29.223Z",
|
||||
"name": "settings",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "ph88gaa5",
|
||||
"name": "interval",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "agw2fyd1",
|
||||
"name": "scan_range",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "slrjkipw",
|
||||
"name": "website_title",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": "",
|
||||
"updateRule": "",
|
||||
"deleteRule": "",
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &models.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return daos.New(db).SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("nmj3ko20gzkg8n3")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dao.DeleteCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("_pb_users_auth_")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dao.DeleteCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
jsonData := `{
|
||||
"id": "_pb_users_auth_",
|
||||
"created": "2023-01-28 19:10:12.835Z",
|
||||
"updated": "2023-01-28 19:10:12.835Z",
|
||||
"name": "users",
|
||||
"type": "auth",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "users_name",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "users_avatar",
|
||||
"name": "avatar",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"mimeTypes": [
|
||||
"image/jpg",
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
"image/gif",
|
||||
"image/webp"
|
||||
],
|
||||
"thumbs": null
|
||||
}
|
||||
}
|
||||
],
|
||||
"listRule": "id = @request.auth.id",
|
||||
"viewRule": "id = @request.auth.id",
|
||||
"createRule": "",
|
||||
"updateRule": "id = @request.auth.id",
|
||||
"deleteRule": "id = @request.auth.id",
|
||||
"options": {
|
||||
"allowEmailAuth": true,
|
||||
"allowOAuth2Auth": true,
|
||||
"allowUsernameAuth": true,
|
||||
"exceptEmailDomains": null,
|
||||
"manageRule": null,
|
||||
"minPasswordLength": 8,
|
||||
"onlyEmailDomains": null,
|
||||
"requireEmail": false
|
||||
}
|
||||
}`
|
||||
|
||||
collection := &models.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return daos.New(db).SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
jsonData := `{
|
||||
"id": "27do0wbcuyfmbmx",
|
||||
"created": "2023-03-04 20:33:00.558Z",
|
||||
"updated": "2023-03-04 20:33:00.558Z",
|
||||
"name": "users",
|
||||
"type": "auth",
|
||||
"system": false,
|
||||
"schema": [],
|
||||
"listRule": null,
|
||||
"viewRule": null,
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {
|
||||
"allowEmailAuth": true,
|
||||
"allowOAuth2Auth": false,
|
||||
"allowUsernameAuth": true,
|
||||
"exceptEmailDomains": [],
|
||||
"manageRule": null,
|
||||
"minPasswordLength": 8,
|
||||
"onlyEmailDomains": [],
|
||||
"requireEmail": false
|
||||
}
|
||||
}`
|
||||
|
||||
collection := &models.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return daos.New(db).SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dao.DeleteCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
collection.CreateRule = nil
|
||||
|
||||
collection.UpdateRule = nil
|
||||
|
||||
collection.DeleteRule = nil
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = nil
|
||||
|
||||
collection.ViewRule = nil
|
||||
|
||||
collection.CreateRule = types.Pointer("")
|
||||
|
||||
collection.UpdateRule = types.Pointer("")
|
||||
|
||||
collection.DeleteRule = types.Pointer("")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("cti4l8f4mz8df3r")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
collection.CreateRule = nil
|
||||
|
||||
collection.UpdateRule = nil
|
||||
|
||||
collection.DeleteRule = nil
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("cti4l8f4mz8df3r")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = nil
|
||||
|
||||
collection.ViewRule = nil
|
||||
|
||||
collection.CreateRule = types.Pointer("")
|
||||
|
||||
collection.UpdateRule = types.Pointer("")
|
||||
|
||||
collection.DeleteRule = types.Pointer("")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("nmj3ko20gzkg8n3")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
collection.CreateRule = nil
|
||||
|
||||
collection.UpdateRule = nil
|
||||
|
||||
collection.DeleteRule = nil
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("nmj3ko20gzkg8n3")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = nil
|
||||
|
||||
collection.ViewRule = nil
|
||||
|
||||
collection.CreateRule = types.Pointer("")
|
||||
|
||||
collection.UpdateRule = types.Pointer("")
|
||||
|
||||
collection.DeleteRule = types.Pointer("")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
jsonData := `{
|
||||
"id": "t1rajoyzl6691g3",
|
||||
"created": "2023-03-09 22:17:29.463Z",
|
||||
"updated": "2023-03-09 22:17:29.463Z",
|
||||
"name": "settings_public",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "s1grje98",
|
||||
"name": "website_title",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "tlzz87pj",
|
||||
"name": "favicon",
|
||||
"type": "file",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"maxSize": 5242880,
|
||||
"mimeTypes": [
|
||||
"image/x-icon",
|
||||
"image/png",
|
||||
"image/svg+xml",
|
||||
"image/gif",
|
||||
"image/jpeg"
|
||||
],
|
||||
"thumbs": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"listRule": "",
|
||||
"viewRule": "",
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &models.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return daos.New(db).SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("t1rajoyzl6691g3")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dao.DeleteCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models/schema"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("nmj3ko20gzkg8n3")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.Name = "settings_private"
|
||||
|
||||
collection.ListRule = nil
|
||||
|
||||
collection.ViewRule = nil
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("slrjkipw")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("nmj3ko20gzkg8n3")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.Name = "settings"
|
||||
|
||||
collection.ListRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
collection.ViewRule = types.Pointer("@request.auth.id != \"\"")
|
||||
|
||||
// add
|
||||
del_website_title := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "slrjkipw",
|
||||
"name": "website_title",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), del_website_title)
|
||||
collection.Schema.AddField(del_website_title)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models/schema"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("t1rajoyzl6691g3")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_setup_completed := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "vrxqcsnv",
|
||||
"name": "setup_completed",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
}`), new_setup_completed)
|
||||
collection.Schema.AddField(new_setup_completed)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("t1rajoyzl6691g3")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("vrxqcsnv")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
jsonData := `{
|
||||
"id": "djqp3uxrac2ores",
|
||||
"created": "2023-06-29 10:39:59.291Z",
|
||||
"updated": "2023-06-29 10:39:59.291Z",
|
||||
"name": "groups",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "b3oaemnp",
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"required": true,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [],
|
||||
"listRule": "@request.auth.id != \"\"",
|
||||
"viewRule": "@request.auth.id != \"\"",
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": null,
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &models.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return daos.New(db).SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("djqp3uxrac2ores")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dao.DeleteCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models/schema"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_groups := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "rk2vrn57",
|
||||
"name": "groups",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "djqp3uxrac2ores",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": []
|
||||
}
|
||||
}`), new_groups)
|
||||
collection.Schema.AddField(new_groups)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("rk2vrn57")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
options := map[string]any{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"allowEmailAuth": true,
|
||||
"allowOAuth2Auth": true,
|
||||
"allowUsernameAuth": true,
|
||||
"exceptEmailDomains": [],
|
||||
"manageRule": null,
|
||||
"minPasswordLength": 8,
|
||||
"onlyEmailDomains": [],
|
||||
"requireEmail": false
|
||||
}`), &options)
|
||||
collection.SetOptions(options)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
options := map[string]any{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"allowEmailAuth": true,
|
||||
"allowOAuth2Auth": false,
|
||||
"allowUsernameAuth": true,
|
||||
"exceptEmailDomains": [],
|
||||
"manageRule": null,
|
||||
"minPasswordLength": 8,
|
||||
"onlyEmailDomains": [],
|
||||
"requireEmail": false
|
||||
}`), &options)
|
||||
collection.SetOptions(options)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.CreateRule = types.Pointer("@request.data.password:isset = false")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.CreateRule = nil
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
options := map[string]any{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"allowEmailAuth": true,
|
||||
"allowOAuth2Auth": true,
|
||||
"allowUsernameAuth": true,
|
||||
"exceptEmailDomains": [],
|
||||
"manageRule": null,
|
||||
"minPasswordLength": 5,
|
||||
"onlyEmailDomains": [],
|
||||
"requireEmail": false
|
||||
}`), &options)
|
||||
collection.SetOptions(options)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
options := map[string]any{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"allowEmailAuth": true,
|
||||
"allowOAuth2Auth": true,
|
||||
"allowUsernameAuth": true,
|
||||
"exceptEmailDomains": [],
|
||||
"manageRule": null,
|
||||
"minPasswordLength": 8,
|
||||
"onlyEmailDomains": [],
|
||||
"requireEmail": false
|
||||
}`), &options)
|
||||
collection.SetOptions(options)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("djqp3uxrac2ores")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.Name = "device_groups"
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("djqp3uxrac2ores")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.Name = "groups"
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
jsonData := `{
|
||||
"id": "7emu7fnnwuim2ua",
|
||||
"created": "2023-08-10 21:19:39.520Z",
|
||||
"updated": "2023-08-10 21:19:39.520Z",
|
||||
"name": "permissions",
|
||||
"type": "base",
|
||||
"system": false,
|
||||
"schema": [
|
||||
{
|
||||
"system": false,
|
||||
"id": "tzxtuykz",
|
||||
"name": "user",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "27do0wbcuyfmbmx",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "nd1ekexz",
|
||||
"name": "create",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "z79gcpy3",
|
||||
"name": "read",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "z5lghx2r3tm45n1",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "t7wwbk2c",
|
||||
"name": "update",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "z5lghx2r3tm45n1",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "b4u0gqa7",
|
||||
"name": "delete",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "z5lghx2r3tm45n1",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": [
|
||||
"name"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"system": false,
|
||||
"id": "nyeqt3fn",
|
||||
"name": "power",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "z5lghx2r3tm45n1",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": null,
|
||||
"displayFields": []
|
||||
}
|
||||
}
|
||||
],
|
||||
"indexes": [
|
||||
"CREATE UNIQUE INDEX ` + "`" + `idx_2GIk1Fo` + "`" + ` ON ` + "`" + `permissions` + "`" + ` (` + "`" + `user` + "`" + `)"
|
||||
],
|
||||
"listRule": "@request.auth.id = user.id",
|
||||
"viewRule": "@request.auth.id = user.id",
|
||||
"createRule": null,
|
||||
"updateRule": null,
|
||||
"deleteRule": "@request.auth.id = user.id",
|
||||
"options": {}
|
||||
}`
|
||||
|
||||
collection := &models.Collection{}
|
||||
if err := json.Unmarshal([]byte(jsonData), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return daos.New(db).SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("7emu7fnnwuim2ua")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return dao.DeleteCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models/schema"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && id ?= @collection.permissions.read.id")
|
||||
|
||||
collection.ViewRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && id ?= @collection.permissions.read.id")
|
||||
|
||||
collection.CreateRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && @collection.permissions.create = true")
|
||||
|
||||
collection.UpdateRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && id ?= @collection.permissions.update.id")
|
||||
|
||||
collection.DeleteRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && id ?= @collection.permissions.delete.id")
|
||||
|
||||
// add
|
||||
new_created_by := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "naciykac",
|
||||
"name": "created_by",
|
||||
"type": "relation",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"collectionId": "27do0wbcuyfmbmx",
|
||||
"cascadeDelete": false,
|
||||
"minSelect": null,
|
||||
"maxSelect": 1,
|
||||
"displayFields": [
|
||||
"username"
|
||||
]
|
||||
}
|
||||
}`), new_created_by)
|
||||
collection.Schema.AddField(new_created_by)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = nil
|
||||
|
||||
collection.ViewRule = nil
|
||||
|
||||
collection.CreateRule = nil
|
||||
|
||||
collection.UpdateRule = nil
|
||||
|
||||
collection.DeleteRule = nil
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("naciykac")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("djqp3uxrac2ores")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.CreateRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && @collection.permissions.create = true")
|
||||
|
||||
collection.UpdateRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && @collection.permissions.create = true")
|
||||
|
||||
collection.DeleteRule = types.Pointer("@request.auth.id = @collection.permissions.user.id && @collection.permissions.create = true")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("djqp3uxrac2ores")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.CreateRule = nil
|
||||
|
||||
collection.UpdateRule = nil
|
||||
|
||||
collection.DeleteRule = nil
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models/schema"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("qqvyfrex")
|
||||
|
||||
// add
|
||||
new_status := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "qmiatdwa",
|
||||
"name": "status",
|
||||
"type": "select",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"maxSelect": 1,
|
||||
"values": [
|
||||
"pending",
|
||||
"online",
|
||||
"offline"
|
||||
]
|
||||
}
|
||||
}`), new_status)
|
||||
collection.Schema.AddField(new_status)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
del_status := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "qqvyfrex",
|
||||
"name": "status",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), del_status)
|
||||
collection.Schema.AddField(del_status)
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("qmiatdwa")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models/schema"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("@request.auth.id = id")
|
||||
|
||||
collection.ViewRule = types.Pointer("@request.auth.id = id")
|
||||
|
||||
collection.UpdateRule = types.Pointer("@request.auth.id = id")
|
||||
|
||||
collection.DeleteRule = types.Pointer("@request.auth.id = id")
|
||||
|
||||
// add
|
||||
new_avatar := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "i1qnezoa",
|
||||
"name": "avatar",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 0,
|
||||
"max": 9
|
||||
}
|
||||
}`), new_avatar)
|
||||
collection.Schema.AddField(new_avatar)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("27do0wbcuyfmbmx")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = nil
|
||||
|
||||
collection.ViewRule = nil
|
||||
|
||||
collection.UpdateRule = nil
|
||||
|
||||
collection.DeleteRule = nil
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("i1qnezoa")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models/schema"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("nmj3ko20gzkg8n3")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_lazy_ping := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "yjyq5pvg",
|
||||
"name": "lazy_ping",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
}`), new_lazy_ping)
|
||||
collection.Schema.AddField(new_lazy_ping)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("nmj3ko20gzkg8n3")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("yjyq5pvg")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("djqp3uxrac2ores")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.CreateRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && @collection.permissions.create = true")
|
||||
|
||||
collection.UpdateRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && @collection.permissions.create = true")
|
||||
|
||||
collection.DeleteRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && @collection.permissions.create = true")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("djqp3uxrac2ores")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.CreateRule = nil
|
||||
|
||||
collection.UpdateRule = nil
|
||||
|
||||
collection.DeleteRule = nil
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && id ?= @collection.permissions.read.id")
|
||||
|
||||
collection.ViewRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && id ?= @collection.permissions.read.id")
|
||||
|
||||
collection.CreateRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && @collection.permissions.create = true")
|
||||
|
||||
collection.UpdateRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && id ?= @collection.permissions.update.id")
|
||||
|
||||
collection.DeleteRule = types.Pointer("@request.auth.id ?= @collection.permissions.user.id && id ?= @collection.permissions.delete.id")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
collection.ListRule = nil
|
||||
|
||||
collection.ViewRule = nil
|
||||
|
||||
collection.CreateRule = nil
|
||||
|
||||
collection.UpdateRule = nil
|
||||
|
||||
collection.DeleteRule = nil
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models/schema"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_sol_enabled := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "ueieydw5",
|
||||
"name": "sol_enabled",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
}`), new_sol_enabled)
|
||||
collection.Schema.AddField(new_sol_enabled)
|
||||
|
||||
// add
|
||||
new_sol_auth := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "yfszwhpw",
|
||||
"name": "sol_auth",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
}`), new_sol_auth)
|
||||
collection.Schema.AddField(new_sol_auth)
|
||||
|
||||
// add
|
||||
new_sol_user := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "dbcmnrmp",
|
||||
"name": "sol_user",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), new_sol_user)
|
||||
collection.Schema.AddField(new_sol_user)
|
||||
|
||||
// add
|
||||
new_sol_password := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "hvz8stfy",
|
||||
"name": "sol_password",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), new_sol_password)
|
||||
collection.Schema.AddField(new_sol_password)
|
||||
|
||||
// add
|
||||
new_sol_port := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "6kfqheid",
|
||||
"name": "sol_port",
|
||||
"type": "number",
|
||||
"required": true,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 1,
|
||||
"max": 65535
|
||||
}
|
||||
}`), new_sol_port)
|
||||
collection.Schema.AddField(new_sol_port)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("ueieydw5")
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("yfszwhpw")
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("dbcmnrmp")
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("hvz8stfy")
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("6kfqheid")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models/schema"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("cti4l8f4mz8df3r")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_number := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "8nwuncgg",
|
||||
"name": "number",
|
||||
"type": "number",
|
||||
"required": true,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 1,
|
||||
"max": 65535
|
||||
}
|
||||
}`), edit_number)
|
||||
collection.Schema.AddField(edit_number)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("cti4l8f4mz8df3r")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_number := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "8nwuncgg",
|
||||
"name": "number",
|
||||
"type": "number",
|
||||
"required": true,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": 65535
|
||||
}
|
||||
}`), edit_number)
|
||||
collection.Schema.AddField(edit_number)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models/schema"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_sol_port := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "6kfqheid",
|
||||
"name": "sol_port",
|
||||
"type": "number",
|
||||
"required": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 1,
|
||||
"max": 65535
|
||||
}
|
||||
}`), edit_sol_port)
|
||||
collection.Schema.AddField(edit_sol_port)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update
|
||||
edit_sol_port := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "6kfqheid",
|
||||
"name": "sol_port",
|
||||
"type": "number",
|
||||
"required": true,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": 1,
|
||||
"max": 65535
|
||||
}
|
||||
}`), edit_sol_port)
|
||||
collection.Schema.AddField(edit_sol_port)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models/schema"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_wake_confirm := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "chtoblvl",
|
||||
"name": "wake_confirm",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
}`), new_wake_confirm)
|
||||
collection.Schema.AddField(new_wake_confirm)
|
||||
|
||||
// add
|
||||
new_shutdown_confirm := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "muqy3axq",
|
||||
"name": "shutdown_confirm",
|
||||
"type": "bool",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {}
|
||||
}`), new_shutdown_confirm)
|
||||
collection.Schema.AddField(new_shutdown_confirm)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("chtoblvl")
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("muqy3axq")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models/schema"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_wake_cmd := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "murx1eum",
|
||||
"name": "wake_cmd",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), new_wake_cmd)
|
||||
collection.Schema.AddField(new_wake_cmd)
|
||||
|
||||
// add
|
||||
new_ping_cmd := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "kefxqjbj",
|
||||
"name": "ping_cmd",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"min": null,
|
||||
"max": null,
|
||||
"pattern": ""
|
||||
}
|
||||
}`), new_ping_cmd)
|
||||
collection.Schema.AddField(new_ping_cmd)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("murx1eum")
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("kefxqjbj")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/daos"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
"github.com/pocketbase/pocketbase/models/schema"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("cti4l8f4mz8df3r")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add
|
||||
new_link := &schema.SchemaField{}
|
||||
json.Unmarshal([]byte(`{
|
||||
"system": false,
|
||||
"id": "i3uvw7ij",
|
||||
"name": "link",
|
||||
"type": "url",
|
||||
"required": false,
|
||||
"presentable": false,
|
||||
"unique": false,
|
||||
"options": {
|
||||
"exceptDomains": null,
|
||||
"onlyDomains": null
|
||||
}
|
||||
}`), new_link)
|
||||
collection.Schema.AddField(new_link)
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
}, func(db dbx.Builder) error {
|
||||
dao := daos.New(db);
|
||||
|
||||
collection, err := dao.FindCollectionByNameOrId("cti4l8f4mz8df3r")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove
|
||||
collection.Schema.RemoveField("i3uvw7ij")
|
||||
|
||||
return dao.SaveCollection(collection)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("pbc_3142635823")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(6, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "number376926767",
|
||||
"max": 9,
|
||||
"min": 0,
|
||||
"name": "avatar",
|
||||
"onlyInt": false,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("pbc_3142635823")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove field
|
||||
collection.Fields.RemoveById("number376926767")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("pbc_3142635823")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(6, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "number376926767",
|
||||
"max": 9,
|
||||
"min": 0,
|
||||
"name": "avatar",
|
||||
"onlyInt": true,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("pbc_3142635823")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(6, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "number376926767",
|
||||
"max": 9,
|
||||
"min": 0,
|
||||
"name": "avatar",
|
||||
"onlyInt": false,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("27do0wbcuyfmbmx")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update collection data
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"createRule": ""
|
||||
}`), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("27do0wbcuyfmbmx")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// update collection data
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"createRule": "@request.body.password:isset = false"
|
||||
}`), &collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
// Up migration: Change `url` field type from URL to string
|
||||
collectionName := "devices"
|
||||
|
||||
return app.RunInTransaction(func(txApp core.App) error {
|
||||
// Step 1: Fetch the collection
|
||||
collection, err := txApp.FindCollectionByNameOrId(collectionName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 2: Add a new text field
|
||||
newField := &core.TextField{
|
||||
Name: "new_field",
|
||||
Required: false,
|
||||
}
|
||||
collection.Fields.AddAt(6, newField)
|
||||
|
||||
if err := txApp.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 3: Migrate data from `url` to `new_field`
|
||||
records, err := txApp.FindAllRecords(collectionName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, record := range records {
|
||||
url := record.GetString("link")
|
||||
record.Set("new_field", url)
|
||||
if err := txApp.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Step 4: Remove the old `url` field
|
||||
collection.Fields.RemoveByName("link")
|
||||
if err := txApp.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 5: Rename `new_field` to `url`
|
||||
renamedField := collection.Fields.GetByName("new_field")
|
||||
renamedField.SetName("link")
|
||||
|
||||
return txApp.Save(collection)
|
||||
})
|
||||
}, func(app core.App) error {
|
||||
// Down migration: Restore the `url` field
|
||||
collectionName := "devices"
|
||||
|
||||
return app.RunInTransaction(func(txApp core.App) error {
|
||||
// Step 1: Fetch the collection
|
||||
collection, err := txApp.FindCollectionByNameOrId(collectionName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 2: Add a new `url` field
|
||||
newField := &core.URLField{
|
||||
Name: "new_field",
|
||||
Required: false,
|
||||
}
|
||||
collection.Fields.AddAt(6, newField)
|
||||
|
||||
if err := txApp.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 3: Migrate data from `url` to `new_field`
|
||||
records, err := txApp.FindAllRecords(collectionName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, record := range records {
|
||||
text := record.GetString("link")
|
||||
record.Set("new_field", text)
|
||||
if err := txApp.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Step 4: Remove the old `url` field
|
||||
collection.Fields.RemoveByName("link")
|
||||
if err := txApp.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 5: Rename `new_field` to `url`
|
||||
renamedField := collection.Fields.GetByName("new_field")
|
||||
renamedField.SetName("link")
|
||||
|
||||
return txApp.Save(collection)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
// Up migration: Change `url` field type from URL to string
|
||||
collectionName := "ports"
|
||||
|
||||
return app.RunInTransaction(func(txApp core.App) error {
|
||||
// Step 1: Fetch the collection
|
||||
collection, err := txApp.FindCollectionByNameOrId(collectionName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 2: Add a new text field
|
||||
newField := &core.TextField{
|
||||
Name: "new_field",
|
||||
Required: false,
|
||||
}
|
||||
collection.Fields.AddAt(5, newField)
|
||||
|
||||
if err := txApp.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 3: Migrate data from `url` to `new_field`
|
||||
records, err := txApp.FindAllRecords(collectionName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, record := range records {
|
||||
url := record.GetString("link")
|
||||
record.Set("new_field", url)
|
||||
if err := txApp.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Step 4: Remove the old `url` field
|
||||
collection.Fields.RemoveByName("link")
|
||||
if err := txApp.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 5: Rename `new_field` to `url`
|
||||
renamedField := collection.Fields.GetByName("new_field")
|
||||
renamedField.SetName("link")
|
||||
|
||||
return txApp.Save(collection)
|
||||
})
|
||||
}, func(app core.App) error {
|
||||
// Down migration: Restore the `url` field
|
||||
collectionName := "ports"
|
||||
|
||||
return app.RunInTransaction(func(txApp core.App) error {
|
||||
// Step 1: Fetch the collection
|
||||
collection, err := txApp.FindCollectionByNameOrId(collectionName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 2: Add a new `url` field
|
||||
newField := &core.URLField{
|
||||
Name: "new_field",
|
||||
Required: false,
|
||||
}
|
||||
collection.Fields.AddAt(5, newField)
|
||||
|
||||
if err := txApp.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 3: Migrate data from `url` to `new_field`
|
||||
records, err := txApp.FindAllRecords(collectionName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, record := range records {
|
||||
text := record.GetString("link")
|
||||
record.Set("new_field", text)
|
||||
if err := txApp.Save(record); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Step 4: Remove the old `url` field
|
||||
collection.Fields.RemoveByName("link")
|
||||
if err := txApp.Save(collection); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Step 5: Rename `new_field` to `url`
|
||||
renamedField := collection.Fields.GetByName("new_field")
|
||||
renamedField.SetName("link")
|
||||
|
||||
return txApp.Save(collection)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(5, []byte(`{
|
||||
"autogeneratePattern": "",
|
||||
"hidden": false,
|
||||
"id": "text1843675174",
|
||||
"max": 0,
|
||||
"min": 0,
|
||||
"name": "description",
|
||||
"pattern": "",
|
||||
"presentable": false,
|
||||
"primaryKey": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "text"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove field
|
||||
collection.Fields.RemoveById("text1843675174")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(8, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "select355930381",
|
||||
"maxSelect": 1,
|
||||
"name": "link_open",
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "select",
|
||||
"values": [
|
||||
"same_tab",
|
||||
"new_tab"
|
||||
]
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove field
|
||||
collection.Fields.RemoveById("select355930381")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(11, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "number361076486",
|
||||
"max": null,
|
||||
"min": 1,
|
||||
"name": "wake_timeout",
|
||||
"onlyInt": true,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove field
|
||||
collection.Fields.RemoveById("number361076486")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
m "github.com/pocketbase/pocketbase/migrations"
|
||||
)
|
||||
|
||||
func init() {
|
||||
m.Register(func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// add field
|
||||
if err := collection.Fields.AddMarshaledJSONAt(15, []byte(`{
|
||||
"hidden": false,
|
||||
"id": "number2068100152",
|
||||
"max": null,
|
||||
"min": 1,
|
||||
"name": "shutdown_timeout",
|
||||
"onlyInt": true,
|
||||
"presentable": false,
|
||||
"required": false,
|
||||
"system": false,
|
||||
"type": "number"
|
||||
}`)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return app.Save(collection)
|
||||
}, func(app core.App) error {
|
||||
collection, err := app.FindCollectionByNameOrId("z5lghx2r3tm45n1")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// remove field
|
||||
collection.Fields.RemoveById("number2068100152")
|
||||
|
||||
return app.Save(collection)
|
||||
})
|
||||
}
|
||||
@@ -6,10 +6,10 @@ import (
|
||||
"net"
|
||||
|
||||
"github.com/mdlayher/wol"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
)
|
||||
|
||||
func SendMagicPacket(device *models.Record) error {
|
||||
func SendMagicPacket(device *core.Record) error {
|
||||
ip := device.GetString("ip")
|
||||
mac := device.GetString("mac")
|
||||
netmask := device.GetString("netmask")
|
||||
@@ -32,23 +32,41 @@ func SendMagicPacket(device *models.Record) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
targetAddr := fmt.Sprintf("%s:%d", broadcastIp, 9)
|
||||
|
||||
// send wake via udp port 9
|
||||
if err := wakeUDP(targetAddr, parsedMac, bytePassword); err != nil {
|
||||
if err := wakeUDP(broadcastIp, parsedMac, bytePassword); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func wakeUDP(addr string, target net.HardwareAddr, password []byte) error {
|
||||
func wakeUDP(broadcastIp string, target net.HardwareAddr, password []byte) error {
|
||||
c, err := wol.NewClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer c.Close()
|
||||
return c.WakePassword(addr, target, password)
|
||||
|
||||
// send 4 magic packets to different addresses to enhance change of waking up
|
||||
destinations := []string{
|
||||
// default user-calculated broadcast to port 9
|
||||
fmt.Sprintf("%s:9", broadcastIp),
|
||||
// user-calculated broadcast to port alternative port 7
|
||||
fmt.Sprintf("%s:7", broadcastIp),
|
||||
// broadcast to port 9
|
||||
"255.255.255.255:9",
|
||||
// broadcast to alternative port 7
|
||||
"255.255.255.255:7",
|
||||
}
|
||||
|
||||
for _, dest := range destinations {
|
||||
if err := c.WakePassword(dest, target, password); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getBroadcastIp(ipStr, maskStr string) (string, error) {
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package networking
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
)
|
||||
|
||||
type Device struct {
|
||||
@@ -17,148 +16,216 @@ type Device struct {
|
||||
}
|
||||
|
||||
func TestSendMagicPacket(t *testing.T) {
|
||||
collection := &models.Collection{}
|
||||
devices_success := []Device{
|
||||
testCases := []struct {
|
||||
name string
|
||||
ip string
|
||||
mac string
|
||||
netmask string
|
||||
password string
|
||||
wantError bool
|
||||
}{
|
||||
// Valid case: all inputs correct
|
||||
{
|
||||
IP: "8.8.8.8",
|
||||
MAC: "aa:aa:aa:aa:aa:aa",
|
||||
Netmask: "255.0.0.0",
|
||||
Password: "",
|
||||
name: "Valid Case",
|
||||
ip: "192.168.1.100",
|
||||
mac: "00:11:22:33:44:55",
|
||||
netmask: "255.255.255.0",
|
||||
password: "secret",
|
||||
wantError: false,
|
||||
},
|
||||
// Invalid MAC address
|
||||
{
|
||||
IP: "1.1.1.1",
|
||||
MAC: "bb:bb:bb:bb:bb:bb",
|
||||
Netmask: "255.255.0.0",
|
||||
Password: "abcd",
|
||||
name: "Invalid MAC",
|
||||
ip: "192.168.1.100",
|
||||
mac: "invalid",
|
||||
netmask: "255.255.255.0",
|
||||
password: "secret",
|
||||
wantError: true,
|
||||
},
|
||||
// Password too short
|
||||
{
|
||||
name: "Password Too Short",
|
||||
ip: "192.168.1.100",
|
||||
mac: "00:11:22:33:44:55",
|
||||
netmask: "255.255.255.0",
|
||||
password: "s", // length 1
|
||||
wantError: true,
|
||||
},
|
||||
// Password too long
|
||||
{
|
||||
name: "Password Too Long",
|
||||
ip: "192.168.1.100",
|
||||
mac: "00:11:22:33:44:55",
|
||||
netmask: "255.255.255.0",
|
||||
password: "password", // length 9
|
||||
wantError: true,
|
||||
},
|
||||
// Invalid IP address
|
||||
{
|
||||
name: "Invalid IP",
|
||||
ip: "256.1.1.1", // invalid
|
||||
mac: "00:11:22:33:44:55",
|
||||
netmask: "255.255.255.0",
|
||||
password: "secret",
|
||||
wantError: true,
|
||||
},
|
||||
// Invalid netmask
|
||||
{
|
||||
name: "Invalid Netmask",
|
||||
ip: "192.168.1.100",
|
||||
mac: "00:11:22:33:44:55",
|
||||
netmask: "300.255.255.0", // invalid
|
||||
password: "secret",
|
||||
wantError: true,
|
||||
},
|
||||
}
|
||||
|
||||
devices_fail := []Device{
|
||||
{
|
||||
IP: "1.1.1.1",
|
||||
MAC: "aa",
|
||||
Netmask: "255.255.0.0",
|
||||
Password: "abcd",
|
||||
},
|
||||
{
|
||||
IP: "1.1.1.1",
|
||||
MAC: "cc:cc:cc:cc:cc:cc",
|
||||
Netmask: "255.255.0.0",
|
||||
Password: "abcdefg",
|
||||
},
|
||||
}
|
||||
collection := &core.Collection{}
|
||||
|
||||
for _, v := range devices_success {
|
||||
device := models.NewRecord(collection)
|
||||
device.Set("ip", v.IP)
|
||||
device.Set("mac", v.MAC)
|
||||
device.Set("netmask", v.Netmask)
|
||||
device.Set("password", v.Password)
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
device := core.NewRecord(collection)
|
||||
device.Set("ip", tc.ip)
|
||||
device.Set("mac", tc.mac)
|
||||
device.Set("netmask", tc.netmask)
|
||||
device.Set("password", tc.password)
|
||||
|
||||
if err := SendMagicPacket(device); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
for _, v := range devices_fail {
|
||||
device := models.NewRecord(collection)
|
||||
device.Set("ip", v.IP)
|
||||
device.Set("mac", v.MAC)
|
||||
device.Set("netmask", v.Netmask)
|
||||
device.Set("password", v.Password)
|
||||
|
||||
if err := SendMagicPacket(device); err == nil {
|
||||
t.Fatal("should have cause an error")
|
||||
}
|
||||
err := SendMagicPacket(device)
|
||||
if tc.wantError {
|
||||
if err == nil {
|
||||
t.Errorf("Expected error but got none")
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
t.Errorf("Got unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestWakeUDP(t *testing.T) {
|
||||
devices := []Device{
|
||||
testCases := []struct {
|
||||
name string
|
||||
broadcastIp string
|
||||
targetMac string
|
||||
password string
|
||||
wantError bool
|
||||
}{
|
||||
// Valid case: all inputs correct
|
||||
{
|
||||
IP: "8.8.8.8",
|
||||
MAC: "aa:aa:aa:aa:aa:aa",
|
||||
Netmask: "255.0.0.0",
|
||||
Password: "",
|
||||
ExpectFailPassword: false,
|
||||
name: "Valid Case",
|
||||
broadcastIp: "192.168.1.255",
|
||||
targetMac: "00:11:22:33:44:55",
|
||||
password: "secret",
|
||||
wantError: false,
|
||||
},
|
||||
// Invalid MAC address
|
||||
{
|
||||
IP: "1.1.1.1",
|
||||
MAC: "bb:bb:bb:bb:bb:bb",
|
||||
Netmask: "255.255.0.0",
|
||||
Password: "abcd",
|
||||
ExpectFailPassword: false,
|
||||
name: "Invalid MAC",
|
||||
broadcastIp: "192.168.1.255",
|
||||
targetMac: "invalid",
|
||||
password: "secret",
|
||||
wantError: true,
|
||||
},
|
||||
// Password too short
|
||||
{
|
||||
IP: "10.10.10.1",
|
||||
MAC: "cc:cc:cc:cc:cc:cc",
|
||||
Netmask: "255.255.0.0",
|
||||
Password: "abcd",
|
||||
ExpectFailPassword: false,
|
||||
name: "Password Too Short",
|
||||
broadcastIp: "192.168.1.255",
|
||||
targetMac: "00:11:22:33:44:55",
|
||||
password: "s", // length 1
|
||||
wantError: true,
|
||||
},
|
||||
// Password too long
|
||||
{
|
||||
IP: "1.1.1.1",
|
||||
MAC: "dd:dd:dd:dd:dd:dd",
|
||||
Netmask: "255.255.0.0",
|
||||
Password: "abcdefg",
|
||||
ExpectFailPassword: true,
|
||||
name: "Password Too Long",
|
||||
broadcastIp: "192.168.1.255",
|
||||
targetMac: "00:11:22:33:44:55",
|
||||
password: "password", // length 9
|
||||
wantError: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, v := range devices {
|
||||
parsedMac, err := net.ParseMAC(v.MAC)
|
||||
if err != nil {
|
||||
t.Fatalf(`%v (parsedMac "%v")`, err, parsedMac)
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
mac, err := net.ParseMAC(tc.targetMac)
|
||||
if err != nil && !tc.wantError {
|
||||
t.Errorf("Unexpected error parsing MAC: %v", err)
|
||||
} else if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var bytePassword []byte
|
||||
if len(v.Password) == 0 || len(v.Password) == 4 || len(v.Password) == 6 {
|
||||
bytePassword = []byte(v.Password)
|
||||
} else if !v.ExpectFailPassword {
|
||||
t.Fatal("password must be 0, 4 or 6 characters long")
|
||||
}
|
||||
|
||||
broadcastIp, err := getBroadcastIp(v.IP, v.Netmask)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
targetAddr := fmt.Sprintf("%s:%d", broadcastIp, 9)
|
||||
|
||||
if err := wakeUDP(targetAddr, parsedMac, bytePassword); err != nil {
|
||||
t.Fatalf(`%v (targetAddr "%v", parsedMac "%v", bytePassword "%v")`, err, targetAddr, parsedMac, bytePassword)
|
||||
}
|
||||
// Now test the wakeUDP function
|
||||
err = wakeUDP(tc.broadcastIp, mac, []byte(tc.password))
|
||||
if tc.wantError {
|
||||
if err == nil {
|
||||
t.Errorf("Expected error but got none")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetBroadcastIp(t *testing.T) {
|
||||
type address struct {
|
||||
IP string
|
||||
Netmask string
|
||||
BroadcastResult string
|
||||
}
|
||||
|
||||
addresses := []address{
|
||||
testCases := []struct {
|
||||
name string
|
||||
ip string
|
||||
netmask string
|
||||
wantIp string
|
||||
wantError bool
|
||||
}{
|
||||
// Valid case: all inputs correct
|
||||
{
|
||||
IP: "192.168.0.1",
|
||||
Netmask: "255.255.255.0",
|
||||
BroadcastResult: "192.168.0.255",
|
||||
}, {
|
||||
IP: "10.1.1.1",
|
||||
Netmask: "255.255.0.0",
|
||||
BroadcastResult: "10.1.255.255",
|
||||
}, {
|
||||
IP: "10.2.3.4",
|
||||
Netmask: "255.0.0.0",
|
||||
BroadcastResult: "10.255.255.255",
|
||||
name: "Valid Case",
|
||||
ip: "192.168.1.100",
|
||||
netmask: "255.255.255.0",
|
||||
wantIp: "192.168.1.255",
|
||||
wantError: false,
|
||||
},
|
||||
// Invalid IP address
|
||||
{
|
||||
name: "Invalid IP",
|
||||
ip: "256.1.1.1", // invalid
|
||||
netmask: "255.255.255.0",
|
||||
wantIp: "",
|
||||
wantError: true,
|
||||
},
|
||||
// Invalid netmask
|
||||
{
|
||||
name: "Invalid Netmask",
|
||||
ip: "192.168.1.100",
|
||||
netmask: "300.255.255.0", // invalid
|
||||
wantIp: "",
|
||||
wantError: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, v := range addresses {
|
||||
broadcast, err := getBroadcastIp(v.IP, v.Netmask)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if broadcast != v.BroadcastResult {
|
||||
t.Fatalf(`getBroadcastIp("%v, %v"), want %v, got %v`, v.IP, v.Netmask, v.BroadcastResult, broadcast)
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ip := net.ParseIP(tc.ip)
|
||||
if ip == nil && !tc.wantError {
|
||||
t.Errorf("Unexpected error parsing IP: %v", ip)
|
||||
} else if ip == nil {
|
||||
return
|
||||
}
|
||||
|
||||
mask := net.ParseIP(tc.netmask)
|
||||
if mask == nil && !tc.wantError {
|
||||
t.Errorf("Unexpected error parsing netmask: %v", mask)
|
||||
} else if mask == nil {
|
||||
return
|
||||
}
|
||||
|
||||
broadcast, err := getBroadcastIp(tc.ip, tc.netmask)
|
||||
if tc.wantError {
|
||||
if err == nil {
|
||||
t.Errorf("Expected error but got none")
|
||||
}
|
||||
} else {
|
||||
if broadcast != tc.wantIp {
|
||||
t.Errorf("Broadcast IP mismatch: expected %s, got %s", tc.wantIp, broadcast)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,44 +1,60 @@
|
||||
package networking
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
probing "github.com/prometheus-community/pro-bing"
|
||||
"github.com/seriousm4x/upsnap/logger"
|
||||
)
|
||||
|
||||
func PingDevice(device *models.Record) bool {
|
||||
func isNoRouteOrDownError(err error) bool {
|
||||
opErr, ok := err.(*net.OpError)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
syscallErr, ok := opErr.Err.(*os.SyscallError)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return syscallErr.Err == syscall.EHOSTUNREACH || syscallErr.Err == syscall.EHOSTDOWN
|
||||
}
|
||||
|
||||
func PingDevice(device *core.Record) (bool, error) {
|
||||
ping_cmd := device.GetString("ping_cmd")
|
||||
if ping_cmd == "" {
|
||||
pinger, err := probing.NewPinger(device.GetString("ip"))
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
return false
|
||||
return false, err
|
||||
}
|
||||
pinger.Count = 1
|
||||
pinger.Timeout = 500 * time.Millisecond
|
||||
privileged, err := strconv.ParseBool(os.Getenv("UPSNAP_PING_PRIVILEGED"))
|
||||
if err != nil {
|
||||
privileged = true
|
||||
|
||||
privileged := isRoot()
|
||||
privilegedEnv := os.Getenv("UPSNAP_PING_PRIVILEGED")
|
||||
if privilegedEnv != "" {
|
||||
privileged, err = strconv.ParseBool(privilegedEnv)
|
||||
if err != nil {
|
||||
privileged = false
|
||||
}
|
||||
}
|
||||
pinger.SetPrivileged(privileged)
|
||||
|
||||
err = pinger.Run()
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
return false
|
||||
if isNoRouteOrDownError(err) {
|
||||
return false, nil
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
stats := pinger.Statistics()
|
||||
if stats.PacketLoss > 0 {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
return stats.PacketLoss == 0, nil
|
||||
} else {
|
||||
var shell string
|
||||
var shell_arg string
|
||||
@@ -53,16 +69,25 @@ func PingDevice(device *models.Record) bool {
|
||||
cmd := exec.Command(shell, shell_arg, ping_cmd)
|
||||
err := cmd.Run()
|
||||
|
||||
return err == nil
|
||||
return err == nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func CheckPort(host string, port string) bool {
|
||||
func CheckPort(host string, port string) (bool, error) {
|
||||
timeout := 500 * time.Millisecond
|
||||
conn, err := net.DialTimeout("tcp", net.JoinHostPort(host, port), timeout)
|
||||
if err != nil {
|
||||
return false
|
||||
// treat "host unreachable", "connection refused" and "timeout" as no error
|
||||
var netErr *net.OpError
|
||||
if errors.As(err, &netErr) {
|
||||
if errors.Is(netErr.Err, syscall.EHOSTUNREACH) ||
|
||||
errors.Is(netErr.Err, syscall.ECONNREFUSED) ||
|
||||
netErr.Timeout() {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
return false, err
|
||||
}
|
||||
defer conn.Close()
|
||||
return conn != nil
|
||||
return conn != nil, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package networking
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
)
|
||||
|
||||
func TestPingDevice(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
ip string
|
||||
ping_cmd string
|
||||
wantError bool
|
||||
}{
|
||||
// Valid case: all inputs correct
|
||||
{
|
||||
name: "Valid Case",
|
||||
ip: "8.8.8.8",
|
||||
ping_cmd: "exit 0",
|
||||
wantError: false,
|
||||
},
|
||||
// Invalid ping command
|
||||
{
|
||||
name: "Invalid Ping Command",
|
||||
ip: "8.8.8.8",
|
||||
ping_cmd: "exit 1",
|
||||
wantError: true,
|
||||
},
|
||||
}
|
||||
|
||||
collection := &core.Collection{}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
device := core.NewRecord(collection)
|
||||
device.Set("ip", tc.ip)
|
||||
device.Set("ping_cmd", tc.ping_cmd)
|
||||
|
||||
_, err := PingDevice(device)
|
||||
if err == nil && tc.wantError {
|
||||
t.Errorf("Expected error but got none")
|
||||
} else if err != nil && !tc.wantError {
|
||||
t.Errorf("Got unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCheckPort(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
host string
|
||||
port string
|
||||
wantError bool
|
||||
}{
|
||||
// Valid case: all inputs correct
|
||||
{
|
||||
name: "Valid Case",
|
||||
host: "8.8.8.8",
|
||||
port: "443",
|
||||
wantError: false,
|
||||
},
|
||||
// Invalid IP address
|
||||
{
|
||||
name: "Invalid IP",
|
||||
host: "256.1.1.1", // invalid
|
||||
port: "443",
|
||||
wantError: true,
|
||||
},
|
||||
// Invalid port number
|
||||
{
|
||||
name: "Invalid Port",
|
||||
host: "8.8.8.8",
|
||||
port: "70000", // invalid
|
||||
wantError: true,
|
||||
},
|
||||
// Port zero
|
||||
{
|
||||
name: "Port Zero",
|
||||
host: "8.8.8.8",
|
||||
port: "0",
|
||||
wantError: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
_, err := CheckPort(tc.host, tc.port)
|
||||
if err == nil && tc.wantError {
|
||||
t.Errorf("Expected error but got none")
|
||||
} else if err != nil && !tc.wantError {
|
||||
t.Errorf("Got unexpected error: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//go:build !windows
|
||||
|
||||
package networking
|
||||
|
||||
import "os"
|
||||
|
||||
func isRoot() bool {
|
||||
return os.Geteuid() == 0
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//go:build windows
|
||||
|
||||
package networking
|
||||
|
||||
import "golang.org/x/sys/windows"
|
||||
|
||||
func isRoot() bool {
|
||||
var sid *windows.SID
|
||||
sid, err := windows.CreateWellKnownSid(windows.WinBuiltinAdministratorsSid)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
token := windows.GetCurrentProcessToken()
|
||||
isAdmin, err := token.IsMember(sid)
|
||||
return err == nil && isAdmin
|
||||
}
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/seriousm4x/upsnap/logger"
|
||||
)
|
||||
|
||||
func ShutdownDevice(device *models.Record) error {
|
||||
func ShutdownDevice(device *core.Record) error {
|
||||
logger.Info.Println("Shutdown triggered for", device.GetString("name"))
|
||||
shutdown_cmd := device.GetString("shutdown_cmd")
|
||||
if shutdown_cmd == "" {
|
||||
@@ -48,18 +48,27 @@ func ShutdownDevice(device *models.Record) error {
|
||||
done <- cmd.Wait()
|
||||
}()
|
||||
|
||||
// check state every seconds for 2 min
|
||||
shutdownTimeout := device.GetInt("shutdown_timeout")
|
||||
if shutdownTimeout <= 0 {
|
||||
shutdownTimeout = 120
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-time.After(1 * time.Second):
|
||||
if time.Since(start) >= 2*time.Minute {
|
||||
if time.Since(start) >= time.Duration(shutdownTimeout)*time.Second {
|
||||
if err := KillProcess(cmd.Process); err != nil {
|
||||
logger.Error.Println(err)
|
||||
}
|
||||
return fmt.Errorf("%s not offline after 2 minutes", device.GetString("name"))
|
||||
return fmt.Errorf("%s not offline after %d seconds", device.GetString("name"), shutdownTimeout)
|
||||
}
|
||||
isOnline, err := PingDevice(device)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
return err
|
||||
}
|
||||
isOnline := PingDevice(device)
|
||||
if !isOnline {
|
||||
if err := KillProcess(cmd.Process); err != nil {
|
||||
logger.Error.Println(err)
|
||||
|
||||
@@ -18,7 +18,7 @@ func SetProcessAttributes(cmd *exec.Cmd) {
|
||||
|
||||
// Kills child processes on Linux. Windows doesn't provide a direct way to kill child processes, so we kill just the main process.
|
||||
func KillProcess(process *os.Process) error {
|
||||
logger.Warning.Println("Your shutdown cmd didn't finish in 2 minutes. It will be killed.")
|
||||
logger.Warning.Println("Your command didn't finish in time. It will be killed.")
|
||||
pgid, err := unix.Getpgid(process.Pid)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/seriousm4x/upsnap/logger"
|
||||
)
|
||||
|
||||
@@ -15,7 +15,7 @@ type SolResponse struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func SleepDevice(device *models.Record) (SolResponse, error) {
|
||||
func SleepDevice(device *core.Record) (SolResponse, error) {
|
||||
logger.Info.Println("Sleep triggered for", device.GetString("name"))
|
||||
|
||||
var solResp SolResponse
|
||||
|
||||
@@ -8,13 +8,18 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/seriousm4x/upsnap/logger"
|
||||
)
|
||||
|
||||
func WakeDevice(device *models.Record) error {
|
||||
func WakeDevice(device *core.Record) error {
|
||||
logger.Info.Println("Wake triggered for", device.GetString("name"))
|
||||
|
||||
wakeTimeout := device.GetInt("wake_timeout")
|
||||
if wakeTimeout <= 0 {
|
||||
wakeTimeout = 120
|
||||
}
|
||||
|
||||
wake_cmd := device.GetString("wake_cmd")
|
||||
if wake_cmd != "" {
|
||||
var shell string
|
||||
@@ -46,18 +51,22 @@ func WakeDevice(device *models.Record) error {
|
||||
done <- cmd.Wait()
|
||||
}()
|
||||
|
||||
// check state every seconds for 2 min
|
||||
start := time.Now()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-time.After(1 * time.Second):
|
||||
if time.Since(start) >= 2*time.Minute {
|
||||
if time.Since(start) >= time.Duration(wakeTimeout)*time.Second {
|
||||
if err := KillProcess(cmd.Process); err != nil {
|
||||
logger.Error.Println(err)
|
||||
}
|
||||
return fmt.Errorf("%s not online after 2 minutes", device.GetString("name"))
|
||||
return fmt.Errorf("%s not online after %d seconds", device.GetString("name"), wakeTimeout)
|
||||
}
|
||||
isOnline, err := PingDevice(device)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
return err
|
||||
}
|
||||
isOnline := PingDevice(device)
|
||||
if isOnline {
|
||||
if err := KillProcess(cmd.Process); err != nil {
|
||||
logger.Error.Println(err)
|
||||
@@ -79,18 +88,21 @@ func WakeDevice(device *models.Record) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// check state every seconds for 2 min
|
||||
start := time.Now()
|
||||
for {
|
||||
time.Sleep(1 * time.Second)
|
||||
isOnline := PingDevice(device)
|
||||
isOnline, err := PingDevice(device)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
return err
|
||||
}
|
||||
if isOnline {
|
||||
return nil
|
||||
}
|
||||
if time.Since(start) >= 2*time.Minute {
|
||||
if time.Since(start) >= time.Duration(wakeTimeout)*time.Second {
|
||||
break
|
||||
}
|
||||
}
|
||||
return fmt.Errorf(device.GetString("name"), "not online after 2 min")
|
||||
return fmt.Errorf("%s not online after %d seconds", device.GetString("name"), wakeTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,71 +10,71 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/pocketbase/pocketbase/apis"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/robfig/cron/v3"
|
||||
"github.com/seriousm4x/upsnap/logger"
|
||||
"github.com/seriousm4x/upsnap/networking"
|
||||
)
|
||||
|
||||
func HandlerWake(c echo.Context) error {
|
||||
record, err := App.Dao().FindFirstRecordByData("devices", "id", c.PathParam("id"))
|
||||
func HandlerWake(e *core.RequestEvent) error {
|
||||
record, err := e.App.FindFirstRecordByData("devices", "id", e.Request.PathValue("id"))
|
||||
if err != nil {
|
||||
return apis.NewNotFoundError("The device does not exist.", err)
|
||||
}
|
||||
record.Set("status", "pending")
|
||||
if err := App.Dao().SaveRecord(record); err != nil {
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
go func(r *models.Record) {
|
||||
go func(r *core.Record) {
|
||||
if err := networking.WakeDevice(r); err != nil {
|
||||
logger.Error.Println(err)
|
||||
r.Set("status", "offline")
|
||||
} else {
|
||||
r.Set("status", "online")
|
||||
}
|
||||
if err := App.Dao().SaveRecord(r); err != nil {
|
||||
if err := e.App.Save(r); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
}(record)
|
||||
return c.JSON(http.StatusOK, record)
|
||||
return e.JSON(http.StatusOK, record)
|
||||
}
|
||||
|
||||
func HandlerSleep(c echo.Context) error {
|
||||
record, err := App.Dao().FindFirstRecordByData("devices", "id", c.PathParam("id"))
|
||||
func HandlerSleep(e *core.RequestEvent) error {
|
||||
record, err := e.App.FindFirstRecordByData("devices", "id", e.Request.PathValue("id"))
|
||||
if err != nil {
|
||||
return apis.NewNotFoundError("The device does not exist.", err)
|
||||
}
|
||||
record.Set("status", "pending")
|
||||
if err := App.Dao().SaveRecord(record); err != nil {
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
resp, err := networking.SleepDevice(record)
|
||||
if err != nil {
|
||||
logger.Error.Println(err)
|
||||
record.Set("status", "online")
|
||||
if err := App.Dao().SaveRecord(record); err != nil {
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
return apis.NewBadRequestError(resp.Message, nil)
|
||||
}
|
||||
record.Set("status", "offline")
|
||||
if err := App.Dao().SaveRecord(record); err != nil {
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
return c.JSON(http.StatusOK, nil)
|
||||
return e.JSON(http.StatusOK, nil)
|
||||
}
|
||||
|
||||
func HandlerReboot(c echo.Context) error {
|
||||
record, err := App.Dao().FindFirstRecordByData("devices", "id", c.PathParam("id"))
|
||||
func HandlerReboot(e *core.RequestEvent) error {
|
||||
record, err := e.App.FindFirstRecordByData("devices", "id", e.Request.PathValue("id"))
|
||||
if err != nil {
|
||||
return apis.NewNotFoundError("The device does not exist.", err)
|
||||
}
|
||||
record.Set("status", "pending")
|
||||
if err := App.Dao().SaveRecord(record); err != nil {
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
go func(r *models.Record) {
|
||||
go func(r *core.Record) {
|
||||
if err := networking.ShutdownDevice(r); err != nil {
|
||||
logger.Error.Println(err)
|
||||
r.Set("status", "online")
|
||||
@@ -87,34 +87,34 @@ func HandlerReboot(c echo.Context) error {
|
||||
r.Set("status", "online")
|
||||
}
|
||||
}
|
||||
if err := App.Dao().SaveRecord(r); err != nil {
|
||||
if err := e.App.Save(r); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
}(record)
|
||||
return c.JSON(http.StatusOK, record)
|
||||
return e.JSON(http.StatusOK, record)
|
||||
}
|
||||
|
||||
func HandlerShutdown(c echo.Context) error {
|
||||
record, err := App.Dao().FindFirstRecordByData("devices", "id", c.PathParam("id"))
|
||||
func HandlerShutdown(e *core.RequestEvent) error {
|
||||
record, err := e.App.FindFirstRecordByData("devices", "id", e.Request.PathValue("id"))
|
||||
if err != nil {
|
||||
return apis.NewNotFoundError("The device does not exist.", err)
|
||||
}
|
||||
record.Set("status", "pending")
|
||||
if err := App.Dao().SaveRecord(record); err != nil {
|
||||
if err := e.App.Save(record); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
go func(r *models.Record) {
|
||||
go func(r *core.Record) {
|
||||
if err := networking.ShutdownDevice(r); err != nil {
|
||||
logger.Error.Println(err)
|
||||
r.Set("status", "online")
|
||||
} else {
|
||||
r.Set("status", "offline")
|
||||
}
|
||||
if err := App.Dao().SaveRecord(r); err != nil {
|
||||
if err := e.App.Save(r); err != nil {
|
||||
logger.Error.Println("Failed to save record:", err)
|
||||
}
|
||||
}(record)
|
||||
return c.JSON(http.StatusOK, record)
|
||||
return e.JSON(http.StatusOK, record)
|
||||
}
|
||||
|
||||
type Nmaprun struct {
|
||||
@@ -127,7 +127,7 @@ type Nmaprun struct {
|
||||
} `xml:"host"`
|
||||
}
|
||||
|
||||
func HandlerScan(c echo.Context) error {
|
||||
func HandlerScan(e *core.RequestEvent) error {
|
||||
// check if nmap installed
|
||||
nmap, err := exec.LookPath("nmap")
|
||||
if err != nil {
|
||||
@@ -135,7 +135,7 @@ func HandlerScan(c echo.Context) error {
|
||||
}
|
||||
|
||||
// check if scan range is valid
|
||||
allPrivateSettings, err := App.Dao().FindRecordsByExpr("settings_private")
|
||||
allPrivateSettings, err := e.App.FindAllRecords("settings_private")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -215,5 +215,65 @@ func HandlerScan(c echo.Context) error {
|
||||
res.Devices = append(res.Devices, dev)
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, res)
|
||||
return e.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
func HandlerInitSuperuser(e *core.RequestEvent) error {
|
||||
superusersCollection, err := e.App.FindCollectionByNameOrId(core.CollectionNameSuperusers)
|
||||
if err != nil {
|
||||
return e.NotFoundError("Failed to retrieve superusers collection", err)
|
||||
}
|
||||
|
||||
totalSuperusers, err := e.App.CountRecords(superusersCollection)
|
||||
if err != nil {
|
||||
return e.InternalServerError("Failed to retrieve superusers count", err)
|
||||
}
|
||||
|
||||
if totalSuperusers > 0 {
|
||||
return e.BadRequestError("An initial superuser already exists", nil)
|
||||
}
|
||||
|
||||
data := struct {
|
||||
Email string `json:"email" form:"email"`
|
||||
Password string `json:"password" form:"password"`
|
||||
PasswordConfirm string `json:"password_confirm" form:"password-confirm"`
|
||||
}{}
|
||||
err = e.BindBody(&data)
|
||||
if err != nil {
|
||||
return e.BadRequestError("Failed to read request data", err)
|
||||
}
|
||||
|
||||
if data.Password != data.PasswordConfirm {
|
||||
return e.BadRequestError("Password don't match", err)
|
||||
}
|
||||
|
||||
record := core.NewRecord(superusersCollection)
|
||||
record.SetEmail(data.Email)
|
||||
record.SetPassword(data.Password)
|
||||
err = e.App.Save(record)
|
||||
if err != nil {
|
||||
return e.BadRequestError("Failed to create initial superuser", err)
|
||||
}
|
||||
|
||||
return apis.RecordAuthResponse(e, record, "", nil)
|
||||
}
|
||||
|
||||
type ValidateCronRequest struct {
|
||||
Cron string `json:"cron"`
|
||||
}
|
||||
|
||||
func HandlerValidateCron(e *core.RequestEvent) error {
|
||||
var body ValidateCronRequest
|
||||
|
||||
if err := e.BindBody(&body); err != nil {
|
||||
logger.Error.Println(err)
|
||||
return e.BadRequestError("invalid request", err)
|
||||
}
|
||||
|
||||
p := cron.NewParser(cron.SecondOptional | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow)
|
||||
if _, err := p.Parse(body.Cron); err != nil {
|
||||
return e.BadRequestError("failed to parse cron expression", err)
|
||||
}
|
||||
|
||||
return e.JSON(200, "valid")
|
||||
}
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
package pb
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/pocketbase/dbx"
|
||||
"github.com/pocketbase/pocketbase/apis"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/pocketbase/pocketbase/tools/hook"
|
||||
)
|
||||
|
||||
func RequireUpSnapPermission() echo.MiddlewareFunc {
|
||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
admin, _ := c.Get(apis.ContextAdminKey).(*models.Admin)
|
||||
if admin != nil {
|
||||
return next(c)
|
||||
func RequireUpSnapPermission() *hook.Handler[*core.RequestEvent] {
|
||||
return &hook.Handler[*core.RequestEvent]{
|
||||
Func: func(e *core.RequestEvent) error {
|
||||
if e.HasSuperuserAuth() {
|
||||
return e.Next()
|
||||
}
|
||||
|
||||
user, _ := c.Get(apis.ContextAuthRecordKey).(*models.Record)
|
||||
user := e.Auth
|
||||
if user == nil {
|
||||
return apis.NewUnauthorizedError("The request requires admin or record authorization token to be set.", nil)
|
||||
return apis.NewUnauthorizedError("The request requires superuser or record authorization token to be set.", nil)
|
||||
}
|
||||
|
||||
deviceId := c.PathParam("id")
|
||||
deviceId := e.Request.PathValue("id")
|
||||
|
||||
// find record where user has device with power permission
|
||||
res, err := App.Dao().FindFirstRecordByFilter("permissions",
|
||||
fmt.Sprintf("user.id = '%s' && power.id ?= '%s'", user.Id, deviceId))
|
||||
res, err := e.App.FindFirstRecordByFilter("permissions", "user.id = {:userId} && power.id ?= {:deviceId}", dbx.Params{
|
||||
"userId": user.Id,
|
||||
"deviceId": deviceId,
|
||||
})
|
||||
if res == nil || err != nil {
|
||||
return apis.NewForbiddenError("You are not allowed to perform this request.", nil)
|
||||
}
|
||||
|
||||
return next(c)
|
||||
}
|
||||
return e.Next()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
package pb
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/pocketbase/pocketbase"
|
||||
"github.com/pocketbase/pocketbase/apis"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
"github.com/pocketbase/pocketbase/models"
|
||||
"github.com/pocketbase/pocketbase/plugins/migratecmd"
|
||||
"github.com/robfig/cron/v3"
|
||||
"github.com/seriousm4x/upsnap/cronjobs"
|
||||
"github.com/seriousm4x/upsnap/logger"
|
||||
_ "github.com/seriousm4x/upsnap/migrations"
|
||||
)
|
||||
|
||||
var App *pocketbase.PocketBase
|
||||
var Version = "(untracked)"
|
||||
|
||||
func StartPocketBase(distDirFS fs.FS) {
|
||||
@@ -49,95 +47,53 @@ func StartPocketBase(distDirFS fs.FS) {
|
||||
}
|
||||
|
||||
// create app
|
||||
App = pocketbase.NewWithConfig(pocketbase.Config{
|
||||
app := pocketbase.NewWithConfig(pocketbase.Config{
|
||||
DefaultDataDir: dataDir,
|
||||
})
|
||||
App.RootCmd.Short = "UpSnap CLI"
|
||||
App.RootCmd.Version = Version
|
||||
app.RootCmd.Short = "UpSnap CLI"
|
||||
app.RootCmd.Version = Version
|
||||
|
||||
// auto migrate db
|
||||
migratecmd.MustRegister(App, App.RootCmd, migratecmd.Config{
|
||||
migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{
|
||||
Automigrate: true,
|
||||
})
|
||||
|
||||
// event hooks
|
||||
App.OnBeforeServe().Add(func(e *core.ServeEvent) error {
|
||||
e.Router.GET("/*", apis.StaticDirectoryHandler(distDirFS, true))
|
||||
app.OnServe().BindFunc(func(se *core.ServeEvent) error {
|
||||
se.Router.GET("/{path...}", apis.Static(distDirFS, true))
|
||||
|
||||
e.Router.AddRoute(echo.Route{
|
||||
Method: http.MethodGet,
|
||||
Path: "/api/upsnap/wake/:id",
|
||||
Handler: HandlerWake,
|
||||
Middlewares: []echo.MiddlewareFunc{
|
||||
apis.ActivityLogger(App),
|
||||
RequireUpSnapPermission(),
|
||||
},
|
||||
})
|
||||
se.Router.GET("/api/upsnap/wake/{id}", HandlerWake).Bind(RequireUpSnapPermission())
|
||||
se.Router.GET("/api/upsnap/sleep/{id}", HandlerSleep).Bind(RequireUpSnapPermission())
|
||||
se.Router.GET("/api/upsnap/reboot/{id}", HandlerReboot).Bind(RequireUpSnapPermission())
|
||||
se.Router.GET("/api/upsnap/shutdown/{id}", HandlerShutdown).Bind(RequireUpSnapPermission())
|
||||
se.Router.GET("/api/upsnap/scan", HandlerScan).Bind(apis.RequireSuperuserAuth())
|
||||
se.Router.POST("/api/upsnap/init-superuser", HandlerInitSuperuser) // https://github.com/pocketbase/pocketbase/discussions/6198
|
||||
se.Router.POST("/api/upsnap/validate-cron", HandlerValidateCron)
|
||||
|
||||
e.Router.AddRoute(echo.Route{
|
||||
Method: http.MethodGet,
|
||||
Path: "/api/upsnap/sleep/:id",
|
||||
Handler: HandlerSleep,
|
||||
Middlewares: []echo.MiddlewareFunc{
|
||||
apis.ActivityLogger(App),
|
||||
RequireUpSnapPermission(),
|
||||
},
|
||||
})
|
||||
|
||||
e.Router.AddRoute(echo.Route{
|
||||
Method: http.MethodGet,
|
||||
Path: "/api/upsnap/reboot/:id",
|
||||
Handler: HandlerReboot,
|
||||
Middlewares: []echo.MiddlewareFunc{
|
||||
apis.ActivityLogger(App),
|
||||
RequireUpSnapPermission(),
|
||||
},
|
||||
})
|
||||
|
||||
e.Router.AddRoute(echo.Route{
|
||||
Method: http.MethodGet,
|
||||
Path: "/api/upsnap/shutdown/:id",
|
||||
Handler: HandlerShutdown,
|
||||
Middlewares: []echo.MiddlewareFunc{
|
||||
apis.ActivityLogger(App),
|
||||
RequireUpSnapPermission(),
|
||||
},
|
||||
})
|
||||
|
||||
e.Router.AddRoute(echo.Route{
|
||||
Method: http.MethodGet,
|
||||
Path: "/api/upsnap/scan",
|
||||
Handler: HandlerScan,
|
||||
Middlewares: []echo.MiddlewareFunc{
|
||||
apis.ActivityLogger(App),
|
||||
apis.RequireAdminAuth(),
|
||||
},
|
||||
})
|
||||
|
||||
if err := importSettings(); err != nil {
|
||||
if err := importSettings(app); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := resetDeviceStates(); err != nil {
|
||||
if err := resetDeviceStates(app); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cronjobs.SetPingJobs(App)
|
||||
cronjobs.SetPingJobs(app)
|
||||
cronjobs.StartPing()
|
||||
cronjobs.SetWakeShutdownJobs(App)
|
||||
cronjobs.SetWakeShutdownJobs(app)
|
||||
cronjobs.StartWakeShutdown()
|
||||
|
||||
// restart ping cronjobs or wake/shutdown cronjobs on model update
|
||||
// add event hook before starting server.
|
||||
// using this outside App.OnBeforeServe() would not work
|
||||
App.OnModelAfterUpdate("settings_private", "devices").Add(func(e *core.ModelEvent) error {
|
||||
app.OnModelAfterUpdateSuccess("settings_private", "devices").BindFunc(func(e *core.ModelEvent) error {
|
||||
if e.Model.TableName() == "settings_private" {
|
||||
cronjobs.SetPingJobs(App)
|
||||
cronjobs.SetPingJobs(app)
|
||||
} else if e.Model.TableName() == "devices" {
|
||||
// only restart wake/shutdown cronjobs if new model's cron changed
|
||||
record := e.Model.(*models.Record)
|
||||
newRecord := record.CleanCopy()
|
||||
oldRecord := record.OriginalCopy()
|
||||
record := e.Model.(*core.Record)
|
||||
newRecord := record.Fresh()
|
||||
oldRecord := record.Original()
|
||||
|
||||
newWakeCron := newRecord.GetString("wake_cron")
|
||||
newWakeCmd := newRecord.GetString("wake_cmd")
|
||||
@@ -159,28 +115,28 @@ func StartPocketBase(distDirFS fs.FS) {
|
||||
newShutdownCron != oldShutdownCron ||
|
||||
newShutdownCronEnabled != oldShutdownCronEnabled ||
|
||||
newShutdownCmd != oldShutdownCmd {
|
||||
cronjobs.SetWakeShutdownJobs(App)
|
||||
cronjobs.SetWakeShutdownJobs(app)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return e.Next()
|
||||
})
|
||||
return nil
|
||||
return se.Next()
|
||||
})
|
||||
|
||||
App.OnModelAfterCreate().Add(func(e *core.ModelEvent) error {
|
||||
if e.Model.TableName() == "_admins" {
|
||||
if err := setSetupCompleted(); err != nil {
|
||||
app.OnModelAfterCreateSuccess().BindFunc(func(e *core.ModelEvent) error {
|
||||
if e.Model.TableName() == "_superusers" {
|
||||
if err := setSetupCompleted(e.App); err != nil {
|
||||
logger.Error.Println(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return e.Next()
|
||||
} else if e.Model.TableName() == "devices" {
|
||||
// when a device is created, give the user all rights to the device he just created
|
||||
deviceRec := e.Model.(*models.Record)
|
||||
deviceRec := e.Model.(*core.Record)
|
||||
userId := deviceRec.GetString("created_by")
|
||||
|
||||
var permissionRec *models.Record
|
||||
permissionRec, err := App.Dao().FindFirstRecordByFilter("permissions",
|
||||
var permissionRec *core.Record
|
||||
permissionRec, err := app.FindFirstRecordByFilter("permissions",
|
||||
fmt.Sprintf("user.id = '%s'", userId))
|
||||
if err != nil && err.Error() != "sql: no rows in result set" {
|
||||
logger.Error.Println(err)
|
||||
@@ -190,57 +146,66 @@ func StartPocketBase(distDirFS fs.FS) {
|
||||
permissionRec.Set("update", append(permissionRec.GetStringSlice("update"), deviceRec.Id))
|
||||
permissionRec.Set("delete", append(permissionRec.GetStringSlice("delete"), deviceRec.Id))
|
||||
permissionRec.Set("power", append(permissionRec.GetStringSlice("power"), deviceRec.Id))
|
||||
if err := App.Dao().SaveRecord(permissionRec); err != nil {
|
||||
if err := app.Save(permissionRec); err != nil {
|
||||
logger.Error.Println(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return e.Next()
|
||||
})
|
||||
App.OnModelAfterDelete().Add(func(e *core.ModelEvent) error {
|
||||
if e.Model.TableName() == "_admins" {
|
||||
if err := setSetupCompleted(); err != nil {
|
||||
|
||||
app.OnModelAfterDeleteSuccess().BindFunc(func(e *core.ModelEvent) error {
|
||||
if e.Model.TableName() == "_superusers" {
|
||||
if err := setSetupCompleted(e.App); err != nil {
|
||||
logger.Error.Println(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return e.Next()
|
||||
})
|
||||
|
||||
App.OnTerminate().Add(func(e *core.TerminateEvent) error {
|
||||
// prevent new superuser bahavior introduced in pocketbase 0.23
|
||||
app.OnRecordCreate(core.CollectionNameSuperusers).BindFunc(func(e *core.RecordEvent) error {
|
||||
if e.Record.Email() == core.DefaultInstallerEmail {
|
||||
return errors.New("skip default PocketBase installer")
|
||||
}
|
||||
return e.Next()
|
||||
})
|
||||
|
||||
app.OnTerminate().BindFunc(func(e *core.TerminateEvent) error {
|
||||
cronjobs.StopAll()
|
||||
return nil
|
||||
return e.Next()
|
||||
})
|
||||
|
||||
if err := App.Start(); err != nil {
|
||||
if err := app.Start(); err != nil {
|
||||
logger.Error.Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
||||
func importSettings() error {
|
||||
settingsPrivateRecords, err := App.Dao().FindRecordsByExpr("settings_private")
|
||||
func importSettings(app *pocketbase.PocketBase) error {
|
||||
settingsPrivateRecords, err := app.FindAllRecords("settings_private")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
settingsPrivateCollection, err := App.Dao().FindCollectionByNameOrId("settings_private")
|
||||
settingsPrivateCollection, err := app.FindCollectionByNameOrId("settings_private")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
settingsPrivate := models.NewRecord(settingsPrivateCollection)
|
||||
settingsPrivate := core.NewRecord(settingsPrivateCollection)
|
||||
if len(settingsPrivateRecords) > 0 {
|
||||
settingsPrivate = settingsPrivateRecords[0]
|
||||
}
|
||||
|
||||
settingsPublicRecords, err := App.Dao().FindRecordsByExpr("settings_public")
|
||||
settingsPublicRecords, err := app.FindAllRecords("settings_public")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
settingsPublicCollection, err := App.Dao().FindCollectionByNameOrId("settings_public")
|
||||
settingsPublicCollection, err := app.FindCollectionByNameOrId("settings_public")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
settingsPublic := models.NewRecord(settingsPublicCollection)
|
||||
settingsPublic := core.NewRecord(settingsPublicCollection)
|
||||
if len(settingsPublicRecords) > 0 {
|
||||
settingsPublic = settingsPublicRecords[0]
|
||||
}
|
||||
@@ -249,7 +214,8 @@ func importSettings() error {
|
||||
// 1st: env var
|
||||
// 2nd: database entry
|
||||
// 3rd: default values
|
||||
interval := "@every 3s"
|
||||
defaultInterval := "*/3 * * * * *"
|
||||
interval := defaultInterval
|
||||
if settingsPrivate.GetString("interval") != "" {
|
||||
interval = settingsPrivate.GetString("interval")
|
||||
}
|
||||
@@ -257,6 +223,22 @@ func importSettings() error {
|
||||
interval = os.Getenv("UPSNAP_INTERVAL")
|
||||
}
|
||||
|
||||
// validate interval before saving
|
||||
p := cron.NewParser(cron.SecondOptional | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow)
|
||||
if _, err := p.Parse(interval); err != nil {
|
||||
if interval == "*/3 * * * *" || interval == "@every 3s" {
|
||||
settingsPrivate.Set("interval", defaultInterval)
|
||||
if e := app.Save(settingsPrivate); e != nil {
|
||||
logger.Error.Println(e)
|
||||
}
|
||||
} else {
|
||||
logger.Error.Printf("'%s' ping interval is not valid.\n", interval)
|
||||
logger.Error.Println("Please go to '/settings/' and change your ping interval.")
|
||||
logger.Error.Println("Falling back to default interval: " + defaultInterval)
|
||||
}
|
||||
interval = defaultInterval
|
||||
}
|
||||
|
||||
settingsPrivate.Set("interval", interval)
|
||||
if scanRange := os.Getenv("UPSNAP_SCAN_RANGE"); scanRange != "" {
|
||||
settingsPrivate.Set("scan_range", scanRange)
|
||||
@@ -266,13 +248,13 @@ func importSettings() error {
|
||||
settingsPublic.Set("website_title", websiteTitle)
|
||||
}
|
||||
|
||||
if err := App.Dao().SaveRecord(settingsPrivate); err != nil {
|
||||
if err := app.Save(settingsPrivate); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := App.Dao().SaveRecord(settingsPublic); err != nil {
|
||||
if err := app.Save(settingsPublic); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := setSetupCompleted(); err != nil {
|
||||
if err := setSetupCompleted(app); err != nil {
|
||||
logger.Error.Println(err)
|
||||
return err
|
||||
}
|
||||
@@ -281,26 +263,26 @@ func importSettings() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func resetDeviceStates() error {
|
||||
devices, err := App.Dao().FindRecordsByExpr("devices")
|
||||
func resetDeviceStates(app *pocketbase.PocketBase) error {
|
||||
devices, err := app.FindAllRecords("devices")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, device := range devices {
|
||||
device.Set("status", "offline")
|
||||
if err := App.Dao().SaveRecord(device); err != nil {
|
||||
if err := app.Save(device); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setSetupCompleted() error {
|
||||
totalAdmins, err := App.Dao().TotalAdmins()
|
||||
func setSetupCompleted(app core.App) error {
|
||||
totalAdmins, err := app.CountRecords(core.CollectionNameSuperusers)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
settingsPublicRecords, err := App.Dao().FindRecordsByExpr("settings_public")
|
||||
settingsPublicRecords, err := app.FindAllRecords("settings_public")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -309,7 +291,7 @@ func setSetupCompleted() error {
|
||||
} else {
|
||||
settingsPublicRecords[0].Set("setup_completed", false)
|
||||
}
|
||||
if err := App.Dao().SaveRecord(settingsPublicRecords[0]); err != nil {
|
||||
if err := app.Save(settingsPublicRecords[0]); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -12,7 +12,7 @@ services:
|
||||
# user: 1000:1000
|
||||
# environment:
|
||||
# - TZ=Europe/Berlin # Set container timezone for cron schedules
|
||||
# - UPSNAP_INTERVAL=@every 10s # Sets the interval in which the devices are pinged
|
||||
# - UPSNAP_INTERVAL=*/10 * * * * * # Sets the interval in which the devices are pinged
|
||||
# - UPSNAP_SCAN_RANGE=192.168.1.0/24 # Scan range is used for device discovery on local network
|
||||
# - UPSNAP_WEBSITE_TITLE=Custom name # Custom website title
|
||||
# # dns is used for name resolution during network scan
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
services:
|
||||
upsnap:
|
||||
container_name: upsnap
|
||||
image: ghcr.io/seriousm4x/upsnap:4 # images are also available on docker hub: seriousm4x/upsnap:4
|
||||
image: ghcr.io/seriousm4x/upsnap:5 # images are also available on docker hub: seriousm4x/upsnap:5
|
||||
network_mode: host
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
@@ -10,7 +10,7 @@ services:
|
||||
# user: 1000:1000
|
||||
# environment:
|
||||
# - TZ=Europe/Berlin # Set container timezone for cron schedules
|
||||
# - UPSNAP_INTERVAL=@every 10s # Sets the interval in which the devices are pinged
|
||||
# - UPSNAP_INTERVAL=*/10 * * * * * # Sets the interval in which the devices are pinged
|
||||
# - UPSNAP_SCAN_RANGE=192.168.1.0/24 # Scan range is used for device discovery on local network
|
||||
# - UPSNAP_SCAN_TIMEOUT=500ms # Scan timeout is nmap's --host-timeout value to wait for devices (https://nmap.org/book/man-performance.html)
|
||||
# - UPSNAP_PING_PRIVILEGED=true # Set to false if you don't have root user permissions
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"adapter": "svelte",
|
||||
"$schema": "https://unpkg.com/typesafe-i18n@5.26.2/schema/typesafe-i18n.json",
|
||||
"outputPath": "./src/lib/i18n/"
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "npm-run-all --parallel vite typesafe-i18n",
|
||||
"dev": "vite dev",
|
||||
"vite": "vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
@@ -11,33 +11,33 @@
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"lint": "eslint --fix --cache .",
|
||||
"format": "prettier --write --cache --cache-strategy content --ignore-path ../.gitignore .",
|
||||
"prepare": "cd .. && husky frontend/.husky",
|
||||
"typesafe-i18n": "typesafe-i18n"
|
||||
"prepare": "svelte-kit sync && cd .. && husky frontend/.husky",
|
||||
"machine-translate": "inlang machine translate --project project.inlang"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.2.2",
|
||||
"@eslint/js": "^9.14.0",
|
||||
"@sveltejs/adapter-static": "^3.0.6",
|
||||
"@sveltejs/kit": "^2.8.1",
|
||||
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"daisyui": "^4.12.14",
|
||||
"eslint": "^9.14.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-svelte": "^2.46.0",
|
||||
"globals": "^15.12.0",
|
||||
"husky": "^9.1.6",
|
||||
"postcss": "^8.4.49",
|
||||
"prettier": "^3.3.3",
|
||||
"prettier-plugin-svelte": "^3.2.8",
|
||||
"prettier-plugin-tailwindcss": "^0.6.8",
|
||||
"svelte": "^4.2.19",
|
||||
"svelte-check": "^4.0.7",
|
||||
"tailwindcss": "^3.4.14",
|
||||
"@eslint/compat": "^1.2.7",
|
||||
"@eslint/js": "^9.22.0",
|
||||
"@inlang/cli": "^3.0.4",
|
||||
"@inlang/paraglide-js": "2.0.0-beta.26",
|
||||
"@sveltejs/adapter-static": "^3.0.8",
|
||||
"@sveltejs/kit": "^2.19.2",
|
||||
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
||||
"daisyui": "^5.0.4",
|
||||
"eslint": "^9.22.0",
|
||||
"eslint-config-prettier": "^10.1.1",
|
||||
"eslint-plugin-svelte": "^2.46.1",
|
||||
"globals": "^15.15.0",
|
||||
"husky": "^9.1.7",
|
||||
"prettier": "^3.5.3",
|
||||
"prettier-plugin-svelte": "^3.3.3",
|
||||
"prettier-plugin-tailwindcss": "^0.6.11",
|
||||
"svelte": "^5.23.1",
|
||||
"svelte-check": "^4.1.5",
|
||||
"tailwindcss": "^4.0.14",
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.6.3",
|
||||
"typescript-eslint": "^8.14.0",
|
||||
"vite": "^5.4.11"
|
||||
"typescript": "^5.8.2",
|
||||
"typescript-eslint": "^8.26.1",
|
||||
"vite": "^6.2.2"
|
||||
},
|
||||
"type": "module",
|
||||
"lint-staged": {
|
||||
@@ -45,14 +45,19 @@
|
||||
"*.{js,css,md,svelte,scss}": "prettier --write --cache --cache-strategy content --ignore-path ../.gitignore ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/free-solid-svg-icons": "^6.6.0",
|
||||
"@fortawesome/free-solid-svg-icons": "^6.7.2",
|
||||
"@tailwindcss/postcss": "^4.0.14",
|
||||
"cron-parser": "^4.9.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"pocketbase": "^0.21.5",
|
||||
"pocketbase": "^0.25.2",
|
||||
"postcss": "^8.5.3",
|
||||
"svelte-fa": "^4.0.3",
|
||||
"svelte-french-toast": "^1.2.0",
|
||||
"theme-change": "^2.5.0",
|
||||
"typesafe-i18n": "^5.26.2"
|
||||
"svelte-french-toast": "https://github.com/seriousm4x/svelte-french-toast.git#fix-72-build",
|
||||
"theme-change": "^2.5.0"
|
||||
},
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"esbuild"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
export default {
|
||||
plugins: {
|
||||
'@tailwindcss/postcss': {}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
cache
|
||||
@@ -0,0 +1 @@
|
||||
StfXY3tZWvr4FQntlM
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"$schema": "https://inlang.com/schema/project-settings",
|
||||
"baseLocale": "en",
|
||||
"locales": ["de", "en", "es", "fr", "id", "it", "ja", "nl", "pl", "pt", "zh-TW", "zh"],
|
||||
"modules": [
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@4/dist/index.js",
|
||||
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2/dist/index.js"
|
||||
],
|
||||
"plugin.inlang.messageFormat": {
|
||||
"pathPattern": "./translations/{locale}.json"
|
||||
},
|
||||
"telemetry": "off"
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
@import 'tailwindcss';
|
||||
|
||||
@plugin "daisyui" {
|
||||
themes: all;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<html lang="%lang%">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<link rel="manifest" href="/manifest.webmanifest" />
|
||||
%sveltekit.head%
|
||||
<script>
|
||||
const darkTheme = 'dark';
|
||||
const lightTheme = 'cupcake';
|
||||
const darkTheme = 'dim';
|
||||
const lightTheme = 'silk';
|
||||
const preferesDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
const theme = localStorage.getItem('theme')
|
||||
? localStorage.getItem('theme')
|
||||
@@ -25,6 +25,7 @@
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { paraglideMiddleware } from '$lib/paraglide/server';
|
||||
import { localeStore } from '$lib/stores/locale';
|
||||
import type { Handle } from '@sveltejs/kit';
|
||||
|
||||
// creating a handle to use the paraglide middleware
|
||||
const paraglideHandle: Handle = ({ event, resolve }) =>
|
||||
paraglideMiddleware(event.request, ({ locale }) => {
|
||||
localeStore.set(locale);
|
||||
return resolve(event, {
|
||||
transformPageChunk: ({ html }) => html.replace('%lang%', locale)
|
||||
});
|
||||
});
|
||||
|
||||
export const handle: Handle = paraglideHandle;
|
||||
@@ -0,0 +1,6 @@
|
||||
import { deLocalizeUrl } from '$lib/paraglide/runtime';
|
||||
import type { Reroute } from '@sveltejs/kit';
|
||||
|
||||
export const reroute: Reroute = (request) => {
|
||||
return deLocalizeUrl(request.url).pathname;
|
||||
};
|
||||
@@ -1,8 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import LL, { locale } from '$lib/i18n/i18n-svelte';
|
||||
import { nextCronDate } from '$lib/helpers/cron';
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import { dateFnsLocale } from '$lib/stores/locale';
|
||||
import { backendUrl, permission, pocketbase } from '$lib/stores/pocketbase';
|
||||
import type { Device } from '$lib/types/device';
|
||||
import { type Device } from '$lib/types/device';
|
||||
import {
|
||||
faBed,
|
||||
faCircleArrowDown,
|
||||
@@ -11,18 +13,7 @@
|
||||
faPen,
|
||||
faRotateLeft
|
||||
} from '@fortawesome/free-solid-svg-icons';
|
||||
import cronParser from 'cron-parser';
|
||||
import type { Locale } from 'date-fns';
|
||||
import { formatDistance, formatRelative, parseISO } from 'date-fns';
|
||||
import { de } from 'date-fns/locale/de';
|
||||
import { enUS } from 'date-fns/locale/en-US';
|
||||
import { es } from 'date-fns/locale/es';
|
||||
import { fr } from 'date-fns/locale/fr';
|
||||
import { it } from 'date-fns/locale/it';
|
||||
import { nl } from 'date-fns/locale/nl';
|
||||
import { pt } from 'date-fns/locale/pt';
|
||||
import { zhCN } from 'date-fns/locale/zh-CN';
|
||||
import { zhTW } from 'date-fns/locale/zh-TW';
|
||||
import { formatDistance, parseISO } from 'date-fns';
|
||||
import Fa from 'svelte-fa';
|
||||
import toast from 'svelte-french-toast';
|
||||
import { scale } from 'svelte/transition';
|
||||
@@ -30,30 +21,32 @@
|
||||
|
||||
export let device: Device;
|
||||
|
||||
let moreButtons = [
|
||||
let modalReboot: HTMLDialogElement;
|
||||
|
||||
$: moreButtons = [
|
||||
{
|
||||
text: $LL.device.card_btn_more_edit(),
|
||||
icon: faPen,
|
||||
onClick: () => goto(`/device/${device.id}`),
|
||||
requires: $pocketbase.authStore.isAdmin || $permission.update?.includes(device.id)
|
||||
},
|
||||
{
|
||||
text: $LL.device.card_btn_more_sleep(),
|
||||
text: m.device_card_btn_more_sleep(),
|
||||
icon: faBed,
|
||||
onClick: () => sleep(),
|
||||
requires:
|
||||
($pocketbase.authStore.isAdmin || $permission.power?.includes(device.id)) &&
|
||||
($pocketbase.authStore.isSuperuser || $permission.power?.includes(device.id)) &&
|
||||
device.status === 'online' &&
|
||||
device.sol_enabled
|
||||
},
|
||||
{
|
||||
text: $LL.device.card_btn_more_reboot(),
|
||||
text: m.device_card_btn_more_reboot(),
|
||||
icon: faRotateLeft,
|
||||
onClick: () => reboot(),
|
||||
onClick: () => askRebootConfirmation(),
|
||||
requires:
|
||||
($pocketbase.authStore.isAdmin || $permission.power?.includes(device.id)) &&
|
||||
($pocketbase.authStore.isSuperuser || $permission.power?.includes(device.id)) &&
|
||||
device.status === 'online' &&
|
||||
device.shutdown_cmd !== ''
|
||||
},
|
||||
{
|
||||
text: m.device_card_btn_more_edit(),
|
||||
icon: faPen,
|
||||
onClick: () => goto(`/device/${device.id}`),
|
||||
requires: $pocketbase.authStore.isSuperuser || $permission.update?.includes(device.id)
|
||||
}
|
||||
];
|
||||
|
||||
@@ -67,54 +60,6 @@
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
// dynamically import locales
|
||||
// it's ugly but the only working solution i found in ~ 3 hours
|
||||
var dateFnsLocale: Locale;
|
||||
$: if ($locale !== undefined) {
|
||||
(async () => {
|
||||
switch ($locale) {
|
||||
case 'de':
|
||||
case 'de-DE':
|
||||
dateFnsLocale = de;
|
||||
break;
|
||||
case 'en':
|
||||
case 'en-US':
|
||||
dateFnsLocale = enUS;
|
||||
break;
|
||||
case 'fr':
|
||||
case 'fr-FR':
|
||||
dateFnsLocale = fr;
|
||||
break;
|
||||
case 'it':
|
||||
case 'it-IT':
|
||||
dateFnsLocale = it;
|
||||
break;
|
||||
case 'es':
|
||||
case 'es-ES':
|
||||
dateFnsLocale = es;
|
||||
break;
|
||||
case 'nl':
|
||||
case 'nl-NL':
|
||||
dateFnsLocale = nl;
|
||||
break;
|
||||
case 'pt':
|
||||
case 'pt-PT':
|
||||
dateFnsLocale = pt;
|
||||
break;
|
||||
case 'zh':
|
||||
case 'zh-CN':
|
||||
dateFnsLocale = zhCN;
|
||||
break;
|
||||
case 'zh-TW':
|
||||
dateFnsLocale = zhTW;
|
||||
break;
|
||||
default:
|
||||
dateFnsLocale = enUS;
|
||||
break;
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
function sleep() {
|
||||
fetch(`${backendUrl}api/upsnap/sleep/${device.id}`, {
|
||||
headers: {
|
||||
@@ -135,15 +80,16 @@
|
||||
});
|
||||
}
|
||||
|
||||
function getNextCronRelativeTime(expression: string, now: number) {
|
||||
const cron = cronParser.parseExpression(expression);
|
||||
return formatRelative(cron.next().toISOString(), now, {
|
||||
locale: dateFnsLocale
|
||||
});
|
||||
function askRebootConfirmation() {
|
||||
if (device.shutdown_confirm) {
|
||||
modalReboot.showModal();
|
||||
} else {
|
||||
reboot();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="card rounded-3xl bg-base-300 shadow-md" transition:scale={{ delay: 0, duration: 200 }}>
|
||||
<div class="card bg-base-200 shadow-sm" transition:scale={{ delay: 0, duration: 200 }}>
|
||||
<div class="card-body p-6">
|
||||
{#if device.link.toString() !== ''}
|
||||
<a href={device.link.toString()} target="_blank">
|
||||
@@ -152,32 +98,33 @@
|
||||
{:else}
|
||||
<h1 class="card-title">{device.name}</h1>
|
||||
{/if}
|
||||
<ul class="menu rounded-box bg-base-200">
|
||||
<!-- TODO: change to nic array once backend supports it -->
|
||||
{#if device.description}
|
||||
<p class="grow-0">{device.description}</p>
|
||||
{/if}
|
||||
<div class="card rounded-box w-full">
|
||||
<DeviceCardNic {device} />
|
||||
</ul>
|
||||
</div>
|
||||
{#if device.wake_cron_enabled || device.shutdown_cron_enabled || device.password}
|
||||
<div class="mt-1 flex flex-row flex-wrap gap-2">
|
||||
{#if device.wake_cron_enabled}
|
||||
<div class="tooltip" data-tip={$LL.device.card_tooltip_wake_cron()}>
|
||||
<div class="tooltip" data-tip={m.device_card_tooltip_wake_cron()}>
|
||||
<span class="badge badge-success gap-1 p-3"
|
||||
><Fa icon={faCircleArrowUp} />{getNextCronRelativeTime(device.wake_cron, now)}</span
|
||||
>
|
||||
><Fa icon={faCircleArrowUp} />
|
||||
{nextCronDate(device.wake_cron)}
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if device.shutdown_cron_enabled}
|
||||
<div class="tooltip" data-tip={$LL.device.card_tooltip_shutdown_cron()}>
|
||||
<div class="tooltip" data-tip={m.device_card_tooltip_shutdown_cron()}>
|
||||
<span class="badge badge-error gap-1 p-3"
|
||||
><Fa icon={faCircleArrowDown} />{getNextCronRelativeTime(
|
||||
device.shutdown_cron,
|
||||
now
|
||||
)}</span
|
||||
>
|
||||
><Fa icon={faCircleArrowDown} />
|
||||
{nextCronDate(device.shutdown_cron)}
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
{#if device.password}
|
||||
<div class="tooltip" data-tip={$LL.device.card_tooltip_wake_password()}>
|
||||
<span class="badge gap-1 p-3"><Fa icon={faLock} />{$LL.device.card_password()}</span>
|
||||
<div class="tooltip" data-tip={m.device_card_tooltip_wake_password()}>
|
||||
<span class="badge gap-1 p-3"><Fa icon={faLock} />{m.device_card_password()}</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -185,38 +132,42 @@
|
||||
<div class="card-actions mt-auto items-center">
|
||||
<span
|
||||
class="tooltip"
|
||||
data-tip="{$LL.device.card_tooltip_last_status_change()}: {device.updated}"
|
||||
data-tip="{m.device_card_tooltip_last_status_change()}: {device.updated}"
|
||||
>
|
||||
{#if dateFnsLocale !== undefined}
|
||||
{formatDistance(parseISO(device.updated), now, {
|
||||
includeSeconds: true,
|
||||
addSuffix: true,
|
||||
locale: dateFnsLocale
|
||||
})}
|
||||
{/if}
|
||||
{formatDistance(parseISO(device.updated), now, {
|
||||
includeSeconds: true,
|
||||
addSuffix: true,
|
||||
locale: $dateFnsLocale
|
||||
})}
|
||||
</span>
|
||||
{#if moreButtons.filter((btn) => btn.requires).length > 0}
|
||||
<div class="dropdown dropdown-end dropdown-top ms-auto bg-base-300">
|
||||
<label tabindex="-1" class="btn btn-sm m-1" for="more-{device.id}"
|
||||
>{$LL.device.card_btn_more()}</label
|
||||
>
|
||||
<ul
|
||||
id="more-{device.id}"
|
||||
tabindex="-1"
|
||||
class="menu dropdown-content z-[1] w-fit rounded-box bg-base-100 p-2 shadow"
|
||||
>
|
||||
{#each moreButtons as btn}
|
||||
{#if btn.requires}
|
||||
<li>
|
||||
<button on:click={btn.onClick}>
|
||||
<Fa icon={btn.icon} />{btn.text}
|
||||
</button>
|
||||
</li>
|
||||
{/if}
|
||||
{/each}
|
||||
</ul>
|
||||
<div class="ms-auto flex flex-row flex-wrap gap-1">
|
||||
{#each moreButtons as btn}
|
||||
{#if btn.requires}
|
||||
<div class="tooltip" data-tip={btn.text}>
|
||||
<button class="btn btn-sm btn-circle" on:click={btn.onClick}>
|
||||
<Fa icon={btn.icon} />
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<dialog class="modal" bind:this={modalReboot}>
|
||||
<div class="modal-box">
|
||||
<h3 class="text-lg font-bold">
|
||||
{m.device_modal_confirm_shutdown_title({ device: device.name })}
|
||||
</h3>
|
||||
<p class="py-4">{m.device_modal_confirm_shutdown_desc({ device: device.name })}</p>
|
||||
<div class="modal-action">
|
||||
<form method="dialog">
|
||||
<button class="btn">{m.buttons_cancel()}</button>
|
||||
<button class="btn btn-success" on:click={reboot}>{m.buttons_confirm()}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import LL from '$lib/i18n/i18n-svelte';
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import { backendUrl, permission, pocketbase } from '$lib/stores/pocketbase';
|
||||
import type { Device } from '$lib/types/device';
|
||||
import { faCircle, faPowerOff } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faPowerOff } from '@fortawesome/free-solid-svg-icons';
|
||||
import Fa from 'svelte-fa';
|
||||
import toast from 'svelte-french-toast';
|
||||
|
||||
@@ -16,35 +16,34 @@
|
||||
let modalShutdown: HTMLDialogElement;
|
||||
|
||||
$: if (device.status === 'pending' && !interval) {
|
||||
countdown(Date.parse(device.updated));
|
||||
countdown(Date.parse(device.updated), 'wake');
|
||||
}
|
||||
$: minutes = Math.floor(timeout / 60);
|
||||
$: seconds = timeout % 60;
|
||||
$: if (device.status === 'pending' || device.status === '') {
|
||||
disabled = true;
|
||||
hoverText = $LL.device.card_nic_tooltip_pending();
|
||||
hoverText = m.device_card_nic_tooltip_pending();
|
||||
} else if (device.status === 'online') {
|
||||
if (device.shutdown_cmd === '') {
|
||||
disabled = true;
|
||||
hoverText = $LL.device.card_nic_tooltip_shutdown_no_cmd();
|
||||
} else if (!$pocketbase.authStore.isAdmin && !$permission.power?.includes(device.id)) {
|
||||
hoverText = m.device_card_nic_tooltip_shutdown_no_cmd();
|
||||
} else if (!$pocketbase.authStore.isSuperuser && !$permission.power?.includes(device.id)) {
|
||||
disabled = true;
|
||||
hoverText = $LL.device.card_nic_tooltip_shutdown_no_permission();
|
||||
hoverText = m.device_card_nic_tooltip_shutdown_no_permission();
|
||||
} else {
|
||||
disabled = false;
|
||||
hoverText = $LL.device.card_nic_tooltip_shutdown();
|
||||
hoverText = m.device_card_nic_tooltip_shutdown();
|
||||
}
|
||||
} else if (device.status === 'offline') {
|
||||
if (!$pocketbase.authStore.isAdmin && !$permission.power?.includes(device.id)) {
|
||||
if (!$pocketbase.authStore.isSuperuser && !$permission.power?.includes(device.id)) {
|
||||
disabled = true;
|
||||
hoverText = $LL.device.card_nic_tooltip_power_no_permission();
|
||||
hoverText = m.device_card_nic_tooltip_power_no_permission();
|
||||
} else {
|
||||
disabled = false;
|
||||
hoverText = $LL.device.card_nic_tooltip_power();
|
||||
hoverText = m.device_card_nic_tooltip_power();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: change wake and shutdown to nic based routes, not device based
|
||||
function wake() {
|
||||
fetch(`${backendUrl}api/upsnap/wake/${device.id}`, {
|
||||
headers: {
|
||||
@@ -52,9 +51,16 @@
|
||||
}
|
||||
})
|
||||
.then((resp) => resp.json())
|
||||
.then((data) => {
|
||||
.then(async (data) => {
|
||||
device = data as Device;
|
||||
countdown(Date.parse(device.updated));
|
||||
await countdown(Date.parse(device.updated), 'wake');
|
||||
if (device.status === 'online' && device.link && device.link_open !== '') {
|
||||
if (device.link_open === 'new_tab') {
|
||||
window.open(device.link, '_blank');
|
||||
} else {
|
||||
window.open(device.link, '_self');
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error(err.message);
|
||||
@@ -70,23 +76,41 @@
|
||||
.then((resp) => resp.json())
|
||||
.then((data) => {
|
||||
device = data as Device;
|
||||
countdown(Date.parse(device.updated));
|
||||
countdown(Date.parse(device.updated), 'shutdown');
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error(err.message);
|
||||
});
|
||||
}
|
||||
|
||||
function countdown(updated: number) {
|
||||
timeout = 120;
|
||||
const end = updated + 2 * 60 * 1000;
|
||||
interval = setInterval(() => {
|
||||
timeout = Math.round((end - Date.now()) / 1000);
|
||||
if (timeout <= 0 || device.status !== 'pending') {
|
||||
clearInterval(interval);
|
||||
interval = 0;
|
||||
function countdown(updated: number, action: 'wake' | 'shutdown') {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
timeout = action === 'wake' ? device.wake_timeout : device.shutdown_timeout;
|
||||
if (timeout <= 0) {
|
||||
timeout = 120;
|
||||
}
|
||||
|
||||
const end = updated + timeout * 1000;
|
||||
|
||||
if (interval) {
|
||||
clearInterval(interval);
|
||||
interval = 0;
|
||||
}
|
||||
|
||||
interval = setInterval(() => {
|
||||
timeout = Math.round((end - Date.now()) / 1000);
|
||||
|
||||
if (timeout <= 0 || device.status !== 'pending') {
|
||||
clearInterval(interval);
|
||||
interval = 0;
|
||||
resolve(interval);
|
||||
}
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
}
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
function handleClick() {
|
||||
@@ -114,72 +138,77 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<li class="tooltip" class:disabled data-tip={hoverText}>
|
||||
<div
|
||||
class="flex items-start gap-4 p-2"
|
||||
on:click={disabled ? null : handleClick}
|
||||
on:keydown={disabled ? null : handleClick}
|
||||
role="none"
|
||||
>
|
||||
{#if device.status === 'offline'}
|
||||
<button class="btn btn-error flex-shrink"><Fa icon={faPowerOff} /></button>
|
||||
{:else if device.status === 'online'}
|
||||
<button
|
||||
class="btn btn-success flex-shrink"
|
||||
class:cursor-not-allowed={device.shutdown_cmd === ''}><Fa icon={faPowerOff} /></button
|
||||
>
|
||||
{:else if device.status === 'pending'}
|
||||
<button class="btn btn-warning flex-shrink">
|
||||
<span class="countdown font-mono">
|
||||
<span style="--value:{minutes};" />:
|
||||
<span style="--value:{seconds};" />
|
||||
</span>
|
||||
</button>
|
||||
{:else}
|
||||
<button class="btn btn-warning flex-shrink">
|
||||
<span class="loading loading-ring loading-sm" />
|
||||
</button>
|
||||
{/if}
|
||||
<div class="grow">
|
||||
<div class="text-lg font-bold leading-4">{device.ip}</div>
|
||||
<div>{device.mac}</div>
|
||||
<div class="flex flex-wrap gap-x-4">
|
||||
{#if device?.expand?.ports}
|
||||
{#each device?.expand?.ports.sort((a, b) => a.number - b.number) as port}
|
||||
<span class="flex items-center gap-1 break-all">
|
||||
{#if port.status}
|
||||
<Fa icon={faCircle} class="text-success" />
|
||||
{:else}
|
||||
<Fa icon={faCircle} class="text-error" />
|
||||
{/if}
|
||||
{#if port.link}
|
||||
<a
|
||||
href={port.link}
|
||||
target="_blank"
|
||||
class="underline"
|
||||
on:click={(e) => e.stopPropagation()}>{port.name} ({port.number})</a
|
||||
>
|
||||
{:else}
|
||||
{port.name} ({port.number})
|
||||
{/if}
|
||||
</span>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
<div
|
||||
class={`tooltip ${disabled ? 'cursor-not-allowed' : 'hover:bg-base-300 cursor-pointer'} bg-base-100 rounded-box flex items-start gap-4 p-2`}
|
||||
data-tip={hoverText}
|
||||
on:click={disabled ? null : handleClick}
|
||||
on:keydown={disabled ? null : handleClick}
|
||||
role="none"
|
||||
>
|
||||
{#if device.status === 'offline'}
|
||||
<button class="btn btn-error btn-circle size-12"><Fa icon={faPowerOff} /></button>
|
||||
{:else if device.status === 'online'}
|
||||
<button
|
||||
class="btn btn-success btn-circle size-12"
|
||||
class:cursor-not-allowed={device.shutdown_cmd === ''}><Fa icon={faPowerOff} /></button
|
||||
>
|
||||
{:else if device.status === 'pending'}
|
||||
<button class="btn btn-warning">
|
||||
<span class="countdown font-mono">
|
||||
<span style="--value:{minutes};"></span>:
|
||||
<span style="--value:{seconds};"></span>
|
||||
</span>
|
||||
</button>
|
||||
{:else}
|
||||
<div class="btn btn-warning btn-circle size-12">
|
||||
<span class="loading loading-ring loading-sm"></span>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="grow">
|
||||
<div class="text-lg leading-4 font-bold">{device.ip}</div>
|
||||
<div>{device.mac}</div>
|
||||
<div class="flex flex-wrap gap-x-4">
|
||||
{#if device?.expand?.ports}
|
||||
{#each device?.expand?.ports.sort((a, b) => a.number - b.number) as port}
|
||||
<span class="flex items-center gap-1 break-all">
|
||||
{#if port.status}
|
||||
<div class="inline-grid *:[grid-area:1/1]">
|
||||
<div class="status status-success h-3 w-3 animate-ping"></div>
|
||||
<div class="status status-success h-3 w-3"></div>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="inline-grid *:[grid-area:1/1]">
|
||||
<div class="status status-error h-3 w-3 animate-ping"></div>
|
||||
<div class="status status-error h-3 w-3"></div>
|
||||
</div>
|
||||
{/if}
|
||||
{#if port.link}
|
||||
<a
|
||||
href={port.link}
|
||||
target="_blank"
|
||||
class="underline"
|
||||
on:click={(e) => e.stopPropagation()}>{port.name} ({port.number})</a
|
||||
>
|
||||
{:else}
|
||||
{port.name} ({port.number})
|
||||
{/if}
|
||||
</span>
|
||||
{/each}
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
|
||||
<dialog class="modal" bind:this={modalWake}>
|
||||
<div class="modal-box">
|
||||
<h3 class="text-lg font-bold">
|
||||
{$LL.device.modal_confirm_wake_title({ device: device.name })}
|
||||
{m.device_modal_confirm_wake_title({ device: device.name })}
|
||||
</h3>
|
||||
<p class="py-4">{$LL.device.modal_confirm_wake_desc({ device: device.name })}</p>
|
||||
<p class="py-4">{m.device_modal_confirm_wake_desc({ device: device.name })}</p>
|
||||
<div class="modal-action">
|
||||
<form method="dialog" class="flex flex-row flex-wrap gap-2">
|
||||
<button class="btn btn-neutral">{$LL.buttons.cancel()}</button>
|
||||
<button class="btn btn-success" on:click={wake}>{$LL.buttons.confirm()}</button>
|
||||
<form method="dialog">
|
||||
<button class="btn">{m.buttons_cancel()}</button>
|
||||
<button class="btn btn-success" on:click={wake}>{m.buttons_confirm()}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -188,20 +217,14 @@
|
||||
<dialog class="modal" bind:this={modalShutdown}>
|
||||
<div class="modal-box">
|
||||
<h3 class="text-lg font-bold">
|
||||
{$LL.device.modal_confirm_shutdown_title({ device: device.name })}
|
||||
{m.device_modal_confirm_shutdown_title({ device: device.name })}
|
||||
</h3>
|
||||
<p class="py-4">{$LL.device.modal_confirm_shutdown_desc({ device: device.name })}</p>
|
||||
<p class="py-4">{m.device_modal_confirm_shutdown_desc({ device: device.name })}</p>
|
||||
<div class="modal-action">
|
||||
<form method="dialog" class="flex flex-row flex-wrap gap-2">
|
||||
<button class="btn btn-neutral">{$LL.buttons.cancel()}</button>
|
||||
<button class="btn btn-success" on:click={shutdown}>{$LL.buttons.confirm()}</button>
|
||||
<form method="dialog">
|
||||
<button class="btn">{m.buttons_cancel()}</button>
|
||||
<button class="btn btn-success" on:click={shutdown}>{m.buttons_confirm()}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<style>
|
||||
:global(.menu li.disabled) {
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import DeviceFormPort from '$lib/components/DeviceFormPort.svelte';
|
||||
import LL from '$lib/i18n/i18n-svelte';
|
||||
import { nextCronDate, parseCron as validateCron } from '$lib/helpers/cron';
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import { permission, pocketbase } from '$lib/stores/pocketbase';
|
||||
import type { Device, Group, Port } from '$lib/types/device';
|
||||
import { faSave, faTrash, faX } from '@fortawesome/free-solid-svg-icons';
|
||||
@@ -20,6 +21,16 @@
|
||||
});
|
||||
|
||||
async function save() {
|
||||
// validate crons
|
||||
if (device.wake_cron_enabled && !(await validateCron(device.wake_cron))) {
|
||||
toast.error(m.settings_invalid_cron());
|
||||
throw new Error('wake_cron not valid');
|
||||
}
|
||||
if (device.shutdown_cron_enabled && !(await validateCron(device.shutdown_cron))) {
|
||||
toast.error(m.settings_invalid_cron());
|
||||
throw new Error('shutdown_cron not valid');
|
||||
}
|
||||
|
||||
// create/update all ports
|
||||
let portIds: string[] = [];
|
||||
await Promise.all(
|
||||
@@ -38,6 +49,10 @@
|
||||
device.ip = device.ip.replaceAll(' ', '');
|
||||
device.mac = device.mac.replaceAll(' ', '');
|
||||
device.netmask = device.netmask.replaceAll(' ', '');
|
||||
device.wake_cmd = device.wake_cmd.trim();
|
||||
device.shutdown_cmd = device.shutdown_cmd.trim();
|
||||
device.wake_cron = device.wake_cron.trim();
|
||||
device.shutdown_cron = device.shutdown_cron.trim();
|
||||
device.ports = portIds;
|
||||
if (device.id) {
|
||||
updateDevice(device);
|
||||
@@ -51,7 +66,7 @@
|
||||
.collection('devices')
|
||||
.update(device.id, device)
|
||||
.then(() => {
|
||||
toast.success($LL.toasts.device_updated({ device: device.name }));
|
||||
toast.success(m.toasts_device_updated({ device: device.name }));
|
||||
goto('/');
|
||||
})
|
||||
.catch((err) => {
|
||||
@@ -60,14 +75,14 @@
|
||||
}
|
||||
|
||||
async function createDevice(device: Device) {
|
||||
device.created_by = $pocketbase.authStore.isAdmin
|
||||
device.created_by = $pocketbase.authStore.isSuperuser
|
||||
? ''
|
||||
: ($pocketbase.authStore.model?.id ?? '');
|
||||
: ($pocketbase.authStore.record?.id ?? '');
|
||||
$pocketbase
|
||||
.collection('devices')
|
||||
.create(device)
|
||||
.then(() => {
|
||||
toast.success($LL.toasts.device_created({ device: device.name }));
|
||||
toast.success(m.toasts_device_created({ device: device.name }));
|
||||
goto('/');
|
||||
})
|
||||
.catch((err) => {
|
||||
@@ -110,7 +125,7 @@
|
||||
.collection('devices')
|
||||
.delete(device.id)
|
||||
.then(() => {
|
||||
toast.success($LL.toasts.device_deleted({ device: device.name }));
|
||||
toast.success(m.toasts_device_deleted({ device: device.name }));
|
||||
goto('/');
|
||||
})
|
||||
.catch((err) => {
|
||||
@@ -141,7 +156,8 @@
|
||||
})
|
||||
.then((res) => {
|
||||
deviceGroups = [...deviceGroups, res as Group];
|
||||
toast.success($LL.toasts.group_created({ group: newGroup }));
|
||||
toast.success(m.toasts_group_created({ group: newGroup }));
|
||||
newGroup = '';
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error(err.message);
|
||||
@@ -159,7 +175,7 @@
|
||||
.delete(group.id)
|
||||
.then(async () => {
|
||||
await getGroups();
|
||||
toast.success($LL.toasts.group_deleted({ group: group.name }));
|
||||
toast.success(m.toasts_group_deleted({ group: group.name }));
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error(err.message);
|
||||
@@ -178,83 +194,78 @@
|
||||
</script>
|
||||
|
||||
<form on:submit|preventDefault={save}>
|
||||
<div class="card w-full bg-base-300 shadow-xl">
|
||||
<div class="card bg-base-200 w-full shadow-sm">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">{$LL.device.general()}</h2>
|
||||
<h2 class="card-title">{m.device_general()}</h2>
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-4">
|
||||
<div class="form-control w-full max-w-xs">
|
||||
<label class="label" for="device-name">
|
||||
<div class="label-text">
|
||||
<span>{$LL.device.general_name()}</span>
|
||||
<span class="text-error">*</span>
|
||||
</div>
|
||||
<fieldset class="fieldset">
|
||||
<label class="floating-label mt-2">
|
||||
<span>{m.device_general_name()} <span class="text-error">*</span></span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={m.device_general_name()}
|
||||
class="input"
|
||||
bind:value={device.name}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
<input
|
||||
id="device-name"
|
||||
type="text"
|
||||
placeholder={$LL.device.general_name_placeholder()}
|
||||
class="input w-full max-w-xs"
|
||||
bind:value={device.name}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div class="form-control w-full max-w-xs">
|
||||
<label class="label" for="device-ip">
|
||||
<div class="label-text">
|
||||
<span>{$LL.device.general_ip()}</span>
|
||||
<span class="text-error">*</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset class="fieldset">
|
||||
<label class="floating-label mt-2">
|
||||
<span>{m.device_general_ip()} <span class="text-error">*</span></span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={m.device_general_ip()}
|
||||
class="input"
|
||||
bind:value={device.ip}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
<input
|
||||
id="device-ip"
|
||||
type="text"
|
||||
placeholder="192.168.0.5"
|
||||
class="input w-full max-w-xs"
|
||||
bind:value={device.ip}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div class="form-control w-full max-w-xs">
|
||||
<label class="label" for="device-mac">
|
||||
<div class="label-text">
|
||||
<span>{$LL.device.general_mac()}</span>
|
||||
<span class="text-error">*</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset class="fieldset">
|
||||
<label class="floating-label mt-2">
|
||||
<span>{m.device_general_mac()} <span class="text-error">*</span></span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={m.device_general_mac()}
|
||||
class="input"
|
||||
bind:value={device.mac}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
<input
|
||||
id="device-mac"
|
||||
type="text"
|
||||
placeholder="aa:bb:cc:dd:ee:ff"
|
||||
class="input w-full max-w-xs"
|
||||
bind:value={device.mac}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div class="form-control w-full max-w-xs">
|
||||
<label class="label" for="device-netmask">
|
||||
<div class="label-text">
|
||||
<span>{$LL.device.general_netmask()}</span>
|
||||
<span class="text-error">*</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset class="fieldset">
|
||||
<label class="floating-label mt-2">
|
||||
<span>{m.device_general_netmask()} <span class="text-error">*</span></span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={m.device_general_netmask()}
|
||||
class="input"
|
||||
bind:value={device.netmask}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
<input
|
||||
id="device-netmask"
|
||||
type="text"
|
||||
placeholder="255.255.255.0"
|
||||
class="input w-full max-w-xs"
|
||||
bind:value={device.netmask}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<span class="badge self-center text-error">* {$LL.device.general_required_field()}</span>
|
||||
</fieldset>
|
||||
<fieldset class="fieldset">
|
||||
<label class="floating-label mt-2">
|
||||
<span>{m.device_general_description()}</span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={m.device_general_description()}
|
||||
class="input"
|
||||
bind:value={device.description}
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
<span class="badge text-error self-center">* {m.device_general_required_field()}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mt-6 w-full bg-base-300 shadow-xl">
|
||||
<div class="card bg-base-200 mt-6 w-full shadow-sm">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">{$LL.device.ports()}</h2>
|
||||
<p class="my-2">{$LL.device.ports_desc()}</p>
|
||||
<div class="form-control w-full">
|
||||
<h2 class="card-title">{m.device_ports()}</h2>
|
||||
<p>{m.device_ports_desc()}</p>
|
||||
<div class="w-full">
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
||||
<!-- eslint-disable-next-line @typescript-eslint/no-unused-vars -->
|
||||
{#each device.expand.ports as _, index}
|
||||
@@ -262,332 +273,390 @@
|
||||
{/each}
|
||||
</div>
|
||||
<button
|
||||
class="btn btn-primary mt-4 max-w-xs"
|
||||
class="btn max-w-xs {device.expand.ports.length > 0 ? 'mt-4' : ''}"
|
||||
on:click={() => createEmptyPort()}
|
||||
type="button">{$LL.device.ports_add_new()}</button
|
||||
type="button">{m.device_ports_add_new()}</button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mt-6 w-full bg-base-300 shadow-xl">
|
||||
<div class="card bg-base-200 mt-6 w-full shadow-sm">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">{$LL.device.link()}</h2>
|
||||
<p class="my-2">
|
||||
{$LL.device.link_desc()}
|
||||
<h2 class="card-title">{m.device_link()}</h2>
|
||||
<p>
|
||||
{m.device_link_desc()}
|
||||
</p>
|
||||
<div class="form-control w-full">
|
||||
<input
|
||||
type="url"
|
||||
placeholder="https:// ..."
|
||||
class="input w-full max-w-xs"
|
||||
bind:value={device.link}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mt-6 w-full bg-base-300 shadow-xl">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">{$LL.device.ping()}</h2>
|
||||
<p class="my-2">
|
||||
<!-- eslint-disable svelte/no-at-html-tags -->
|
||||
{@html $LL.device.ping_desc()}
|
||||
</p>
|
||||
<div class="form-control w-full">
|
||||
<label class="label cursor-pointer" for="ping-cmd">
|
||||
<span class="label-text">{$LL.device.ping_cmd()}</span>
|
||||
</label>
|
||||
<input
|
||||
id="ping-cmd"
|
||||
type="text"
|
||||
placeholder="$:"
|
||||
class="input mb-2 w-full max-w-xs"
|
||||
bind:value={device.ping_cmd}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mt-6 w-full bg-base-300 shadow-xl">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">{$LL.device.wake()}</h2>
|
||||
<p class="my-2">
|
||||
{$LL.device.wake_desc()}
|
||||
<!-- eslint-disable svelte/no-at-html-tags -->
|
||||
{@html $LL.settings.ping_interval_desc2()}
|
||||
</p>
|
||||
<div class="form-control w-full">
|
||||
<label class="label cursor-pointer" for="wake-cmd">
|
||||
<span class="label-text">{$LL.device.wake_cmd()}</span>
|
||||
</label>
|
||||
<input
|
||||
id="wake-cmd"
|
||||
type="text"
|
||||
placeholder="$:"
|
||||
class="input mb-2 w-full max-w-xs"
|
||||
bind:value={device.wake_cmd}
|
||||
/>
|
||||
</div>
|
||||
<div class="form-control flex flex-row flex-wrap gap-4">
|
||||
<div class="flex flex-row items-center gap-2">
|
||||
<input
|
||||
id="wake-confirm"
|
||||
type="checkbox"
|
||||
class="toggle toggle-success"
|
||||
bind:checked={device.wake_confirm}
|
||||
/>
|
||||
<label class="label cursor-pointer" for="wake-confirm">
|
||||
<span class="label-text">{$LL.device.require_confirmation()}</span>
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
||||
<fieldset class="fieldset">
|
||||
<label class="floating-label mt-2">
|
||||
<span>{m.device_link()}</span>
|
||||
<input
|
||||
type="url"
|
||||
placeholder={m.device_link()}
|
||||
class="input"
|
||||
bind:value={device.link}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset class="fieldset">
|
||||
<label class="floating-label mt-2">
|
||||
<span>{m.device_link_open()}</span>
|
||||
<select class="select" bind:value={device.link_open}>
|
||||
<option value="">{m.device_link_open_no()}</option>
|
||||
<option value="same_tab">{m.device_link_open_same_tab()}</option>
|
||||
<option value="new_tab">{m.device_link_open_new_tab()}</option>
|
||||
</select>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="form-control flex flex-row flex-wrap gap-4">
|
||||
<div class="w-full max-w-xs">
|
||||
<label class="label" for="wake-cron">
|
||||
<span class="label-text"
|
||||
>{$LL.device.wake_cron()}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card bg-base-200 mt-6 w-full shadow-sm">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">{m.device_ping()}</h2>
|
||||
<p>
|
||||
<!-- eslint-disable svelte/no-at-html-tags -->
|
||||
{@html m.device_ping_desc()}
|
||||
</p>
|
||||
<fieldset class="fieldset">
|
||||
<label class="input mt-2">
|
||||
<span>$:</span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={m.device_ping_cmd()}
|
||||
class="grow"
|
||||
bind:value={device.ping_cmd}
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card bg-base-200 mt-6 w-full shadow-sm">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">{m.device_wake()}</h2>
|
||||
<p>
|
||||
{m.device_wake_desc()}
|
||||
<!-- eslint-disable svelte/no-at-html-tags -->
|
||||
{@html m.settings_ping_interval_desc2()}
|
||||
</p>
|
||||
<div class="flex flex-row flex-wrap gap-4">
|
||||
<fieldset class="fieldset">
|
||||
<label class="floating-label mt-2">
|
||||
<span>{m.device_wake_timeout()}</span>
|
||||
<input
|
||||
type="number"
|
||||
min="0"
|
||||
placeholder={m.device_wake_timeout()}
|
||||
class="input"
|
||||
bind:value={device.wake_timeout}
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
<fieldset class="fieldset">
|
||||
<label class="input mt-2">
|
||||
<span>$:</span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={m.device_wake_cmd()}
|
||||
class="grow"
|
||||
bind:value={device.wake_cmd}
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="flex flex-row flex-wrap gap-4">
|
||||
<fieldset
|
||||
class="fieldset bg-base-100 border-base-300 rounded-box w-fit min-w-64 border p-4"
|
||||
>
|
||||
<legend class="fieldset-legend">{m.device_wake_cron_enable()}</legend>
|
||||
<label class="fieldset-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={device.wake_cron_enabled}
|
||||
class="toggle toggle-success"
|
||||
/>
|
||||
{m.device_wake_cron_enable()}
|
||||
</label>
|
||||
<label class="floating-label mt-2">
|
||||
<span
|
||||
>{m.device_wake_cron()}
|
||||
{#if device.wake_cron_enabled}
|
||||
<span class="text-error">*</span>
|
||||
{/if}
|
||||
</span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={m.device_wake_cron()}
|
||||
class="input"
|
||||
bind:value={device.wake_cron}
|
||||
disabled={!device.wake_cron_enabled}
|
||||
required={device.wake_cron_enabled}
|
||||
/>
|
||||
{#if device.wake_cron_enabled}
|
||||
<p class="fieldset-label">
|
||||
{#await validateCron(device.wake_cron)}
|
||||
<span class="loading loading-spinner loading-xs"></span>
|
||||
{:then valid}
|
||||
{valid ? '✅ ' + nextCronDate(device.wake_cron) : m.settings_invalid_cron()}
|
||||
{/await}
|
||||
</p>
|
||||
{/if}
|
||||
</label>
|
||||
<input
|
||||
id="wake-cron"
|
||||
type="text"
|
||||
placeholder="M H DoM M DoW"
|
||||
class="input w-full max-w-xs"
|
||||
bind:value={device.wake_cron}
|
||||
disabled={!device.wake_cron_enabled}
|
||||
required={device.wake_cron_enabled}
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<label class="label cursor-pointer" for="wake-cron-enable">
|
||||
<span class="label-text">{$LL.device.wake_cron_enable()}</span>
|
||||
{#if device.wake_cron_enabled}
|
||||
<pre class="bg-base-100 text-base-content/80 w-fit rounded p-2"><code
|
||||
>* * * * * *
|
||||
| | | | | |
|
||||
| | | | | day of the week (0–6)
|
||||
| | | | month (1–12)
|
||||
| | | day of the month (1–31)
|
||||
| | hour (0–23)
|
||||
| minute (0–59)
|
||||
second (0–59, optional)
|
||||
</code></pre>
|
||||
{/if}
|
||||
</fieldset>
|
||||
<fieldset class="fieldset bg-base-100 border-base-300 rounded-box w-64 border p-4">
|
||||
<legend class="fieldset-legend">{m.device_require_confirmation()}</legend>
|
||||
<label class="fieldset-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={device.wake_confirm}
|
||||
class="toggle toggle-success"
|
||||
/>
|
||||
{m.device_require_confirmation()}
|
||||
</label>
|
||||
<input
|
||||
id="wake-cron-enable"
|
||||
type="checkbox"
|
||||
class="toggle toggle-success"
|
||||
bind:checked={device.wake_cron_enabled}
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mt-6 w-full bg-base-300 shadow-xl">
|
||||
<div class="card bg-base-200 mt-6 w-full shadow-sm">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">{m.device_shutdown()}</h2>
|
||||
<p>
|
||||
<!-- eslint-disable svelte/no-at-html-tags -->
|
||||
{@html m.device_shutdown_desc()}
|
||||
</p>
|
||||
<div class="flex flex-row flex-wrap gap-4">
|
||||
<fieldset class="fieldset">
|
||||
<label class="floating-label mt-2">
|
||||
<span>{m.device_shutdown_timeout()}</span>
|
||||
<input
|
||||
type="number"
|
||||
min="0"
|
||||
placeholder={m.device_shutdown_timeout()}
|
||||
class="input"
|
||||
bind:value={device.shutdown_timeout}
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
<fieldset class="fieldset">
|
||||
<label class="input mt-2">
|
||||
<span>$:</span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={m.device_shutdown_cmd()}
|
||||
class="grow"
|
||||
bind:value={device.shutdown_cmd}
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
<p class="font-bold">{m.device_shutdown_examples()}</p>
|
||||
<div class="mockup-code max-w-fit min-w-0 text-sm">
|
||||
<pre data-prefix="#" class="italic"><code>{m.device_shutdown_examples_windows()}</code
|
||||
></pre>
|
||||
<pre data-prefix="$" class="text-warning"><code
|
||||
>net rpc shutdown -I 192.168.1.13 -U "user%password"</code
|
||||
></pre>
|
||||
</div>
|
||||
<div class="mockup-code max-w-fit min-w-0 text-sm">
|
||||
<pre data-prefix="#" class="italic"><code>{m.device_shutdown_examples_linux()}</code></pre>
|
||||
<pre data-prefix="$" class="text-warning"><code
|
||||
>sshpass -p password ssh -o "StrictHostKeyChecking=no" user@192.168.1.13 "sudo poweroff"</code
|
||||
></pre>
|
||||
</div>
|
||||
<p>
|
||||
{m.device_shutdown_cron_desc()}
|
||||
</p>
|
||||
<div class="flex flex-row flex-wrap gap-4">
|
||||
<fieldset
|
||||
class="fieldset bg-base-100 border-base-300 rounded-box w-fit min-w-64 border p-4"
|
||||
>
|
||||
<legend class="fieldset-legend">{m.device_shutdown_cron_enable()}</legend>
|
||||
<label class="fieldset-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={device.shutdown_cron_enabled}
|
||||
class="toggle toggle-success"
|
||||
/>
|
||||
{m.device_shutdown_cron_enable()}
|
||||
</label>
|
||||
<label class="floating-label mt-2">
|
||||
<span
|
||||
>{m.device_shutdown_cron()}
|
||||
{#if device.shutdown_cron_enabled}
|
||||
<span class="text-error">*</span>
|
||||
{/if}
|
||||
</span>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={m.device_shutdown_cron()}
|
||||
class="input validator"
|
||||
bind:value={device.shutdown_cron}
|
||||
disabled={!device.shutdown_cron_enabled}
|
||||
required={device.shutdown_cron_enabled}
|
||||
/>
|
||||
{#if device.shutdown_cron_enabled}
|
||||
<p class="fieldset-label">
|
||||
{#await validateCron(device.shutdown_cron)}
|
||||
<span class="loading loading-spinner loading-xs"></span>
|
||||
{:then valid}
|
||||
{valid ? '✅ ' + nextCronDate(device.shutdown_cron) : m.settings_invalid_cron()}
|
||||
{/await}
|
||||
</p>
|
||||
{/if}
|
||||
</label>
|
||||
{#if device.shutdown_cron_enabled}
|
||||
<pre class="bg-base-100 text-base-content/80 w-fit rounded p-2"><code
|
||||
>* * * * * *
|
||||
| | | | | |
|
||||
| | | | | day of the week (0–6)
|
||||
| | | | month (1–12)
|
||||
| | | day of the month (1–31)
|
||||
| | hour (0–23)
|
||||
| minute (0–59)
|
||||
second (0–59, optional)
|
||||
</code></pre>
|
||||
{/if}
|
||||
</fieldset>
|
||||
<fieldset class="fieldset bg-base-100 border-base-300 rounded-box w-64 border p-4">
|
||||
<legend class="fieldset-legend">{m.device_require_confirmation()}</legend>
|
||||
<label class="fieldset-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={device.shutdown_confirm}
|
||||
class="toggle toggle-success"
|
||||
/>
|
||||
{m.device_require_confirmation()}
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card bg-base-200 mt-6 w-full shadow-sm">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">Sleep-On-LAN</h2>
|
||||
<p class="mt-2">
|
||||
<p>
|
||||
<!-- eslint-disable svelte/no-at-html-tags -->
|
||||
{@html $LL.device.sol_desc1()}
|
||||
{@html m.device_sol_desc1()}
|
||||
</p>
|
||||
<p>
|
||||
{$LL.device.sol_desc2()}
|
||||
{m.device_sol_desc2()}
|
||||
</p>
|
||||
<p class="font-bold">
|
||||
<!-- eslint-disable svelte/no-at-html-tags -->
|
||||
{@html $LL.device.sol_desc3()}
|
||||
{@html m.device_sol_desc3()}
|
||||
</p>
|
||||
<div class="mt-4 flex flex-row flex-wrap items-end gap-4">
|
||||
<div>
|
||||
<div class="form-control flex flex-row flex-wrap gap-4">
|
||||
<div class="flex flex-row items-center gap-2">
|
||||
<input
|
||||
id="sol-enable"
|
||||
type="checkbox"
|
||||
class="toggle toggle-success"
|
||||
bind:checked={device.sol_enabled}
|
||||
/>
|
||||
<label class="label cursor-pointer" for="sol-enable">
|
||||
<span class="label-text">{$LL.device.sol_enable()}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-control flex flex-col">
|
||||
<label class="label" for="sol-port">
|
||||
<span class="label-text"
|
||||
>{$LL.device.sol_port()}
|
||||
{#if device.sol_enabled}
|
||||
<span class="text-error">*</span>
|
||||
{/if}
|
||||
</span>
|
||||
</label>
|
||||
<div class="flex flex-row flex-wrap gap-4">
|
||||
<fieldset class="fieldset bg-base-100 border-base-300 rounded-box w-64 border p-4">
|
||||
<legend class="fieldset-legend">{m.device_sol_enable()}</legend>
|
||||
<label class="fieldset-label">
|
||||
<input
|
||||
id="sol-port"
|
||||
type="checkbox"
|
||||
bind:checked={device.sol_enabled}
|
||||
class="toggle toggle-success"
|
||||
/>
|
||||
{m.device_sol_enable()}
|
||||
</label>
|
||||
<label class="floating-label mt-2">
|
||||
<span
|
||||
>{m.device_sol_port()}
|
||||
{#if device.sol_enabled}
|
||||
<span class="text-error">*</span>
|
||||
{/if}
|
||||
</span>
|
||||
<input
|
||||
class="input"
|
||||
type="number"
|
||||
min="1"
|
||||
max="65535"
|
||||
class="input"
|
||||
placeholder={m.device_sol_port()}
|
||||
bind:value={device.sol_port}
|
||||
disabled={!device.sol_enabled}
|
||||
required={device.sol_enabled}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</fieldset>
|
||||
{#if device.sol_enabled}
|
||||
<div>
|
||||
<div class="form-control flex flex-row flex-wrap gap-4">
|
||||
<div class="flex flex-row items-center gap-2">
|
||||
<input
|
||||
id="sol-auth"
|
||||
type="checkbox"
|
||||
class="toggle toggle-success"
|
||||
bind:checked={device.sol_auth}
|
||||
/>
|
||||
<label class="label cursor-pointer" for="sol-auth">
|
||||
<span class="label-text">{$LL.device.sol_authorization()}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-control flex flex-col">
|
||||
<label class="label" for="sol-user">
|
||||
<span class="label-text"
|
||||
>{$LL.device.sol_user()}
|
||||
{#if device.sol_auth}
|
||||
<span class="text-error">*</span>
|
||||
{/if}
|
||||
</span>
|
||||
</label>
|
||||
<fieldset class="fieldset bg-base-100 border-base-300 rounded-box w-64 border p-4">
|
||||
<legend class="fieldset-legend">{m.device_sol_authorization()}</legend>
|
||||
<label class="fieldset-label">
|
||||
<input type="checkbox" bind:checked={device.sol_auth} class="toggle toggle-success" />
|
||||
{m.device_sol_authorization()}
|
||||
</label>
|
||||
<label class="floating-label mt-2">
|
||||
<span
|
||||
>{m.device_sol_user()}
|
||||
{#if device.sol_auth}
|
||||
<span class="text-error">*</span>
|
||||
{/if}
|
||||
</span>
|
||||
<input
|
||||
id="sol-user"
|
||||
type="text"
|
||||
placeholder={$LL.device.sol_user()}
|
||||
placeholder={m.device_sol_user()}
|
||||
class="input"
|
||||
bind:value={device.sol_user}
|
||||
disabled={!device.sol_auth}
|
||||
required={device.sol_auth}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-control flex flex-col">
|
||||
<label class="label" for="sol-password">
|
||||
<span class="label-text"
|
||||
>{$LL.device.sol_password()}
|
||||
</label>
|
||||
<label class="floating-label mt-2">
|
||||
<span
|
||||
>{m.device_sol_password()}
|
||||
{#if device.sol_auth}
|
||||
<span class="text-error">*</span>
|
||||
{/if}
|
||||
</span>
|
||||
<input
|
||||
type="password"
|
||||
placeholder={m.device_sol_password()}
|
||||
class="input"
|
||||
bind:value={device.sol_password}
|
||||
disabled={!device.sol_auth}
|
||||
required={device.sol_auth}
|
||||
/>
|
||||
</label>
|
||||
<input
|
||||
id="sol-password"
|
||||
type="password"
|
||||
placeholder={$LL.device.sol_password()}
|
||||
class="input"
|
||||
bind:value={device.sol_password}
|
||||
disabled={!device.sol_auth}
|
||||
required={device.sol_auth}
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mt-6 w-full bg-base-300 shadow-xl">
|
||||
<div class="card bg-base-200 mt-6 w-full shadow-sm">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">{$LL.device.shutdown()}</h2>
|
||||
<p class="my-2">
|
||||
<h2 class="card-title">{m.device_password()}</h2>
|
||||
<p>
|
||||
<!-- eslint-disable svelte/no-at-html-tags -->
|
||||
{@html $LL.device.shutdown_desc()}
|
||||
{@html m.device_password_desc()}
|
||||
</p>
|
||||
<p class="my-2 font-bold">{$LL.device.shutdown_examples()}</p>
|
||||
<div class="mockup-code min-w-0 max-w-fit text-sm">
|
||||
<pre data-prefix="#"><code>{$LL.device.shutdown_examples_windows()}</code></pre>
|
||||
<pre data-prefix="$" class="text-warning"><code
|
||||
>net rpc shutdown -I 192.168.1.13 -U "user%password"</code
|
||||
></pre>
|
||||
</div>
|
||||
<div class="mockup-code min-w-0 max-w-fit text-sm">
|
||||
<pre data-prefix="#"><code>{$LL.device.shutdown_examples_linux()}</code></pre>
|
||||
<pre data-prefix="$" class="text-warning"><code
|
||||
>sshpass -p password ssh -o "StrictHostKeyChecking=no" user@192.168.1.13 "sudo poweroff"</code
|
||||
></pre>
|
||||
</div>
|
||||
<div class="form-control w-full">
|
||||
<label class="label cursor-pointer" for="shutdown-cmd">
|
||||
<span class="label-text">{$LL.device.shutdown_cmd()}</span>
|
||||
</label>
|
||||
<input
|
||||
id="shutdown-cmd"
|
||||
type="text"
|
||||
placeholder="$:"
|
||||
class="input mb-2 w-full max-w-xs"
|
||||
bind:value={device.shutdown_cmd}
|
||||
/>
|
||||
</div>
|
||||
<div class="form-control flex flex-row flex-wrap gap-4">
|
||||
<div class="flex flex-row items-center gap-2">
|
||||
<fieldset class="fieldset">
|
||||
<label class="floating-label mt-2">
|
||||
<span>{m.device_password()}</span>
|
||||
<input
|
||||
id="shutdown-confirm"
|
||||
type="checkbox"
|
||||
class="toggle toggle-success"
|
||||
bind:checked={device.shutdown_confirm}
|
||||
/>
|
||||
<label class="label cursor-pointer" for="shutdown-confirm">
|
||||
<span class="label-text">{$LL.device.require_confirmation()}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<p class="my-2">
|
||||
{$LL.device.shutdown_cron_desc()}
|
||||
</p>
|
||||
<div class="form-control flex flex-row flex-wrap gap-4">
|
||||
<div class="w-full max-w-xs">
|
||||
<label class="label" for="shutdown-cron">
|
||||
<span class="label-text"
|
||||
>{$LL.device.shutdown_cron()}
|
||||
{#if device.shutdown_cron_enabled}
|
||||
<span class="text-error">*</span>
|
||||
{/if}
|
||||
</span>
|
||||
</label>
|
||||
<input
|
||||
id="shutdown-cron"
|
||||
type="text"
|
||||
placeholder="M H DoM M DoW"
|
||||
class="input w-full max-w-xs"
|
||||
bind:value={device.shutdown_cron}
|
||||
disabled={!device.shutdown_cron_enabled}
|
||||
required={device.shutdown_cron_enabled}
|
||||
placeholder={m.device_password()}
|
||||
class="input"
|
||||
maxlength="6"
|
||||
bind:value={device.password}
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<label class="label cursor-pointer" for="shutdown-cron-enable">
|
||||
<span class="label-text">{$LL.device.shutdown_cron_enable()}</span>
|
||||
</label>
|
||||
<input
|
||||
id="shutdown-cron-enable"
|
||||
type="checkbox"
|
||||
class="toggle toggle-success"
|
||||
bind:checked={device.shutdown_cron_enabled}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mt-6 w-full bg-base-300 shadow-xl">
|
||||
<div class="card bg-base-200 mt-6 w-full shadow-sm">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">{$LL.device.password()}</h2>
|
||||
<p class="my-2">
|
||||
<!-- eslint-disable svelte/no-at-html-tags -->
|
||||
{@html $LL.device.password_desc()}
|
||||
</p>
|
||||
<div class="form-control w-full">
|
||||
<input
|
||||
type="password"
|
||||
placeholder="123456"
|
||||
class="input w-full max-w-xs"
|
||||
maxlength="6"
|
||||
bind:value={device.password}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card mt-6 w-full bg-base-300 shadow-xl">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">{$LL.device.groups()}</h2>
|
||||
<p class="my-2">
|
||||
{$LL.device.groups_desc()}
|
||||
<h2 class="card-title">{m.device_groups()}</h2>
|
||||
<p>
|
||||
{m.device_groups_desc()}
|
||||
</p>
|
||||
<div class="flex flex-row flex-wrap gap-2">
|
||||
{#each deviceGroups as group}
|
||||
@@ -606,7 +675,7 @@
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="checkbox checked:checkbox-primary"
|
||||
class="checkbox"
|
||||
checked={device.groups.indexOf(group.id) !== -1}
|
||||
/>
|
||||
{group.name}
|
||||
@@ -614,37 +683,43 @@
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="join max-w-xs">
|
||||
<div class="join">
|
||||
<input
|
||||
class="input join-item input-bordered w-full"
|
||||
placeholder={$LL.device.groups_placeholder()}
|
||||
class="input join-item"
|
||||
placeholder={m.device_groups_placeholder()}
|
||||
type="text"
|
||||
on:keydown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
addGroup();
|
||||
}
|
||||
}}
|
||||
bind:value={newGroup}
|
||||
/>
|
||||
<button class="btn btn-primary join-item" type="button" on:click={() => addGroup()}
|
||||
>{$LL.buttons.add()}</button
|
||||
<button class="btn btn-neutral join-item" type="button" on:click={() => addGroup()}
|
||||
>{m.buttons_add()}</button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-actions mt-6 justify-end gap-4">
|
||||
{#if $pocketbase.authStore.isAdmin || $permission.delete?.includes(device.id)}
|
||||
{#if $pocketbase.authStore.isSuperuser || $permission.delete?.includes(device.id)}
|
||||
<button class="btn btn-error" type="button" on:click={() => deleteModal.showModal()}
|
||||
><Fa icon={faTrash} />{$LL.buttons.delete()}</button
|
||||
><Fa icon={faTrash} />{m.buttons_delete()}</button
|
||||
>
|
||||
<dialog class="modal" bind:this={deleteModal}>
|
||||
<form method="dialog" class="modal-box">
|
||||
<h3 class="text-lg font-bold">{$LL.users.confirm_delete_title()}</h3>
|
||||
<p class="py-4">{$LL.users.confirm_delete_desc({ username: device.name })}</p>
|
||||
<div class="modal-action">
|
||||
<button class="btn">{$LL.buttons.cancel()}</button>
|
||||
<button class="btn btn-error" on:click={() => deleteDevice()}
|
||||
>{$LL.buttons.delete()}</button
|
||||
>
|
||||
</div>
|
||||
</form>
|
||||
</dialog>
|
||||
{/if}
|
||||
<button class="btn btn-success" type="submit"><Fa icon={faSave} />{$LL.buttons.save()}</button>
|
||||
<button class="btn btn-success" type="submit"><Fa icon={faSave} />{m.buttons_save()}</button>
|
||||
</div>
|
||||
</form>
|
||||
<dialog class="modal" bind:this={deleteModal}>
|
||||
<div class="modal-box">
|
||||
<h3 class="text-lg font-bold">{m.users_confirm_delete_title()}</h3>
|
||||
<p class="py-4">{m.users_confirm_delete_desc({ username: device.name })}</p>
|
||||
<div class="modal-action">
|
||||
<form method="dialog">
|
||||
<button class="btn">{m.buttons_cancel()}</button>
|
||||
<button class="btn btn-error" on:click={() => deleteDevice()}>{m.buttons_delete()}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<script lang="ts">
|
||||
import LL from '$lib/i18n/i18n-svelte';
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import { pocketbase } from '$lib/stores/pocketbase';
|
||||
import type { Device, Port } from '$lib/types/device';
|
||||
import { faTrash } from '@fortawesome/free-solid-svg-icons';
|
||||
import type { RecordModel } from 'pocketbase';
|
||||
import Fa from 'svelte-fa';
|
||||
import toast from 'svelte-french-toast';
|
||||
import { scale } from 'svelte/transition';
|
||||
|
||||
export let device: Device;
|
||||
export let index: number;
|
||||
@@ -28,57 +27,51 @@
|
||||
</script>
|
||||
|
||||
{#if device.expand.ports[index]}
|
||||
<div class="card bg-base-100 shadow-sm" transition:scale={{ delay: 0, duration: 200 }}>
|
||||
<div class="card-body p-3">
|
||||
<div class="flex flex-row gap-2">
|
||||
<div>
|
||||
<label class="label p-0" for="port-name-{index}">
|
||||
<span class="label-text">{$LL.device.ports_name()}</span>
|
||||
</label>
|
||||
<fieldset class="fieldset bg-base-100 border-base-300 rounded-box w-xs max-w-full border p-4">
|
||||
<legend class="fieldset-legend"># {device.expand.ports.length}</legend>
|
||||
<div class="flex flex-row gap-2">
|
||||
<fieldset class="fieldset">
|
||||
<label class="floating-label">
|
||||
<span>{m.device_ports_name()} <span class="text-error">*</span></span>
|
||||
<input
|
||||
id="port-name-{index}"
|
||||
type="text"
|
||||
placeholder="ssh"
|
||||
class="input input-sm input-bordered w-full"
|
||||
placeholder={m.device_ports_name()}
|
||||
class="input"
|
||||
required
|
||||
bind:value={device.expand.ports[index].name}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label p-0" for="port-number-{index}">
|
||||
<span class="label-text">{$LL.device.ports_number()}</span>
|
||||
</label>
|
||||
</label>
|
||||
</fieldset>
|
||||
<fieldset class="fieldset">
|
||||
<label class="floating-label">
|
||||
<span>{m.device_ports_number()} <span class="text-error">*</span></span>
|
||||
<input
|
||||
id="port-number-{index}"
|
||||
type="number"
|
||||
placeholder="22"
|
||||
placeholder={m.device_ports_number()}
|
||||
class="input"
|
||||
min="1"
|
||||
max="65535"
|
||||
class="input input-sm input-bordered w-full"
|
||||
required
|
||||
bind:value={device.expand.ports[index].number}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label p-0" for="port-link-{index}">
|
||||
<span class="label-text">{$LL.device.link()}</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
<fieldset class="fieldset">
|
||||
<label class="floating-label">
|
||||
<span>{m.device_link()}</span>
|
||||
<input
|
||||
id="port-link-{index}"
|
||||
type="url"
|
||||
placeholder="https:// ..."
|
||||
class="input input-sm input-bordered w-full"
|
||||
type="text"
|
||||
placeholder={m.device_link()}
|
||||
class="input"
|
||||
bind:value={device.expand.ports[index].link}
|
||||
/>
|
||||
</div>
|
||||
<div class="card-actions justify-end">
|
||||
<button
|
||||
class="btn btn-outline btn-error btn-xs"
|
||||
on:click={() => deletePort(device.expand.ports[index])}
|
||||
type="button"><Fa icon={faTrash} />{$LL.buttons.delete()}</button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</fieldset>
|
||||
<button
|
||||
class="btn btn-error btn-xs btn-soft ms-auto"
|
||||
on:click={() => deletePort(device.expand.ports[index])}
|
||||
type="button"><Fa icon={faTrash} />{m.buttons_delete()}</button
|
||||
>
|
||||
</fieldset>
|
||||
{/if}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import LL from '$lib/i18n/i18n-svelte';
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import { backendUrl, permission, pocketbase } from '$lib/stores/pocketbase';
|
||||
import { settingsPub } from '$lib/stores/settings';
|
||||
import {
|
||||
@@ -52,17 +52,19 @@
|
||||
'dim',
|
||||
'nord',
|
||||
'sunset',
|
||||
'colorful'
|
||||
'caramellatte',
|
||||
'abyss',
|
||||
'silk'
|
||||
];
|
||||
let activeTheme: string | null = '';
|
||||
let avatar = $pocketbase.authStore.model?.avatar;
|
||||
$: avatar = $pocketbase.authStore.record?.avatar;
|
||||
|
||||
onMount(() => {
|
||||
themeChange(false);
|
||||
activeTheme = document.documentElement.getAttribute('data-theme');
|
||||
|
||||
$pocketbase.authStore.onChange(() => {
|
||||
avatar = $pocketbase.authStore.model?.avatar;
|
||||
avatar = $pocketbase.authStore.record?.avatar;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -100,7 +102,7 @@
|
||||
<ul
|
||||
id="mobile-menu"
|
||||
tabindex="-1"
|
||||
class="menu dropdown-content z-[1] mt-3 w-max gap-1 rounded-box bg-base-300 p-2 shadow"
|
||||
class="menu dropdown-content rounded-box bg-base-200 z-[1] mt-3 w-max gap-1 p-2 shadow-sm"
|
||||
>
|
||||
{#if $settingsPub?.website_title}
|
||||
<div class="menu-title">
|
||||
@@ -109,16 +111,16 @@
|
||||
{/if}
|
||||
<li>
|
||||
<a href="/" class="px-4 py-2" class:active={$page.url.pathname === '/'}
|
||||
><Fa icon={faHome} />{$LL.home.page_title()}</a
|
||||
><Fa icon={faHome} />{m.home_page_title()}</a
|
||||
>
|
||||
</li>
|
||||
{#if $pocketbase.authStore.isAdmin}
|
||||
{#if $pocketbase.authStore.isSuperuser}
|
||||
<li>
|
||||
<a
|
||||
href="/users"
|
||||
class="px-4 py-2"
|
||||
class:active={$page.url.pathname.startsWith('/users')}
|
||||
><Fa icon={faUsersGear} />{$LL.users.page_title()}</a
|
||||
><Fa icon={faUsersGear} />{m.users_page_title()}</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
@@ -126,7 +128,7 @@
|
||||
href="/settings/"
|
||||
class="px-4 py-2"
|
||||
class:active={$page.url.pathname.startsWith('/settings')}
|
||||
><Fa icon={faCog} />{$LL.settings.page_title()}</a
|
||||
><Fa icon={faCog} />{m.settings_page_title()}</a
|
||||
>
|
||||
</li>
|
||||
{/if}
|
||||
@@ -139,35 +141,24 @@
|
||||
<ul>
|
||||
<div class="h-fit max-h-72 overflow-scroll">
|
||||
{#each availableThemes as theme}
|
||||
<li>
|
||||
<li class="w-full">
|
||||
<button
|
||||
class="overflow-hidden rounded-lg text-left outline-base-content"
|
||||
class="gap-3 px-2"
|
||||
data-set-theme={theme}
|
||||
on:click={() => (activeTheme = theme)}
|
||||
on:keydown={() => (activeTheme = theme)}
|
||||
>
|
||||
<div
|
||||
data-theme={theme}
|
||||
class="w-full cursor-pointer rounded bg-base-100 font-sans text-base-content"
|
||||
class="bg-base-100 grid shrink-0 grid-cols-2 gap-0.5 rounded-md p-1 shadow-sm"
|
||||
>
|
||||
<div class="grid grid-cols-5 grid-rows-3">
|
||||
<div
|
||||
class="col-span-5 row-span-3 row-start-1 flex items-center gap-2 px-4 py-3"
|
||||
>
|
||||
<Fa
|
||||
icon={faCheck}
|
||||
class={activeTheme === theme ? 'visible' : 'invisible'}
|
||||
/>
|
||||
<div class="flex-grow text-sm">{theme}</div>
|
||||
<div class="flex h-full flex-shrink-0 flex-wrap gap-1">
|
||||
<div class="w-2 rounded bg-primary" />
|
||||
<div class="w-2 rounded bg-secondary" />
|
||||
<div class="w-2 rounded bg-accent" />
|
||||
<div class="w-2 rounded bg-neutral" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-base-content size-1 rounded-full"></div>
|
||||
<div class="bg-primary size-1 rounded-full"></div>
|
||||
<div class="bg-secondary size-1 rounded-full"></div>
|
||||
<div class="bg-accent size-1 rounded-full"></div>
|
||||
</div>
|
||||
<div class="truncate">{theme}</div>
|
||||
<Fa icon={faCheck} class={activeTheme === theme ? 'visible' : 'invisible'} />
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
@@ -177,7 +168,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<a class="btn btn-ghost px-2 text-xl normal-case" href="/">
|
||||
<a class="btn btn-ghost h-full border-0 px-2 text-xl" href="/">
|
||||
<img
|
||||
src={$settingsPub?.id && $settingsPub?.favicon
|
||||
? `${backendUrl}api/files/settings_public/${$settingsPub?.id}/${$settingsPub?.favicon}`
|
||||
@@ -192,94 +183,91 @@
|
||||
{#if $settingsPub?.website_title}
|
||||
<span class="px-2">{$settingsPub?.website_title}</span>
|
||||
{/if}
|
||||
<ul class="menu menu-horizontal gap-1 px-1">
|
||||
<li>
|
||||
<a href="/" class="p-2" class:active={$page.url.pathname === '/'}
|
||||
><Fa icon={faHome} />{$LL.home.page_title()}</a
|
||||
<ul class="menu menu-horizontal h-full gap-1 px-1">
|
||||
<li class="h-full">
|
||||
<a href="/" class="p-2" class:menu-active={$page.url.pathname === '/'}
|
||||
><Fa icon={faHome} />{m.home_page_title()}</a
|
||||
>
|
||||
</li>
|
||||
{#if $pocketbase.authStore.isAdmin}
|
||||
<li>
|
||||
<a href="/users" class="p-2" class:active={$page.url.pathname.startsWith('/users')}
|
||||
><Fa icon={faUsersGear} />{$LL.users.page_title()}</a
|
||||
{#if $pocketbase.authStore.isSuperuser}
|
||||
<li class="h-full">
|
||||
<a href="/users" class="p-2" class:menu-active={$page.url.pathname.startsWith('/users')}
|
||||
><Fa icon={faUsersGear} />{m.users_page_title()}</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/settings/" class="p-2" class:active={$page.url.pathname.startsWith('/settings')}
|
||||
><Fa icon={faCog} />{$LL.settings.page_title()}</a
|
||||
<li class="h-full">
|
||||
<a
|
||||
href="/settings/"
|
||||
class="p-2"
|
||||
class:menu-active={$page.url.pathname.startsWith('/settings')}
|
||||
><Fa icon={faCog} />{m.settings_page_title()}</a
|
||||
>
|
||||
</li>
|
||||
{/if}
|
||||
</ul>
|
||||
<div class="dropdown dropdown-end">
|
||||
<div tabindex="-1" class="btn btn-ghost normal-case">
|
||||
<Fa icon={faSwatchbook} />
|
||||
<span class="font-normal">{$LL.navbar.theme()}</span>
|
||||
<Fa icon={faChevronDown} />
|
||||
</div>
|
||||
<div
|
||||
class="dropdown-content z-[1] mt-3 h-fit max-h-96 w-56 overflow-y-auto rounded-box bg-base-200 text-base-content shadow"
|
||||
>
|
||||
<div class="grid grid-cols-1 gap-3 p-3" tabindex="-1">
|
||||
{#each availableThemes as theme}
|
||||
<button
|
||||
class="overflow-hidden rounded-lg text-left outline-base-content"
|
||||
data-set-theme={theme}
|
||||
on:click={() => (activeTheme = theme)}
|
||||
on:keydown={() => (activeTheme = theme)}
|
||||
>
|
||||
<div
|
||||
data-theme={theme}
|
||||
class="w-full cursor-pointer bg-base-100 font-sans text-base-content"
|
||||
>
|
||||
<div class="grid grid-cols-5 grid-rows-3">
|
||||
<div class="col-span-5 row-span-3 row-start-1 flex items-center gap-2 px-4 py-3">
|
||||
<Fa icon={faCheck} class={activeTheme === theme ? 'visible' : 'invisible'} />
|
||||
<div class="flex-grow text-sm">{theme}</div>
|
||||
<div class="flex h-full flex-shrink-0 flex-wrap gap-1">
|
||||
<div class="w-2 rounded bg-primary" />
|
||||
<div class="w-2 rounded bg-secondary" />
|
||||
<div class="w-2 rounded bg-accent" />
|
||||
<div class="w-2 rounded bg-neutral" />
|
||||
</div>
|
||||
<div class="dropdown dropdown-end">
|
||||
<button class="btn btn-ghost hover:bg-base-content/10 h-full border-0 p-2" tabindex="0">
|
||||
<Fa icon={faSwatchbook} />
|
||||
<span class="font-normal">{m.navbar_theme()}</span>
|
||||
<Fa icon={faChevronDown} />
|
||||
</button>
|
||||
<div class="dropdown-content bg-base-200 rounded-box z-1 mt-3 w-52 shadow-sm">
|
||||
<ul class="menu menu-horizontal h-fit max-h-96 overflow-y-auto">
|
||||
{#each availableThemes as theme}
|
||||
<li class="w-full">
|
||||
<button
|
||||
class="gap-3 px-2"
|
||||
data-set-theme={theme}
|
||||
on:click={() => (activeTheme = theme)}
|
||||
on:keydown={() => (activeTheme = theme)}
|
||||
>
|
||||
<div
|
||||
data-theme={theme}
|
||||
class="bg-base-100 grid shrink-0 grid-cols-2 gap-0.5 rounded-md p-1 shadow-sm"
|
||||
>
|
||||
<div class="bg-base-content size-1 rounded-full"></div>
|
||||
<div class="bg-primary size-1 rounded-full"></div>
|
||||
<div class="bg-secondary size-1 rounded-full"></div>
|
||||
<div class="bg-accent size-1 rounded-full"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
{/each}
|
||||
<div class="truncate">{theme}</div>
|
||||
<Fa icon={faCheck} class={activeTheme === theme ? 'visible' : 'invisible'} />
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ms-auto justify-end">
|
||||
{#if $pocketbase.authStore?.model !== null}
|
||||
{#if $pocketbase.authStore.isAdmin || $permission.create}
|
||||
{#if $pocketbase.authStore?.record !== null}
|
||||
{#if $pocketbase.authStore.isSuperuser || $permission.create}
|
||||
<a class="btn btn-success me-4" href="/device/new">
|
||||
<Fa icon={faPlus} />
|
||||
{$LL.navbar.new()}
|
||||
{m.navbar_new()}
|
||||
</a>
|
||||
{/if}
|
||||
<div class="dropdown dropdown-end">
|
||||
<label tabindex="-1" class="avatar btn btn-circle btn-ghost" for="avatar">
|
||||
<div class="w-10 rounded-full" id="avatar">
|
||||
<img src="{backendUrl}_/images/avatars/avatar{avatar}.svg" alt="Avatar {avatar}" />
|
||||
<img src="/avatars/avatar{avatar}.svg" alt="Avatar {avatar}" />
|
||||
</div>
|
||||
</label>
|
||||
<ul
|
||||
tabindex="-1"
|
||||
class="menu dropdown-content z-[1] mt-3 rounded-box bg-base-300 p-2 shadow"
|
||||
class="menu dropdown-content rounded-box bg-base-200 z-[1] mt-3 w-52 p-2 shadow"
|
||||
>
|
||||
<li class="menu-title">
|
||||
{$pocketbase.authStore.isAdmin
|
||||
? $pocketbase.authStore.model.email
|
||||
: $pocketbase.authStore.model.username}
|
||||
{$pocketbase.authStore.isSuperuser
|
||||
? $pocketbase.authStore.record?.email
|
||||
: $pocketbase.authStore.record?.username}
|
||||
</li>
|
||||
<li>
|
||||
<a href="/account"><Fa icon={faUserGear} />{$LL.navbar.edit_account()}</a>
|
||||
<a href="/account"><Fa icon={faUserGear} />{m.navbar_edit_account()}</a>
|
||||
</li>
|
||||
<li>
|
||||
<div on:click={async () => logout()} on:keydown={async () => logout()} role="none">
|
||||
<Fa icon={faDoorOpen} />{$LL.navbar.logout()}
|
||||
<Fa icon={faDoorOpen} />{m.navbar_logout()}
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import PageLoading from '$lib/components/PageLoading.svelte';
|
||||
import LL from '$lib/i18n/i18n-svelte';
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import { localeStore } from '$lib/stores/locale';
|
||||
import { backendUrl, pocketbase } from '$lib/stores/pocketbase';
|
||||
import { settingsPriv } from '$lib/stores/settings';
|
||||
import type { Device } from '$lib/types/device';
|
||||
@@ -28,8 +29,9 @@
|
||||
.collection('settings_private')
|
||||
.getFirstListItem('')
|
||||
.then((res) => {
|
||||
settingsPriv.set(res as SettingsPrivate);
|
||||
scanRange = $settingsPriv.scan_range;
|
||||
const settings = res as SettingsPrivate;
|
||||
settingsPriv.set(settings);
|
||||
scanRange = settings.scan_range;
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error(err.message);
|
||||
@@ -47,7 +49,7 @@
|
||||
})
|
||||
.then((res) => {
|
||||
settingsPriv.set(res as SettingsPrivate);
|
||||
toast.success($LL.device.network_scan_range_saved());
|
||||
toast.success(m.device_network_scan_range_saved());
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error(err.message);
|
||||
@@ -89,7 +91,7 @@
|
||||
async function addSingle(device: ScannedDevice) {
|
||||
await createDevice(device)
|
||||
.then(() => {
|
||||
toast.success($LL.toasts.device_created({ device: device.name }));
|
||||
toast.success(m.toasts_device_created({ device: device.name }));
|
||||
})
|
||||
.catch((err) => {
|
||||
toast.error(err.message);
|
||||
@@ -110,63 +112,65 @@
|
||||
});
|
||||
})
|
||||
);
|
||||
toast.success($LL.toasts.devices_created_multiple({ count: count }));
|
||||
toast.success(m.toasts_devices_created_multiple({ count: count }));
|
||||
goto('/');
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if $settingsPriv}
|
||||
<div class="card mt-6 w-full bg-base-300 shadow-xl">
|
||||
<div class="card bg-base-200 mt-6 w-full shadow-sm">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title">{$LL.device.tabs[1]()}</h2>
|
||||
<h2 class="card-title">{m['device_tabs.1']()}</h2>
|
||||
<p class="my-2">
|
||||
{$LL.device.network_scan_desc()}
|
||||
{m.device_network_scan_desc()}
|
||||
</p>
|
||||
<div class="flex flex-row flex-wrap items-end gap-4">
|
||||
<form on:submit|preventDefault={saveSettings}>
|
||||
<label class="label" for="scan-range">
|
||||
<span class="label-text">{$LL.device.network_scan_ip_range()}</span>
|
||||
</label>
|
||||
<div class="join max-w-xs">
|
||||
<input
|
||||
id="scan-range"
|
||||
class="input join-item input-bordered w-full"
|
||||
type="text"
|
||||
placeholder="192.168.1.0/24"
|
||||
bind:value={scanRange}
|
||||
/>
|
||||
<button class="btn btn-primary join-item" type="submit">{$LL.buttons.save()}</button>
|
||||
</div>
|
||||
<fieldset class="fieldset p-0">
|
||||
<label class="floating-label mt-2">
|
||||
<span>{m.device_network_scan_ip_range()}</span>
|
||||
<div class="join max-w-xs">
|
||||
<input
|
||||
id="scan-range"
|
||||
class="input join-item w-full"
|
||||
type="text"
|
||||
placeholder="192.168.1.0/24"
|
||||
bind:value={scanRange}
|
||||
/>
|
||||
<button class="btn btn-neutral join-item" type="submit">{m.buttons_save()}</button>
|
||||
</div>
|
||||
</label>
|
||||
</fieldset>
|
||||
</form>
|
||||
<div>
|
||||
<div>
|
||||
{#if !$settingsPriv.scan_range}
|
||||
<button class="btn btn-error" disabled>
|
||||
<Fa icon={faX} />
|
||||
{$LL.device.network_scan_no_range()}
|
||||
{m.device_network_scan_no_range()}
|
||||
</button>
|
||||
{:else if scanRange !== $settingsPriv.scan_range}
|
||||
<button class="btn btn-error" disabled>
|
||||
<Fa icon={faX} />
|
||||
{$LL.device.network_scan_unsaved_changes()}
|
||||
{m.device_network_scan_unsaved_changes()}
|
||||
</button>
|
||||
{:else if scanRunning}
|
||||
<button class="btn no-animation">
|
||||
<span class="loading loading-spinner" />
|
||||
{$LL.device.network_scan_running()}
|
||||
<span class="loading loading-spinner"></span>
|
||||
{m.device_network_scan_running()}
|
||||
</button>
|
||||
{:else}
|
||||
<button class="btn btn-success" on:click={() => scan()}>
|
||||
<Fa icon={faMagnifyingGlass} />
|
||||
{$LL.device.network_scan()}
|
||||
{m.device_network_scan()}
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{#if scanResponse.devices?.length > 0}
|
||||
{#each scanResponse.devices.sort( (a, b) => a.ip.localeCompare( b.ip, undefined, { numeric: true } ) ) as device, index}
|
||||
<div class="collapse collapse-arrow bg-base-200">
|
||||
{#each scanResponse.devices.sort( (a, b) => a.ip.localeCompare( b.ip, $localeStore, { numeric: true } ) ) as device, index}
|
||||
<div class="collapse-arrow bg-base-100 collapse">
|
||||
<input type="radio" name="scanned-devices" checked={index === 0} />
|
||||
<div class="collapse-title font-bold">
|
||||
{device.name} <span class="badge">{device.ip}</span>
|
||||
@@ -174,20 +178,20 @@
|
||||
<div class="collapse-content">
|
||||
<div class="flex flex-row flex-wrap gap-4">
|
||||
<div>
|
||||
<strong>{$LL.device.network_scan_ip()}</strong><br />
|
||||
<strong>{m.device_network_scan_ip()}</strong><br />
|
||||
{device.ip}
|
||||
</div>
|
||||
<div>
|
||||
<strong>{$LL.device.network_scan_mac()}</strong><br />
|
||||
<strong>{m.device_network_scan_mac()}</strong><br />
|
||||
{device.mac}
|
||||
</div>
|
||||
<div>
|
||||
<strong>{$LL.device.network_scan_mac_vendor()}</strong><br />
|
||||
<strong>{m.device_network_scan_mac_vendor()}</strong><br />
|
||||
{device.mac_vendor}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<strong>{$LL.device.network_scan_netmask()}</strong><br />
|
||||
<strong>{m.device_network_scan_netmask()}</strong><br />
|
||||
{scanResponse.netmask}
|
||||
</div>
|
||||
<div class="ms-auto">
|
||||
@@ -196,28 +200,29 @@
|
||||
on:click={(e) => {
|
||||
addSingle(device);
|
||||
e.currentTarget.disabled = true;
|
||||
}}><Fa icon={faPlus} />{$LL.buttons.add()}</button
|
||||
}}><Fa icon={faPlus} />{m.buttons_add()}</button
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
<h2 class="card-title mt-4">{$LL.device.network_scan_add_all()}</h2>
|
||||
<div class="form-control max-w-fit">
|
||||
<h2 class="card-title mt-4">{m.device_network_scan_add_all()}</h2>
|
||||
<div class="max-w-fit">
|
||||
<label class="label cursor-pointer">
|
||||
<input type="checkbox" class="checkbox" bind:checked={replaceNetmaskCheckbox} />
|
||||
<span class="label-text ms-2">{$LL.device.network_scan_replace_netmask()}</span>
|
||||
<span class="ms-2 text-wrap break-words">{m.device_network_scan_replace_netmask()}</span
|
||||
>
|
||||
</label>
|
||||
</div>
|
||||
{#if replaceNetmaskCheckbox}
|
||||
<div class="form-control max-w-fit">
|
||||
<div class="max-w-fit">
|
||||
<label class="label cursor-pointer" for="replaceNetmaskInput">
|
||||
<span class="label-text ms-2">{$LL.device.network_scan_new_netmask()}</span>
|
||||
<span class="ms-2">{m.device_network_scan_new_netmask()}</span>
|
||||
</label>
|
||||
<input
|
||||
id="replaceNetmaskInput"
|
||||
class="input input-bordered"
|
||||
class="input"
|
||||
type="text"
|
||||
placeholder="255.255.255.0"
|
||||
bind:value={replaceNetmask}
|
||||
@@ -225,10 +230,12 @@
|
||||
</div>
|
||||
{/if}
|
||||
{#if scanResponse.devices.find((dev) => dev.name === 'Unknown')}
|
||||
<div class="form-control max-w-fit">
|
||||
<div class="max-w-fit">
|
||||
<label class="label cursor-pointer">
|
||||
<input type="checkbox" class="checkbox" bind:checked={addAllCheckbox} />
|
||||
<span class="label-text ms-2">{$LL.device.network_scan_include_unknown()}</span>
|
||||
<span class="ms-2 text-wrap break-words"
|
||||
>{m.device_network_scan_include_unknown()}</span
|
||||
>
|
||||
</label>
|
||||
{#if addAllCheckbox}
|
||||
<button
|
||||
@@ -237,7 +244,7 @@
|
||||
disabled={scanResponse.devices.length === 0}
|
||||
>
|
||||
<Fa icon={faPlus} />
|
||||
{$LL.device.network_scan_add_all()} ({scanResponse.devices.length})
|
||||
{m.device_network_scan_add_all()} ({scanResponse.devices.length})
|
||||
</button>
|
||||
{:else}
|
||||
<button
|
||||
@@ -246,21 +253,21 @@
|
||||
disabled={scanResponse.devices.filter((dev) => dev.name !== 'Unknown').length === 0}
|
||||
>
|
||||
<Fa icon={faPlus} />
|
||||
{$LL.device.network_scan_add_all()} ({scanResponse.devices.filter(
|
||||
{m.device_network_scan_add_all()} ({scanResponse.devices.filter(
|
||||
(dev) => dev.name !== 'Unknown'
|
||||
).length})
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<div class="form-control max-w-fit">
|
||||
<div class="max-w-fit">
|
||||
<button
|
||||
class="btn btn-success"
|
||||
on:click={() => addAll()}
|
||||
disabled={scanResponse.devices.length === 0}
|
||||
>
|
||||
<Fa icon={faPlus} />
|
||||
{$LL.device.network_scan_add_all()} ({scanResponse.devices.length})
|
||||
{m.device_network_scan_add_all()} ({scanResponse.devices.length})
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<div class="container mx-auto max-w-lg text-center">
|
||||
<span class="loading loading-dots loading-lg" />
|
||||
<span class="loading loading-dots loading-lg"></span>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { m } from '$lib/paraglide/messages';
|
||||
import { dateFnsLocale } from '$lib/stores/locale';
|
||||
import { backendUrl } from '$lib/stores/pocketbase';
|
||||
import cronParser from 'cron-parser';
|
||||
import { formatDate, type Locale } from 'date-fns';
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
export const cronRegex = new RegExp(/((((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ?){5,6})/);
|
||||
|
||||
export function nextCronDate(expression: string) {
|
||||
try {
|
||||
if (
|
||||
expression === '' ||
|
||||
!cronRegex.test(expression) ||
|
||||
Object.keys(cronParser.parseString(expression).errors).length > 0
|
||||
) {
|
||||
throw new Error('cron-parser failed to parse string');
|
||||
}
|
||||
|
||||
const cron = cronParser.parseExpression(expression, {});
|
||||
|
||||
return formatDate(cron.next().toISOString(), 'PPpp', {
|
||||
locale: get(dateFnsLocale) as unknown as Locale
|
||||
});
|
||||
} catch {
|
||||
return m.settings_invalid_cron();
|
||||
}
|
||||
}
|
||||
|
||||
export function parseCron(expression: string): Promise<boolean> {
|
||||
return fetch(backendUrl + 'api/upsnap/validate-cron', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
cron: expression
|
||||
})
|
||||
})
|
||||
.then((response) => {
|
||||
return response.ok;
|
||||
})
|
||||
.catch(() => {
|
||||
return false;
|
||||
});
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
import de from '../de';
|
||||
import type { Translation } from '../i18n-types';
|
||||
|
||||
const de_DE = {
|
||||
...(de as unknown as Translation)
|
||||
} satisfies Translation;
|
||||
|
||||
export default de_DE;
|
||||
@@ -1,226 +0,0 @@
|
||||
import en from '../en';
|
||||
import type { Translation } from '../i18n-types';
|
||||
|
||||
const de = {
|
||||
...(en as unknown as Translation),
|
||||
home: {
|
||||
page_title: 'Home',
|
||||
order_groups: 'Gruppen',
|
||||
order_name: 'Name',
|
||||
order_ip: 'IP',
|
||||
order_tooltip: 'Sortieren',
|
||||
no_devices: 'Keine Geräte.',
|
||||
add_first_device: 'Füge dein erstes Gerät hinzu',
|
||||
grant_permissions:
|
||||
'Bitte frag den Administrator, dir Berechtigungen für bestehende Geräte zu erteilen oder neue Geräte zu erstellen.'
|
||||
},
|
||||
account: {
|
||||
page_title: 'Account',
|
||||
account_type_admin: 'Admin',
|
||||
account_type_user: 'Benutzer',
|
||||
avatar_title: 'Avatar',
|
||||
language_title: 'Sprache',
|
||||
language_option_auto: 'Automatisch',
|
||||
change_password_title: 'Passwort ändern',
|
||||
change_password_body: 'Nachdem das Passwort geändert wurde, musst du dich neu einloggen.',
|
||||
change_password_label: 'Altes Passwort',
|
||||
change_password_new: 'Neues Password',
|
||||
change_password_confirm: 'Password bestätigen'
|
||||
},
|
||||
device: {
|
||||
page_title: 'Neues Gerät',
|
||||
tabs: ['Manuell', 'Netzwerkscan'],
|
||||
card_btn_more: 'Mehr',
|
||||
card_btn_more_edit: 'Bearbeiten',
|
||||
card_btn_more_sleep: 'Ruhezustand',
|
||||
card_btn_more_reboot: 'Neustart',
|
||||
card_tooltip_wake_cron: 'Einschalten Cron',
|
||||
card_tooltip_shutdown_cron: 'Ausschalten Cron',
|
||||
card_tooltip_wake_password: 'Einschalten Passwort',
|
||||
card_tooltip_last_status_change: 'Letzte Statusänderung',
|
||||
card_password: 'Passwort',
|
||||
card_nic_tooltip_pending: 'Warten',
|
||||
card_nic_tooltip_shutdown: 'Ausschalten',
|
||||
card_nic_tooltip_shutdown_no_cmd: 'Kein Ausschaltbefehl gesetzt',
|
||||
card_nic_tooltip_shutdown_no_permission: 'Keine Berechtigung zum ausschalten',
|
||||
card_nic_tooltip_power: 'Einschalten',
|
||||
card_nic_tooltip_power_no_permission: 'Keine Berechtigung zum einschalten',
|
||||
modal_confirm_wake_title: '{device} einschalten?',
|
||||
modal_confirm_wake_desc: 'Bitte bestätigen, um {device} einzuschalten.',
|
||||
modal_confirm_shutdown_title: '{device} herunterfahren?',
|
||||
modal_confirm_shutdown_desc: 'Bitte bestätigen, um {device} herunterzufahren.',
|
||||
general: 'Allgemein',
|
||||
general_name: 'Name',
|
||||
general_name_placeholder: 'Gerätename',
|
||||
general_ip: 'IP',
|
||||
general_mac: 'Mac',
|
||||
general_netmask: 'Netmask',
|
||||
general_required_field: 'Pflichtfeld',
|
||||
ports: 'Ports',
|
||||
ports_desc: 'UpSnap kann auch prüfen, ob bestimmte Ports offen sind.',
|
||||
ports_add_new: 'Port hinzufügen',
|
||||
ports_name: 'Name',
|
||||
ports_number: 'Nummer',
|
||||
link: 'Link',
|
||||
link_desc:
|
||||
'Macht Ihren Gerätenamen zu einem anklickbaren Link, ideal zum Beispiel für die Verknüpfung eines Dashboards.',
|
||||
ping: 'Ping',
|
||||
ping_desc:
|
||||
'Du kannst einen benutzerdefinierten Shell-Befehl verwenden, um festzustellen, ob das Gerät eingeschaltet ist. Der Befehl sollte einen Exit-Code von <span class="badge">0</span> zurückgeben, um anzuzeigen, dass das Gerät eingeschaltet ist. Jeder andere Exit-Code setzt den Status auf offline.',
|
||||
ping_cmd: 'Eigener Ping-Befehl',
|
||||
wake: 'Einschalten',
|
||||
wake_desc: 'Du kannst das Gerät mit einem Cron-Job einschalten.',
|
||||
wake_cmd: 'Eigener Einschalt-Befehl',
|
||||
wake_cron: 'Cron',
|
||||
wake_cron_enable: 'Aktivieren',
|
||||
sol: 'Sleep-On-LAN',
|
||||
sol_desc1:
|
||||
'Du kannst Computer mithilfe des Tools <a class="link" href="https://github.com/SR-G/sleep-on-lan" target="_blank">Sleep-On-LAN</a> in den Ruhezustand versetzen. Sleep-On-LAN (SOL) ist ein externes Tool/Daemon, das auf den PCs arbeitet, die du in den Ruhezustand versetzen möchtest, und stellt einen REST-Endpunkt bereit. Für Anweisungen zur Einrichtung von Sleep-On-LAN verweise bitte auf den Abschnitt <a href="https://github.com/SR-G/sleep-on-lan#usage" class="link" target="_blank">Usage</a>.',
|
||||
sol_desc2:
|
||||
'SOL ist so konfiguriert, dass es Anfragen über HTTP statt über UDP sendet, um eine Autorisierung zu ermöglichen und die Zuverlässigkeit der Anfragen zu erhöhen.',
|
||||
sol_desc3:
|
||||
'Daher stell bitte sicher, dass du <span class="badge">HTTP:<DEINPORT></span> im Abschnitt <span class="badge">Listener</span> der <a href="https://github.com/SR-G/sleep-on-lan#configuration" class="link" target="_blank">SOL-Konfiguration</a> hinzufügst.',
|
||||
sol_enable: 'Sleep-On-LAN aktivieren',
|
||||
sol_port: 'SOL Port',
|
||||
sol_authorization: 'Authorisierung',
|
||||
sol_user: 'SOL Benutzer',
|
||||
sol_password: 'SOL Passwort',
|
||||
shutdown: 'Ausschalten',
|
||||
shutdown_desc:
|
||||
'Dieser <strong>Shell-Befehl</strong> wird in deinem Container ausgeführt (wenn du Docker verwendest) oder auf deinem Host (wenn du die Binärdatei verwendest). Um zu überprüfen, ob das funktioniert, kannst du den Befehl zuerst im Container oder auf deiner Host-Shell ausführen. Übliche Befehle sind <span class="badge">net rpc</span> für Windows, <span class="badge">sshpass</span> für Linux oder <span class="badge">curl</span> im Allgemeinen, um Webanfragen durchzuführen.',
|
||||
shutdown_examples: 'Beispiele:',
|
||||
shutdown_examples_windows: 'Entfernten Windows PC ausschalten:',
|
||||
shutdown_examples_linux: 'Entfernten Linux PC ausschalten:',
|
||||
shutdown_cmd: 'Befehl zum ausschalten',
|
||||
shutdown_cron_desc:
|
||||
'Genau wie das Einrichten eines Cron-Jobs, um das Gerät aufzuwecken, kannst du auch einen Cron-Job planen, um dieses Gerät herunterzufahren.',
|
||||
shutdown_cron: 'Cron',
|
||||
shutdown_cron_enable: 'Aktivieren',
|
||||
password: 'Password',
|
||||
password_desc:
|
||||
'Einige Netzwerkkarten bieten die Möglichkeit, ein Passwort für Magic Packets zu setzen, auch <span class="badge">SecureON</span> genannt. Das Passwort kann nur 0, 4 oder 6 Zeichen lang sein.',
|
||||
groups: 'Gruppen',
|
||||
groups_desc:
|
||||
'Du kannst Geräte einer Gruppe hinzufügen, um sie auf dem Dashboard nach Gruppen sortiert anzuzeigen.',
|
||||
groups_placeholder: "z.B. 'Keller' or 'Büro'",
|
||||
network_scan_range_saved: 'Scan-Bereich gespeichert',
|
||||
network_scan_desc:
|
||||
'Automatisches Scannen deines Netzwerks nach Geräten. Damit dies funktioniert, musst du UpSnap als Administrator/root ausführen und nmap installiert und im $PATH verfügbar haben (Für Docker-Benutzer ist das bereits der Fall, und du musst nichts weiter tun). Das Scannen kann einige Sekunden dauern.',
|
||||
network_scan_ip_range: 'IP-Bereich',
|
||||
network_scan_no_range: 'Kein Scan-Bereich',
|
||||
network_scan_unsaved_changes: 'Ungespeicherte Änderungen',
|
||||
network_scan_running: 'Scan läuft',
|
||||
network_scan: 'Scan',
|
||||
network_scan_ip: 'IP:',
|
||||
network_scan_mac: 'Mac:',
|
||||
network_scan_mac_vendor: 'Mac Hersteller:',
|
||||
network_scan_netmask: 'Netmask:',
|
||||
network_scan_add_all: 'Alle Geräte hinzufügen',
|
||||
network_scan_replace_netmask: 'Netmask für alle Geräte ändern?',
|
||||
network_scan_new_netmask: 'Neue Netmask',
|
||||
network_scan_include_unknown: 'Schließe Geräte ein, bei denen der Name "Unknown" ist.',
|
||||
require_confirmation: 'Bestätigung erforderlich'
|
||||
},
|
||||
login: {
|
||||
welcome: 'Willkommen',
|
||||
email_label: 'Email oder Nutzername:',
|
||||
password_label: 'Passwort:',
|
||||
btn_more: 'Mehr',
|
||||
menu_title_auth_providers: 'Andere Login Provider',
|
||||
btn_login: 'Login'
|
||||
},
|
||||
settings: {
|
||||
page_title: 'Einstellungen',
|
||||
ping_interval_title: 'Ping Intervall',
|
||||
ping_interval_desc1:
|
||||
'Legt den Intervall fest, in dem Geräte gepingt werden. Leer lassen um den Standardwert von <span class="badge">@every 3s</span> zu verwenden.',
|
||||
ping_interval_desc2:
|
||||
'Lerne mehr über die korrekte Cron Syntax auf <a class="link" href="https://de.wikipedia.org/wiki/Cron" target="_blank">Wikipedia</a> oder sieh dir die <a class="link" href="https://pkg.go.dev/github.com/robfig/cron/v3" target="_blank">Paketdokumentation</a> an.',
|
||||
lazy_ping_title: 'Lazy Ping',
|
||||
lazy_ping_desc:
|
||||
'Wenn Lazy Ping aktiviert ist, pingt UpSnap die Geräte nur an, wenn ein aktiver Benutzer die Website besucht. Wenn es ausgeschaltet ist, pingt UpSnap die Geräte immer an.',
|
||||
lazy_ping_enable: 'Aktivieren',
|
||||
website_title_title: 'Seitentitel',
|
||||
website_title_desc: 'Setzt den Seiten- und den Tabtitel.',
|
||||
icon_title: 'Icon',
|
||||
icon_desc: 'Eigenes Favicon nutzen. Unterstützte Dateitypen sind:',
|
||||
upsnap_version: 'UpSnap Version'
|
||||
},
|
||||
users: {
|
||||
page_title: 'Benutzer',
|
||||
allow_create_devices:
|
||||
'{username} erlauben neue Geräte zu erstellen und Gerätegruppen zu bearbeiten',
|
||||
device_permissions: 'Geräteberechtigungen',
|
||||
create_new_device: 'Neues Gerät erstellen',
|
||||
read: 'Lesen',
|
||||
update: 'Ändern',
|
||||
delete: 'Löschen',
|
||||
power: 'Power',
|
||||
toggle: 'Toggle',
|
||||
confirm_delete_title: 'Löschen bestätigen',
|
||||
confirm_delete_desc: 'Soll {username} wirklich gelöscht werden?',
|
||||
create_new_user: 'Neuen Benutzer erstellen',
|
||||
username: 'Benutzername',
|
||||
password: 'Passwort',
|
||||
password_confirm: 'Passwort bestätigen',
|
||||
required_field: 'Pflichtfeld'
|
||||
},
|
||||
buttons: {
|
||||
save: 'Speichern',
|
||||
delete: 'Löschen',
|
||||
change: 'Ändern',
|
||||
reset: 'Zurücksetzen',
|
||||
cancel: 'Abbrechen',
|
||||
add: 'Hinzufügen',
|
||||
confirm: 'Bestätigen'
|
||||
},
|
||||
welcome: {
|
||||
step1_page_title: 'Willkommen bei UpSnap 🥳',
|
||||
step1_setup_desc:
|
||||
'Bitte schließe die nachfolgenden Schritte ab, um die Einrichtung abzuschließen.',
|
||||
step1_setup_btn_next: 'Weiter',
|
||||
step2_page_title: 'Erstelle einen Admin Account',
|
||||
step2_label_email: 'Email:',
|
||||
step2_label_password: 'Passwort:',
|
||||
step2_label_min_chars: 'min. 10 Zeichen',
|
||||
step2_label_password_confirm: 'Passwort bestätigen:',
|
||||
step2_btn_create: 'Erstellen',
|
||||
step3_page_title: 'Du bist fertig! 🎉',
|
||||
step3_page_desc: 'Füge Geräte zu deinem Dashboard hinzu.',
|
||||
step3_btn_done: 'Lets go!',
|
||||
not_expected_title: 'Ich hab dich hier nicht erwartet! 🧐',
|
||||
not_expected_desc: 'Du hast die Einrichtung bereits abgeschlossen! Hier gibts nichts zu tun.',
|
||||
not_expected_back: 'Bring mich zurück',
|
||||
progress_step1: 'Willkommen',
|
||||
progress_step2: 'Account erstellen',
|
||||
progress_step3: 'Fertig'
|
||||
},
|
||||
toasts: {
|
||||
admin_saved: 'Admin gespeichert',
|
||||
user_saved: 'Benutzer gespeichert',
|
||||
user_created: 'Benutzer {username} erstellt',
|
||||
user_deleted: 'Benutzer {username} gelöscht',
|
||||
settings_saved: 'Einstellungen gespeichert',
|
||||
password_changed: 'Passwort geändert. Bitte neu einloggen.',
|
||||
passwords_missmatch: 'Passwörter stimmen nicht überein',
|
||||
permissions_created: 'Berechtigungen für {username} erstellt',
|
||||
permissions_deleted: 'Berechtigungen für {username} gelöscht',
|
||||
permissions_updated: 'Berechtigungen für {username} geändert',
|
||||
permissions_updated_personal: 'Deine Berechtigungen wurden geupdated',
|
||||
no_permission: 'Du hast keine Berechtigung für {url}',
|
||||
device_created: '{device} erstellt',
|
||||
devices_created_multiple: '{count|int} Geräte erstellt',
|
||||
device_updated: '{device} geändert',
|
||||
device_deleted: '{device} gelöscht',
|
||||
group_created: 'Gruppe {group} erstellt',
|
||||
group_deleted: 'Gruppe {group} gelöscht'
|
||||
},
|
||||
navbar: {
|
||||
theme: 'Theme',
|
||||
new: 'Neu',
|
||||
edit_account: 'Account bearbeiten',
|
||||
logout: 'Abmelden'
|
||||
}
|
||||
} satisfies Translation;
|
||||
|
||||
export default de;
|
||||