2023-02-11 06:41:02 +00:00
|
|
|
<template>
|
2023-06-30 14:17:07 +00:00
|
|
|
<div v-if="show" class="form-container">
|
2023-02-11 06:41:02 +00:00
|
|
|
<form @submit.prevent="submit">
|
|
|
|
<div>
|
|
|
|
<object width="64" height="64" data="/icon.svg" />
|
|
|
|
<div style="font-size: 28px; font-weight: bold; margin-top: 5px;">
|
|
|
|
Uptime Kuma
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-06-30 14:17:07 +00:00
|
|
|
<div v-if="info.runningSetup" class="mt-5">
|
|
|
|
<div class="alert alert-success" role="alert">
|
|
|
|
<div class="d-flex align-items-center">
|
|
|
|
<strong>Setting up the database. It may take a while, please be patient.</strong>
|
|
|
|
<div class="spinner-border ml-auto" role="status" aria-hidden="true"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-11 06:41:02 +00:00
|
|
|
</div>
|
|
|
|
|
2023-06-30 14:17:07 +00:00
|
|
|
<template v-if="!info.runningSetup">
|
|
|
|
<div class="form-floating short mt-3">
|
|
|
|
<select id="language" v-model="$root.language" class="form-select">
|
|
|
|
<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>
|
2023-02-11 06:41:02 +00:00
|
|
|
|
2023-06-30 14:17:07 +00:00
|
|
|
<p class="mt-5 short">
|
|
|
|
{{ $t("setupDatabaseChooseDatabase") }}
|
|
|
|
</p>
|
2023-02-11 06:41:02 +00:00
|
|
|
|
2023-06-30 14:17:07 +00:00
|
|
|
<div class="btn-group" role="group" aria-label="Basic radio toggle button group">
|
|
|
|
<template v-if="info.isEnabledEmbeddedMariaDB">
|
|
|
|
<input id="btnradio3" v-model="dbConfig.type" type="radio" class="btn-check" autocomplete="off" value="embedded-mariadb">
|
2023-02-11 06:41:02 +00:00
|
|
|
|
2023-06-30 14:17:07 +00:00
|
|
|
<label class="btn btn-outline-primary" for="btnradio3">
|
|
|
|
Embedded MariaDB
|
|
|
|
</label>
|
|
|
|
</template>
|
2023-02-11 06:41:02 +00:00
|
|
|
|
2023-06-30 14:17:07 +00:00
|
|
|
<input id="btnradio2" v-model="dbConfig.type" type="radio" class="btn-check" autocomplete="off" value="mariadb">
|
|
|
|
<label class="btn btn-outline-primary" for="btnradio2">
|
|
|
|
MariaDB/MySQL
|
|
|
|
</label>
|
2023-02-11 06:41:02 +00:00
|
|
|
|
2023-06-30 14:17:07 +00:00
|
|
|
<input id="btnradio1" v-model="dbConfig.type" type="radio" class="btn-check" autocomplete="off" value="sqlite">
|
|
|
|
<label class="btn btn-outline-primary" for="btnradio1">
|
|
|
|
SQLite
|
|
|
|
</label>
|
2023-02-11 06:41:02 +00:00
|
|
|
</div>
|
|
|
|
|
2023-06-30 14:17:07 +00:00
|
|
|
<p v-if="dbConfig.type === 'embedded-mariadb'" class="mt-3">
|
|
|
|
{{ $t("setupDatabaseEmbeddedMariaDB") }}
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p v-if="dbConfig.type === 'mariadb'" class="mt-3">
|
|
|
|
{{ $t("setupDatabaseMariaDB") }}
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p v-if="dbConfig.type === 'sqlite'" class="mt-3">
|
|
|
|
{{ $t("setupDatabaseSQLite") }}
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<template v-if="dbConfig.type === 'mariadb'">
|
|
|
|
<div class="form-floating mt-3 short">
|
|
|
|
<input id="floatingInput" v-model="dbConfig.hostname" type="text" class="form-control" required>
|
|
|
|
<label for="floatingInput">{{ $t("Hostname") }}</label>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-floating mt-3 short">
|
|
|
|
<input id="floatingInput" v-model="dbConfig.port" type="text" class="form-control" required>
|
|
|
|
<label for="floatingInput">{{ $t("Port") }}</label>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-floating mt-3 short">
|
|
|
|
<input id="floatingInput" v-model="dbConfig.username" type="text" class="form-control" required>
|
|
|
|
<label for="floatingInput">{{ $t("Username") }}</label>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-floating mt-3 short">
|
|
|
|
<input id="floatingInput" v-model="dbConfig.password" type="passwrod" class="form-control" required>
|
|
|
|
<label for="floatingInput">{{ $t("Password") }}</label>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-floating mt-3 short">
|
|
|
|
<input id="floatingInput" v-model="dbConfig.dbName" type="text" class="form-control" required>
|
|
|
|
<label for="floatingInput">{{ $t("dbName") }}</label>
|
|
|
|
</div>
|
|
|
|
</template>
|
2023-02-11 06:41:02 +00:00
|
|
|
|
2023-06-30 14:17:07 +00:00
|
|
|
<button class="btn btn-primary mt-4 short" type="submit" :disabled="disabledButton">
|
|
|
|
{{ $t("Next") }}
|
|
|
|
</button>
|
2023-02-11 06:41:02 +00:00
|
|
|
</template>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import axios from "axios";
|
|
|
|
import { useToast } from "vue-toastification";
|
|
|
|
import { sleep } from "../util.ts";
|
|
|
|
const toast = useToast();
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2023-06-30 14:17:07 +00:00
|
|
|
show: false,
|
2023-02-11 06:41:02 +00:00
|
|
|
dbConfig: {
|
|
|
|
type: undefined,
|
|
|
|
port: 3306,
|
|
|
|
hostname: "",
|
|
|
|
username: "",
|
|
|
|
password: "",
|
|
|
|
dbName: "kuma",
|
|
|
|
},
|
2023-06-30 14:17:07 +00:00
|
|
|
info: {
|
|
|
|
needSetup: false,
|
|
|
|
runningSetup: false,
|
|
|
|
isEnabledEmbeddedMariaDB: false,
|
|
|
|
},
|
2023-02-11 06:41:02 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
disabledButton() {
|
2023-06-30 14:17:07 +00:00
|
|
|
return this.dbConfig.type === undefined || this.info.runningSetup;
|
2023-02-11 06:41:02 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
async mounted() {
|
2023-06-30 14:17:07 +00:00
|
|
|
let res = await axios.get("/setup-database-info");
|
|
|
|
this.info = res.data;
|
|
|
|
|
|
|
|
if (this.info && this.info.needSetup === false) {
|
|
|
|
location.href = "/setup";
|
|
|
|
} else {
|
|
|
|
this.show = true;
|
|
|
|
}
|
2023-02-11 06:41:02 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async submit() {
|
2023-06-30 14:17:07 +00:00
|
|
|
this.info.runningSetup = true;
|
2023-02-11 06:41:02 +00:00
|
|
|
|
|
|
|
try {
|
2023-06-30 18:48:42 +00:00
|
|
|
await axios.post("/setup-database", {
|
2023-02-11 06:41:02 +00:00
|
|
|
dbConfig: this.dbConfig,
|
|
|
|
});
|
|
|
|
await sleep(2000);
|
|
|
|
await this.goToMainServerWhenReady();
|
|
|
|
} catch (e) {
|
|
|
|
toast.error(e.response.data);
|
|
|
|
} finally {
|
2023-06-30 14:17:07 +00:00
|
|
|
this.info.runningSetup = false;
|
2023-02-11 06:41:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
async goToMainServerWhenReady() {
|
|
|
|
try {
|
|
|
|
console.log("Trying...");
|
2023-06-30 14:17:07 +00:00
|
|
|
let res = await axios.get("/setup-database-info");
|
|
|
|
if (res.data && res.data.needSetup === false) {
|
|
|
|
this.show = false;
|
|
|
|
location.href = "/setup";
|
2023-02-11 06:41:02 +00:00
|
|
|
} else {
|
2023-06-30 14:17:07 +00:00
|
|
|
if (res.data) {
|
|
|
|
this.info = res.data;
|
|
|
|
}
|
2023-02-11 06:41:02 +00:00
|
|
|
throw new Error("not ready");
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.log("Not ready yet");
|
|
|
|
await sleep(2000);
|
|
|
|
await this.goToMainServerWhenReady();
|
|
|
|
}
|
2023-06-30 14:17:07 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
test() {
|
|
|
|
toast.error("not implemented");
|
2023-02-11 06:41:02 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.form-container {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
padding-top: 40px;
|
|
|
|
padding-bottom: 40px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.btn-group {
|
|
|
|
label {
|
|
|
|
width: 200px;
|
|
|
|
line-height: 55px;
|
|
|
|
font-size: 16px;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.short {
|
|
|
|
width: 300px;
|
|
|
|
}
|
|
|
|
|
|
|
|
form {
|
|
|
|
max-width: 800px;
|
|
|
|
text-align: center;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
</style>
|