move user/next_door call to "store"
This commit is contained in:
parent
4fbdb94caa
commit
ca8df3ba10
5 changed files with 36 additions and 44 deletions
|
@ -4,10 +4,6 @@
|
||||||
<figure>
|
<figure>
|
||||||
<figcaption class="has-text-primary-dark">
|
<figcaption class="has-text-primary-dark">
|
||||||
{{ figure_caption }}
|
{{ figure_caption }}
|
||||||
<template v-if="next_door !== null">
|
|
||||||
<br />
|
|
||||||
Zeit zum nächsten Türchen: <CountDown :millis="next_door" />
|
|
||||||
</template>
|
|
||||||
</figcaption>
|
</figcaption>
|
||||||
<div class="image is-unselectable">
|
<div class="image is-unselectable">
|
||||||
<img :src="$advent22.api_url('user/background_image')" />
|
<img :src="$advent22.api_url('user/background_image')" />
|
||||||
|
@ -33,7 +29,6 @@ import { Door } from "@/lib/door";
|
||||||
import { advent22Store } from "@/plugins/store";
|
import { advent22Store } from "@/plugins/store";
|
||||||
import { Options, Vue } from "vue-class-component";
|
import { Options, Vue } from "vue-class-component";
|
||||||
|
|
||||||
import CountDown from "./CountDown.vue";
|
|
||||||
import MultiModal from "./MultiModal.vue";
|
import MultiModal from "./MultiModal.vue";
|
||||||
import BulmaButton from "./bulma/Button.vue";
|
import BulmaButton from "./bulma/Button.vue";
|
||||||
import CalendarDoor from "./calendar/CalendarDoor.vue";
|
import CalendarDoor from "./calendar/CalendarDoor.vue";
|
||||||
|
@ -41,7 +36,6 @@ import ThouCanvas from "./calendar/ThouCanvas.vue";
|
||||||
|
|
||||||
@Options({
|
@Options({
|
||||||
components: {
|
components: {
|
||||||
CountDown,
|
|
||||||
MultiModal,
|
MultiModal,
|
||||||
BulmaButton,
|
BulmaButton,
|
||||||
ThouCanvas,
|
ThouCanvas,
|
||||||
|
@ -58,14 +52,6 @@ export default class extends Vue {
|
||||||
|
|
||||||
private multi_modal?: MultiModal;
|
private multi_modal?: MultiModal;
|
||||||
public figure_caption = this.idle_caption;
|
public figure_caption = this.idle_caption;
|
||||||
public next_door: number | null = null;
|
|
||||||
|
|
||||||
public mounted(): void {
|
|
||||||
this.$advent22
|
|
||||||
.api_get<number | null>("user/next_door")
|
|
||||||
.then((next_door) => (this.next_door = next_door))
|
|
||||||
.catch(this.$advent22.alert_user_error);
|
|
||||||
}
|
|
||||||
|
|
||||||
public modal_handle(modal: MultiModal) {
|
public modal_handle(modal: MultiModal) {
|
||||||
this.multi_modal = modal;
|
this.multi_modal = modal;
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { Options, Vue } from "vue-class-component";
|
||||||
|
|
||||||
@Options({
|
@Options({
|
||||||
props: {
|
props: {
|
||||||
millis: Number,
|
until: Number,
|
||||||
tick_time: {
|
tick_time: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: 200,
|
default: 200,
|
||||||
|
@ -16,18 +16,14 @@ import { Options, Vue } from "vue-class-component";
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
export default class extends Vue {
|
export default class extends Vue {
|
||||||
private millis!: number;
|
private until!: number;
|
||||||
private tick_time!: number;
|
private tick_time!: number;
|
||||||
|
|
||||||
private interval_id: number | null = null;
|
private interval_id: number | null = null;
|
||||||
public string_repr = "";
|
public string_repr = "";
|
||||||
|
|
||||||
private get target_date_ms(): number {
|
|
||||||
return Date.now() + this.millis;
|
|
||||||
}
|
|
||||||
|
|
||||||
private tick(): void {
|
private tick(): void {
|
||||||
const distance_ms = this.target_date_ms - Date.now();
|
const distance_ms = this.until - Date.now();
|
||||||
|
|
||||||
if (distance_ms <= 0) {
|
if (distance_ms <= 0) {
|
||||||
this.string_repr = "Jetzt!";
|
this.string_repr = "Jetzt!";
|
||||||
|
|
|
@ -1,34 +1,32 @@
|
||||||
<template>
|
<template>
|
||||||
<Calendar :doors="doors" />
|
<Calendar :doors="doors" />
|
||||||
<hr />
|
<hr />
|
||||||
<div class="content">
|
<div class="content" v-html="store.site_config.content" />
|
||||||
<h3>Anleitung</h3>
|
<template v-if="store.next_door_target !== null">
|
||||||
<p>
|
<hr />
|
||||||
Hier findest Du für jedes Türchen des Adventskalenders ein kleines
|
<div class="content has-text-primary">
|
||||||
farbiges Bildchen. Diese werden automatisch am jeweiligen Tag anklickbar
|
Zeit zum nächsten Türchen: <CountDown :until="store.next_door_target" />
|
||||||
und zeigen Dir das neue jeweilige dahinter versteckte Bild.
|
</div>
|
||||||
</p>
|
</template>
|
||||||
<p>
|
|
||||||
Welches Bildchen zu welchem Tag gehört, erfährst Du, indem Du Deine Maus
|
|
||||||
darüber bewegst: Bei den bereits freigeschalteten Bildern wird angezeigt,
|
|
||||||
um welchen Tag es sich handelt.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DoorsSaved } from "@/lib/api";
|
import { DoorsSaved } from "@/lib/api";
|
||||||
import { Door } from "@/lib/door";
|
import { Door } from "@/lib/door";
|
||||||
|
import { advent22Store } from "@/plugins/store";
|
||||||
import { Options, Vue } from "vue-class-component";
|
import { Options, Vue } from "vue-class-component";
|
||||||
|
|
||||||
import Calendar from "./Calendar.vue";
|
import Calendar from "./Calendar.vue";
|
||||||
|
import CountDown from "./CountDown.vue";
|
||||||
|
|
||||||
@Options({
|
@Options({
|
||||||
components: {
|
components: {
|
||||||
Calendar,
|
Calendar,
|
||||||
|
CountDown,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
export default class extends Vue {
|
export default class extends Vue {
|
||||||
|
public readonly store = advent22Store();
|
||||||
public doors: Door[] = [];
|
public doors: Door[] = [];
|
||||||
|
|
||||||
public mounted(): void {
|
public mounted(): void {
|
||||||
|
|
|
@ -41,8 +41,10 @@
|
||||||
<dd>{{ num_user_doors }}</dd>
|
<dd>{{ num_user_doors }}</dd>
|
||||||
|
|
||||||
<dt>Zeit zum nächsten Türchen</dt>
|
<dt>Zeit zum nächsten Türchen</dt>
|
||||||
<dd v-if="next_door === null">Kein nächstes Türchen</dd>
|
<dd v-if="store.next_door_target === null">
|
||||||
<dd v-else><CountDown :millis="next_door" /></dd>
|
Kein nächstes Türchen
|
||||||
|
</dd>
|
||||||
|
<dd v-else><CountDown :until="store.next_door_target" /></dd>
|
||||||
|
|
||||||
<dt>Erstes Türchen</dt>
|
<dt>Erstes Türchen</dt>
|
||||||
<dd>{{ fmt_puzzle_date("first") }}</dd>
|
<dd>{{ fmt_puzzle_date("first") }}</dd>
|
||||||
|
@ -160,6 +162,7 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { AdminConfigModel, Credentials, DoorsSaved } from "@/lib/api";
|
import { AdminConfigModel, Credentials, DoorsSaved } from "@/lib/api";
|
||||||
|
import { advent22Store } from "@/plugins/store";
|
||||||
import { DateTime } from "luxon";
|
import { DateTime } from "luxon";
|
||||||
import { Options, Vue } from "vue-class-component";
|
import { Options, Vue } from "vue-class-component";
|
||||||
|
|
||||||
|
@ -175,6 +178,8 @@ import CountDown from "../CountDown.vue";
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
export default class extends Vue {
|
export default class extends Vue {
|
||||||
|
public readonly store = advent22Store();
|
||||||
|
|
||||||
public admin_config_model: AdminConfigModel = {
|
public admin_config_model: AdminConfigModel = {
|
||||||
solution: {
|
solution: {
|
||||||
value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
value: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||||
|
@ -213,7 +218,6 @@ export default class extends Vue {
|
||||||
};
|
};
|
||||||
public doors: DoorsSaved = [];
|
public doors: DoorsSaved = [];
|
||||||
public num_user_doors = 0;
|
public num_user_doors = 0;
|
||||||
public next_door: number | null = null;
|
|
||||||
public dav_credentials: Credentials = ["", ""];
|
public dav_credentials: Credentials = ["", ""];
|
||||||
public ui_credentials: Credentials = ["", ""];
|
public ui_credentials: Credentials = ["", ""];
|
||||||
|
|
||||||
|
@ -229,13 +233,11 @@ export default class extends Vue {
|
||||||
this.$advent22.api_get<AdminConfigModel>("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<number | null>("user/next_door"),
|
|
||||||
])
|
])
|
||||||
.then(([admin_config_model, doors, user_doors, next_door]) => {
|
.then(([admin_config_model, doors, user_doors]) => {
|
||||||
this.admin_config_model = admin_config_model;
|
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.next_door = next_door;
|
|
||||||
|
|
||||||
ready();
|
ready();
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,6 +11,7 @@ export const advent22Store = defineStore({
|
||||||
|
|
||||||
state: () => ({
|
state: () => ({
|
||||||
api_creds: empty_creds(),
|
api_creds: empty_creds(),
|
||||||
|
is_touch_device: check_touch_device(),
|
||||||
is_admin: false,
|
is_admin: false,
|
||||||
site_config: {
|
site_config: {
|
||||||
title: "Adventskalender",
|
title: "Adventskalender",
|
||||||
|
@ -18,7 +19,7 @@ export const advent22Store = defineStore({
|
||||||
content: "",
|
content: "",
|
||||||
footer: "",
|
footer: "",
|
||||||
} as SiteConfigModel,
|
} as SiteConfigModel,
|
||||||
is_touch_device: check_touch_device(),
|
next_door_target: null as number | null,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
getters: {
|
getters: {
|
||||||
|
@ -44,10 +45,19 @@ export const advent22Store = defineStore({
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => {});
|
||||||
|
|
||||||
ADVENT22.api_get<SiteConfigModel>("user/site_config")
|
Promise.all([
|
||||||
.then((site_config) => {
|
ADVENT22.api_get<SiteConfigModel>("user/site_config"),
|
||||||
document.title = `${site_config.title} – ${site_config.subtitle}`;
|
ADVENT22.api_get<number | null>("user/next_door"),
|
||||||
|
])
|
||||||
|
.then(([site_config, next_door]) => {
|
||||||
|
document.title = site_config.title;
|
||||||
|
|
||||||
|
if (site_config.subtitle !== "")
|
||||||
|
document.title += " – " + site_config.subtitle;
|
||||||
|
|
||||||
this.site_config = site_config;
|
this.site_config = site_config;
|
||||||
|
if (next_door !== null)
|
||||||
|
this.next_door_target = Date.now() + next_door;
|
||||||
})
|
})
|
||||||
.catch(ADVENT22.alert_user_error);
|
.catch(ADVENT22.alert_user_error);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue