diff --git a/.gitignore b/.gitignore index 70bdf955..ce33fd59 100644 --- a/.gitignore +++ b/.gitignore @@ -192,5 +192,10 @@ package # End of https://www.toptal.com/developers/gitignore/api/go,visualstudiocode,svelte,node +frontend/build +frontend/.svelte-kit +frontend/vite.config.js.timestamp-* +frontend/vite.config.ts.timestamp-* backend/pb_data +backend/pb_public/* diff --git a/README.md b/README.md index b2402c19..c3bc7e4d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,51 @@ -# to do +# UpSnap v3 -- add db import from v2 -- rewrite sveltekit frontend +> This is the dev branch for v3. It's very much in progress but will have a release candidate once all boxes below are checked. + +## Help developing + +Fork this branch and clone it. + +1. Start backend + +```sh +cd backend +go mod tidy +go run main.go serve +``` + +Log in to [http://127.0.0.1:8090/\_/](http://127.0.0.1:8090/_/), create an admin user and add some devices. + +2. Start frontend + +```sh +cd frontend +pnpm i +pnpm run dev +``` + +Open up [localhost:5173/](localhost:5173/) + +## To do + +- frontend + + - [ ] add rest of settings page + - [ ] form for adding new devices + - [ ] add per device settings + - [ ] theme toggle button + - [ ] add device ports to cards + +- backend + + - [ ] make sure ping works + - [ ] make sure arp works + - [ ] make sure wake works + - [ ] remove nmap? + - [ ] [#34 Add support for WOL passwords](https://github.com/seriousm4x/UpSnap/issues/34) + - [x] [~~#33 Seemingly High Ram usage~~](https://github.com/seriousm4x/UpSnap/issues/33) + - [x] [~~#32 API available?~~](https://github.com/seriousm4x/UpSnap/issues/32) + +- [x] ~~add db import from v2~~ +- [ ] move docker images to github packages and setup new workflow file +- [ ] create dockerfile and docker-compose.yml diff --git a/frontend/.gitignore b/frontend/.gitignore deleted file mode 100644 index 6635cf55..00000000 --- a/frontend/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.DS_Store -node_modules -/build -/.svelte-kit -/package -.env -.env.* -!.env.example -vite.config.js.timestamp-* -vite.config.ts.timestamp-* diff --git a/frontend/package.json b/frontend/package.json index 8fd56221..2c796ae7 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -10,7 +10,7 @@ "format": "prettier --plugin-search-dir . --write ." }, "devDependencies": { - "@sveltejs/adapter-auto": "^1.0.1", + "@sveltejs/adapter-static": "^1.0.1", "@sveltejs/kit": "^1.1.1", "eslint": "^8.32.0", "eslint-config-prettier": "^8.6.0", diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index c54f515b..0a29213c 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -3,7 +3,7 @@ lockfileVersion: 5.4 specifiers: '@fortawesome/free-solid-svg-icons': ^6.2.1 '@popperjs/core': ^2.11.6 - '@sveltejs/adapter-auto': ^1.0.1 + '@sveltejs/adapter-static': ^1.0.1 '@sveltejs/kit': ^1.1.1 bootstrap: 5.3.0-alpha1 date-fns: ^2.29.3 @@ -29,7 +29,7 @@ dependencies: svelte-fa: 3.0.3 devDependencies: - '@sveltejs/adapter-auto': 1.0.1_@sveltejs+kit@1.1.1 + '@sveltejs/adapter-static': 1.0.4_@sveltejs+kit@1.1.1 '@sveltejs/kit': 1.1.1_svelte@3.55.1+vite@4.0.4 eslint: 8.32.0 eslint-config-prettier: 8.6.0_eslint@8.32.0 @@ -324,13 +324,12 @@ packages: resolution: {integrity: sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==} dev: false - /@sveltejs/adapter-auto/1.0.1_@sveltejs+kit@1.1.1: - resolution: {integrity: sha512-IGek24xN1wJb+gz0hyGSxbIvM7q2K+BXquyycteCWbH9MPosjw8+LuIB2HIH20thE/647UEQBNqCM9R73lAUXA==} + /@sveltejs/adapter-static/1.0.4_@sveltejs+kit@1.1.1: + resolution: {integrity: sha512-L6kGg19MBHW3kv3GWAPl9tJo3ohNM+dcj9Yq1U1XVu0J0MKrusyCWQ62XOfxFgS6T8Fq0KYJ5NSSAPGppvX4xA==} peerDependencies: '@sveltejs/kit': ^1.0.0 dependencies: '@sveltejs/kit': 1.1.1_svelte@3.55.1+vite@4.0.4 - import-meta-resolve: 2.2.1 dev: true /@sveltejs/kit/1.1.1_svelte@3.55.1+vite@4.0.4: @@ -894,10 +893,6 @@ packages: resolve-from: 4.0.0 dev: true - /import-meta-resolve/2.2.1: - resolution: {integrity: sha512-C6lLL7EJPY44kBvA80gq4uMsVFw5x3oSKfuMl1cuZ2RkI5+UJqQXgn+6hlUew0y4ig7Ypt4CObAAIzU53Nfpuw==} - dev: true - /imurmurhash/0.1.4: resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} engines: {node: '>=0.8.19'} diff --git a/frontend/src/app.html b/frontend/src/app.html index effe0d0d..f4a15b7a 100644 --- a/frontend/src/app.html +++ b/frontend/src/app.html @@ -1,12 +1,12 @@ - + %sveltekit.head% - +
%sveltekit.body%
diff --git a/frontend/src/components/DeviceCard.svelte b/frontend/src/components/DeviceCard.svelte index fa86257b..c901391e 100644 --- a/frontend/src/components/DeviceCard.svelte +++ b/frontend/src/components/DeviceCard.svelte @@ -1,31 +1,61 @@ - - -
-
-
-

