1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00
wakapi/views/signup.tpl.html

129 lines
5.5 KiB
HTML

<!DOCTYPE html>
<html lang="en">
{{ template "head.tpl.html" . }}
<script type="module">
// Constants
const defaultAvatarUrl = 'assets/images/unknown.svg'
const avatarUrlTemplate = {{ avatarUrlTemplate }}
function guessTimezone() {
return Intl.DateTimeFormat().resolvedOptions().timeZone
}
let debounceTimeout
PetiteVue.createApp({
timezone: guessTimezone(),
username: '',
email: '',
avatarUrl: defaultAvatarUrl,
updateAvatar() {
if (!avatarUrlTemplate) return
if (debounceTimeout) {
clearTimeout(debounceTimeout)
}
debounceTimeout = setTimeout(() => {
let url = avatarUrlTemplate
if ((url.includes('{username') && !this.username) || (url.includes('{email') && !this.email)) {
url = defaultAvatarUrl
} else {
url = url.replaceAll('{username}', this.username)
url = url.replaceAll('{email}', this.email)
url = url.replaceAll('{username_hash}', MD5(this.username))
url = url.replaceAll('{email_hash}', MD5(this.email))
url = url.includes('{') ? defaultAvatarUrl : url
}
console.log(url)
this.avatarUrl = url
}, 500)
}
}).mount('#signup-page')
</script>
<body class="bg-gray-900 text-gray-700 p-4 pt-10 flex flex-col min-h-screen max-w-screen-lg mx-auto justify-center">
{{ template "header.tpl.html" . }}
{{ template "alerts.tpl.html" . }}
<main class="mt-10 flex-grow flex justify-center w-full" id="signup-page">
<div class="flex-grow max-w-lg mt-10">
<div class="mb-8">
<h1 class="font-semibold text-3xl text-white m-0 mb-2">Sign up to Wakapi</h1>
<p class="text-sm text-gray-600">
Welcome to Wakapi! Your first step is to create an account.
Afterwards, make sure to set up the <a href="https://wakatime.com" target="_blank" rel="noopener noreferrer" class="text-gray-300 hover:text-gray-400">WakaTime</a> client tools.
Instruction can be found in our <a href="https://github.com/muety/wakapi#-client-setup" target="_blank"
rel="noopener noreferrer"
class="text-gray-300 hover:text-gray-400">README</a>.
</p>
</div>
<div>
</div>
<form class="mt-10" action="signup" method="post">
<input type="hidden" name="location" id="input-location" v-model="timezone">
<div class="flex space-x-4">
<div class="mt-1">
<img v-cloak id="avatar" :src="avatarUrl" width="96px" class="rounded-full border-4 border-green-700 cursor-pointer" alt="User Profile Avatar" title="Your Avatar"/>
</div>
<div>
<div class="mb-4">
<input class="appearance-none bg-gray-850 focus:bg-gray-800 text-gray-300 outline-none rounded w-full py-2 px-4"
v-model="username"
type="text" id="username"
name="username" placeholder="Choose a username" minlength="1"
@keyup="updateAvatar"
required autofocus>
</div>
<div class="mb-4">
<input class="appearance-none bg-gray-850 focus:bg-gray-800 text-gray-300 outline-none rounded w-full py-2 px-4"
v-model="email"
type="email" id="email"
name="email" @keyup="updateAvatar" placeholder="Your e-mail address">
<div class="text-xs text-gray-600 mt-2">E-Mail address is optional, but required for some weekly reports and password reset.</div>
</div>
</div>
</div>
<div class="mb-4">
<input class="appearance-none bg-gray-850 focus:bg-gray-800 text-gray-300 outline-none rounded w-full py-2 px-4"
type="password" id="password"
name="password" placeholder="Choose a password" minlength="6" required>
</div>
<div class="mb-4">
<input class="appearance-none bg-gray-850 focus:bg-gray-800 text-gray-300 outline-none rounded w-full py-2 px-4"
type="password" id="password_repeat"
name="password_repeat" placeholder="And again..." minlength="6" required>
</div>
{{ if eq .TotalUsers 0 }}
<p class="text-sm text-gray-300 mt-4 mb-8">
⚠️ <strong>Please note: </strong> Since there are no users registered in the system, yet, the first user will have administrative privileges, while additional users won't.
</p>
{{ end }}
<div class="flex space-x-2 justify-end">
<a href="login">
<button type="button" class="py-2 px-4 font-semibold rounded bg-gray-800 hover:bg-gray-850 text-white text-sm">Log in</button>
</a>
<button type="submit" class="py-2 px-4 font-semibold rounded bg-green-700 hover:bg-green-800 text-white text-sm">
Create Account
</button>
</div>
</form>
</div>
</main>
{{ template "footer.tpl.html" . }}
{{ template "foot.tpl.html" . }}
</body>
</html>