working on user lost for admin

This commit is contained in:
2025-07-02 09:17:05 +02:00
parent 086f722074
commit 372cce43fa
7 changed files with 89 additions and 34 deletions

View File

@@ -17,11 +17,8 @@
function loadTheme(name){
if (!name) return;
console.log({theme:name});
const url = `${location.protocol}//${location.host.replace('5173','8080')}/css/${name}.css`;
fetch(url).then(resp => resp.text()).then(css => {
document.getElementById('usercss').innerText = css;
});
fetch(url).then(resp => resp.text()).then(css => document.getElementById('usercss').innerText = css);
}
$effect(() => loadTheme(user.theme));

View File

@@ -0,0 +1,44 @@
<script>
import { onMount } from 'svelte';
import { t } from '../../translations.svelte.js';
import { user } from '../../user.svelte.js';
let users = $state([]);
onMount(async () => {
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/user/list`;
const resp = await fetch(url,{credentials:'include'});
if (resp.ok){
const json = await resp.json();
for (let user of json) users.push(user);
}
});
</script>
<fieldset>
<legend>{t('user.list')}</legend>
<table>
<thead>
<tr>
<th>{t('user.id')}</th>
<th>{t('user.name')}</th>
<th>{t('user.email')}</th>
<th>{t('user.language')}</th>
<th>{t('user.actions')}</th>
</tr>
</thead>
<tbody>
{#each users as u,i}
<tr>
<td>{u.id}</td>
<td>{u.name}</td>
<td>{u.email}</td>
<td>{u.language}</td>
<td>
Check permissions, add button here
</td>
</tr>
{/each}
</tbody>
</table>
</fieldset>

View File

@@ -4,6 +4,7 @@
import ClickInput from '../../Components/ClickInput.svelte';
import ClickSelect from '../../Components/ClickSelect.svelte';
import EditPassword from './EditPassword.svelte';
import UserList from './List.svelte';
let editPassword = false;
async function patch(changeset){
@@ -92,9 +93,6 @@
</fieldset>
{#if user.permissions.includes('LIST_USERS')}
<fieldset>
<legend>{t('user.list')}</legend>
User list goes here…
</fieldset>
<UserList />
{/if}

View File

@@ -12,7 +12,7 @@ export function t(key,...args){
let keys = key.split('.');
for (let token of keys){
if (!set[token]){
console.log('Missing translation for '+key);
console.warn('Missing translation for '+key);
return keys[keys.length-1].replaceAll('_',' ');
}
set = set[token];

View File

@@ -4,7 +4,6 @@ export const user = $state({
})
export async function checkUser(){
console.log('checkUser()');
const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/user/whoami`;
const response = await fetch(url,{
credentials: 'include'