2024-12-24 13:53:00 +01:00
|
|
|
<template>
|
|
|
|
<div class="w-full h-full flex flex-col gap-2">
|
|
|
|
<Spinner v-if="status == 'loading'" />
|
|
|
|
<div class="grow">
|
|
|
|
<iframe ref="viewer" class="w-full h-full" />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button primary-outline class="!w-fit self-end" @click="closeModal">schließen</button>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { defineComponent } from "vue";
|
|
|
|
import { mapState, mapActions } from "pinia";
|
|
|
|
import { useModalStore } from "@/stores/modal";
|
|
|
|
import Spinner from "@/components/Spinner.vue";
|
2025-01-02 18:28:13 +01:00
|
|
|
import { useTemplateUsageStore } from "@/stores/admin/settings/templateUsage";
|
2024-12-24 13:53:00 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
export default defineComponent({
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
status: null as null | "loading" | { status: "success" | "failed"; reason?: string },
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState(useModalStore, ["data"]),
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.fetchItem();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions(useModalStore, ["closeModal"]),
|
|
|
|
...mapActions(useTemplateUsageStore, ["previewTemplateUsage"]),
|
|
|
|
fetchItem() {
|
|
|
|
this.status = "loading"
|
|
|
|
this.previewTemplateUsage(this.data)
|
|
|
|
.then((response) => {
|
|
|
|
this.status = { status: "success" };
|
|
|
|
const blob = new Blob([response.data], { type: "application/pdf" });
|
|
|
|
(this.$refs.viewer as HTMLIFrameElement).src = window.URL.createObjectURL(blob);
|
|
|
|
})
|
|
|
|
.catch(() => {
|
2024-12-26 12:04:00 +01:00
|
|
|
this.status = { status: "failed" };
|
2024-12-24 13:53:00 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|