mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 00:03:07 +00:00
remove DayStrModel
This commit is contained in:
parent
24e9c93eef
commit
7bc94804e3
5 changed files with 26 additions and 36 deletions
|
@ -93,35 +93,28 @@ async def get_config_model(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class DayStrModel(BaseModel):
|
|
||||||
day: int
|
|
||||||
value: str
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/day_parts")
|
@router.get("/day_parts")
|
||||||
async def get_day_parts(
|
async def get_day_parts(
|
||||||
_: None = Depends(require_admin),
|
_: None = Depends(require_admin),
|
||||||
parts: dict[int, str] = Depends(get_all_parts),
|
parts: dict[int, str] = Depends(get_all_parts),
|
||||||
) -> list[DayStrModel]:
|
) -> dict[int, str]:
|
||||||
"""
|
"""
|
||||||
Zuordnung der Lösungsteile zu den Tagen
|
Zuordnung der Lösungsteile zu den Tagen
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return [DayStrModel(day=day, value=part) for day, part in sorted(parts.items())]
|
return parts
|
||||||
|
|
||||||
|
|
||||||
@router.get("/day_image_names")
|
@router.get("/day_image_names")
|
||||||
async def get_day_image_names(
|
async def get_day_image_names(
|
||||||
_: None = Depends(require_admin),
|
_: None = Depends(require_admin),
|
||||||
image_names: dict[int, str] = Depends(get_all_image_names),
|
image_names: dict[int, str] = Depends(get_all_image_names),
|
||||||
) -> list[DayStrModel]:
|
) -> dict[int, str]:
|
||||||
"""
|
"""
|
||||||
Zuordnung der verwendeten Bilder zu den Tagen
|
Zuordnung der verwendeten Bilder zu den Tagen
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return [
|
return image_names
|
||||||
DayStrModel(day=day, value=name) for day, name in sorted(image_names.items())
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/doors")
|
@router.get("/doors")
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DayStrModel } from "@/lib/api";
|
import { Dictionary } from "@/lib/api";
|
||||||
import { Options, Vue } from "vue-class-component";
|
import { Options, Vue } from "vue-class-component";
|
||||||
|
|
||||||
import MultiModal from "../MultiModal.vue";
|
import MultiModal from "../MultiModal.vue";
|
||||||
|
@ -62,7 +62,7 @@ import BulmaDrawer from "../bulma/Drawer.vue";
|
||||||
})
|
})
|
||||||
export default class extends Vue {
|
export default class extends Vue {
|
||||||
public day_data: {
|
public day_data: {
|
||||||
[day: number]: {
|
[day: string]: {
|
||||||
part: string;
|
part: string;
|
||||||
image_name: string;
|
image_name: string;
|
||||||
};
|
};
|
||||||
|
@ -76,24 +76,24 @@ 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<DayStrModel[]>("admin/day_parts"),
|
this.$advent22.api_get<Dictionary>("admin/day_parts"),
|
||||||
this.$advent22.api_get<DayStrModel[]>("admin/day_image_names"),
|
this.$advent22.api_get<Dictionary>("admin/day_image_names"),
|
||||||
])
|
])
|
||||||
.then(([day_parts, day_image_names]) => {
|
.then(([day_parts, day_image_names]) => {
|
||||||
const _ensure_day = (day: number) => {
|
const _ensure_day = (day: string) => {
|
||||||
if (!(day in this.day_data)) {
|
if (!(day in this.day_data)) {
|
||||||
this.day_data[day] = { part: "", image_name: "" };
|
this.day_data[day] = { part: "", image_name: "" };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const day_part of day_parts) {
|
for (const day in day_parts) {
|
||||||
_ensure_day(day_part.day);
|
_ensure_day(day);
|
||||||
this.day_data[day_part.day].part = day_part.value;
|
this.day_data[day].part = day_parts[day];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const day_part of day_image_names) {
|
for (const day in day_image_names) {
|
||||||
_ensure_day(day_part.day);
|
_ensure_day(day);
|
||||||
this.day_data[day_part.day].image_name = day_part.value;
|
this.day_data[day].image_name = day_image_names[day];
|
||||||
}
|
}
|
||||||
|
|
||||||
ready();
|
ready();
|
||||||
|
@ -101,7 +101,7 @@ export default class extends Vue {
|
||||||
.catch(fail);
|
.catch(fail);
|
||||||
}
|
}
|
||||||
|
|
||||||
public door_click(day: number) {
|
public door_click(day: unknown) {
|
||||||
if (this.multi_modal === undefined) return;
|
if (this.multi_modal === undefined) return;
|
||||||
this.multi_modal.show_progress();
|
this.multi_modal.show_progress();
|
||||||
|
|
||||||
|
|
|
@ -51,13 +51,11 @@
|
||||||
|
|
||||||
<dt>Türchen</dt>
|
<dt>Türchen</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<template
|
<template v-for="(part, day) in day_parts" :key="`door-${day}`">
|
||||||
v-for="(day_part, index) in day_parts"
|
|
||||||
:key="`door-${index}`"
|
|
||||||
>
|
|
||||||
<span>
|
<span>
|
||||||
<template v-if="index > 0">, </template>
|
<template v-if="Number(day) > 1">, </template>
|
||||||
{{ day_part.day }}
|
<span v-if="part == ''" class="tag is-warning">_</span>
|
||||||
|
<template v-else>{{ part }}</template>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</dd>
|
</dd>
|
||||||
|
@ -124,7 +122,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ConfigModel, DayStrModel, DoorsSaved } from "@/lib/api";
|
import { ConfigModel, Dictionary, 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";
|
||||||
|
|
||||||
|
@ -169,7 +167,7 @@ export default class extends Vue {
|
||||||
config_file: "sed diam nonumy",
|
config_file: "sed diam nonumy",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
public day_parts: DayStrModel[] = [];
|
public day_parts: Dictionary = {};
|
||||||
public num_user_doors = 0;
|
public num_user_doors = 0;
|
||||||
public next_door: number | null = null;
|
public next_door: number | null = null;
|
||||||
public dav_credentials: Credentials = { username: "", password: "" };
|
public dav_credentials: Credentials = { username: "", password: "" };
|
||||||
|
@ -185,7 +183,7 @@ 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<ConfigModel>("admin/config_model"),
|
||||||
this.$advent22.api_get<DayStrModel[]>("admin/day_parts"),
|
this.$advent22.api_get<Dictionary>("admin/day_parts"),
|
||||||
this.$advent22.api_get<DoorsSaved>("user/doors"),
|
this.$advent22.api_get<DoorsSaved>("user/doors"),
|
||||||
this.$advent22.api_get<number | null>("user/next_door"),
|
this.$advent22.api_get<number | null>("user/next_door"),
|
||||||
])
|
])
|
||||||
|
|
|
@ -23,9 +23,8 @@ export interface ConfigModel {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DayStrModel {
|
export interface Dictionary {
|
||||||
day: number;
|
[day: string]: string;
|
||||||
value: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DoorSaved {
|
export interface DoorSaved {
|
||||||
|
|
|
@ -24,7 +24,7 @@ export class Advent22 {
|
||||||
return `//${window.location.hostname}:8000/api`;
|
return `//${window.location.hostname}:8000/api`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public name_door(day: number): string {
|
public name_door(day: unknown): string {
|
||||||
return `Türchen ${day}`;
|
return `Türchen ${day}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue