ssb: The block list can be crudely managed through the admin app.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 8m54s

This commit is contained in:
2025-11-29 11:33:16 -05:00
parent fa4ef3b082
commit bc3fd57d7a
7 changed files with 123 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
{
"type": "tildefriends-app",
"emoji": "🎛",
"previous": "&kmKNyb/uaXNb24gCinJtfS8iWx4cLUWdtl0y2DwEUas=.sha256"
"previous": "&bRhS1LQIH8WQjbBfQqdhjLv7tqDdHT7IEPyCmj39b+4=.sha256"
}

View File

@@ -8,12 +8,20 @@ tfrpc.register(function global_settings_set(key, value) {
return core.globalSettingsSet(key, value);
});
tfrpc.register(function addBlock(id) {
return ssb.addBlock(id);
});
tfrpc.register(function removeBlock(id) {
return ssb.removeBlock(id);
});
async function main() {
try {
let data = {
users: {},
granted: await core.allPermissionsGranted(),
settings: await core.globalSettingsDescriptions(),
blocks: await ssb.getBlocks(),
};
for (let user of await core.users()) {
data.users[user] = await core.permissionsForUser(user);

View File

@@ -16,6 +16,14 @@ function delete_user(user) {
}
}
async function add_block() {
await tfrpc.rpc.addBlock(document.getElementById('add_block').value);
}
async function remove_block(id) {
await tfrpc.rpc.removeBlock(id);
}
function global_settings_set(key, value) {
tfrpc.rpc
.global_settings_set(key, value)
@@ -94,11 +102,32 @@ ${description.value}</textarea
${user}: ${permissions.map((x) => permission_template(x))}
</li>
`;
const block_template = (block) => html`
<li class="w3-card w3-margin">
<button
class="w3-button w3-theme-action"
@click=${(e) => remove_block(block.id)}
>
Delete
</button>
<code>${block.id}</code>
${new Date(block.timestamp)}
</li>
`;
const users_template = (users) =>
html` <header class="w3-container w3-theme-l2"><h2>Users</h2></header>
<ul class="w3-ul">
${Object.entries(users).map((u) => user_template(u[0], u[1]))}
</ul>`;
const blocks_template = (blocks) =>
html` <header class="w3-container w3-theme-l2"><h2>Blocks</h2></header>
<div class="w3-row w3-margin">
<input type="text" class="w3-threequarter w3-input" id="add_block"></input>
<button class="w3-quarter w3-button w3-theme-action" @click=${add_block}>Add</button>
</div>
<ul class="w3-ul">
${blocks.map((b) => block_template(b))}
</ul>`;
const page_template = (data) =>
html`<div style="padding: 0; margin: 0; width: 100%; max-width: 100%">
<header class="w3-container w3-theme-l2"><h2>Global Settings</h2></header>
@@ -109,7 +138,7 @@ ${description.value}</textarea
.map((x) => html`${input_template(x, data.settings[x])}`)}
</ul>
</div>
${users_template(data.users)}
${users_template(data.users)} ${blocks_template(data.blocks)}
</div> `;
render(page_template(g_data), document.body);
});