Compare commits

..

4 Commits

Author SHA1 Message Date
Maxi Quoß 0efd8a8674 update lock file 2025-05-16 10:19:02 +02:00
Maxi Quoß 1bf01cadc7 fix: only clear auth on 401 or 403, close #1158 2025-05-16 10:18:34 +02:00
dependabot[bot] 1bd2f64729 npm-dep: bump svelte-check from 4.1.7 to 4.2.0 in /frontend
Bumps [svelte-check](https://github.com/sveltejs/language-tools) from 4.1.7 to 4.2.0.
- [Release notes](https://github.com/sveltejs/language-tools/releases)
- [Commits](https://github.com/sveltejs/language-tools/compare/svelte-check-4.1.7...svelte-check-4.2.0)

---
updated-dependencies:
- dependency-name: svelte-check
  dependency-version: 4.2.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-15 09:40:58 +00:00
Maxi Quoß 58971d0e66 fix: countdown would not show after login 2025-05-14 11:53:32 +02:00
5 changed files with 53 additions and 39 deletions
+1 -1
View File
@@ -32,7 +32,7 @@
"prettier-plugin-svelte": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.11",
"svelte": "^5.28.6",
"svelte-check": "^4.1.7",
"svelte-check": "^4.2.0",
"tailwindcss": "^4.1.6",
"tslib": "^2.8.1",
"typescript": "^5.8.3",
+5 -5
View File
@@ -87,8 +87,8 @@ importers:
specifier: ^5.28.6
version: 5.28.6
svelte-check:
specifier: ^4.1.7
version: 4.1.7(picomatch@4.0.2)(svelte@5.28.6)(typescript@5.8.3)
specifier: ^4.2.0
version: 4.2.0(picomatch@4.0.2)(svelte@5.28.6)(typescript@5.8.3)
tailwindcss:
specifier: ^4.1.6
version: 4.1.6
@@ -2728,10 +2728,10 @@ packages:
}
engines: { node: '>=8' }
svelte-check@4.1.7:
svelte-check@4.2.0:
resolution:
{
integrity: sha512-1jX4BzXrQJhC/Jt3SqYf6Ntu//vmfc6VWp07JkRfK2nn+22yIblspVUo96gzMkg0Zov8lQicxhxsMzOctwcMQQ==
integrity: sha512-79ozTLjGBQ2R5PvZ7enSYBsMyY1fy3pwQ/N1BtuTVXtQRH9Vc10eV66LePV52t1ZlflZBTkIGz79cStPnCUEEQ==
}
engines: { node: '>= 18.0.0' }
hasBin: true
@@ -4492,7 +4492,7 @@ snapshots:
dependencies:
has-flag: 4.0.0
svelte-check@4.1.7(picomatch@4.0.2)(svelte@5.28.6)(typescript@5.8.3):
svelte-check@4.2.0(picomatch@4.0.2)(svelte@5.28.6)(typescript@5.8.3):
dependencies:
'@jridgewell/trace-mapping': 0.3.25
chokidar: 4.0.3
@@ -11,7 +11,7 @@
let hoverText = '';
let disabled = false;
let timeout = 120;
var interval: number;
let interval: number;
let modalWake: HTMLDialogElement;
let modalShutdown: HTMLDialogElement;
@@ -45,6 +45,9 @@
}
function wake() {
countdown(Date.now(), 'wake');
device.status = 'pending';
fetch(`${backendUrl}api/upsnap/wake/${device.id}`, {
headers: {
Authorization: $pocketbase.authStore.token
@@ -52,8 +55,11 @@
})
.then((resp) => resp.json())
.then(async (data) => {
if (data.status !== 200) {
device.status = 'offline';
return;
}
device = data as Device;
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');
@@ -68,15 +74,21 @@
}
function shutdown() {
countdown(Date.now(), 'shutdown');
device.status = 'pending';
fetch(`${backendUrl}api/upsnap/shutdown/${device.id}`, {
headers: {
Authorization: $pocketbase.authStore.token
}
})
.then((resp) => resp.json())
.then((data) => {
.then(async (data) => {
if (data.status !== 200) {
device.status = 'online';
return;
}
device = data as Device;
countdown(Date.parse(device.updated), 'shutdown');
})
.catch((err) => {
toast.error(err.message);
@@ -84,33 +96,26 @@
}
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;
}
timeout = action === 'wake' ? device.wake_timeout : device.shutdown_timeout;
if (timeout <= 0) {
timeout = 120;
}
const end = updated + timeout * 1000;
const end = updated + timeout * 1000;
if (interval) {
clearInterval(interval);
interval = 0;
}
if (interval) {
clearInterval(interval);
interval = 0;
}
interval = setInterval(() => {
timeout = Math.round((end - Date.now()) / 1000);
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);
if (timeout <= 0 || device.status !== 'pending') {
clearInterval(interval);
interval = 0;
}
});
}, 1000);
}
function handleClick() {
+16 -6
View File
@@ -59,17 +59,27 @@
await $pocketbase
.collection('_superusers')
.authRefresh()
.catch(() => {
$pocketbase.authStore.clear();
goto('/login');
.catch((err) => {
// clear the store only on invalidated/expired token
const status = err?.status << 0;
if (status == 401 || status == 403) {
$pocketbase.authStore.clear();
goto('/login');
} else {
console.log('NOT CLEARED');
}
});
} else {
await $pocketbase
.collection('users')
.authRefresh()
.catch(() => {
$pocketbase.authStore.clear();
goto('/login');
.catch((err) => {
// clear the store only on invalidated/expired token
const status = err?.status << 0;
if (status == 401 || status == 403) {
$pocketbase.authStore.clear();
goto('/login');
}
});
}
});
-1
View File
@@ -41,7 +41,6 @@
localStorage.setItem('orderByGroups', String(orderByGroups));
}
onMount(() => {});
const filteredDevices = () =>
devices.filter(
(dev) =>