add user config page and admin menu

This commit is contained in:
2019-12-17 19:28:30 +01:00
parent 4c33b0841e
commit 7653470a7c
16 changed files with 648 additions and 107 deletions

View File

@@ -0,0 +1,37 @@
{{define "email_confirm"}}<!DOCTYPE html>
<html>
<head>
{{template "meta_tags" "E-mail verification"}}
{{template "user_style" .}}
</head>
<body>
{{template "page_top" .}}
<div class="page_content">
<div class="limit_width">
{{if eq .Other "success"}}
<h1>Success!</h1>
<p>
Your account's e-mail address has been updated.
</p>
{{else if eq .Other "not_found"}}
<h1>E-mail change failed</h1>
<p>
This e-mail change request does not exist or has expired.
Please try again if you still want to change your e-mail
address.
</p>
{{else}}
<h1>Error</h1>
<p>
Something went wrong while processing this request. Please
try again later.
</p>
{{end}}
</div>
</div>
{{template "page_bottom" .}}
{{template "analytics"}}
</body>
</html>
{{end}}

View File

@@ -12,11 +12,12 @@
<h1>Welcome home, {{.Username}}!</h1>
<div class="page_content"><div class="limit_width">
<h2>Actions</h2>
<h2>Account information</h2>
<ul>
<li><a href="/user/change_password" class="button">Change my password</a></li>
<li><a href="/logout" class="button">Log out</a></li>
<li>Username: {{.Username}}</li>
<li>E-mail address: {{.Email}}</li>
</ul>
<a href="/user/settings" class="button">Update account settings</a>
<h2>Your most recently uploaded files:</h2>
<div class="highlight_dark">

View File

@@ -8,14 +8,11 @@
<body>
{{template "page_top" .}}
<h1>User configuration</h1>
<h1>{{.Title}}</h1>
<div class="page_content"><div class="limit_width">
<p>What would you like to do?</p>
<ul>
<li><a href="/user/change_password">Change my password</a></li>
</ul>
{{template "form" .Other.PasswordForm}}
{{template "form" .Other.EmailForm}}
{{template "form" .Other.UsernameForm}}
</div></div>
{{template "page_bottom" .}}
{{template "analytics"}}

View File

@@ -77,7 +77,14 @@
},
ticks: {
callback: function(value, index, values) {
return Math.round((value*8/1e6)/(interval*60)) + " Mbps";
if (value > 1e12) {
return Math.round(value/1e9)/1e3 + " TB";
} else if (value > 1e9) {
return Math.round(value/1e6)/1e3 + " GB";
} else if (value > 1e6) {
return Math.round(value/1e3)/1e3 + " MB";
}
return value/1e3 + " kB";
}
},
gridLines: {
@@ -127,6 +134,10 @@
setData();
</script>
<hr/>
<div class="limit_width">
<a href="/admin/globals">Update global settings</a>
</div>
{{else}}
<h1 style="text-align: center;">;)</h1>
{{end}}

View File

@@ -1,24 +1,23 @@
{{define "form"}}
<h1>{{.Title}}</h1>
{{.PreFormHTML}}
{{if eq .Submitted true}}
{{if eq .SubmitSuccess true}}
<div id="submit_result" class="highlight_green">
{{index .SubmitMessages 0}}
</div>
{{else}}
<div id="submit_result" class="highlight_red">
Something went wrong, please correct these errors before continuing:<br/>
<ul>
{{range $msg := .SubmitMessages}}
<li>{{$msg}}</li>
{{end}}
</ul>
</div>
{{end}}
{{end}}
<form class="highlight_dark" method="POST">
{{if eq .Submitted true}}
{{if eq .SubmitSuccess true}}
<div id="submit_result" class="highlight_green">
{{index .SubmitMessages 0}}
</div>
{{else}}
<div id="submit_result" class="highlight_red">
Something went wrong, please correct these errors before continuing:<br/>
<ul>
{{range $msg := .SubmitMessages}}
<li>{{$msg}}</li>
{{end}}
</ul>
</div>
{{end}}
{{end}}
<input type="text" name="form" value="{{.Name}}" style="display: none;" readonly="readonly"/>
{{if ne .Username ""}}
<!-- The invisible username field is so browsers know which user the form was for -->
@@ -27,23 +26,32 @@
<table class="form">
{{range $index, $field := .Fields}}
<tr class="form">
<td>{{$field.Label}}</td>
<td>
{{if eq $field.Type "text"}}
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="text" class="form_input"/>
{{else if eq $field.Type "username"}}
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="text" autocomplete="username" class="form_input"/>
{{else if eq $field.Type "email"}}
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="email" autocomplete="email" class="form_input"/>
{{else if eq $field.Type "current-password"}}
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="password" autocomplete="current-password" class="form_input"/>
{{else if eq $field.Type "new-password"}}
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="password" autocomplete="new-password" class="form_input"/>
{{else if eq $field.Type "captcha"}}
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<div class="g-recaptcha" data-theme="dark" data-sitekey="{{$field.CaptchaSiteKey}}"></div>
{{end}}
</td>
{{if eq $field.Type "textarea"}}
<td colspan="2">
{{$field.Label}}<br/>
<textarea id="input_{{$field.Name}}" name="{{$field.Name}}" class="form_input" style="width: 100%; height: 5em; resize: vertical;">{{$field.DefaultValue}}</textarea>
</td>
{{else}}
<td>{{$field.Label}}</td>
<td>
{{if eq $field.Type "text"}}
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="text" class="form_input"/>
{{else if eq $field.Type "number"}}
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="number" class="form_input"/>
{{else if eq $field.Type "username"}}
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="text" autocomplete="username" class="form_input"/>
{{else if eq $field.Type "email"}}
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="email" autocomplete="email" class="form_input"/>
{{else if eq $field.Type "current-password"}}
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="password" autocomplete="current-password" class="form_input"/>
{{else if eq $field.Type "new-password"}}
<input id="input_{{$field.Name}}" name="{{$field.Name}}" value="{{$field.DefaultValue}}" type="password" autocomplete="new-password" class="form_input"/>
{{else if eq $field.Type "captcha"}}
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<div class="g-recaptcha" data-theme="dark" data-sitekey="{{$field.CaptchaSiteKey}}"></div>
{{end}}
</td>
{{end}}
{{if or (ne $field.Description "") (eq $field.Separator true)}}
<tr class="form">
<td colspan="2">