diff --git a/apps/admin/app.js b/apps/admin/app.js index 6cc76dea..0a1c35e8 100644 --- a/apps/admin/app.js +++ b/apps/admin/app.js @@ -9,14 +9,18 @@ tfrpc.register(function global_settings_set(key, value) { }); async function main() { - let data = { - users: {}, - granted: await core.allPermissionsGranted(), - settings: await core.globalSettingsDescriptions(), - }; - for (let user of await core.users()) { - data.users[user] = await core.permissionsForUser(user); + try { + let data = { + users: {}, + granted: await core.allPermissionsGranted(), + settings: await core.globalSettingsDescriptions(), + }; + for (let user of await core.users()) { + data.users[user] = await core.permissionsForUser(user); + } + await app.setDocument(utf8Decode(getFile('index.html')).replace('$data', JSON.stringify(data))); + } catch { + await app.setDocument('Only an administrator can modify these settings.'); } - await app.setDocument(utf8Decode(getFile('index.html')).replace('$data', JSON.stringify(data))); } main(); \ No newline at end of file diff --git a/apps/admin/index.html b/apps/admin/index.html index fea8a6cb..eabbf708 100644 --- a/apps/admin/index.html +++ b/apps/admin/index.html @@ -1,9 +1,9 @@ - + - +

Tilde Friends Administration

diff --git a/apps/admin/script.js b/apps/admin/script.js index 858a6de4..584db890 100644 --- a/apps/admin/script.js +++ b/apps/admin/script.js @@ -25,29 +25,37 @@ window.addEventListener('load', function() { function input_template(key, description) { if (description.type === 'boolean') { return html` - - -
- - ${description.description} +
+ +
+ + +
${description.description}
+
`; } else if (description.type === 'textarea') { return html` - - -
- - ${description.description} +
+ +
+
+ +
+ +
${description.description}
+
`; } else { return html` - - -
- - ${description.description} +
+ +
+ + +
${description.description}
+
`; } @@ -67,12 +75,13 @@ window.addEventListener('load', function() { ${Object.entries(users).map(u => user_template(u[0], u[1]))} `; const page_template = (data) => - html`
-

Global Settings

-
- ${Object.keys(data.settings).sort().map(x => html`${input_template(x, data.settings[x])}`)} + html`
+

Global Settings

+
+ ${Object.keys(data.settings).sort().map(x => html`${input_template(x, data.settings[x])}`)} +
+ ${users_template(data.users)}
- ${users_template(data.users)} -
`; + `; render(page_template(g_data), document.body); }); \ No newline at end of file