Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
83ce9c8
style: update button styles and layout for improved UI consistency
kulikp1 May 25, 2026
2e4bacd
feat: enhance UI components and improve button styles for better user…
kulikp1 May 26, 2026
9f9a139
fix: refactor template structure in VisionAction.vue for improved rea…
kulikp1 May 26, 2026
d35d347
feat: replace custom progress bar implementation with reusable Progre…
kulikp1 May 26, 2026
e5cb6b1
fix: update progress bar and dialog visual
kulikp1 May 26, 2026
b9db38b
feat: add i18n support for user prompts and messages in VisionAction.vue
kulikp1 May 26, 2026
d10bce6
fix: update adminforth dependency version to 2.67.2 and adjust relate…
kulikp1 May 27, 2026
461670c
fix: adjust icon size and tooltip formatting in VisionTable.vue for c…
kulikp1 May 27, 2026
56659a0
fix: refactor vision table component for best visible
kulikp1 May 29, 2026
99b18ad
fix: fix close modal logic
kulikp1 May 29, 2026
5215f14
fix: fix edit prompt logic
kulikp1 May 29, 2026
edceeb0
fix: implement toggle functionality for card value mode in VisionTable
kulikp1 Jun 1, 2026
8dc3e52
fix: add no old value state
kulikp1 Jun 1, 2026
296d379
fix: update generated photo size
kulikp1 Jun 1, 2026
c1639d9
fix: add no old value state
kulikp1 Jun 1, 2026
baa9f65
fix: add handleBeforeCancel
kulikp1 Jun 1, 2026
0dabc7b
fix: move regeneration logic from cell buttons to global regenerate a…
kulikp1 Jun 2, 2026
8da3505
fix: fix carousel open/close bugs
kulikp1 Jun 2, 2026
b75d7d9
fix: change no image template
kulikp1 Jun 2, 2026
0f16ce0
fix: update style for no image mode
kulikp1 Jun 2, 2026
366d7cf
fix: delete unused border
kulikp1 Jun 2, 2026
6d78538
fix: change value description to caps
kulikp1 Jun 2, 2026
aef5115
fix: delete unused padding in grid
kulikp1 Jun 2, 2026
21ac9d7
fix: change generationStatus style for best reusable
kulikp1 Jun 2, 2026
e60aaef
fix: centred cards with progress bar wrapper
kulikp1 Jun 2, 2026
77dea52
fix: update template while image generate
kulikp1 Jun 2, 2026
17b56d5
fix: update skeleton style
kulikp1 Jun 3, 2026
35f673a
fix: update skeleton for image
kulikp1 Jun 3, 2026
e6fa1c0
fix: add standart pagination
kulikp1 Jun 4, 2026
0058942
fix: delete id section
kulikp1 Jun 4, 2026
c92a27e
fix: changed the rendering of the old/new select depending on the mode
kulikp1 Jun 4, 2026
dec3f8f
fix: disable Regenerate button when overwrite not allowed
kulikp1 Jun 4, 2026
b742016
fix: update style for generate status icon
kulikp1 Jun 4, 2026
f5b378c
fix: increase af version
kulikp1 Jun 5, 2026
3914796
fix: refactor imageGenerationCarousel logic and UI UX
kulikp1 Jun 5, 2026
cdea291
fix: refactor imageGenerationCarousel logic and UI UX
kulikp1 Jun 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
252 changes: 105 additions & 147 deletions custom/ImageGenerationCarousel.vue
Original file line number Diff line number Diff line change
@@ -1,144 +1,98 @@

<template>
<!-- Main modal -->
<div tabindex="-1" class="[scrollbar-gutter:stable] fixed inset-0 z-40 flex justify-center items-center bg-gray-800/50 dark:bg-gray-900/50 overflow-y-auto">
<div class="relative p-4 w-full max-w-[1600px]">
<!-- Modal content -->
<div class="relative bg-white rounded-lg shadow-xl dark:bg-gray-700">
<!-- Modal header -->
<div class="flex items-center justify-between p-3 md:p-4 border-b rounded-t dark:border-gray-600">
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">
{{ $t('Generate image with AI') }}
</h3>
<button type="button"
@click="emit('close')"
class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white" >
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
</svg>
<span class="sr-only">{{ $t('Close modal') }}</span>
</button>
<Dialog
ref="dialogRef"
:header="$t('Generate image with AI')"
:closable="true"
class="w-full lg:w-[1100px]"
:beforeCancelFunction="async () => { emit('close'); return true; }"
:buttons="dialogButtons"
:click-to-close-outside="false"
>
<div class="flex flex-col gap-4">
<Textarea
v-model="prompt"
:placeholder="$t('Prompt which will be passed to AI network')"
class="w-full text-sm leading-relaxed border border-gray-200 bg-gray-50/30 dark:border-gray-700 dark:bg-gray-800/40 dark:text-gray-100 rounded-xl focus:outline-none focus:border-gray-300 resize-none"
/>