- -

-

{device.name} ({device.status})

-

{device.ip}

-
- -
-
+ + +
+
+
+
+
+ wake() + : device.status == 'online' + ? () => shutdown() + : ''} + on:keydown={device.status == 'offline' + ? () => wake() + : device.status == 'online' + ? () => shutdown() + : ''} + > + + +
+
+ +
+
+

{device.name}

+

{device.ip}

+

+ {formatDistance(parseISO(device.updated), now, { + includeSeconds: true, + addSuffix: true + })} +

+
+
+
diff --git a/frontend/src/components/Navbar.svelte b/frontend/src/components/Navbar.svelte index e69de29b..d6b53602 100644 --- a/frontend/src/components/Navbar.svelte +++ b/frontend/src/components/Navbar.svelte @@ -0,0 +1,27 @@ + + + diff --git a/frontend/src/components/Transition.svelte b/frontend/src/components/Transition.svelte new file mode 100644 index 00000000..60e55d95 --- /dev/null +++ b/frontend/src/components/Transition.svelte @@ -0,0 +1,10 @@ + + +{#key url} +
+ +
+{/key} diff --git a/frontend/src/routes/+layout.js b/frontend/src/routes/+layout.js new file mode 100644 index 00000000..189f71e2 --- /dev/null +++ b/frontend/src/routes/+layout.js @@ -0,0 +1 @@ +export const prerender = true; diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index 9e7bcc36..860ba01b 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -1,22 +1,39 @@ - + - + + + diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index b2fc7ecb..9c5a85be 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -1,38 +1,40 @@ -
+
{#each Object.entries(devices) as [_, device]} diff --git a/frontend/src/routes/settings/+page.svelte b/frontend/src/routes/settings/+page.svelte index c06b53d5..af942a99 100644 --- a/frontend/src/routes/settings/+page.svelte +++ b/frontend/src/routes/settings/+page.svelte @@ -1,12 +1,14 @@
-

Settings

-
+

Settings

+
+

Restore

+
+ If you were running UpSnap v2.3.2 (or higher), you can restore your devices here. This will + wipe the existing database. +
restoreV2Backup(e)} /> -
+
diff --git a/frontend/src/scss/main.scss b/frontend/src/scss/main.scss index 680103a2..d04916e0 100644 --- a/frontend/src/scss/main.scss +++ b/frontend/src/scss/main.scss @@ -32,9 +32,83 @@ $body-bg-dark: $gray-1000; @import '../../node_modules/bootstrap/scss/grid'; @import '../../node_modules/bootstrap/scss/helpers'; @import '../../node_modules/bootstrap/scss/card'; +@import '../../node_modules/bootstrap/scss/nav'; +@import '../../node_modules/bootstrap/scss/navbar'; +@import '../../node_modules/bootstrap/scss/forms'; @import '../../node_modules/bootstrap/scss/utilities/api'; +section { + padding: 1rem; + margin: 1rem 0; + border-radius: 1rem; +} + +.nav-link { + padding: 0.3rem 0.6rem !important; + border-radius: 0.4rem; + + &.active { + background-color: $gray-300; + } +} + .text-success { color: $teal-500 !important; } + +.text-warning { + color: $yellow !important; +} + +.text-danger { + color: #ef476f !important; +} + +.callout { + padding: 1rem; + border-radius: 0.3rem; + margin: 1rem 0; + + &.callout-info { + background-color: #1177b21f; + border-left: 0.5rem solid #1177b21f; + } + + &.callout-danger { + background-color: #ef476f1f; + border-left: 0.5rem solid #ef476f1f; + } +} + +html[data-bs-theme='light'] { + html, + body { + background: #f0f1f2; + } + + section, + .card { + background: #ffffff; + box-shadow: 0 1rem 1rem rgba(238, 238, 238, 0.7); + } +} + +html[data-bs-theme='dark'] { + html, + body { + background: #171718; + } + + section, + .card { + background: #252525; + box-shadow: 0 1rem 1rem rgba(32, 32, 32, 0.4); + } + + .nav-link { + &.active { + background-color: $gray-800; + } + } +} diff --git a/frontend/src/stores/pocketbase.js b/frontend/src/stores/pocketbase.js new file mode 100644 index 00000000..38bc88ac --- /dev/null +++ b/frontend/src/stores/pocketbase.js @@ -0,0 +1,4 @@ +import { writable } from 'svelte/store'; +import PocketBase from 'pocketbase'; + +export let pocketbase = writable(new PocketBase('http://127.0.0.1:8090')); diff --git a/frontend/static/favicon.png b/frontend/static/favicon.png index 825b9e65..9c658ae5 100644 Binary files a/frontend/static/favicon.png and b/frontend/static/favicon.png differ diff --git a/frontend/svelte.config.js b/frontend/svelte.config.js index 08d74a86..b0ca8a6b 100644 --- a/frontend/svelte.config.js +++ b/frontend/svelte.config.js @@ -1,18 +1,19 @@ -import adapter from '@sveltejs/adapter-auto'; +import adapter from '@sveltejs/adapter-static'; import preprocess from 'svelte-preprocess'; import path from 'path'; /** @type {import('@sveltejs/kit').Config} */ const config = { // Consult https://github.com/sveltejs/svelte-preprocess - // for more information about preprocessors - preprocess: preprocess(), + // for more information about preprocessors + preprocess: preprocess(), kit: { adapter: adapter(), - alias: { - '@components': path.resolve('./src/components') - } + alias: { + '@components': path.resolve('./src/components'), + '@stores': path.resolve('./src/stores') + } } };