advent22/ui/src/components/CalendarDoor.vue

56 lines
1.1 KiB
Vue
Raw Normal View History

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 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
import { Door } from "./door_map/calendar";
import SVGRect from "./rects/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-06 18:44:19 +00:00
emits: [
2023-09-07 00:41:38 +00:00
"doorClick",
"doorSuccess",
"doorFailure",
2023-09-06 18:44:19 +00:00
],
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 (
(reason instanceof AxiosError)
&& (reason.response !== undefined)
&& (reason.response.status === 401)
) {
msg = "Netter Versuch :)";
}
this.$emit("doorFailure", msg);
},
2023-09-06 18:44:19 +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;
}
</style>