submit user perms

This commit is contained in:
iou1name 2019-10-17 13:38:40 -04:00
parent c0df27cf96
commit 7ed42e017e
2 changed files with 22 additions and 1 deletions

View File

@ -37,3 +37,22 @@ function perm_change(row) {
}
console.log("perms_changed = " + perms_changed);
}
function submit_user_perms(row) {
let row_perms = {};
for (let child of row.children) {
if (child.firstChild.type == "checkbox") {
if (child.firstChild.checked) {
row_perms[child.firstChild.dataset.appName] = true;
} else {
row_perms[child.firstChild.dataset.appName] = false;
}
}
}
console.log(row_perms);
fetch(window.location.pathname, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: row_perms
});
}

View File

@ -32,6 +32,7 @@
<section>
<h2>Admin Panel</h2>
<article style="display: none;">
<hr>
<section class="sub_section">
<h3>User Permissions</h3>
<article style="display: none;">
@ -53,13 +54,14 @@
{% for name, value in values.items() %}
<td><input aria-label="{{ username }}-{{ name }}" data-app-name={{ name }} type="checkbox" onchange="perm_change(this.parentElement.parentElement)"{% if value %} checked{% endif %}></td>
{% endfor %}
<td><input type="submit"></td>
<td><input type="submit" value="Save" onclick="submit_user_perms(this.parentElement.parentElement)"></td>
</tr>
{% endfor %}
</tbody>
</table>
</article>
</section>
<br>
<section class="sub_section">
<h3>Invite New User</h3>
<article style="display: none;">