From 917974676353a799ae46e51e1ba320a9af226fc1 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Sat, 5 Aug 2023 01:22:27 +0000 Subject: [PATCH] Freaking CSS. Trying to make the admin page...work. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4385 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- apps/admin/app.js | 20 ++++++++++------- apps/admin/index.html | 4 ++-- apps/admin/script.js | 51 +++++++++++++++++++++++++------------------ 3 files changed, 44 insertions(+), 31 deletions(-) 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