working on permissions and messages

This commit is contained in:
2025-07-02 23:41:04 +02:00
parent 5100ac244a
commit caf2356f48
4 changed files with 17 additions and 11 deletions

View File

@@ -13,6 +13,7 @@
let options = $state([]);
let sent = $state(false);
let caption = $state(t('user.save_user'));
let message = $state(t('user.loading_data'));
onMount(async () => {
let url = `${location.protocol}//${location.host.replace('5173','8080')}/themes.json`;
@@ -28,7 +29,12 @@
url = `${location.protocol}//${location.host.replace('5173','8080')}/api/user/${user_id}`;
resp = await fetch(url,{credentials:'include'});
if (resp.ok) editUser = await resp.json();
if (resp.ok) {
editUser = await resp.json();
} else {
message = await resp.text();
if (message == "") message = t(resp);
}
});
async function save(elem){
@@ -97,6 +103,6 @@
</table>
<button onclick={save} disabled={sent}>{caption}</button>
{:else}
{t('user.loading_data')}
{message}
{/if}
</fieldset>

View File

@@ -8,6 +8,7 @@ export async function loadTranslation(lang){
}
export function t(key,...args){
if (key instanceof Response) key = 'status.'+key.status;
let set = translations.values;
let keys = key.split('.');
for (let token of keys){