lighthouse score

This commit is contained in:
iou1name 2019-09-26 14:39:48 -04:00
parent 0cad501405
commit 4309d65c85
3 changed files with 12 additions and 12 deletions

View File

@ -44,16 +44,16 @@ async def index(request):
"SELECT * FROM user_credential WHERE user_id = $1",
request['session']['id'])
active_sessions = await conn.fetch(
"SELECT ip_address FROM user_session "
"SELECT id, ip_address FROM user_session "
"WHERE user_id = $1",
request['session']['id'])
if request['session']['admin']:
users = defaultdict(lambda: [False]*len(apps))
users = defaultdict(lambda: {app['name']: False for app in apps})
for user_perm in user_perms:
index = tools.find_dict(apps, 'id', user_perm['app_id'])
if index != -1:
users[user_perm['username']][index] = True
users[user_perm['username']][apps[index]['name']] = True
users_json = json.dumps(users)
return render_template("index.html", request, locals())

View File

@ -14,19 +14,19 @@ function load() {
function perm_change(row) {
let user_perms = users_perms[row.children[0].textContent];
let row_perms = [];
let row_perms = {};
for (let child of row.children) {
if (child.firstChild.type == "checkbox") {
if (child.firstChild.checked) {
row_perms.push(true);
row_perms[child.firstChild.dataset.appName] = true;
} else {
row_perms.push(false);
row_perms[child.firstChild.dataset.appName] = false;
}
}
}
let perms_changed = false;
for (let i = 0; i < user_perms.length; i++) {
if (user_perms[i] != row_perms[i]) {
for (let app_name of Object.keys(user_perms)) {
if (user_perms[app_name] != row_perms[app_name]) {
perms_changed = true;
}
}

View File

@ -47,8 +47,8 @@
{% for username, values in users.items() %}
<tr>
<td>{{ username }}</td>
{% for value in values %}
<td><input type="checkbox" onchange="perm_change(this.parentElement.parentElement)"{% if value %} checked{% endif %}></td>
{% 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>
</tr>
@ -89,7 +89,7 @@
{% for key in fido2_keys %}
<tr>
<td>{{ key['nick'] }}</td>
<td><input type="checkbox"></td>
<td><input aria-label="Delete {{ key['nick'] }}" id="fido-{{ key['id'] }}" name="fido-{{ key['id'] }}" type="checkbox"></td>
</tr>
{% endfor %}
</tbody>
@ -115,7 +115,7 @@
{% for session in active_sessions %}
<tr>
<td>{{ session['ip_address'] }}</td>
<td><input type="checkbox"></td>
<td><input aria-label="Delete {{ session['id'][:5] }}" id="session-{{ session['id'][:5] }}" name="session-{{ session['id'][:5] }}" type="checkbox"></td>
</tr>
{% endfor %}
</tbody>