<div class="grid grid-cols-2 gap-4">
<div class="flex flex-col gap-2">
<p class="text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider">
{{ $t('Source Image') }}
</p>
<div class="h-96 rounded-default border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 overflow-hidden flex items-center justify-center">
<img
v-if="attachmentFiles[0]"
:src="attachmentFiles[0]"
class="w-full h-full object-contain"
/>
<div v-else class="flex flex-col items-center justify-center gap-2 text-gray-400">
<svg class="w-12 h-12 text-gray-300 stroke-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
<p class="text-xs font-medium">{{ $t('No source image') }}</p>
</div>
<!-- Modal body -->
<div class="p-4 md:p-5">
<!-- PROMPT TEXTAREA -->
<!-- Textarea -->
<textarea
id="message"
rows="3"
class="block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
:placeholder="$t('Prompt which will be passed to AI network')"
v-model="prompt"
:title="$t('Prompt which will be passed to AI network')"
></textarea>

<!-- Thumbnails -->
<div class="mt-2 flex flex-wrap gap-2">
<img
v-for="(img, idx) in attachmentFiles"
:key="idx"
:src="img"
class="w-20 h-20 object-cover rounded cursor-pointer border hover:border-blue-500 transition"
:alt="`Generated image ${idx + 1}`"
@click="zoomImage(img)"
/>
</div>

<!-- Fullscreen Modal -->
<div
v-if="zoomedImage"
class="w-full h-full fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-80"
@click.self="closeZoom"
>
<img
:src="zoomedImage"
ref="zoomedImg"
class="max-w-full max-h-full rounded-lg object-contain cursor-grab z-75"
/>
</div>

<div class="flex flex-col items-center justify-center w-full relative">
<div
v-if="loading"
class=" absolute flex items-center justify-center w-full h-full z-40 bg-white/80 dark:bg-gray-900/80 rounded-lg"
>
<div role="status" class="absolute -translate-x-1/2 -translate-y-1/2 top-2/4 left-1/2">
<svg aria-hidden="true" class="w-8 h-8 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/><path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/></svg>
<span class="sr-only">{{ $t('Loading...') }}</span>
</div>
</div>

