@adminforth/upload 1.0.26 → 1.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog.md +7 -2
- package/custom/imageGenerator.vue +16 -10
- package/custom/preview.vue +1 -1
- package/custom/uploader.vue +20 -12
- package/dist/custom/imageGenerator.vue +16 -10
- package/dist/custom/preview.vue +1 -1
- package/dist/custom/uploader.vue +20 -12
- package/package.json +1 -1
package/ChangeLog.md
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
## [1.0.
|
|
3
|
+
## [1.0.24] - 2023-12-24
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Add translation
|
|
7
|
+
|
|
8
|
+
## [1.0.23] - 2023-10-07
|
|
4
9
|
|
|
5
10
|
### Fixed
|
|
6
11
|
- preview maxWidth to limit max width of image
|
|
7
|
-
- Added accept attribute to input
|
|
12
|
+
- Added accept attribute to input
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<!-- Modal header -->
|
|
9
9
|
<div class="flex items-center justify-between p-3 md:p-4 border-b rounded-t dark:border-gray-600">
|
|
10
10
|
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">
|
|
11
|
-
Generate image with AI
|
|
11
|
+
{{ $('Generate image with AI') }}
|
|
12
12
|
</h3>
|
|
13
13
|
<button type="button"
|
|
14
14
|
@click="emit('close')"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
|
17
17
|
<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"/>
|
|
18
18
|
</svg>
|
|
19
|
-
<span class="sr-only">Close modal</span>
|
|
19
|
+
<span class="sr-only">{{ $('Close modal') }}</span>
|
|
20
20
|
</button>
|
|
21
21
|
</div>
|
|
22
22
|
<!-- Modal body -->
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
>
|
|
34
34
|
<div role="status" class="absolute -translate-x-1/2 -translate-y-1/2 top-2/4 left-1/2">
|
|
35
35
|
<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>
|
|
36
|
-
<span class="sr-only">Loading
|
|
36
|
+
<span class="sr-only">{{ $('Loading...') }}</span>
|
|
37
37
|
</div>
|
|
38
38
|
</div>
|
|
39
39
|
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
|
|
50
50
|
<button @click="generateImages" type="button" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4
|
|
51
51
|
focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center
|
|
52
|
-
dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 ms-2">Generate images</button>
|
|
52
|
+
dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 ms-2">{{ $('Generate images') }}</button>
|
|
53
53
|
|
|
54
54
|
</div>
|
|
55
55
|
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
<svg class="w-4 h-4 text-white dark:text-gray-800 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
|
|
63
63
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 1 1 5l4 4"/>
|
|
64
64
|
</svg>
|
|
65
|
-
<span class="sr-only">Previous</span>
|
|
65
|
+
<span class="sr-only">{{ $('Previous') }}</span>
|
|
66
66
|
</span>
|
|
67
67
|
</button>
|
|
68
68
|
<button type="button" class="absolute top-0 end-0 z-30 flex items-center justify-center h-full px-4 cursor-pointer group focus:outline-none"
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
<svg class="w-4 h-4 text-white dark:text-gray-800 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
|
|
73
73
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
|
|
74
74
|
</svg>
|
|
75
|
-
<span class="sr-only">Next</span>
|
|
75
|
+
<span class="sr-only">{{ $('Next') }}</span>
|
|
76
76
|
</span>
|
|
77
77
|
</button>
|
|
78
78
|
|
|
@@ -87,10 +87,10 @@
|
|
|
87
87
|
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
|
|
88
88
|
dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800
|
|
89
89
|
disabled:opacity-50 disabled:cursor-not-allowed"
|
|
90
|
-
>Use image</button>
|
|
90
|
+
>{{ $('Use image') }}</button>
|
|
91
91
|
<button type="button" class="py-2.5 px-5 ms-3 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"
|
|
92
92
|
@click="emit('close')"
|
|
93
|
-
>Cancel</button>
|
|
93
|
+
>{{ $('Cancel') }}</button>
|
|
94
94
|
</div>
|
|
95
95
|
</div>
|
|
96
96
|
</div>
|
|
@@ -106,6 +106,9 @@
|
|
|
106
106
|
import { ref, onMounted, nextTick } from 'vue'
|
|
107
107
|
import { Carousel } from 'flowbite';
|
|
108
108
|
import { callAdminForthApi } from '@/utils';
|
|
109
|
+
import { useI18n } from 'vue-i18n';
|
|
110
|
+
|
|
111
|
+
const { t: $t } = useI18n();
|
|
109
112
|
|
|
110
113
|
const prompt = ref('');
|
|
111
114
|
const emit = defineEmits(['close', 'uploadImage']);
|
|
@@ -130,7 +133,10 @@ onMounted(() => {
|
|
|
130
133
|
}).join('\n');
|
|
131
134
|
}
|
|
132
135
|
|
|
133
|
-
prompt.value =
|
|
136
|
+
prompt.value = $t('Generate image for field "{field}" in {resource}. No text should be on image.', {
|
|
137
|
+
field: props.meta.pathColumnLabel,
|
|
138
|
+
resource: props.meta.resourceLabel,
|
|
139
|
+
});
|
|
134
140
|
if (additionalContext) {
|
|
135
141
|
prompt.value += ` ${additionalContext}`;
|
|
136
142
|
}
|
|
@@ -180,7 +186,7 @@ async function generateImages() {
|
|
|
180
186
|
|
|
181
187
|
if (resp.error) {
|
|
182
188
|
window.adminforth.alert({
|
|
183
|
-
message:
|
|
189
|
+
message: $t('Error: {error}', { error: JSON.stringify(resp.error) }),
|
|
184
190
|
variant: 'danger',
|
|
185
191
|
timeout: 15,
|
|
186
192
|
});
|
package/custom/preview.vue
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<svg class="w-4 h-4 me-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
26
26
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
|
|
27
27
|
</svg>
|
|
28
|
-
Download file
|
|
28
|
+
{{ $('Download file') }}
|
|
29
29
|
</a>
|
|
30
30
|
</template>
|
|
31
31
|
|
package/custom/uploader.vue
CHANGED
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
</svg>
|
|
32
32
|
|
|
33
33
|
<template v-if="!uploaded">
|
|
34
|
-
<p class="mb-2 text-sm text-gray-500 dark:text-gray-400"><span class="font-semibold">Click to upload</span> or drag and drop</p>
|
|
34
|
+
<p class="mb-2 text-sm text-gray-500 dark:text-gray-400"><span class="font-semibold">{{ $t('Click to upload') }}</span> {{ $t('or drag and drop') }}</p>
|
|
35
35
|
<p class="text-xs text-gray-500 dark:text-gray-400">
|
|
36
|
-
{{ allowedExtensionsLabel }} {{ meta.maxFileSize ? `(up to
|
|
36
|
+
{{ allowedExtensionsLabel }} {{ meta.maxFileSize ? $t(`(up to {size})`, { size: humanifySize(meta.maxFileSize) }) : '' }}
|
|
37
37
|
</p>
|
|
38
38
|
</template>
|
|
39
39
|
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
|
|
51
51
|
</svg>
|
|
52
52
|
<p class="ml-2 text-sm text-green-600 dark:text-green-400 flex items-center">
|
|
53
|
-
File uploaded
|
|
53
|
+
{{ $('File uploaded') }}
|
|
54
54
|
<span class="text-xs text-gray-500 dark:text-gray-400">{{ humanifySize(uploadedSize) }}</span>
|
|
55
55
|
</p>
|
|
56
56
|
|
|
57
57
|
<button @click.stop.prevent="clear" class="ml-2 text-xs text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-500
|
|
58
|
-
hover:underline dark:hover:underline focus:outline-none">Clear</button>
|
|
58
|
+
hover:underline dark:hover:underline focus:outline-none">{{ $t('Clear') }}</button>
|
|
59
59
|
</div>
|
|
60
60
|
|
|
61
61
|
</div>
|
|
@@ -69,6 +69,9 @@
|
|
|
69
69
|
import { computed, ref, onMounted, watch } from 'vue'
|
|
70
70
|
import { callAdminForthApi } from '@/utils'
|
|
71
71
|
import { IconMagic } from '@iconify-prerendered/vue-mdi';
|
|
72
|
+
import { useI18n } from 'vue-i18n';
|
|
73
|
+
|
|
74
|
+
const { t } = useI18n();
|
|
72
75
|
|
|
73
76
|
const inputId = computed(() => `dropzone-file-${props.meta.pluginInstanceId}`);
|
|
74
77
|
|
|
@@ -103,7 +106,6 @@ watch(() => uploaded, (value) => {
|
|
|
103
106
|
|
|
104
107
|
function uploadGeneratedImage(imgBlob) {
|
|
105
108
|
// update the value
|
|
106
|
-
console.log('⚓⚓ Generated image uploaded:', imgBlob);
|
|
107
109
|
|
|
108
110
|
const file = new File([imgBlob], 'generated.png', { type: imgBlob.type });
|
|
109
111
|
onFileChange({
|
|
@@ -130,7 +132,7 @@ const allowedExtensionsLabel = computed(() => {
|
|
|
130
132
|
// make upper case and write in format EXT1, EXT2 or EXT3
|
|
131
133
|
let label = allowedExtensions.map(ext => ext.toUpperCase()).join(', ');
|
|
132
134
|
// last comma to 'or'
|
|
133
|
-
label = label.replace(/,([^,]*)$/, '
|
|
135
|
+
label = label.replace(/,([^,]*)$/, ` ${t('or')}$1`)
|
|
134
136
|
return label
|
|
135
137
|
});
|
|
136
138
|
|
|
@@ -191,7 +193,10 @@ const onFileChange = async (e) => {
|
|
|
191
193
|
const allowedExtensions = props.meta.allowedExtensions || []
|
|
192
194
|
if (allowedExtensions.length > 0 && !allowedExtensions.includes(extension)) {
|
|
193
195
|
window.adminforth.alert({
|
|
194
|
-
message:
|
|
196
|
+
message: t('Sorry but the file type {extension} is not allowed. Please upload a file with one of the following extensions: {allowedExtensionsLabel}', {
|
|
197
|
+
extension,
|
|
198
|
+
allowedExtensionsLabel: allowedExtensionsLabel.value,
|
|
199
|
+
}),
|
|
195
200
|
variant: 'danger'
|
|
196
201
|
});
|
|
197
202
|
return;
|
|
@@ -200,13 +205,16 @@ const onFileChange = async (e) => {
|
|
|
200
205
|
// validate file size
|
|
201
206
|
if (props.meta.maxFileSize && size > props.meta.maxFileSize) {
|
|
202
207
|
window.adminforth.alert({
|
|
203
|
-
message:
|
|
208
|
+
message: t('Sorry but the file size {size} is too large. Please upload a file with a maximum size of {maxFileSize}', {
|
|
209
|
+
size: humanifySize(size),
|
|
210
|
+
maxFileSize: humanifySize(props.meta.maxFileSize),
|
|
211
|
+
}),
|
|
204
212
|
variant: 'danger'
|
|
205
213
|
});
|
|
206
214
|
return;
|
|
207
215
|
}
|
|
208
216
|
|
|
209
|
-
emit('update:inValidity', 'Upload in progress...');
|
|
217
|
+
emit('update:inValidity', t('Upload in progress...'));
|
|
210
218
|
try {
|
|
211
219
|
// supports preview
|
|
212
220
|
if (type.startsWith('image/')) {
|
|
@@ -230,7 +238,7 @@ const onFileChange = async (e) => {
|
|
|
230
238
|
|
|
231
239
|
if (error) {
|
|
232
240
|
window.adminforth.alert({
|
|
233
|
-
message:
|
|
241
|
+
message: t('File was not uploaded because of error: {error}', { error }),
|
|
234
242
|
variant: 'danger'
|
|
235
243
|
});
|
|
236
244
|
imgPreview.value = null;
|
|
@@ -258,7 +266,7 @@ const onFileChange = async (e) => {
|
|
|
258
266
|
});
|
|
259
267
|
if (!success) {
|
|
260
268
|
window.adminforth.alert({
|
|
261
|
-
messageHtml: `<div
|
|
269
|
+
messageHtml: `<div>${$t('Sorry but the file was not uploaded because of S3 Request Error:')}</div>
|
|
262
270
|
<pre style="white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; max-width: 100%;">${
|
|
263
271
|
xhr.responseText.replace(/</g, '<').replace(/>/g, '>')
|
|
264
272
|
}</pre>`,
|
|
@@ -275,7 +283,7 @@ const onFileChange = async (e) => {
|
|
|
275
283
|
} catch (error) {
|
|
276
284
|
console.error('Error uploading file:', error);
|
|
277
285
|
window.adminforth.alert({
|
|
278
|
-
message:
|
|
286
|
+
message: t('Sorry but the file was not be uploaded. Please try again: {error}', { error: error.message }),
|
|
279
287
|
variant: 'danger'
|
|
280
288
|
});
|
|
281
289
|
imgPreview.value = null;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<!-- Modal header -->
|
|
9
9
|
<div class="flex items-center justify-between p-3 md:p-4 border-b rounded-t dark:border-gray-600">
|
|
10
10
|
<h3 class="text-xl font-semibold text-gray-900 dark:text-white">
|
|
11
|
-
Generate image with AI
|
|
11
|
+
{{ $('Generate image with AI') }}
|
|
12
12
|
</h3>
|
|
13
13
|
<button type="button"
|
|
14
14
|
@click="emit('close')"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
|
17
17
|
<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"/>
|
|
18
18
|
</svg>
|
|
19
|
-
<span class="sr-only">Close modal</span>
|
|
19
|
+
<span class="sr-only">{{ $('Close modal') }}</span>
|
|
20
20
|
</button>
|
|
21
21
|
</div>
|
|
22
22
|
<!-- Modal body -->
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
>
|
|
34
34
|
<div role="status" class="absolute -translate-x-1/2 -translate-y-1/2 top-2/4 left-1/2">
|
|
35
35
|
<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>
|
|
36
|
-
<span class="sr-only">Loading
|
|
36
|
+
<span class="sr-only">{{ $('Loading...') }}</span>
|
|
37
37
|
</div>
|
|
38
38
|
</div>
|
|
39
39
|
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
|
|
50
50
|
<button @click="generateImages" type="button" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4
|
|
51
51
|
focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center
|
|
52
|
-
dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 ms-2">Generate images</button>
|
|
52
|
+
dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 ms-2">{{ $('Generate images') }}</button>
|
|
53
53
|
|
|
54
54
|
</div>
|
|
55
55
|
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
<svg class="w-4 h-4 text-white dark:text-gray-800 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
|
|
63
63
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 1 1 5l4 4"/>
|
|
64
64
|
</svg>
|
|
65
|
-
<span class="sr-only">Previous</span>
|
|
65
|
+
<span class="sr-only">{{ $('Previous') }}</span>
|
|
66
66
|
</span>
|
|
67
67
|
</button>
|
|
68
68
|
<button type="button" class="absolute top-0 end-0 z-30 flex items-center justify-center h-full px-4 cursor-pointer group focus:outline-none"
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
<svg class="w-4 h-4 text-white dark:text-gray-800 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
|
|
73
73
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
|
|
74
74
|
</svg>
|
|
75
|
-
<span class="sr-only">Next</span>
|
|
75
|
+
<span class="sr-only">{{ $('Next') }}</span>
|
|
76
76
|
</span>
|
|
77
77
|
</button>
|
|
78
78
|
|
|
@@ -87,10 +87,10 @@
|
|
|
87
87
|
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
|
|
88
88
|
dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800
|
|
89
89
|
disabled:opacity-50 disabled:cursor-not-allowed"
|
|
90
|
-
>Use image</button>
|
|
90
|
+
>{{ $('Use image') }}</button>
|
|
91
91
|
<button type="button" class="py-2.5 px-5 ms-3 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"
|
|
92
92
|
@click="emit('close')"
|
|
93
|
-
>Cancel</button>
|
|
93
|
+
>{{ $('Cancel') }}</button>
|
|
94
94
|
</div>
|
|
95
95
|
</div>
|
|
96
96
|
</div>
|
|
@@ -106,6 +106,9 @@
|
|
|
106
106
|
import { ref, onMounted, nextTick } from 'vue'
|
|
107
107
|
import { Carousel } from 'flowbite';
|
|
108
108
|
import { callAdminForthApi } from '@/utils';
|
|
109
|
+
import { useI18n } from 'vue-i18n';
|
|
110
|
+
|
|
111
|
+
const { t: $t } = useI18n();
|
|
109
112
|
|
|
110
113
|
const prompt = ref('');
|
|
111
114
|
const emit = defineEmits(['close', 'uploadImage']);
|
|
@@ -130,7 +133,10 @@ onMounted(() => {
|
|
|
130
133
|
}).join('\n');
|
|
131
134
|
}
|
|
132
135
|
|
|
133
|
-
prompt.value =
|
|
136
|
+
prompt.value = $t('Generate image for field "{field}" in {resource}. No text should be on image.', {
|
|
137
|
+
field: props.meta.pathColumnLabel,
|
|
138
|
+
resource: props.meta.resourceLabel,
|
|
139
|
+
});
|
|
134
140
|
if (additionalContext) {
|
|
135
141
|
prompt.value += ` ${additionalContext}`;
|
|
136
142
|
}
|
|
@@ -180,7 +186,7 @@ async function generateImages() {
|
|
|
180
186
|
|
|
181
187
|
if (resp.error) {
|
|
182
188
|
window.adminforth.alert({
|
|
183
|
-
message:
|
|
189
|
+
message: $t('Error: {error}', { error: JSON.stringify(resp.error) }),
|
|
184
190
|
variant: 'danger',
|
|
185
191
|
timeout: 15,
|
|
186
192
|
});
|
package/dist/custom/preview.vue
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<svg class="w-4 h-4 me-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
26
26
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
|
|
27
27
|
</svg>
|
|
28
|
-
Download file
|
|
28
|
+
{{ $('Download file') }}
|
|
29
29
|
</a>
|
|
30
30
|
</template>
|
|
31
31
|
|
package/dist/custom/uploader.vue
CHANGED
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
</svg>
|
|
32
32
|
|
|
33
33
|
<template v-if="!uploaded">
|
|
34
|
-
<p class="mb-2 text-sm text-gray-500 dark:text-gray-400"><span class="font-semibold">Click to upload</span> or drag and drop</p>
|
|
34
|
+
<p class="mb-2 text-sm text-gray-500 dark:text-gray-400"><span class="font-semibold">{{ $t('Click to upload') }}</span> {{ $t('or drag and drop') }}</p>
|
|
35
35
|
<p class="text-xs text-gray-500 dark:text-gray-400">
|
|
36
|
-
{{ allowedExtensionsLabel }} {{ meta.maxFileSize ? `(up to
|
|
36
|
+
{{ allowedExtensionsLabel }} {{ meta.maxFileSize ? $t(`(up to {size})`, { size: humanifySize(meta.maxFileSize) }) : '' }}
|
|
37
37
|
</p>
|
|
38
38
|
</template>
|
|
39
39
|
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
|
|
51
51
|
</svg>
|
|
52
52
|
<p class="ml-2 text-sm text-green-600 dark:text-green-400 flex items-center">
|
|
53
|
-
File uploaded
|
|
53
|
+
{{ $('File uploaded') }}
|
|
54
54
|
<span class="text-xs text-gray-500 dark:text-gray-400">{{ humanifySize(uploadedSize) }}</span>
|
|
55
55
|
</p>
|
|
56
56
|
|
|
57
57
|
<button @click.stop.prevent="clear" class="ml-2 text-xs text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-500
|
|
58
|
-
hover:underline dark:hover:underline focus:outline-none">Clear</button>
|
|
58
|
+
hover:underline dark:hover:underline focus:outline-none">{{ $t('Clear') }}</button>
|
|
59
59
|
</div>
|
|
60
60
|
|
|
61
61
|
</div>
|
|
@@ -69,6 +69,9 @@
|
|
|
69
69
|
import { computed, ref, onMounted, watch } from 'vue'
|
|
70
70
|
import { callAdminForthApi } from '@/utils'
|
|
71
71
|
import { IconMagic } from '@iconify-prerendered/vue-mdi';
|
|
72
|
+
import { useI18n } from 'vue-i18n';
|
|
73
|
+
|
|
74
|
+
const { t } = useI18n();
|
|
72
75
|
|
|
73
76
|
const inputId = computed(() => `dropzone-file-${props.meta.pluginInstanceId}`);
|
|
74
77
|
|
|
@@ -103,7 +106,6 @@ watch(() => uploaded, (value) => {
|
|
|
103
106
|
|
|
104
107
|
function uploadGeneratedImage(imgBlob) {
|
|
105
108
|
// update the value
|
|
106
|
-
console.log('⚓⚓ Generated image uploaded:', imgBlob);
|
|
107
109
|
|
|
108
110
|
const file = new File([imgBlob], 'generated.png', { type: imgBlob.type });
|
|
109
111
|
onFileChange({
|
|
@@ -130,7 +132,7 @@ const allowedExtensionsLabel = computed(() => {
|
|
|
130
132
|
// make upper case and write in format EXT1, EXT2 or EXT3
|
|
131
133
|
let label = allowedExtensions.map(ext => ext.toUpperCase()).join(', ');
|
|
132
134
|
// last comma to 'or'
|
|
133
|
-
label = label.replace(/,([^,]*)$/, '
|
|
135
|
+
label = label.replace(/,([^,]*)$/, ` ${t('or')}$1`)
|
|
134
136
|
return label
|
|
135
137
|
});
|
|
136
138
|
|
|
@@ -191,7 +193,10 @@ const onFileChange = async (e) => {
|
|
|
191
193
|
const allowedExtensions = props.meta.allowedExtensions || []
|
|
192
194
|
if (allowedExtensions.length > 0 && !allowedExtensions.includes(extension)) {
|
|
193
195
|
window.adminforth.alert({
|
|
194
|
-
message:
|
|
196
|
+
message: t('Sorry but the file type {extension} is not allowed. Please upload a file with one of the following extensions: {allowedExtensionsLabel}', {
|
|
197
|
+
extension,
|
|
198
|
+
allowedExtensionsLabel: allowedExtensionsLabel.value,
|
|
199
|
+
}),
|
|
195
200
|
variant: 'danger'
|
|
196
201
|
});
|
|
197
202
|
return;
|
|
@@ -200,13 +205,16 @@ const onFileChange = async (e) => {
|
|
|
200
205
|
// validate file size
|
|
201
206
|
if (props.meta.maxFileSize && size > props.meta.maxFileSize) {
|
|
202
207
|
window.adminforth.alert({
|
|
203
|
-
message:
|
|
208
|
+
message: t('Sorry but the file size {size} is too large. Please upload a file with a maximum size of {maxFileSize}', {
|
|
209
|
+
size: humanifySize(size),
|
|
210
|
+
maxFileSize: humanifySize(props.meta.maxFileSize),
|
|
211
|
+
}),
|
|
204
212
|
variant: 'danger'
|
|
205
213
|
});
|
|
206
214
|
return;
|
|
207
215
|
}
|
|
208
216
|
|
|
209
|
-
emit('update:inValidity', 'Upload in progress...');
|
|
217
|
+
emit('update:inValidity', t('Upload in progress...'));
|
|
210
218
|
try {
|
|
211
219
|
// supports preview
|
|
212
220
|
if (type.startsWith('image/')) {
|
|
@@ -230,7 +238,7 @@ const onFileChange = async (e) => {
|
|
|
230
238
|
|
|
231
239
|
if (error) {
|
|
232
240
|
window.adminforth.alert({
|
|
233
|
-
message:
|
|
241
|
+
message: t('File was not uploaded because of error: {error}', { error }),
|
|
234
242
|
variant: 'danger'
|
|
235
243
|
});
|
|
236
244
|
imgPreview.value = null;
|
|
@@ -258,7 +266,7 @@ const onFileChange = async (e) => {
|
|
|
258
266
|
});
|
|
259
267
|
if (!success) {
|
|
260
268
|
window.adminforth.alert({
|
|
261
|
-
messageHtml: `<div
|
|
269
|
+
messageHtml: `<div>${$t('Sorry but the file was not uploaded because of S3 Request Error:')}</div>
|
|
262
270
|
<pre style="white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; max-width: 100%;">${
|
|
263
271
|
xhr.responseText.replace(/</g, '<').replace(/>/g, '>')
|
|
264
272
|
}</pre>`,
|
|
@@ -275,7 +283,7 @@ const onFileChange = async (e) => {
|
|
|
275
283
|
} catch (error) {
|
|
276
284
|
console.error('Error uploading file:', error);
|
|
277
285
|
window.adminforth.alert({
|
|
278
|
-
message:
|
|
286
|
+
message: t('Sorry but the file was not be uploaded. Please try again: {error}', { error: error.message }),
|
|
279
287
|
variant: 'danger'
|
|
280
288
|
});
|
|
281
289
|
imgPreview.value = null;
|