From a9d41dd580938f3544fca976e047454ba784c22e Mon Sep 17 00:00:00 2001 From: Vitalii Kulyk Date: Thu, 27 Feb 2025 13:05:00 +0200 Subject: [PATCH 01/67] fix: improve medium-zoom overlay styling for dark mode --- custom/preview.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/custom/preview.vue b/custom/preview.vue index cb65ad2..392f61d 100644 --- a/custom/preview.vue +++ b/custom/preview.vue @@ -39,7 +39,11 @@ background: rgba(0, 0, 0, 0.8); } .medium-zoom-overlay { - background: rgba(255, 255, 255, 0.8) !important + z-index: 99; + background: rgba(255, 255, 255, 0.8) !important; + } + html.dark .medium-zoom-overlay { + background: rgba(17, 24, 39, 0.7) !important; } body.medium-zoom--opened aside { filter: grayscale(1) From baeb863fdd469877a4a6d484cf02b2d3dc3350d6 Mon Sep 17 00:00:00 2001 From: Vitalii Kulyk Date: Thu, 13 Mar 2025 14:06:15 +0200 Subject: [PATCH 02/67] feat: add maxListWidth and maxShowWidth options for preview image dimensions --- custom/preview.vue | 10 +++++++++- index.ts | 2 ++ types.ts | 10 ++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/custom/preview.vue b/custom/preview.vue index 392f61d..d20c756 100644 --- a/custom/preview.vue +++ b/custom/preview.vue @@ -61,6 +61,7 @@ \ No newline at end of file From 4a706f96d01a700ae3aba0563c48e0acd37bff08 Mon Sep 17 00:00:00 2001 From: Ivan Borshchov Date: Sun, 4 May 2025 14:03:13 +0000 Subject: [PATCH 21/67] fix: preview put zoom on preview when content type or url changes --- custom/preview.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom/preview.vue b/custom/preview.vue index c5e64a6..4080b14 100644 --- a/custom/preview.vue +++ b/custom/preview.vue @@ -141,7 +141,8 @@ function guessContentType(url) { } -watch([url, contentType], async ([url, contentType]) => { +watch([contentType], async ([contentType]) => { + // since content type might change after true guessing (HEAD request might be slow) we need to try initializing zoom again if (zoom.value) { zoom.value.detach(); } From 7c4dcb0048788b526b8a559fa1682910b03be846 Mon Sep 17 00:00:00 2001 From: Ivan Borshchov Date: Sun, 4 May 2025 19:59:18 +0000 Subject: [PATCH 22/67] rebuild --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6367e67..14795c1 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ Allows to upload files to Amazon S3 bucket from adminforth application. -## For usage, see [AdminForth Upload Documentation](https://adminforth.dev/docs/tutorial/Plugins/upload/) \ No newline at end of file +## For usage, see [AdminForth Upload Documentation](https://adminforth.dev/docs/tutorial/Plugins/upload/) From 24a517b6312bf49bd572de5e3244e9c5477ceb40 Mon Sep 17 00:00:00 2001 From: Maksym Pipkun Date: Mon, 5 May 2025 14:56:32 +0300 Subject: [PATCH 23/67] feat: implement attachment file retrieval and zoom functionality in image generator --- custom/imageGenerator.vue | 80 ++++++++++++++++++++++++++++++++++++--- index.ts | 24 ++++++++++++ 2 files changed, 99 insertions(+), 5 deletions(-) diff --git a/custom/imageGenerator.vue b/custom/imageGenerator.vue index dd6299c..3773f82 100644 --- a/custom/imageGenerator.vue +++ b/custom/imageGenerator.vue @@ -21,10 +21,41 @@
- + > + + +
+ +
+ + +
+ +
-import { ref, onMounted, nextTick, Ref, h, computed } from 'vue' +import { ref, onMounted, nextTick, Ref, h, computed, watch, reactive } from 'vue' import { Carousel } from 'flowbite'; import { callAdminForthApi } from '@/utils'; import { useI18n } from 'vue-i18n'; @@ -158,6 +189,7 @@ const emit = defineEmits(['close', 'uploadImage']); const props = defineProps(['meta', 'record']); const images = ref([]); const loading = ref(false); +const attachmentFiles = ref([]) function minifyField(field: string): string { if (field.length > 100) { @@ -167,7 +199,7 @@ function minifyField(field: string): string { } const caurosel = ref(null); -onMounted(() => { +onMounted(async () => { // Initialize carousel const context = { field: props.meta.pathColumnLabel, @@ -203,7 +235,24 @@ onMounted(() => { prompt.value = template.replace(regex, (_, field) => { return context[field.trim()] || ''; }); + + const recordId = props.record[props.meta.recorPkFieldName]; + if (!recordId) return; + + try { + const resp = await callAdminForthApi({ + path: `/plugin/${props.meta.pluginInstanceId}/get_attachment_files`, + method: 'POST', + body: { recordId }, + }); + if (resp?.files?.length) { + attachmentFiles.value = resp.files; + console.log('attachmentFiles', attachmentFiles.value); + } + } catch (err) { + console.error('Failed to fetch attachment files', err); + } }); async function slide(direction: number) { @@ -357,6 +406,27 @@ async function generateImages() { loading.value = false; } +import mediumZoom from 'medium-zoom' +const zoomedImage = ref(null) +const zoomedImg = ref(null) + +function zoomImage(img) { + zoomedImage.value = img +} +function closeZoom() { + zoomedImage.value = null +} + +watch(zoomedImage, async (val) => { + await nextTick() + if (val && zoomedImg.value) { + mediumZoom(zoomedImg.value, { + margin: 24, + background: 'rgba(0, 0, 0, 0.9)', + scrollOffset: 150 + }).show() + } +}) diff --git a/index.ts b/index.ts index 3fb70f0..8a8e2f0 100644 --- a/index.ts +++ b/index.ts @@ -423,6 +423,30 @@ export default class UploadPlugin extends AdminForthPlugin { return null } }); + + server.endpoint({ + method: 'POST', + path: `/plugin/${this.pluginInstanceId}/get_attachment_files`, + handler: async ({ body, adminUser }) => { + const { recordId } = body; + + if (!recordId) return { error: 'Missing recordId' }; + + const record = await this.adminforth.resource(this.resourceConfig.resourceId).get([ + Filters.EQ(this.resourceConfig.columns.find((col: any) => col.primaryKey)?.name, recordId), + ]); + + if (!record) return { error: 'Record not found' }; + + if (!this.options.generation.attachFiles) return { files: [] }; + + const files = await this.options.generation.attachFiles({ record, adminUser }); + + return { + files: Array.isArray(files) ? files : [files], + }; + }, + }); } From fed48268e96847253d3d659abc9c1bf672280d3b Mon Sep 17 00:00:00 2001 From: Maksym Pipkun Date: Tue, 6 May 2025 10:47:22 +0300 Subject: [PATCH 24/67] fix: adjust z-index values for loading and error overlays in image generator --- custom/imageGenerator.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/custom/imageGenerator.vue b/custom/imageGenerator.vue index 3773f82..4165387 100644 --- a/custom/imageGenerator.vue +++ b/custom/imageGenerator.vue @@ -53,14 +53,14 @@
@@ -68,7 +68,7 @@
-
+
@@ -88,7 +88,7 @@
-
+
{{ errorMessage }}
@@ -97,7 +97,7 @@