aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorJulian Hurst <ark@mansus.space>2023-01-25 01:23:58 +0100
committerJulian Hurst <ark@mansus.space>2023-01-25 01:23:58 +0100
commitf416775268085c7fb7f90cf54ea2149267b960e6 (patch)
treed7e38e94795368f39cda882cd61c16b01eb56dd3 /templates
parente7a3649280d20d9b4f68572721684a01049ec40f (diff)
downloaddocspace-f416775268085c7fb7f90cf54ea2149267b960e6.tar.gz
Add user impersonation support for admins
Diffstat (limited to 'templates')
-rw-r--r--templates/createuser.html2
-rw-r--r--templates/imgs.html8
-rw-r--r--templates/imgs_page.html6
-rw-r--r--templates/nav_logged.html5
-rw-r--r--templates/user.html12
5 files changed, 33 insertions, 0 deletions
diff --git a/templates/createuser.html b/templates/createuser.html
index ee4858b..92a1b22 100644
--- a/templates/createuser.html
+++ b/templates/createuser.html
@@ -10,6 +10,8 @@
<input required type="email" name="email" id="email" placeholder="Email"><br/><br/>
<input required type="password" name="pass" id="pass" placeholder="Mot de passe" minlength="10"><br/><br/>
<input required type="password" name="cpass" id="cpass" placeholder="Confirmation du mot de passe" minlength="10"><br/><br/>
+ <label for="isadmin">Admin?</label>
+ <input type="checkbox" name="isadmin" id="isadmin"><br/><br/>
<input type="submit" value="Créer">
</form>
{{end}}
diff --git a/templates/imgs.html b/templates/imgs.html
index e747034..51b489d 100644
--- a/templates/imgs.html
+++ b/templates/imgs.html
@@ -4,13 +4,21 @@
{{template "imgspage" .}}
<noscript>
{{if ne .Page 0}}
+ {{if ne .UserImpersonation ""}}
+ <a href="/imgs?page={{add .Page -1}}&user={{.UserImpersonation}}">Previous page</a>
+ {{else}}
<a href="/imgs?page={{add .Page -1}}">Previous page</a>
+ {{end}}
{{if lt .End .NbFiles}}
|
{{end}}
{{end}}
{{if lt .End .NbFiles}}
+ {{if ne .UserImpersonation ""}}
+ <a href="/imgs?page={{add .Page 1}}&user={{.UserImpersonation}}">Next page</a>
+ {{else}}
<a href="/imgs?page={{add .Page 1}}">Next page</a>
+ {{end}}
{{end}}
</noscript>
<br/><span>{{.NbFiles}} images</span>
diff --git a/templates/imgs_page.html b/templates/imgs_page.html
index 665daf3..3f1ce58 100644
--- a/templates/imgs_page.html
+++ b/templates/imgs_page.html
@@ -1,9 +1,15 @@
{{define "imgspage"}}
{{range $i, $img := .Imgs}}
{{if eq (add $i $.Start) $.End}}
+ {{if ne $.UserImpersonation ""}}
+ <div hx-get="/imgs?page={{add $.Page 1}}&fragment&user={{$.UserImpersonation}}"
+ hx-trigger="revealed"
+ hx-swap="afterend">
+ {{else}}
<div hx-get="/imgs?page={{add $.Page 1}}&fragment"
hx-trigger="revealed"
hx-swap="afterend">
+ {{end}}
<span>{{$img.Name}}</span><br/>
<a href="{{$img.Link}}"><img src="{{$img.Link}}" /></a><br/>
{{else}}
diff --git a/templates/nav_logged.html b/templates/nav_logged.html
index 50e9a36..06c7a21 100644
--- a/templates/nav_logged.html
+++ b/templates/nav_logged.html
@@ -2,8 +2,13 @@
<nav>
<ul class="navlogged">
<!--<li><a href="/admin">Admin</a></li>-->
+ {{if .UserImpersonation}}
+ <li><a href="/?user={{.UserImpersonation}}">Accueil</a></li>
+ <li><a href="/imgs?user={{.UserImpersonation}}">Images</a></li>
+ {{else}}
<li><a href="/">Accueil</a></li>
<li><a href="/imgs">Images</a></li>
+ {{end}}
<li><a href="/logout">Se déconnecter</a></li>
</ul>
</nav>
diff --git a/templates/user.html b/templates/user.html
index cd0d98c..9a3a333 100644
--- a/templates/user.html
+++ b/templates/user.html
@@ -5,11 +5,19 @@
{{if .Error}}
<p class="error">{{.Error}}</p>
{{end}}
+ {{if ne .UserImpersonation ""}}
+ <form action="/upload?user={{.UserImpersonation}}" method="POST" enctype="multipart/form-data">
+ {{else}}
<form action="/upload" method="POST" enctype="multipart/form-data">
+ {{end}}
<input type="file" name="files" multiple />
<input type="submit" value="Upload" />
</form>
+ {{if ne .UserImpersonation ""}}
+ <form action="/download?user={{.UserImpersonation}}" method="POST" class="inline">
+ {{else}}
<form action="/download" method="POST" class="inline">
+ {{end}}
<div class="docs">
<table>
<tr>
@@ -39,7 +47,11 @@
<br/>
<input type="submit" value="Télécharger les fichiers sélectionnés">
</form>
+ {{if ne .UserImpersonation ""}}
+ <form action="/download?user={{.UserImpersonation}}" method="GET" class="inlineblk">
+ {{else}}
<form action="/download" method="GET" class="inlineblk">
+ {{end}}
<input type="submit" value="Télécharger tous les fichiers">
</form>
{{end}}