advent22/ui/src/components/admin/ConfigView.vue

277 lines
8 KiB
Vue
Raw Normal View History

2023-09-10 03:10:22 +00:00
<template>
2023-09-14 12:51:30 +00:00
<BulmaDrawer header="Konfiguration" @open="on_open" refreshable>
2023-09-10 03:25:12 +00:00
<div class="card-content">
2023-09-10 03:38:24 +00:00
<div class="columns">
<div class="column is-one-third">
<div class="content">
2023-10-31 19:18:18 +00:00
<h3>Lösung</h3>
<dl>
<dt>Wert</dt>
<dd>
Eingabe:
<span class="is-family-monospace">
2023-11-02 12:49:02 +00:00
"{{ admin_config_model.solution.value }}"
2023-10-31 19:18:18 +00:00
</span>
</dd>
<dd>
Ausgabe:
<span class="is-family-monospace">
2023-11-02 12:49:02 +00:00
"{{ admin_config_model.solution.clean }}"
2023-10-31 19:18:18 +00:00
</span>
</dd>
<dt>Transformation</dt>
<dd>
Whitespace:
<span class="is-uppercase is-family-monospace">
2023-11-02 12:49:02 +00:00
{{ admin_config_model.solution.whitespace }}
2023-10-31 19:18:18 +00:00
</span>
</dd>
2023-11-21 22:20:22 +00:00
<dd>
Sonderzeichen:
<span class="is-uppercase is-family-monospace">
{{ admin_config_model.solution.special_chars }}
</span>
</dd>
2023-10-31 19:18:18 +00:00
<dd>
Buchstaben:
<span class="is-uppercase is-family-monospace">
2023-11-02 12:49:02 +00:00
{{ admin_config_model.solution.case }}
2023-10-31 19:18:18 +00:00
</span>
</dd>
</dl>
2023-09-21 08:52:35 +00:00
<h3>Rätsel</h3>
<dl>
<dt>Offene Türchen</dt>
2023-11-04 04:17:36 +00:00
<dd>{{ store.user_doors.length }}</dd>
2023-09-10 03:10:22 +00:00
2023-09-15 16:55:03 +00:00
<dt>Zeit zum nächsten Türchen</dt>
2023-11-03 17:07:25 +00:00
<dd v-if="store.next_door_target === null">
Kein nächstes Türchen
</dd>
<dd v-else><CountDown :until="store.next_door_target" /></dd>
2023-09-10 03:10:22 +00:00
<dt>Erstes Türchen</dt>
2023-09-16 00:17:13 +00:00
<dd>{{ fmt_puzzle_date("first") }}</dd>
2023-09-10 03:10:22 +00:00
2023-09-15 17:06:28 +00:00
<dt>Nächstes Türchen</dt>
2023-09-16 00:17:13 +00:00
<dd>{{ fmt_puzzle_date("next") }}</dd>
2023-09-15 17:06:28 +00:00
<dt>Letztes Türchen</dt>
2023-09-16 00:17:13 +00:00
<dd>{{ fmt_puzzle_date("last") }}</dd>
2023-09-10 03:10:22 +00:00
<dt>Rätsel schließt nach</dt>
2023-09-16 00:17:13 +00:00
<dd>{{ fmt_puzzle_date("end") }}</dd>
2023-09-10 03:10:22 +00:00
<dt>Zufalls-Seed</dt>
2023-09-11 22:50:11 +00:00
<dd class="is-family-monospace">
2023-11-02 12:49:02 +00:00
"{{ admin_config_model.puzzle.seed }}"
2023-09-11 22:50:11 +00:00
</dd>
2023-11-24 00:01:09 +00:00
<dt>Leere Türchen</dt>
<dd v-if="admin_config_model.puzzle.skip_empty">Überspringen</dd>
<dd v-else>Anzeigen</dd>
</dl>
</div>
2023-09-10 03:10:22 +00:00
</div>
<div class="column is-one-third">
<div class="content">
2023-09-21 08:52:35 +00:00
<h3>Kalender</h3>
<dl>
<dt>Definition</dt>
2023-11-02 12:49:02 +00:00
<dd>{{ admin_config_model.calendar.config_file }}</dd>
<dt>Hintergrundbild</dt>
2023-11-02 12:49:02 +00:00
<dd>{{ admin_config_model.calendar.background }}</dd>
2023-11-02 12:48:52 +00:00
<dt>Favicon</dt>
<dd>{{ admin_config_model.calendar.favicon }}</dd>
2023-09-26 22:23:43 +00:00
<dt>Türchen ({{ doors.length }} Stück)</dt>
2023-09-11 02:36:51 +00:00
<dd>
2023-09-26 22:23:43 +00:00
<template v-for="(door, index) in doors" :key="`door-${index}`">
2023-09-12 13:56:05 +00:00
<span>
2023-10-29 16:28:19 +00:00
<template v-if="index > 0">, </template>
2023-09-26 22:23:43 +00:00
{{ door.day }}
2023-09-11 02:36:51 +00:00
</span>
2023-09-12 13:56:05 +00:00
</template>
2023-09-11 02:36:51 +00:00
</dd>
</dl>
2023-09-21 08:52:35 +00:00
<h3>Bilder</h3>
<dl>
<dt>Größe</dt>
2023-11-02 12:49:02 +00:00
<dd>{{ admin_config_model.image.size }} px</dd>
<dt>Rand</dt>
2023-11-02 12:49:02 +00:00
<dd>{{ admin_config_model.image.border }} px</dd>
<dt>Schriftarten</dt>
2023-09-11 22:50:11 +00:00
<dd
2023-11-02 12:49:02 +00:00
v-for="(font, index) in admin_config_model.fonts"
2023-09-12 14:55:08 +00:00
:key="`font-${index}`"
2023-09-11 22:50:11 +00:00
>
2023-11-01 00:30:33 +00:00
{{ font.file }} ({{ font.size }} pt)
2023-09-11 22:50:11 +00:00
</dd>
</dl>
</div>
2023-09-10 03:10:22 +00:00
</div>
<div class="column is-one-third">
<div class="content">
2023-09-21 08:52:35 +00:00
<h3>WebDAV</h3>
<dl>
<dt>URL</dt>
2023-11-02 12:49:02 +00:00
<dd>{{ admin_config_model.webdav.url }}</dd>
<dt>Zugangsdaten</dt>
<dd class="is-family-monospace">
<BulmaSecret @load="load_dav_credentials">
<span class="tag is-danger">user</span>
2023-09-21 12:25:23 +00:00
{{ dav_credentials[0] }}
<br />
<span class="tag is-danger">pass</span>
2023-09-21 12:25:23 +00:00
{{ dav_credentials[1] }}
</BulmaSecret>
2023-09-11 02:36:51 +00:00
</dd>
<dt>Cache-Dauer</dt>
2023-11-02 12:49:02 +00:00
<dd>{{ admin_config_model.webdav.cache_ttl }} s</dd>
<dt>Konfigurationsdatei</dt>
2023-11-02 12:49:02 +00:00
<dd>{{ admin_config_model.webdav.config_file }}</dd>
2023-10-31 19:27:50 +00:00
</dl>
</div>
<div class="content">
<h3>Sonstige</h3>
<dl>
<dt>Redis</dt>
2023-11-02 12:49:02 +00:00
<dd>Host: {{ admin_config_model.redis.host }}</dd>
<dd>Port: {{ admin_config_model.redis.port }}</dd>
<dd>Datenbank: {{ admin_config_model.redis.db }}</dd>
<dd>Protokoll: {{ admin_config_model.redis.protocol }}</dd>
<dt>UI-Admin</dt>
<dd class="is-family-monospace">
<BulmaSecret @load="load_ui_credentials">
<span class="tag is-danger">user</span>
2023-09-21 12:25:23 +00:00
{{ ui_credentials[0] }}
<br />
<span class="tag is-danger">pass</span>
2023-09-21 12:25:23 +00:00
{{ ui_credentials[1] }}
</BulmaSecret>
2023-09-11 02:36:51 +00:00
</dd>
</dl>
</div>
2023-09-10 03:10:22 +00:00
</div>
</div>
</div>
2023-09-10 03:38:24 +00:00
</BulmaDrawer>
2023-09-10 03:10:22 +00:00
</template>
<script lang="ts">
2023-11-09 23:08:35 +00:00
import { AdminConfigModel, Credentials, DoorSaved } from "@/lib/api";
2023-11-03 17:07:25 +00:00
import { advent22Store } from "@/plugins/store";
2023-09-16 00:17:13 +00:00
import { DateTime } from "luxon";
2023-09-10 03:10:22 +00:00
import { Options, Vue } from "vue-class-component";
2023-09-14 12:51:30 +00:00
import BulmaDrawer from "../bulma/Drawer.vue";
2023-09-13 16:08:05 +00:00
import BulmaSecret from "../bulma/Secret.vue";
2023-09-15 16:55:03 +00:00
import CountDown from "../CountDown.vue";
2023-09-10 03:10:22 +00:00
@Options({
components: {
BulmaDrawer,
BulmaSecret,
2023-09-15 16:55:03 +00:00
CountDown,
2023-09-10 03:10:22 +00:00
},
})
2023-09-11 22:24:01 +00:00
export default class extends Vue {
2023-11-03 17:07:25 +00:00
public readonly store = advent22Store();
2023-11-02 12:49:02 +00:00
public admin_config_model: AdminConfigModel = {
2023-10-31 19:18:18 +00:00
solution: {
value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
2023-10-31 21:36:22 +00:00
whitespace: "KEEP",
2023-11-21 22:20:22 +00:00
special_chars: "KEEP",
2023-10-31 21:36:22 +00:00
case: "KEEP",
2023-10-31 19:18:18 +00:00
clean: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
},
2023-09-11 22:24:01 +00:00
puzzle: {
2023-11-24 00:01:09 +00:00
skip_empty: true,
2023-09-16 00:17:13 +00:00
first: "2023-12-01",
next: "2023-12-01",
last: "2023-12-24",
end: "2024-04-01",
2023-09-11 22:24:01 +00:00
seed: "",
},
calendar: {
2023-09-16 00:17:13 +00:00
config_file: "lorem ipsum",
2023-11-02 12:48:52 +00:00
background: "dolor sit",
favicon: "sit amet",
2023-09-11 22:24:01 +00:00
},
image: {
size: 500,
2023-09-16 00:17:13 +00:00
border: 0,
2023-09-11 22:24:01 +00:00
},
2023-11-01 00:30:33 +00:00
fonts: [{ file: "consetetur", size: 0 }],
2023-10-31 21:48:27 +00:00
redis: {
host: "0.0.0.0",
port: 6379,
db: 0,
protocol: 3,
},
2023-09-11 22:24:01 +00:00
webdav: {
2023-09-16 00:17:13 +00:00
url: "sadipscing elitr",
cache_ttl: 0,
config_file: "sed diam nonumy",
2023-09-11 22:24:01 +00:00
},
};
2023-11-09 23:08:35 +00:00
public doors: DoorSaved[] = [];
2023-09-21 12:25:23 +00:00
public dav_credentials: Credentials = ["", ""];
public ui_credentials: Credentials = ["", ""];
2023-09-11 22:24:01 +00:00
2023-11-02 12:49:02 +00:00
public fmt_puzzle_date(name: keyof AdminConfigModel["puzzle"]): string {
const iso_date = this.admin_config_model.puzzle[name];
2023-11-24 00:01:09 +00:00
if (!(typeof iso_date == "string")) return "-";
2023-09-16 00:17:13 +00:00
return DateTime.fromISO(iso_date).toLocaleString(DateTime.DATE_SHORT);
}
2023-09-14 12:51:30 +00:00
public on_open(ready: () => void, fail: () => void): void {
2023-09-12 16:26:12 +00:00
Promise.all([
2023-11-02 12:49:02 +00:00
this.$advent22.api_get<AdminConfigModel>("admin/config_model"),
2023-11-09 23:08:35 +00:00
this.$advent22.api_get<DoorSaved[]>("admin/doors"),
2023-09-12 16:26:12 +00:00
])
2023-11-04 04:17:36 +00:00
.then(([admin_config_model, doors]) => {
2023-11-03 14:40:44 +00:00
this.admin_config_model = admin_config_model;
this.doors = doors;
2023-09-12 21:06:52 +00:00
2023-11-03 14:40:44 +00:00
ready();
})
2023-09-14 12:51:30 +00:00
.catch(fail);
2023-09-11 22:24:01 +00:00
}
public load_dav_credentials(): void {
this.$advent22
2023-09-21 12:25:23 +00:00
.api_get<Credentials>("admin/dav_credentials")
.then((creds) => (this.dav_credentials = creds))
2023-09-13 15:58:15 +00:00
.catch(() => {});
}
public load_ui_credentials(): void {
this.$advent22
2023-09-21 12:25:23 +00:00
.api_get<Credentials>("admin/ui_credentials")
.then((creds) => (this.ui_credentials = creds))
2023-09-13 15:58:15 +00:00
.catch(() => {});
}
2023-09-11 22:24:01 +00:00
}
2023-09-10 03:10:22 +00:00
</script>
2023-09-10 20:08:13 +00:00
<style scoped>
dd {
overflow-x: auto;
}
</style>