diff --git a/.gitignore b/.gitignore index ce33fd59..821a6718 100644 --- a/.gitignore +++ b/.gitignore @@ -199,3 +199,4 @@ frontend/vite.config.ts.timestamp-* backend/pb_data backend/pb_public/* +!backend/pb_public/.gitkeep diff --git a/README.md b/README.md index 8f2fbce6..6c2a0349 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Open up [http://localhost:5173/](http://localhost:5173/) - [x] ~~add rest of settings page~~ - [x] ~~form for adding new devices~~ - - [ ] add per device settings + - [x] ~~add per device settings~~ - [x] ~~theme toggle button~~ - [x] ~~add device ports to cards~~ diff --git a/backend/cronjobs/cronjobs.go b/backend/cronjobs/cronjobs.go index 2502b650..9234e1a5 100644 --- a/backend/cronjobs/cronjobs.go +++ b/backend/cronjobs/cronjobs.go @@ -20,6 +20,11 @@ func RunCron(app *pocketbase.PocketBase) { // init cronjob Jobs = cron.New() Jobs.AddFunc(settingsRecords[0].GetString("interval"), func() { + // skip cron if no realtime clients connected + realtimeClients := len(app.SubscriptionsBroker().Clients()) + if realtimeClients == 0 { + return + } // expand ports field expandFetchFunc := func(c *models.Collection, ids []string) ([]*models.Record, error) { return app.Dao().FindRecordsByIds(c.Id, ids, nil) diff --git a/backend/pb_public/.gitkeep b/backend/pb_public/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/backend/upsnap b/backend/upsnap new file mode 100755 index 00000000..1f3e9d84 Binary files /dev/null and b/backend/upsnap differ diff --git a/frontend/src/app.html b/frontend/src/app.html index f4a15b7a..a3dcb59b 100644 --- a/frontend/src/app.html +++ b/frontend/src/app.html @@ -4,6 +4,7 @@ + UpSnap %sveltekit.head% diff --git a/frontend/src/components/DeviceCard.svelte b/frontend/src/components/DeviceCard.svelte index 6d5af769..9442112a 100644 --- a/frontend/src/components/DeviceCard.svelte +++ b/frontend/src/components/DeviceCard.svelte @@ -61,7 +61,9 @@ {/if}
- + + +
{#if device.link} diff --git a/frontend/src/components/DeviceForm.svelte b/frontend/src/components/DeviceForm.svelte new file mode 100644 index 00000000..1586d68a --- /dev/null +++ b/frontend/src/components/DeviceForm.svelte @@ -0,0 +1,350 @@ + + +
+

{mode === 'add' ? 'Add new device' : device.name}

+
+
+
+
Required:
+
+ Name + +
+
+ IP + +
+
+ MAC + +
+
+ Netmask + +
+
Optional:
+ {#if device?.expand?.ports} + {#each device?.expand?.ports as port, idx} +
+ Port + + + +
+ {/each} + {/if} +
+ Port + + + +
+
+ Link + +
+
+ Wake Cron(1) + +
+
+ Shutdown Cron(1) + +
+
+ Shutdown Cmd(2) + +
+
+ Password(3) + + +
+ +
+
+
+
+
Optional:
+

(1) Same cron syntax as for ping interval.

+

(2) Shell command to be executed. e.g.:

+
    +
  • Windows: "net rpc shutdown -I 192.168.1.13 -U test%test"
  • +
  • + Linux: "sshpass -p your_password ssh -o 'StrictHostKeyChecking=no' user@hostname 'sudo + shutdown'" +
  • +
+

+ (3) Some network cards have the option to set a password for magic packets, also called + "SecureON". Password can only be 0, 4 or 6 characters in length. +

+
+ {#if mode === 'edit'} +
+ +
+ {/if} +
+
+
diff --git a/frontend/src/components/Navbar.svelte b/frontend/src/components/Navbar.svelte index a20c67d1..39fbe6ce 100644 --- a/frontend/src/components/Navbar.svelte +++ b/frontend/src/components/Navbar.svelte @@ -8,7 +8,7 @@