Compare commits

..

6 Commits

Author SHA1 Message Date
Maxi Quoß 60837d2dd7 fix: remove btn margin 2023-08-21 20:21:06 +02:00
Maxi Quoß 59f1bf3f9c fix: re-add forgotten oidc login #103 2023-08-21 20:17:54 +02:00
Maxi Quoß 448dcbd16c fix: put more buttons into array 2023-08-21 17:35:16 +02:00
dependabot[bot] 88d8a4b952 npm-dep: bump tslib from 2.6.1 to 2.6.2 in /frontend
Bumps [tslib](https://github.com/Microsoft/tslib) from 2.6.1 to 2.6.2.
- [Release notes](https://github.com/Microsoft/tslib/releases)
- [Commits](https://github.com/Microsoft/tslib/compare/v2.6.1...v2.6.2)

---
updated-dependencies:
- dependency-name: tslib
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-21 09:44:39 +00:00
seriousm4x d7b4ef75de remove tailing dots on toast messages 2023-08-19 00:23:07 +02:00
seriousm4x 84deb379e7 fix: break device name line on small screens 2023-08-19 00:17:37 +02:00
9 changed files with 91 additions and 32 deletions
+1 -1
View File
@@ -29,7 +29,7 @@
"svelte": "^4.2.0",
"svelte-check": "^3.5.0",
"tailwindcss": "^3.3.3",
"tslib": "^2.6.1",
"tslib": "^2.6.2",
"typescript": "^5.1.6",
"vite": "^4.4.9"
},
+4 -4
View File
@@ -74,8 +74,8 @@ devDependencies:
specifier: ^3.3.3
version: 3.3.3
tslib:
specifier: ^2.6.1
version: 2.6.1
specifier: ^2.6.2
version: 2.6.2
typescript:
specifier: ^5.1.6
version: 5.1.6
@@ -3014,10 +3014,10 @@ packages:
}
dev: true
/tslib@2.6.1:
/tslib@2.6.2:
resolution:
{
integrity: sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==
integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==
}
dev: true
+37 -13
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { pocketbase, isAdmin, backendUrl, permission } from '$lib/stores/pocketbase';
import DeviceCardNic from './DeviceCardNic.svelte';
import Fa from 'svelte-fa';
@@ -17,6 +18,33 @@
export let device: Device;
let moreButtons = [
{
text: 'Edit',
icon: faPen,
onClick: () => goto(`/device/${device.id}`),
requires: $isAdmin || $permission.update?.includes(device.id)
},
{
text: 'Sleep',
icon: faBed,
onClick: () => sleep(),
requires:
($isAdmin || $permission.power?.includes(device.id)) &&
device.status === 'online' &&
device.sol_enabled
},
{
text: 'Reboot',
icon: faRotateLeft,
onClick: () => reboot(),
requires:
($isAdmin || $permission.power?.includes(device.id)) &&
device.status === 'online' &&
device.shutdown_cmd !== ''
}
];
// update device status change
let now = Date.now();
let interval: number;
@@ -91,7 +119,7 @@
addSuffix: true
})}
</span>
{#if $isAdmin || $permission.update?.includes(device.id) || $permission.power?.includes(device.id)}
{#if moreButtons.filter((btn) => btn.requires).length > 0}
<div class="dropdown dropdown-top dropdown-end bg-base-300 ms-auto">
<label tabindex="-1" class="btn btn-sm m-1" for="more-{device.id}">More</label>
<ul
@@ -99,19 +127,15 @@
tabindex="-1"
class="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-fit"
>
{#if ($isAdmin || $permission.power?.includes(device.id)) && device.status === 'online'}
{#if device.shutdown_cmd !== ''}
<li><button on:click={() => reboot()}><Fa icon={faRotateLeft} />Reboot</button></li>
{#each moreButtons as btn}
{#if btn.requires}
<li>
<button on:click={btn.onClick}>
<Fa icon={btn.icon} />{btn.text}
</button>
</li>
{/if}
{#if device.sol_enabled}
<li><button on:click={() => sleep()}><Fa icon={faBed} />Sleep</button></li>
{/if}
{/if}
{#if $isAdmin || $permission.update?.includes(device.id)}
<li>
<a href="/device/{device.id}"><Fa icon={faPen} />Edit</a>
</li>
{/if}
{/each}
</ul>
</div>
{/if}
+1 -1
View File
@@ -33,7 +33,7 @@
$pocketbase.collection('permissions').subscribe('*', (event) => {
permission.set(event.record as Permission);
toast.success('Your permissions have been updated.');
toast.success('Your permissions have been updated');
});
}
});
+3 -3
View File
@@ -27,7 +27,7 @@
$pocketbase.admins
.update($pocketbase.authStore.model.id, { avatar: newAvatar })
.then(() => {
toast.success('Avatar saved.');
toast.success('Avatar saved');
})
.catch((err) => {
toast.error(err.message);
@@ -38,7 +38,7 @@
.collection('users')
.update($pocketbase.authStore.model.id, { avatar: newAvatar })
.then(() => {
toast.success('Avatar saved.');
toast.success('Avatar saved');
})
.catch((err) => {
toast.error(err.message);
@@ -70,7 +70,7 @@
if (j?.data?.password?.message) {
toast.error(j?.data?.password?.message);
} else if (j?.data?.passwordConfirm?.message) {
toast.error("Passwords don't match.");
toast.error("Passwords don't match");
} else if (j.data?.oldPassword?.message) {
toast.error(j.data.oldPassword.message);
} else {
+1 -1
View File
@@ -33,7 +33,7 @@
{#await getDevice()}
<PageLoading />
{:then device}
<h1 class="text-3xl font-bold mb-8">{device.name}</h1>
<h1 class="text-3xl font-bold mb-8 sm:break-all">{device.name}</h1>
<DeviceForm {device} />
{:catch err}
<div class="container max-w-lg mx-auto">
+38 -3
View File
@@ -3,7 +3,7 @@
import { pocketbase, isAdmin } from '$lib/stores/pocketbase';
import { settingsPub } from '$lib/stores/settings';
import Fa from 'svelte-fa';
import { faLockOpen, faEye } from '@fortawesome/free-solid-svg-icons';
import { faLockOpen, faEye, faQuestionCircle } from '@fortawesome/free-solid-svg-icons';
import { toggleVisibility } from '$lib/helpers/forms';
import toast from 'svelte-french-toast';
import { onMount } from 'svelte';
@@ -40,6 +40,21 @@
});
});
}
function loginOIDC() {
$pocketbase
.collection('users')
.authWithOAuth2({ provider: 'oidc' })
.then(() => {
isAdmin.set(true);
goto('/');
})
.catch((err) => {
console.log(err);
toast.error(err.message);
});
}
</script>
<div class="mt-10 flex items-center justify-center">
@@ -85,8 +100,28 @@
bind:this={inputPassword}
/>
</label>
<div class="card-actions justify-end mt-4">
<button class="btn btn-primary" type="submit">Login <Fa icon={faLockOpen} /></button>
<div class="card-actions mt-4">
<div class="dropdown">
<label tabindex="-1" class="btn btn-neutral" for="other-providers">Other</label>
<ul
id="other-providers"
tabindex="-1"
class="dropdown-content z-[1] menu p-2 shadow bg-base-200 rounded-box w-56"
>
<li class="menu-title flex flex-row gap-2 items-center">
Other Auth Providers <a
href="https://github.com/seriousm4x/UpSnap/wiki/Auth-providers"
target="_blank"><Fa icon={faQuestionCircle} /></a
>
</li>
<li>
<button type="button" on:click={loginOIDC}>OIDC 1</button>
</li>
</ul>
</div>
<button class="btn btn-primary ms-auto" type="submit"
>Login <Fa icon={faLockOpen} /></button
>
</div>
</form>
</div>
+5 -5
View File
@@ -58,7 +58,7 @@
.collection('users')
.create(newUser)
.then((data) => {
toast.success(`User ${data.username} created.`);
toast.success(`User ${data.username} created`);
newUser.username = '';
newUser.password = '';
newUser.passwordConfirm = '';
@@ -74,14 +74,14 @@
.collection('users')
.delete(user.id)
.then(async () => {
toast.success(`User ${user.username} deleted.`);
toast.success(`User ${user.username} deleted`);
let permission = permissions.find((perm) => perm.user === user.id);
if (permission?.id !== undefined) {
await $pocketbase
.collection('permissions')
.delete(permission.id)
.then(() => {
toast.success(`Permissions for ${user.username} deleted.`);
toast.success(`Permissions for ${user.username} deleted`);
})
.catch((err) => {
toast.error(err.message);
@@ -130,7 +130,7 @@
// if (i > -1) {
// permissions[i] = data as Permission;
// }
toast.success(`Permissions for ${user.username} created.`);
toast.success(`Permissions for ${user.username} created`);
reload();
})
.catch((err) => {
@@ -142,7 +142,7 @@
.collection('permissions')
.update(permission.id, permission)
.then(() => {
toast.success(`Permissions for ${user.username} updated.`);
toast.success(`Permissions for ${user.username} updated`);
reload();
})
.catch((err) => {
+1 -1
View File
@@ -46,7 +46,7 @@
})
.catch((err) => {
if (err.data?.data?.passwordConfirm?.message) {
toast.error("Passwords don't match.");
toast.error("Passwords don't match");
} else if (err.data?.data?.email?.message) {
toast.error(err.data.data.email.message);
} else {