ConfigModel -> AdminConfigModel

This commit is contained in:
Jörn-Michael Miehe 2023-11-02 12:49:02 +00:00
parent 600ee99520
commit 0bc31529bc
3 changed files with 38 additions and 35 deletions

View file

@ -27,7 +27,7 @@ async def is_admin(
return is_admin return is_admin
class ConfigModel(BaseModel): class AdminConfigModel(BaseModel):
class __Solution(BaseModel): class __Solution(BaseModel):
value: str value: str
whitespace: str whitespace: str
@ -71,12 +71,12 @@ async def get_config_model(
cal_cfg: CalendarConfig = Depends(get_calendar_config), cal_cfg: CalendarConfig = Depends(get_calendar_config),
event_dates: EventDates = Depends(get_all_event_dates), event_dates: EventDates = Depends(get_all_event_dates),
ttfonts: list[TTFont] = Depends(get_all_ttfonts), ttfonts: list[TTFont] = Depends(get_all_ttfonts),
) -> ConfigModel: ) -> AdminConfigModel:
""" """
Kombiniert aus privaten `settings`, `config` und `calendar_config` Kombiniert aus privaten `settings`, `config` und `calendar_config`
""" """
return ConfigModel.model_validate( return AdminConfigModel.model_validate(
{ {
"solution": { "solution": {
"value": cfg.solution.value, "value": cfg.solution.value,

View file

@ -10,13 +10,13 @@
<dd> <dd>
Eingabe: Eingabe:
<span class="is-family-monospace"> <span class="is-family-monospace">
"{{ config_model.solution.value }}" "{{ admin_config_model.solution.value }}"
</span> </span>
</dd> </dd>
<dd> <dd>
Ausgabe: Ausgabe:
<span class="is-family-monospace"> <span class="is-family-monospace">
"{{ config_model.solution.clean }}" "{{ admin_config_model.solution.clean }}"
</span> </span>
</dd> </dd>
@ -24,13 +24,13 @@
<dd> <dd>
Whitespace: Whitespace:
<span class="is-uppercase is-family-monospace"> <span class="is-uppercase is-family-monospace">
{{ config_model.solution.whitespace }} {{ admin_config_model.solution.whitespace }}
</span> </span>
</dd> </dd>
<dd> <dd>
Buchstaben: Buchstaben:
<span class="is-uppercase is-family-monospace"> <span class="is-uppercase is-family-monospace">
{{ config_model.solution.case }} {{ admin_config_model.solution.case }}
</span> </span>
</dd> </dd>
</dl> </dl>
@ -64,7 +64,7 @@
<dt>Zufalls-Seed</dt> <dt>Zufalls-Seed</dt>
<dd class="is-family-monospace"> <dd class="is-family-monospace">
"{{ config_model.puzzle.seed }}" "{{ admin_config_model.puzzle.seed }}"
</dd> </dd>
</dl> </dl>
</div> </div>
@ -74,10 +74,10 @@
<h3>Kalender</h3> <h3>Kalender</h3>
<dl> <dl>
<dt>Definition</dt> <dt>Definition</dt>
<dd>{{ config_model.calendar.config_file }}</dd> <dd>{{ admin_config_model.calendar.config_file }}</dd>
<dt>Hintergrundbild</dt> <dt>Hintergrundbild</dt>
<dd>{{ config_model.calendar.background }}</dd> <dd>{{ admin_config_model.calendar.background }}</dd>
<dt>Favicon</dt> <dt>Favicon</dt>
<dd>{{ admin_config_model.calendar.favicon }}</dd> <dd>{{ admin_config_model.calendar.favicon }}</dd>
@ -96,14 +96,14 @@
<h3>Bilder</h3> <h3>Bilder</h3>
<dl> <dl>
<dt>Größe</dt> <dt>Größe</dt>
<dd>{{ config_model.image.size }} px</dd> <dd>{{ admin_config_model.image.size }} px</dd>
<dt>Rand</dt> <dt>Rand</dt>
<dd>{{ config_model.image.border }} px</dd> <dd>{{ admin_config_model.image.border }} px</dd>
<dt>Schriftarten</dt> <dt>Schriftarten</dt>
<dd <dd
v-for="(font, index) in config_model.fonts" v-for="(font, index) in admin_config_model.fonts"
:key="`font-${index}`" :key="`font-${index}`"
> >
{{ font.file }} ({{ font.size }} pt) {{ font.file }} ({{ font.size }} pt)
@ -116,7 +116,7 @@
<h3>WebDAV</h3> <h3>WebDAV</h3>
<dl> <dl>
<dt>URL</dt> <dt>URL</dt>
<dd>{{ config_model.webdav.url }}</dd> <dd>{{ admin_config_model.webdav.url }}</dd>
<dt>Zugangsdaten</dt> <dt>Zugangsdaten</dt>
<dd class="is-family-monospace"> <dd class="is-family-monospace">
@ -130,10 +130,10 @@
</dd> </dd>
<dt>Cache-Dauer</dt> <dt>Cache-Dauer</dt>
<dd>{{ config_model.webdav.cache_ttl }} s</dd> <dd>{{ admin_config_model.webdav.cache_ttl }} s</dd>
<dt>Konfigurationsdatei</dt> <dt>Konfigurationsdatei</dt>
<dd>{{ config_model.webdav.config_file }}</dd> <dd>{{ admin_config_model.webdav.config_file }}</dd>
</dl> </dl>
</div> </div>
@ -141,10 +141,10 @@
<h3>Sonstige</h3> <h3>Sonstige</h3>
<dl> <dl>
<dt>Redis</dt> <dt>Redis</dt>
<dd>Host: {{ config_model.redis.host }}</dd> <dd>Host: {{ admin_config_model.redis.host }}</dd>
<dd>Port: {{ config_model.redis.port }}</dd> <dd>Port: {{ admin_config_model.redis.port }}</dd>
<dd>Datenbank: {{ config_model.redis.db }}</dd> <dd>Datenbank: {{ admin_config_model.redis.db }}</dd>
<dd>Protokoll: {{ config_model.redis.protocol }}</dd> <dd>Protokoll: {{ admin_config_model.redis.protocol }}</dd>
<dt>UI-Admin</dt> <dt>UI-Admin</dt>
<dd class="is-family-monospace"> <dd class="is-family-monospace">
@ -165,7 +165,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { ConfigModel, Credentials, DoorsSaved } from "@/lib/api"; import { AdminConfigModel, Credentials, DoorsSaved } from "@/lib/api";
import { DateTime } from "luxon"; import { DateTime } from "luxon";
import { Options, Vue } from "vue-class-component"; import { Options, Vue } from "vue-class-component";
@ -181,7 +181,7 @@ import CountDown from "../CountDown.vue";
}, },
}) })
export default class extends Vue { export default class extends Vue {
public config_model: ConfigModel = { public admin_config_model: AdminConfigModel = {
solution: { solution: {
value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
whitespace: "KEEP", whitespace: "KEEP",
@ -225,8 +225,8 @@ export default class extends Vue {
public dav_credentials: Credentials = ["", ""]; public dav_credentials: Credentials = ["", ""];
public ui_credentials: Credentials = ["", ""]; public ui_credentials: Credentials = ["", ""];
public fmt_puzzle_date(name: keyof ConfigModel["puzzle"]): string { public fmt_puzzle_date(name: keyof AdminConfigModel["puzzle"]): string {
const iso_date = this.config_model.puzzle[name]; const iso_date = this.admin_config_model.puzzle[name];
if (iso_date === null) return "-"; if (iso_date === null) return "-";
return DateTime.fromISO(iso_date).toLocaleString(DateTime.DATE_SHORT); return DateTime.fromISO(iso_date).toLocaleString(DateTime.DATE_SHORT);
@ -234,15 +234,16 @@ export default class extends Vue {
public on_open(ready: () => void, fail: () => void): void { public on_open(ready: () => void, fail: () => void): void {
Promise.all([ Promise.all([
this.$advent22.api_get<ConfigModel>("admin/config_model"), this.$advent22.api_get<AdminConfigModel>("admin/config_model"),
this.$advent22.api_get<DoorsSaved>("admin/doors"), this.$advent22.api_get<DoorsSaved>("admin/doors"),
this.$advent22.api_get<DoorsSaved>("user/doors"), this.$advent22.api_get<DoorsSaved>("user/doors"),
this.$advent22.api_get<string>("user/title"), this.$advent22.api_get<string>("user/title"),
this.$advent22.api_get<string>("user/footer"), this.$advent22.api_get<string>("user/footer"),
this.$advent22.api_get<number | null>("user/next_door"), this.$advent22.api_get<number | null>("user/next_door"),
]) ])
.then(([config_model, doors, user_doors, title, footer, next_door]) => { .then(
this.config_model = config_model; ([admin_config_model, doors, user_doors, title, footer, next_door]) => {
this.admin_config_model = admin_config_model;
this.doors = doors; this.doors = doors;
this.num_user_doors = user_doors.length; this.num_user_doors = user_doors.length;
this.title = title; this.title = title;
@ -250,7 +251,8 @@ export default class extends Vue {
this.next_door = next_door; this.next_door = next_door;
ready(); ready();
}) },
)
.catch(fail); .catch(fail);
} }

View file

@ -1,4 +1,4 @@
export interface ConfigModel { export interface AdminConfigModel {
solution: { solution: {
value: string; value: string;
whitespace: string; whitespace: string;
@ -15,6 +15,7 @@ export interface ConfigModel {
calendar: { calendar: {
config_file: string; config_file: string;
background: string; background: string;
favicon: string;
}; };
image: { image: {
size: number; size: number;