forked from cory/tildefriends
Exposing setting the index page in the admin app and added a crude emoji picker, finally.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3966 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@@ -11,9 +11,22 @@ function delete_user(user) {
|
||||
}
|
||||
}
|
||||
|
||||
function global_settings_set(key, value) {
|
||||
tfrpc.rpc.global_settings_set(key, value).then(function() {
|
||||
alert(`Set "${key}" to "${value}".`);
|
||||
}).catch(function(error) {
|
||||
alert(`Failed to set "${key}": ${JSON.stringify(error, null, 2)}.`);
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener('load', function() {
|
||||
const permission_template = (permission) =>
|
||||
html` <code>${permission}</code>`;
|
||||
const input_template = (key, value) => html`
|
||||
<label ?for=${'gs_' + key}>${key}: </label>
|
||||
<input type="text" value="${value}" ?id=${'gs_' + key}></input>
|
||||
<button @click=${(e) => global_settings_set(key, e.srcElement.previousElementSibling.value)}>Set</button>
|
||||
`;
|
||||
const user_template = (user, permissions) => html`
|
||||
<li>
|
||||
<button @click=${(e) => delete_user(user)}>
|
||||
@@ -24,8 +37,15 @@ window.addEventListener('load', function() {
|
||||
</li>
|
||||
`;
|
||||
const users_template = (users) =>
|
||||
html`<ul>
|
||||
${users.map(u => user_template(u[0], u[1]))}
|
||||
html`<h2>Users</h2>
|
||||
<ul>
|
||||
${Object.entries(users).map(u => user_template(u[0], u[1]))}
|
||||
</ul>`;
|
||||
render(users_template(Object.entries(g_data.users)), document.body);
|
||||
const page_template = (data) =>
|
||||
html`<div>
|
||||
<h2>Global Settings</h2>
|
||||
${input_template('index', data.index)}
|
||||
${users_template(data.users)}
|
||||
</div>`;
|
||||
render(page_template(g_data), document.body);
|
||||
});
|
Reference in New Issue
Block a user