working on permissions and messages
This commit is contained in:
@@ -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>
|
||||
@@ -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){
|
||||
|
||||
Reference in New Issue
Block a user