mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
WIP
This commit is contained in:
parent
ddcb9ed0cc
commit
d6c810fd34
5 changed files with 142 additions and 1 deletions
28
static/manage-edit-group.html
Normal file
28
static/manage-edit-group.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Edit group</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="/common.css">
|
||||
<link rel="stylesheet" type="text/css" href="/galene.css"/>
|
||||
<link rel="author" href="https://www.irif.fr/~jch/"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1 id="title" class="navbar-brand">Edit group</h1>
|
||||
|
||||
<div id="description"></div>
|
||||
|
||||
<div id="users"></div>
|
||||
|
||||
<div id="tokens"></div>
|
||||
|
||||
<p id="message"></p>
|
||||
|
||||
<p id="errormessage"></p>
|
||||
|
||||
<script src="/management.js" defer></script>
|
||||
<script src="/manage-edit-group.js" defer></script>
|
||||
</body>
|
||||
</html>
|
41
static/manage-edit-group.js
Normal file
41
static/manage-edit-group.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
async function doit(group) {
|
||||
let de = await getGroup(group);
|
||||
let d = document.getElementById('description');
|
||||
for(let k in de.data) {
|
||||
let p = document.createElement('p');
|
||||
p.textContent = `${k}: ${de.data[k]}`;
|
||||
d.appendChild(p);
|
||||
}
|
||||
|
||||
let users = await listUsers(group);
|
||||
let u = document.getElementById('users');
|
||||
for(let i = 0; i < users.length; i++) {
|
||||
let username = users[i];
|
||||
let ut = await getUser(group, username, false);
|
||||
let p = document.createElement('p');
|
||||
p.textContent = `${username} ${ut.data.permissions}`
|
||||
u.appendChild(p);
|
||||
}
|
||||
|
||||
let tokens = await listTokens(group);
|
||||
let t = document.getElementById('tokens');
|
||||
for(let i = 0; i < tokens.length; i++) {
|
||||
let token = tokens[i];
|
||||
let tt = await getToken(group, token);
|
||||
let p = document.createElement('p');
|
||||
p.textContent = `${token} ${tt.expires || '(no expiration)'}`
|
||||
t.appendChild(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function displayError(message) {
|
||||
document.getElementById('errormessage').textContent = (message || '');
|
||||
}
|
||||
|
||||
let parms = new URLSearchParams(window.location.search);
|
||||
if(!parms.has('group')) {
|
||||
displayError('Unknown group');
|
||||
} else {
|
||||
doit(parms.get('group')).catch(displayError);
|
||||
}
|
24
static/manage-groups.html
Normal file
24
static/manage-groups.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Manage groups</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="/common.css">
|
||||
<link rel="stylesheet" type="text/css" href="/galene.css"/>
|
||||
<link rel="author" href="https://www.irif.fr/~jch/"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1 id="title" class="navbar-brand">Manage groups</h1>
|
||||
|
||||
<div id="groups"></div>
|
||||
|
||||
<p id="message"></p>
|
||||
|
||||
<p id="errormessage"></p>
|
||||
|
||||
<script src="/management.js" defer></script>
|
||||
<script src="/manage-groups.js" defer></script>
|
||||
</body>
|
||||
</html>
|
46
static/manage-groups.js
Normal file
46
static/manage-groups.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
async function doit() {
|
||||
let groups = await listGroups();
|
||||
let s = document.getElementById('groups');
|
||||
for(let i = 0; i < groups.length; i++) {
|
||||
let group = groups[i];
|
||||
let e = document.createElement('button');
|
||||
e.textContent = "Edit";
|
||||
e.onclick = e => {
|
||||
e.preventDefault();
|
||||
editHandler(group);
|
||||
}
|
||||
let d = document.createElement('button');
|
||||
d.textContent = "Delete";
|
||||
d.onclick = e => {
|
||||
e.preventDefault();
|
||||
deleteHandler(group);
|
||||
}
|
||||
let p = document.createElement('p');
|
||||
p.textContent = group;
|
||||
p.appendChild(e);
|
||||
p.appendChild(d);
|
||||
s.appendChild(p);
|
||||
}
|
||||
}
|
||||
|
||||
function editHandler(group) {
|
||||
document.location.href = `/manage-edit-group.html?group=${encodeURI(group)}`
|
||||
}
|
||||
|
||||
async function deleteHandler(group) {
|
||||
let ok = confirm(`Do you want to delete group ${group}?`);
|
||||
if(ok) {
|
||||
try {
|
||||
await deleteGroup(group);
|
||||
location.reload();
|
||||
} catch(e) {
|
||||
displayError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function displayError(message) {
|
||||
document.getElementById('errormessage').textContent = (message || '');
|
||||
}
|
||||
|
||||
doit().catch(displayError);
|
|
@ -15,6 +15,8 @@
|
|||
"files": [
|
||||
"protocol.js",
|
||||
"galene.js",
|
||||
"management.js"
|
||||
"management.js",
|
||||
"manage-groups.js",
|
||||
"manage-edit-group.js"
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue