2022-10-30 01:27:46 +00:00
|
|
|
<template>
|
2023-09-07 00:41:38 +00:00
|
|
|
<SVGRect :rectangle="door.position" :focused="false" @click="on_click" />
|
2022-10-30 01:27:46 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2023-09-07 02:08:56 +00:00
|
|
|
import { Door } from "@/lib/door";
|
2023-09-07 00:41:38 +00:00
|
|
|
import { AxiosError } from "axios";
|
2023-09-06 16:25:35 +00:00
|
|
|
import { Options, Vue } from "vue-class-component";
|
2023-09-07 00:41:38 +00:00
|
|
|
|
2023-09-07 02:08:56 +00:00
|
|
|
import SVGRect from "./SVGRect.vue";
|
2022-10-30 01:27:46 +00:00
|
|
|
|
|
|
|
@Options({
|
2023-09-07 00:41:38 +00:00
|
|
|
components: {
|
|
|
|
SVGRect,
|
|
|
|
},
|
2022-10-30 01:27:46 +00:00
|
|
|
props: {
|
2023-09-07 00:41:38 +00:00
|
|
|
door: Door,
|
2022-10-30 01:27:46 +00:00
|
|
|
},
|
2023-09-07 01:17:14 +00:00
|
|
|
emits: ["doorClick", "doorSuccess", "doorFailure"],
|
2022-10-30 01:27:46 +00:00
|
|
|
})
|
2023-01-24 23:18:09 +00:00
|
|
|
export default class extends Vue {
|
2023-09-07 00:41:38 +00:00
|
|
|
public door!: Door;
|
2022-10-30 03:10:07 +00:00
|
|
|
|
2023-09-06 16:25:35 +00:00
|
|
|
public on_click() {
|
2023-09-07 00:41:38 +00:00
|
|
|
this.$emit("doorClick");
|
2023-09-06 18:44:19 +00:00
|
|
|
|
|
|
|
this.$advent22.api_get_blob(
|
2023-09-07 00:41:38 +00:00
|
|
|
`days/image/${this.door.day}`,
|
|
|
|
(data) => this.$emit("doorSuccess", data),
|
|
|
|
(_, reason) => {
|
|
|
|
let msg = "Unbekannter Fehler, bitte wiederholen!";
|
|
|
|
|
|
|
|
if (
|
2023-09-07 01:17:14 +00:00
|
|
|
reason instanceof AxiosError &&
|
|
|
|
reason.response !== undefined &&
|
|
|
|
reason.response.status === 401
|
2023-09-07 00:41:38 +00:00
|
|
|
) {
|
|
|
|
msg = "Netter Versuch :)";
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$emit("doorFailure", msg);
|
|
|
|
},
|
2023-09-06 18:44:19 +00:00
|
|
|
);
|
2022-11-03 23:01:28 +00:00
|
|
|
}
|
2022-10-30 01:27:46 +00:00
|
|
|
}
|
|
|
|
</script>
|
2023-09-07 00:41:38 +00:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
rect {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2023-09-07 01:17:14 +00:00
|
|
|
</style>
|