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 Protocols h2 h2c http/1.1
DocumentRoot /var/simpleWeb/apps/acoeur/public 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>
<VirtualHost *:80> <VirtualHost *:80>

View File

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

View File

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

View File

@ -9,14 +9,16 @@ document.querySelectorAll('aside#actions #create')
}) })
document.querySelectorAll('aside#actions #delete') document.querySelectorAll('aside#actions #delete')
.forEach(elt => elt.onclick = () => .forEach(elt => elt.onclick = () => {
fetch(document.body.dataset.editUrl.replace('/_index', '.delete'), { method: 'PUT' }) if (confirm(elt.dataset.confirm))
.then(() => sleep(1)) fetch(document.body.dataset.editUrl.replace('/_index', '.delete'), { method: 'PUT' })
.then(() => window.location.assign('/' + topSection)) .then(() => sleep(1))
.catch(error => console.error(`Error deleting #{topSection}`, error))) .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 = () => .forEach(elt => elt.onchange = () =>
[...elt.files].forEach(file => [...elt.files].forEach(file =>
fetch(document.body.dataset.editUrl.replace('_index', file.name), { method: 'PUT', body: 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]') document.querySelectorAll('body.users .ac_choice input[type=radio]')
.forEach(elt => .forEach(elt =>
elt.onchange = () => fetch(document.body.dataset.editUrl + '.choice', { elt.onchange = () => fetch(document.body.dataset.editUrl + '.choice', {
method: 'PUT', method: 'PUT',
body: new URLSearchParams(new FormData(elt.form)) body: new URLSearchParams(new FormData(elt.form))
}) })
.then(() => document.body.classList.add('choosing'))
.then(() => sleep(1)) .then(() => sleep(1))
.then(() => fetch(document.body.dataset.editUrl + '.result')) .then(() => fetch(document.body.dataset.editUrl + '.result'))
.then(response => response.text()) .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))) .catch(error => console.error('Error sending answer', error)))

View File

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

View File

@ -2,9 +2,21 @@
<article class="pa3 pa4-ns nested-copy-line-height"> <article class="pa3 pa4-ns nested-copy-line-height">
<aside id="actions" class="w-30-l mt4-l fr tc"> <aside id="actions" class="w-30-l mt4-l fr tc">
{{ if .Parent.IsHome }} {{ 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 }} {{ 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 }} {{ end }}
</aside> </aside>