Compare commits

...

4 Commits

Author SHA1 Message Date
Maxi Quoß 2bc7bab5f7 remove v2 restore 2023-06-01 14:38:07 +02:00
Maxi Quoß 4eed2bf31b format 2023-06-01 14:37:10 +02:00
Maxi Quoß 326a7f359f update dependencies 2023-06-01 14:33:49 +02:00
Maxi Quoß cbbd0f301e workflow: add codeberg mirror 2023-06-01 13:18:27 +02:00
7 changed files with 800 additions and 1144 deletions
+19
View File
@@ -0,0 +1,19 @@
# Sync repo to the Codeberg mirror
name: Mirror Sync
on:
push:
branches: ["master"]
workflow_dispatch:
schedule:
- cron: "0 */24 * * *"
jobs:
codeberg:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: pixta-dev/repository-mirroring-action@v1
with:
target_repo_url: "git@codeberg.org:seriousm4x/UpSnap.git"
ssh_private_key: ${{ secrets.CODEBERG_SSH }}
+38 -37
View File
@@ -6,7 +6,7 @@ require (
github.com/labstack/echo/v5 v5.0.0-20220201181537-ed2888cfa198
github.com/mdlayher/wol v0.0.0-20220221231636-b763a792253a
github.com/pocketbase/dbx v1.10.0
github.com/pocketbase/pocketbase v0.14.3
github.com/pocketbase/pocketbase v0.16.3
github.com/prometheus-community/pro-bing v0.1.0
github.com/robfig/cron/v3 v3.0.1
)
@@ -14,28 +14,28 @@ require (
require (
github.com/AlecAivazis/survey/v2 v2.3.6 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go v1.44.239 // indirect
github.com/aws/aws-sdk-go-v2 v1.17.8 // indirect
github.com/aws/aws-sdk-go v1.44.273 // indirect
github.com/aws/aws-sdk-go-v2 v1.18.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect
github.com/aws/aws-sdk-go-v2/config v1.18.20 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.19 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.2 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.61 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.32 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.26 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.33 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.24 // indirect
github.com/aws/aws-sdk-go-v2/config v1.18.25 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.24 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3 // indirect
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.67 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.25 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.27 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.26 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.1 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.31.2 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.12.7 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.7 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.18.8 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.28 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.27 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.2 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.33.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.12.10 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.19.0 // indirect
github.com/aws/smithy-go v1.13.5 // indirect
github.com/disintegration/imaging v1.6.2 // indirect
github.com/domodwyer/mailyak/v3 v3.5.0 // indirect
github.com/domodwyer/mailyak/v3 v3.6.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
@@ -46,51 +46,52 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/wire v0.5.0 // indirect
github.com/googleapis/gax-go/v2 v2.8.0 // indirect
github.com/googleapis/gax-go/v2 v2.10.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.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-isatty v0.0.18 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118 // indirect
github.com/mdlayher/packet v1.1.1 // indirect
github.com/mdlayher/socket v0.4.0 // indirect
github.com/mdlayher/packet v1.1.2 // indirect
github.com/mdlayher/socket v0.4.1 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/cobra v1.7.0 // 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.29.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/image v0.7.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.8.0 // indirect
golang.org/x/tools v0.9.2 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.116.0 // indirect
google.golang.org/api v0.125.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230403163135-c38d8f061ccd // indirect
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/grpc v1.55.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
lukechampine.com/uint128 v1.3.0 // indirect
modernc.org/cc/v3 v3.40.0 // indirect
modernc.org/ccgo/v3 v3.16.13 // indirect
modernc.org/libc v1.22.3 // indirect
modernc.org/libc v1.22.6 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.5.0 // indirect
modernc.org/opt v0.1.3 // indirect
modernc.org/sqlite v1.21.1 // indirect
modernc.org/sqlite v1.22.1 // indirect
modernc.org/strutil v1.1.3 // indirect
modernc.org/token v1.1.0 // indirect
)
+83 -295
View File
File diff suppressed because it is too large Load Diff
+325 -352
View File
File diff suppressed because it is too large Load Diff
+15 -15
View File
@@ -12,30 +12,30 @@
},
"devDependencies": {
"@sveltejs/adapter-static": "^1.0.6",
"@sveltejs/kit": "^1.15.2",
"@typescript-eslint/eslint-plugin": "^5.57.1",
"@typescript-eslint/parser": "^5.57.1",
"eslint": "^8.37.0",
"@sveltejs/kit": "^1.20.0",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-svelte3": "^4.0.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.1",
"prettier": "^2.8.7",
"prettier-plugin-svelte": "^2.10.0",
"svelte": "^3.58.0",
"svelte-preprocess": "^5.0.3",
"lint-staged": "^13.2.2",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1",
"svelte": "^3.59.1",
"svelte-preprocess": "^5.0.4",
"typescript": "^4.9.5",
"vite": "^4.2.1"
"vite": "^4.3.9"
},
"type": "module",
"dependencies": {
"@fortawesome/free-solid-svg-icons": "^6.4.0",
"@popperjs/core": "^2.11.7",
"bootstrap": "5.3.0-alpha1",
"date-fns": "^2.29.3",
"@popperjs/core": "^2.11.8",
"bootstrap": "5.3.0",
"date-fns": "^2.30.0",
"pocketbase": "^0.10.2",
"sass": "^1.61.0",
"svelte-fa": "^3.0.3"
"sass": "^1.62.1",
"svelte-fa": "^3.0.4"
},
"lint-staged": {
"*.{js,svelte}": "eslint --fix --ignore-path ../.gitignore .",
+320 -336
View File
File diff suppressed because it is too large Load Diff
-109
View File
@@ -10,17 +10,12 @@
let iconFiles = [];
let iconPreview;
let restoreFiles = [];
let timeout;
let buttons = {
settings: {
state: 'none',
error: ''
},
restore: {
state: 'none',
error: ''
},
scan: {
state: 'none',
error: ''
@@ -149,75 +144,6 @@
await $pocketbase.collection('devices').create(device);
$devices[device.id] = device;
}
async function restoreV2Backup() {
buttons.restore.state = 'waiting';
try {
// delete all devices in pocketbase
let result = await $pocketbase.collection('devices').getFullList();
for (let index = 0; index < result.length; index++) {
$pocketbase.collection('devices').delete(result[index].id);
}
// delete all ports in pocketbase
result = await $pocketbase.collection('ports').getFullList();
for (let index = 0; index < result.length; index++) {
await $pocketbase.collection('ports').delete(result[index].id);
}
let reader = new FileReader();
reader.readAsText(restoreFiles[0]);
reader.onload = async (e) => {
// parse uploaded file
let data = JSON.parse(e.target.result);
if (!Array.isArray(data)) {
return;
}
// loop devices
for (let index = 0; index < data.length; index++) {
const device = data[index];
// create ports
let thisDevicePorts = [];
for (let index = 0; index < device.ports.length; index++) {
const port = device.ports[index];
const record = await $pocketbase.collection('ports').create({
name: port.name,
number: port.number
});
thisDevicePorts.push(record.id);
}
// create device
await $pocketbase.collection('devices').create({
name: device.name,
ip: device.ip,
mac: device.mac,
netmask: device.netmask,
ports: thisDevicePorts,
link: device.link,
wake_cron: device.wake.cron,
wake_cron_enabled: device.wake.enabled,
shutdown_cron: device.shutdown.cron,
shutdown_cron_enabled: device.shutdown.cron.enabled,
shutdown_cmd: device.shutdown.command
});
}
};
setTimeout(() => {
buttons.restore.state = 'none';
}, 3000);
buttons.restore.state = 'success';
} catch (error) {
setTimeout(() => {
buttons.restore.error = '';
buttons.restore.state = 'none';
}, 3000);
buttons.restore.error = error;
buttons.restore.state = 'failed';
}
}
</script>
<div class="container">
@@ -429,41 +355,6 @@
</div>
{/if}
</section>
<section class="m-0 my-4 p-4 shadow-sm">
<h3 class="mb-3">Restore</h3>
<p>
If you had UpSnap &gt;=2.3.2 and &lt;3.0.0 running before, you can restore your devices
here.
</p>
<div class="callout callout-danger fw-bold">This will wipe the existing database!</div>
<input
class="form-control mb-3"
aria-label="Restore"
aria-describedby="Restore"
type="file"
accept=".json"
bind:files={restoreFiles}
/>
<button
type="button"
class="btn btn-secondary"
class:btn-success={buttons.restore.state === 'success' ? true : false}
class:btn-warning={buttons.restore.state === 'waiting' ? true : false}
class:btn-danger={buttons.restore.state === 'failed' ? true : false}
disabled={restoreFiles ? false : true}
on:click={() => restoreV2Backup()}
>
{#if buttons.restore.state === 'none'}
Restore
{:else if buttons.restore.state === 'success'}
Restored
{:else if buttons.restore.state === 'waiting'}
Waiting
{:else if buttons.restore.state === 'failed'}
Failed: {buttons.restore.error}
{/if}
</button>
</section>
<p class="m-0 my-4 p-4 text-center text-muted">
{#if version !== undefined}
UpSnap version: <a