2022-12-14 02:39:32 +00:00
|
|
|
<template>
|
2023-09-07 02:33:45 +00:00
|
|
|
<div v-show="active" class="modal is-active">
|
2022-12-14 02:39:32 +00:00
|
|
|
<div class="modal-background" />
|
|
|
|
|
|
|
|
<div class="modal-card">
|
|
|
|
<form @submit.prevent="submit">
|
|
|
|
<header class="modal-card-head">
|
|
|
|
<p class="modal-card-title">Login</p>
|
2023-09-07 02:33:45 +00:00
|
|
|
<button
|
|
|
|
class="delete"
|
|
|
|
aria-label="close"
|
|
|
|
@click.left="set_active(false)"
|
|
|
|
/>
|
2022-12-14 02:39:32 +00:00
|
|
|
</header>
|
|
|
|
|
|
|
|
<section class="modal-card-body">
|
|
|
|
<div class="field">
|
|
|
|
<label class="label">Username</label>
|
|
|
|
<div class="control">
|
2023-09-07 02:33:45 +00:00
|
|
|
<input
|
|
|
|
ref="username_input"
|
|
|
|
class="input"
|
|
|
|
type="text"
|
|
|
|
v-model="username"
|
|
|
|
/>
|
2022-12-14 02:39:32 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="field">
|
2023-09-10 00:10:11 +00:00
|
|
|
<label class="label">Passwort</label>
|
2022-12-14 02:39:32 +00:00
|
|
|
<div class="control">
|
|
|
|
<input class="input" type="password" v-model="password" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</form>
|
2023-09-10 00:10:11 +00:00
|
|
|
|
2023-09-10 00:25:22 +00:00
|
|
|
<footer class="modal-card-foot is-flex is-justify-content-space-around">
|
2023-09-10 00:10:11 +00:00
|
|
|
<BulmaButton
|
|
|
|
class="button is-success"
|
|
|
|
@click.left="submit"
|
|
|
|
icon="fa-solid fa-unlock"
|
|
|
|
text="Login"
|
|
|
|
/>
|
|
|
|
<BulmaButton
|
|
|
|
class="button is-danger"
|
|
|
|
@click.left="set_active(false)"
|
|
|
|
icon="fa-solid fa-circle-xmark"
|
|
|
|
text="Abbrechen"
|
|
|
|
/>
|
|
|
|
</footer>
|
2022-12-14 02:39:32 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2023-09-10 00:10:11 +00:00
|
|
|
import { Options, Vue } from "vue-class-component";
|
|
|
|
|
|
|
|
import BulmaButton from "./bulma/Button.vue";
|
2022-12-14 02:39:32 +00:00
|
|
|
|
2023-09-10 00:10:11 +00:00
|
|
|
@Options({
|
|
|
|
components: {
|
|
|
|
BulmaButton,
|
|
|
|
},
|
|
|
|
})
|
2023-01-24 23:18:09 +00:00
|
|
|
export default class extends Vue {
|
2023-09-06 16:25:35 +00:00
|
|
|
public active = false;
|
|
|
|
public username = "";
|
|
|
|
public password = "";
|
2022-12-14 02:39:32 +00:00
|
|
|
|
2023-09-07 02:33:45 +00:00
|
|
|
declare $refs: {
|
|
|
|
username_input: HTMLInputElement | null | undefined;
|
|
|
|
};
|
|
|
|
|
2023-01-17 14:28:11 +00:00
|
|
|
public created() {
|
2022-12-21 23:51:25 +00:00
|
|
|
window.addEventListener("keydown", (e) => {
|
|
|
|
if (e.key == "Escape") this.set_active(false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-01-17 14:28:11 +00:00
|
|
|
public set_active(state: boolean) {
|
2022-12-14 02:39:32 +00:00
|
|
|
this.active = state;
|
|
|
|
|
2023-09-07 02:33:45 +00:00
|
|
|
if (this.active) {
|
2023-09-10 00:10:11 +00:00
|
|
|
this.username = "";
|
|
|
|
this.password = "";
|
|
|
|
|
2023-09-07 02:33:45 +00:00
|
|
|
this.$nextTick(() => {
|
|
|
|
if (this.$refs.username_input instanceof HTMLInputElement) {
|
|
|
|
this.$refs.username_input?.focus();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-12-14 02:39:32 +00:00
|
|
|
}
|
|
|
|
|
2023-09-06 16:25:35 +00:00
|
|
|
public submit() {
|
2022-12-14 02:39:32 +00:00
|
|
|
this.$advent22.set_api_auth(this.username, this.password);
|
|
|
|
this.set_active(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|