mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 00:03:07 +00:00
ConfigView.num_user_doors
This commit is contained in:
parent
60a451a426
commit
2d0209ae61
2 changed files with 19 additions and 5 deletions
|
@ -2,7 +2,7 @@ from fastapi import APIRouter, Depends, HTTPException, status
|
|||
from fastapi.responses import StreamingResponse
|
||||
from PIL import Image
|
||||
|
||||
from ..core.calendar_config import CalendarConfig, get_calendar_config
|
||||
from ..core.calendar_config import CalendarConfig, DoorsSaved, get_calendar_config
|
||||
from ..core.depends import get_day_image
|
||||
from ..core.helpers import api_return_image, load_image
|
||||
from ._security import user_can_view_day, user_is_admin
|
||||
|
@ -41,3 +41,14 @@ async def get_image_for_day(
|
|||
raise HTTPException(status.HTTP_401_UNAUTHORIZED, "Wie unhöflich!!!")
|
||||
|
||||
return await api_return_image(image)
|
||||
|
||||
|
||||
@router.get("/doors")
|
||||
async def get_doors(
|
||||
cal_cfg: CalendarConfig = Depends(get_calendar_config),
|
||||
) -> DoorsSaved:
|
||||
"""
|
||||
User-sichtbare Türchen lesen
|
||||
"""
|
||||
|
||||
return [door for door in cal_cfg.doors if await user_can_view_day(door.day)]
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
<dd>{{ config_model.puzzle.solution }}</dd>
|
||||
|
||||
<dt>Offene Türchen</dt>
|
||||
<!-- TODO -->
|
||||
<dd>10</dd>
|
||||
<dd>{{ num_user_doors }}</dd>
|
||||
|
||||
<dt>Nächstes Türchen in</dt>
|
||||
<!-- TODO -->
|
||||
|
@ -122,7 +121,7 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { ConfigModel, DayStrModel } from "@/lib/api";
|
||||
import { ConfigModel, DayStrModel, DoorsSaved } from "@/lib/api";
|
||||
import { Options, Vue } from "vue-class-component";
|
||||
|
||||
import BulmaDrawer from "./bulma/Drawer.vue";
|
||||
|
@ -159,6 +158,7 @@ export default class extends Vue {
|
|||
},
|
||||
};
|
||||
public day_parts: DayStrModel[] = [];
|
||||
public num_user_doors = 0;
|
||||
|
||||
public on_open(): void {
|
||||
this.is_loaded = false;
|
||||
|
@ -166,10 +166,13 @@ export default class extends Vue {
|
|||
Promise.all([
|
||||
this.$advent22.api_get<ConfigModel>("admin/config_model"),
|
||||
this.$advent22.api_get<DayStrModel[]>("admin/day_parts"),
|
||||
this.$advent22.api_get<DoorsSaved>("user/doors"),
|
||||
])
|
||||
.then(([config_model, day_parts]) => {
|
||||
.then(([config_model, day_parts, user_doors]) => {
|
||||
this.config_model = config_model;
|
||||
this.day_parts = day_parts;
|
||||
this.num_user_doors = user_doors.length;
|
||||
|
||||
this.is_loaded = true;
|
||||
})
|
||||
.catch(console.log);
|
||||
|
|
Loading…
Reference in a new issue