<div v-if="loadingTimer" class="absolute pt-12 flex items-center justify-center w-full h-full z-40 bg-white/80 dark:bg-gray-900/80 rounded-lg">
<div class="text-gray-800 dark:text-gray-100 text-lg font-semibold"
v-if="!historicalAverage"
>
{{ formatTime(loadingTimer) }} {{ $t('passed...') }}
</div>
<div class="w-64" v-else>
<ProgressBar
class="absolute max-w-full"
:currentValue="loadingTimer < historicalAverage ? loadingTimer : historicalAverage"
:minValue="0"
:maxValue="historicalAverage"
:showValues="false"
:progressFormatter="(value: number, percentage: number) => `${ formatTime(loadingTimer) } ( ~ ${ Math.floor( (
loadingTimer < historicalAverage ? loadingTimer : historicalAverage
) / historicalAverage * 100) }% )`"
/>
</div>
</div>
</div>
<div v-if="attachmentFiles.length > 1" class="flex flex-wrap gap-1.5">
<img
v-for="(img, idx) in attachmentFiles"
:key="idx"
:src="img"
class="w-10 h-10 object-cover rounded border border-gray-200"
/>
</div>
</div>

<div v-if="errorMessage" class="absolute flex items-center justify-center w-full h-full z-40 bg-white/80 dark:bg-gray-900/80 rounded-lg">
<div class="pt-20 text-red-500 dark:text-red-400 text-lg font-semibold">
{{ errorMessage }}
</div>
<div class="flex flex-col gap-2">
<p class="text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider">
{{ $t('Generated Image') }}
</p>
<div class="relative h-96 rounded-default border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 overflow-hidden">
<div v-if="loading || loadingTimer" class="absolute inset-0 z-10 flex flex-col items-center justify-center bg-white/80 dark:bg-gray-900/80">
<Spinner v-if="loading" class="w-8 h-8" />
<div v-if="loadingTimer" class="mt-3">
<div v-if="!historicalAverage" class="text-gray-800 dark:text-gray-100 text-sm font-semibold">
{{ formatTime(loadingTimer) }} {{ $t('passed...') }}
</div>


<div id="gallery" class="relative w-full min-w-0" data-carousel="static">
<!-- Carousel wrapper -->
<div class="relative h-56 overflow-hidden rounded-lg md:h-[calc(100vh-400px)]">
<Swiper
ref="sliderRef"
:images="images"
/>
</div>
<div v-else class="w-40">
<ProgressBar
:currentValue="loadingTimer < historicalAverage ? loadingTimer : historicalAverage"
:minValue="0"
:maxValue="historicalAverage"
:showValues="false"
:progressFormatter="(_value: number, _percentage: number) => `${ formatTime(loadingTimer) } ( ~ ${ Math.floor( (
loadingTimer < historicalAverage ? loadingTimer : historicalAverage
) / historicalAverage * 100) }% )`"
/>
</div>
</div>
</div>
<!-- Modal footer -->
<div class="flex justify-between p-4 md:p-5 border-t border-gray-200 rounded-b dark:border-gray-600 gap-3">
<button type="button" class="px-5 py-2.5 bg-gradient-to-r from-purple-500 via-purple-600 to-purple-700 hover:bg-gradient-to-br focus:ring-4 focus:outline-none focus:ring-purple-300 dark:focus:ring-purple-800 rounded-md text-white"
@click="generateImages"
>{{ $t('Regenerate') }}</button>
<div class="flex gap-3">
<button type="button" class="py-2.5 px-5 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700"
@click="emit('close')"
>{{ $t('Cancel') }}</button>
<button type="button" @click="confirmImage"
:disabled="loading || images.length === 0"
class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center
dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800
disabled:opacity-50 disabled:cursor-not-allowed"
>{{ $t('Use image') }}</button>
</div>

<div v-if="errorMessage" class="absolute inset-0 z-10 flex items-center justify-center bg-white/80 dark:bg-gray-900/80">
<p class="text-red-500 dark:text-red-400 text-sm font-semibold px-4 text-center">{{ errorMessage }}</p>
</div>

<Swiper ref="sliderRef" :images="images" class="h-full" />
</div>
</div>
</div>
</div>
</div>
</Dialog>

</template>

<script setup lang="ts">

import { ref, onMounted, nextTick, Ref, watch } from 'vue'
import { Carousel } from 'flowbite';
import { ref, onMounted, nextTick, Ref, computed } from 'vue'
import { callAdminForthApi } from '@/utils';
import { useI18n } from 'vue-i18n';
import adminforth from '@/adminforth';
import { ProgressBar } from '@/afcl';
import { ProgressBar, Dialog, Textarea, Spinner } from '@/afcl';
import Swiper from './Swiper.vue';

const { t: $t } = useI18n();
const { t } = useI18n();
const dialogRef = ref(null)
const sliderRef = ref(null)

const prompt = ref('');
Expand Down Expand Up @@ -168,8 +122,35 @@ onMounted(async () => {
template = 'Generate image for field {{field}} in {{resource}}. No text should be on image.';
}
prompt.value = template;
dialogRef.value?.open();
});

const dialogButtons = computed(() => [
{
label: t('Cancel'),
options: {
class: 'afcl-button',
mode: 'secondary',
},
onclick: () => emit('close'),
},
{
label: t('Use image'),
options: {
class: 'afcl-button',
disabled: loading.value || images.value.length === 0,
loader: loading.value,
},
onclick: () => confirmImage(),
},
{
label: t('Regenerate'),
options: {
class: 'afcl-button',
},
onclick: () => generateImages(),
},
]);

async function confirmImage() {
loading.value = true;
Expand Down Expand Up @@ -275,7 +256,7 @@ async function generateImages() {
error = resp.error;
}
if (!resp) {
error = $t('Error creating image generation job');
error = t('Error creating image generation job');
}

if (error) {
Expand Down Expand Up @@ -306,7 +287,7 @@ async function generateImages() {
};
jobStatus = jobResponse?.job?.status;
if (jobStatus === 'failed') {
error = jobResponse?.job?.error || $t('Image generation job failed');
error = jobResponse?.job?.error || t('Image generation job failed');
}
await new Promise((resolve) => setTimeout(resolve, props.regenerateImagesRefreshRate));
}
Expand Down Expand Up @@ -339,31 +320,8 @@ async function generateImages() {
sliderRef.value?.slideTo(images.value.length-1);

await nextTick();

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
loading.value = false;
}

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()
}
})
</script>
Loading