Add or delete user

This commit is contained in:
echarp 2022-11-16 22:47:33 +01:00
parent e2496cf17d
commit f1dd0bac0f
7 changed files with 43 additions and 15 deletions

View File

@ -5,6 +5,16 @@ ServerSignature Off
Protocols h2 h2c http/1.1
DocumentRoot /var/simpleWeb/apps/acoeur/public
<Location /author>
Require all granted
# Send back all headers, most importantly the eventual "authorization" one
Header always echo
# Do not send a 404
Redirect 204 /
# For development
Header always set authorization "test"
</Location>
</VirtualHost>
<VirtualHost *:80>

View File

@ -1,6 +1,7 @@
title: moteur acoeur
languageCode: fr
theme: [acoeur, ananke]
baseURL: http://acoeur
DefaultContentLanguage: fr
enableRobotsTXT: true

View File

@ -1,5 +1,5 @@
* {
transition: box-shadow 1s;
transition: all 1s;
}
.breadcrumb {
@ -36,6 +36,10 @@ dd {
font-weight: bold;
}
body.choosing {
background-color: black;
}
body [contenteditable]:hover,
body [contenteditable]:focus,
body #content:hover,
@ -46,9 +50,8 @@ body #content:focus {
background-color: rgba(255, 255, 255, 0.5);
}
body.invitations .ac_choices {
display: none;
}
.author-only { display: none; }
body.author .author-only { display: initial; }
body.author .ac_choices .destination {
display: none;
position: relative;

View File

@ -9,14 +9,16 @@ document.querySelectorAll('aside#actions #create')
})
document.querySelectorAll('aside#actions #delete')
.forEach(elt => elt.onclick = () =>
fetch(document.body.dataset.editUrl.replace('/_index', '.delete'), { method: 'PUT' })
.then(() => sleep(1))
.then(() => window.location.assign('/' + topSection))
.catch(error => console.error(`Error deleting #{topSection}`, error)))
.forEach(elt => elt.onclick = () => {
if (confirm(elt.dataset.confirm))
fetch(document.body.dataset.editUrl.replace('/_index', '.delete'), { method: 'PUT' })
.then(() => sleep(1))
.then(() => window.location.assign('/' + topSection))
.catch(error => console.error(`Error deleting #{topSection}`, error))
})
document.querySelectorAll('body.assets aside#actions input#file')
document.querySelectorAll('aside#actions input#file')
.forEach(elt => elt.onchange = () =>
[...elt.files].forEach(file =>
fetch(document.body.dataset.editUrl.replace('_index', file.name), { method: 'PUT', body: file })

View File

@ -1,13 +1,12 @@
const resultUrl = '/users/' + window.location.pathname.split('/')[2]
document.querySelectorAll('body.users .ac_choice input[type=radio]')
.forEach(elt =>
elt.onchange = () => fetch(document.body.dataset.editUrl + '.choice', {
method: 'PUT',
body: new URLSearchParams(new FormData(elt.form))
})
.then(() => document.body.classList.add('choosing'))
.then(() => sleep(1))
.then(() => fetch(document.body.dataset.editUrl + '.result'))
.then(response => response.text())
.then(result => window.location.assign(resultUrl + result))
.then(result => window.location.assign('/users/' + window.location.pathname.split('/')[2] + result))
.catch(error => console.error('Error sending answer', error)))

View File

@ -8,6 +8,7 @@ pages:
users:
create: Créer un nouvel utilisateur
delete: Supprimer utilisateur
send: Envoyer invitation
assets:
create: Transmettre une image
delete: 🗑

View File

@ -2,9 +2,21 @@
<article class="pa3 pa4-ns nested-copy-line-height">
<aside id="actions" class="w-30-l mt4-l fr tc">
{{ if .Parent.IsHome }}
<button id="create" class="br-pill pa3 pointer">{{ T (print .Section ".create") }}</button>
<button id="create"
class="br-pill f6 link dim br3 ph3 pv2 mb2 dib white bg-dark-gray pointer">
{{ T (print .Section ".create") }}
</button>
{{ else if .Parent.Parent.IsHome }}
<button id="delete" class="br-pill pa3 pointer">{{ T (print .Section ".delete") }}</button>
<button id="delete"
class="br-pill f6 link dim br3 ph3 pv2 mb2 dib white bg-dark-gray pointer author-only"
data-confirm="{{ T (print .Section ".delete") }}?">
{{ T (print .Section ".delete") }}
</button>
<a href="mailto:?subject=invitation&body={{.Permalink}}"
class="br-pill f6 link dim br3 ph3 pv2 mb2 dib white bg-dark-gray author-only">
{{ T (print .Section ".send") }}
</a>
{{ end }}
</aside>