depends.get_all_image_names, CalendarAssistant.day_image_names

This commit is contained in:
Jörn-Michael Miehe 2023-09-12 17:31:08 +00:00
parent 0550621835
commit d4f8469a7a
3 changed files with 54 additions and 24 deletions

View file

@ -71,6 +71,19 @@ async def get_all_auto_image_names(
return dict(zip(days, rnd.shuffled(ls)))
async def get_all_image_names(
auto_image_names: dict[int, str] = Depends(get_all_auto_image_names),
) -> dict[int, str]:
"""
Bilder "auto" und "manual" zu Tagen zuordnen
"""
# TODO penner
# "manual"-Bilder erkennen (hier neue variable anlegen)
return auto_image_names
async def gen_day_auto_image(
day: int,
cfg: Config = Depends(get_config),

View file

@ -5,7 +5,7 @@ from pydantic import BaseModel
from ..core.calendar_config import CalendarConfig, DoorsSaved, get_calendar_config
from ..core.config import Config, get_config
from ..core.depends import get_all_parts
from ..core.depends import get_all_image_names, get_all_parts
from ..core.settings import SETTINGS
from ._security import require_admin, user_is_admin
@ -105,6 +105,20 @@ async def get_day_parts(
return [DayStrModel(day=day, value=part) for day, part in sorted(parts.items())]
@router.get("/day_image_names")
async def get_day_image_names(
_: None = Depends(require_admin),
image_names: dict[int, str] = Depends(get_all_image_names),
) -> list[DayStrModel]:
"""
Zuordnung der verwendeten Bilder zu den Tagen
"""
return [
DayStrModel(day=day, value=name) for day, name in sorted(image_names.items())
]
@router.get("/doors")
async def get_doors(
_: None = Depends(require_admin),

View file

@ -9,18 +9,6 @@
>
<div class="card-content">
<div class="content">
<h4>Alle Türchen</h4>
<div class="tags are-medium">
<BulmaButton
v-for="(day_part, index) in day_parts"
:key="`btn-${index}`"
class="tag button is-primary"
icon="fa-solid fa-door-open"
:text="`${day_part.day}`"
@click.left="door_click(day_part.day)"
/>
</div>
<h4>Buchstaben-Zuordnung</h4>
<div class="tags are-medium">
<span
@ -33,16 +21,26 @@
</div>
<h4>Bilder-Zuordnung</h4>
<!-- TODO -->
<div class="tags are-medium">
<span class="tag is-primary">1: images_auto/1.jpg</span>
<span class="tag is-primary">2: images_manual/1.jpg</span>
<span class="tag is-primary">3: images_auto/penelope.png</span>
<span class="tag is-primary">4: images_auto/hand.png</span>
<span class="tag is-primary">5: images_auto/hand.jpg</span>
<span class="tag is-primary">6: images_auto/Zaphod.jpg</span>
<span class="tag is-primary">7: images_auto/Zaphod.jpg</span>
<span class="tag is-primary"></span>
<span
v-for="(day_part, index) in day_image_names"
:key="`part-${index}`"
class="tag is-primary"
>
{{ day_part.day }}: {{ day_part.value }}
</span>
</div>
<h4>Alle Türchen</h4>
<div class="tags are-medium">
<BulmaButton
v-for="(day_part, index) in day_parts"
:key="`btn-${index}`"
class="tag button is-primary"
icon="fa-solid fa-door-open"
:text="`${day_part.day}`"
@click.left="door_click(day_part.day)"
/>
</div>
</div>
</div>
@ -67,6 +65,7 @@ import MultiModal from "./calendar/MultiModal.vue";
export default class extends Vue {
public is_loaded = true;
public day_parts: DayStrModel[] = [];
public day_image_names: DayStrModel[] = [];
declare $refs: {
multi_modal: MultiModal;
@ -75,9 +74,13 @@ export default class extends Vue {
public on_open(): void {
this.is_loaded = false;
Promise.all([this.$advent22.api_get<DayStrModel[]>("admin/day_parts")])
.then(([day_parts]) => {
Promise.all([
this.$advent22.api_get<DayStrModel[]>("admin/day_parts"),
this.$advent22.api_get<DayStrModel[]>("admin/day_image_names"),
])
.then(([day_parts, day_image_names]) => {
this.day_parts = day_parts;
this.day_image_names = day_image_names;
this.is_loaded = true;
})
.catch(console.log);