2021-07-11 05:47:57 +00:00
|
|
|
<template>
|
2022-06-16 06:06:34 +00:00
|
|
|
<div class="form-container" data-cy="setup-form">
|
2021-07-11 05:47:57 +00:00
|
|
|
<div class="form">
|
|
|
|
<form @submit.prevent="submit">
|
|
|
|
<div>
|
2021-07-27 17:47:13 +00:00
|
|
|
<object width="64" height="64" data="/icon.svg" />
|
|
|
|
<div style="font-size: 28px; font-weight: bold; margin-top: 5px;">
|
|
|
|
Uptime Kuma
|
|
|
|
</div>
|
2021-07-11 05:47:57 +00:00
|
|
|
</div>
|
|
|
|
|
2021-07-27 17:47:13 +00:00
|
|
|
<p class="mt-3">
|
2021-08-29 21:07:58 +00:00
|
|
|
{{ $t("Create your admin account") }}
|
2021-07-27 17:47:13 +00:00
|
|
|
</p>
|
2021-07-11 05:47:57 +00:00
|
|
|
|
|
|
|
<div class="form-floating">
|
2023-02-06 14:35:56 +00:00
|
|
|
<select id="language" v-model="$root.language" class="form-select">
|
2021-09-05 13:40:35 +00:00
|
|
|
<option v-for="(lang, i) in $i18n.availableLocales" :key="`Lang${i}`" :value="lang">
|
|
|
|
{{ $i18n.messages[lang].languageName }}
|
|
|
|
</option>
|
|
|
|
</select>
|
|
|
|
<label for="language" class="form-label">{{ $t("Language") }}</label>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-floating mt-3">
|
2022-06-16 06:06:34 +00:00
|
|
|
<input id="floatingInput" v-model="username" type="text" class="form-control" placeholder="Username" required data-cy="username-input">
|
2021-08-29 21:07:58 +00:00
|
|
|
<label for="floatingInput">{{ $t("Username") }}</label>
|
2021-07-11 05:47:57 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-floating mt-3">
|
2022-06-16 06:06:34 +00:00
|
|
|
<input id="floatingPassword" v-model="password" type="password" class="form-control" placeholder="Password" required data-cy="password-input">
|
2021-08-29 21:07:58 +00:00
|
|
|
<label for="floatingPassword">{{ $t("Password") }}</label>
|
2021-07-11 05:47:57 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-floating mt-3">
|
2022-06-16 06:06:34 +00:00
|
|
|
<input id="repeat" v-model="repeatPassword" type="password" class="form-control" placeholder="Repeat Password" required data-cy="password-repeat-input">
|
2021-08-29 21:07:58 +00:00
|
|
|
<label for="repeat">{{ $t("Repeat Password") }}</label>
|
2021-07-11 05:47:57 +00:00
|
|
|
</div>
|
|
|
|
|
2022-06-16 06:06:34 +00:00
|
|
|
<button class="w-100 btn btn-primary mt-3" type="submit" :disabled="processing" data-cy="submit-setup-form">
|
2021-09-05 13:40:35 +00:00
|
|
|
{{ $t("Create") }}
|
2021-07-27 17:47:13 +00:00
|
|
|
</button>
|
2021-07-11 05:47:57 +00:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-10-01 12:57:31 +00:00
|
|
|
import { useToast } from "vue-toastification";
|
|
|
|
const toast = useToast();
|
2021-07-11 05:47:57 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
processing: false,
|
|
|
|
username: "",
|
|
|
|
password: "",
|
|
|
|
repeatPassword: "",
|
2021-10-01 12:57:31 +00:00
|
|
|
};
|
2021-07-11 05:47:57 +00:00
|
|
|
},
|
2021-09-05 13:40:35 +00:00
|
|
|
watch: {
|
2023-02-06 14:35:56 +00:00
|
|
|
|
2021-09-05 13:40:35 +00:00
|
|
|
},
|
2021-07-11 05:47:57 +00:00
|
|
|
mounted() {
|
2023-06-30 14:17:07 +00:00
|
|
|
// TODO: Check if it is a database setup
|
|
|
|
|
2021-07-11 05:47:57 +00:00
|
|
|
this.$root.getSocket().emit("needSetup", (needSetup) => {
|
|
|
|
if (! needSetup) {
|
2021-10-01 12:57:31 +00:00
|
|
|
this.$router.push("/");
|
2021-07-11 05:47:57 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
methods: {
|
2022-06-02 12:46:44 +00:00
|
|
|
/**
|
|
|
|
* Submit form data for processing
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2021-07-11 05:47:57 +00:00
|
|
|
submit() {
|
|
|
|
this.processing = true;
|
|
|
|
|
|
|
|
if (this.password !== this.repeatPassword) {
|
2021-10-18 19:25:53 +00:00
|
|
|
toast.error(this.$t("PasswordsDoNotMatch"));
|
2021-07-11 05:47:57 +00:00
|
|
|
this.processing = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$root.getSocket().emit("setup", this.username, this.password, (res) => {
|
|
|
|
this.processing = false;
|
2021-10-01 12:57:31 +00:00
|
|
|
this.$root.toastRes(res);
|
2021-07-11 05:47:57 +00:00
|
|
|
|
|
|
|
if (res.ok) {
|
2021-09-07 08:25:25 +00:00
|
|
|
this.processing = true;
|
|
|
|
|
2021-10-01 12:57:31 +00:00
|
|
|
this.$root.login(this.username, this.password, "", () => {
|
2021-09-07 08:25:25 +00:00
|
|
|
this.processing = false;
|
2021-10-01 12:57:31 +00:00
|
|
|
this.$router.push("/");
|
|
|
|
});
|
2021-07-11 05:47:57 +00:00
|
|
|
}
|
2021-10-01 12:57:31 +00:00
|
|
|
});
|
2021-07-27 17:47:13 +00:00
|
|
|
},
|
|
|
|
},
|
2021-10-01 12:57:31 +00:00
|
|
|
};
|
2021-07-11 05:47:57 +00:00
|
|
|
</script>
|
|
|
|
|
2021-10-01 12:57:31 +00:00
|
|
|
<style lang="scss" scoped>
|
2021-07-11 05:47:57 +00:00
|
|
|
.form-container {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
padding-top: 40px;
|
|
|
|
padding-bottom: 40px;
|
|
|
|
}
|
|
|
|
|
2021-10-01 12:57:31 +00:00
|
|
|
.form-floating {
|
|
|
|
> .form-select {
|
|
|
|
padding-left: 1.3rem;
|
|
|
|
padding-top: 1.525rem;
|
|
|
|
line-height: 1.35;
|
|
|
|
|
|
|
|
~ label {
|
|
|
|
padding-left: 1.3rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> label {
|
|
|
|
padding-left: 1.3rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .form-control {
|
|
|
|
padding-left: 1.3rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-11 05:47:57 +00:00
|
|
|
.form {
|
|
|
|
|
|
|
|
width: 100%;
|
|
|
|
max-width: 330px;
|
|
|
|
padding: 15px;
|
|
|
|
margin: auto;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
</style>
|