2024-08-10 08:09:17 +00:00
|
|
|
<template>
|
|
|
|
<v-carousel
|
|
|
|
hide-delimiter-background
|
|
|
|
hide-delimiters
|
2024-08-11 16:54:49 +00:00
|
|
|
:progress="attachments.length > 1 ? 'primary' : false"
|
2024-08-10 08:09:17 +00:00
|
|
|
:show-arrows="attachments.length > 1 ? 'hover' : false"
|
|
|
|
height="auto"
|
|
|
|
>
|
|
|
|
<v-carousel-item v-for="item in metadata" class="fill-height">
|
2024-08-16 16:43:08 +00:00
|
|
|
<nuxt-link v-if="item.mimetype.split('/')[0] == 'image' && !props.noClickableAttachment"
|
|
|
|
:to="`/gallery/${item.id}`">
|
|
|
|
<attachment-renderer :item="item" />
|
|
|
|
</nuxt-link>
|
|
|
|
<div v-else>
|
|
|
|
<attachment-renderer :item="item" />
|
|
|
|
</div>
|
2024-08-10 08:09:17 +00:00
|
|
|
</v-carousel-item>
|
|
|
|
</v-carousel>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2024-08-16 16:43:08 +00:00
|
|
|
const props = defineProps<{ attachments: number[], noClickableAttachment?: boolean }>()
|
2024-08-11 06:53:58 +00:00
|
|
|
const emits = defineEmits(["update:metadata"])
|
2024-08-10 08:09:17 +00:00
|
|
|
|
|
|
|
const config = useRuntimeConfig()
|
|
|
|
|
|
|
|
const { data } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/files/attachments?take=${props.attachments.length}&id=${props.attachments.join(",")}`)
|
|
|
|
const metadata = computed(() => data.value.data)
|
|
|
|
|
2024-08-11 06:53:58 +00:00
|
|
|
watch(metadata, (value) => {
|
|
|
|
emits("update:metadata", value)
|
|
|
|
}, { deep: true, immediate: true })
|
|
|
|
|
2024-08-10 08:09:17 +00:00
|
|
|
function getAttachmentUrl(id: number) {
|
|
|
|
return `${config.public.solarNetworkApi}/cgi/files/attachments/${id}`
|
|
|
|
}
|
|
|
|
</script>
|