add user_doors into store
This commit is contained in:
parent
6efa2aef9b
commit
644b1eb3e3
3 changed files with 15 additions and 19 deletions
|
@ -11,7 +11,6 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { DoorsSaved } from "@/lib/api";
|
|
||||||
import { Door } from "@/lib/door";
|
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";
|
||||||
|
@ -27,19 +26,15 @@ import CountDown from "./CountDown.vue";
|
||||||
})
|
})
|
||||||
export default class extends Vue {
|
export default class extends Vue {
|
||||||
public readonly store = advent22Store();
|
public readonly store = advent22Store();
|
||||||
public doors: Door[] = [];
|
|
||||||
|
|
||||||
public mounted(): void {
|
public get doors(): Door[] {
|
||||||
this.$advent22
|
const result = [];
|
||||||
.api_get<DoorsSaved>("user/doors")
|
|
||||||
.then((data) => {
|
|
||||||
this.doors.length = 0;
|
|
||||||
|
|
||||||
for (const value of data) {
|
for (const value of this.store.user_doors) {
|
||||||
this.doors.push(Door.load(value));
|
result.push(Door.load(value));
|
||||||
}
|
}
|
||||||
})
|
|
||||||
.catch(this.$advent22.alert_user_error);
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
<h3>Rätsel</h3>
|
<h3>Rätsel</h3>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Offene Türchen</dt>
|
<dt>Offene Türchen</dt>
|
||||||
<dd>{{ num_user_doors }}</dd>
|
<dd>{{ store.user_doors.length }}</dd>
|
||||||
|
|
||||||
<dt>Zeit zum nächsten Türchen</dt>
|
<dt>Zeit zum nächsten Türchen</dt>
|
||||||
<dd v-if="store.next_door_target === null">
|
<dd v-if="store.next_door_target === null">
|
||||||
|
@ -217,7 +217,6 @@ export default class extends Vue {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
public doors: DoorsSaved = [];
|
public doors: DoorsSaved = [];
|
||||||
public num_user_doors = 0;
|
|
||||||
public dav_credentials: Credentials = ["", ""];
|
public dav_credentials: Credentials = ["", ""];
|
||||||
public ui_credentials: Credentials = ["", ""];
|
public ui_credentials: Credentials = ["", ""];
|
||||||
|
|
||||||
|
@ -232,12 +231,10 @@ export default class extends Vue {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
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"),
|
|
||||||
])
|
])
|
||||||
.then(([admin_config_model, doors, user_doors]) => {
|
.then(([admin_config_model, 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;
|
|
||||||
|
|
||||||
ready();
|
ready();
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Credentials, SiteConfigModel } from "@/lib/api";
|
import { Credentials, DoorsSaved, SiteConfigModel } from "@/lib/api";
|
||||||
import { ADVENT22 } from "@/plugins/advent22";
|
import { ADVENT22 } from "@/plugins/advent22";
|
||||||
import { AxiosBasicCredentials } from "axios";
|
import { AxiosBasicCredentials } from "axios";
|
||||||
import { acceptHMRUpdate, defineStore } from "pinia";
|
import { acceptHMRUpdate, defineStore } from "pinia";
|
||||||
|
@ -19,6 +19,7 @@ export const advent22Store = defineStore({
|
||||||
content: "",
|
content: "",
|
||||||
footer: "",
|
footer: "",
|
||||||
} as SiteConfigModel,
|
} as SiteConfigModel,
|
||||||
|
user_doors: [] as DoorsSaved,
|
||||||
next_door_target: null as number | null,
|
next_door_target: null as number | null,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -47,15 +48,18 @@ export const advent22Store = defineStore({
|
||||||
|
|
||||||
Promise.all([
|
Promise.all([
|
||||||
ADVENT22.api_get<SiteConfigModel>("user/site_config"),
|
ADVENT22.api_get<SiteConfigModel>("user/site_config"),
|
||||||
|
ADVENT22.api_get<DoorsSaved>("user/doors"),
|
||||||
ADVENT22.api_get<number | null>("user/next_door"),
|
ADVENT22.api_get<number | null>("user/next_door"),
|
||||||
])
|
])
|
||||||
.then(([site_config, next_door]) => {
|
.then(([site_config, user_doors, next_door]) => {
|
||||||
document.title = site_config.title;
|
document.title = site_config.title;
|
||||||
|
|
||||||
if (site_config.subtitle !== "")
|
if (site_config.subtitle !== "")
|
||||||
document.title += " – " + site_config.subtitle;
|
document.title += " – " + site_config.subtitle;
|
||||||
|
|
||||||
this.site_config = site_config;
|
this.site_config = site_config;
|
||||||
|
this.user_doors = user_doors;
|
||||||
|
|
||||||
if (next_door !== null)
|
if (next_door !== null)
|
||||||
this.next_door_target = Date.now() + next_door;
|
this.next_door_target = Date.now() + next_door;
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue