@adminforth/upload 1.4.4 → 1.4.6
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/build.log +2 -2
- package/custom/imageGenerator.vue +33 -13
- package/dist/custom/imageGenerator.vue +33 -13
- package/index.ts +0 -1
- package/package.json +1 -1
package/build.log
CHANGED
|
@@ -11,5 +11,5 @@ custom/preview.vue
|
|
|
11
11
|
custom/tsconfig.json
|
|
12
12
|
custom/uploader.vue
|
|
13
13
|
|
|
14
|
-
sent 42,
|
|
15
|
-
total size is
|
|
14
|
+
sent 42,982 bytes received 134 bytes 86,232.00 bytes/sec
|
|
15
|
+
total size is 42,493 speedup is 0.99
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
<template>
|
|
3
3
|
<!-- Main modal -->
|
|
4
|
-
<div tabindex="-1" class="overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 bottom-0 z-50 flex justify-center items-center w-full md:inset-0 h-
|
|
5
|
-
<div class="relative p-4 w-
|
|
4
|
+
<div tabindex="-1" class="overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 bottom-0 z-50 flex justify-center items-center w-full md:inset-0 h-full max-h-full bg-white bg-opacity-50 dark:bg-gray-900 dark:bg-opacity-50">
|
|
5
|
+
<div class="relative p-4 w-10/12 max-w-full max-h-full ">
|
|
6
6
|
<!-- Modal content -->
|
|
7
7
|
<div class="relative bg-white rounded-lg shadow-xl dark:bg-gray-700">
|
|
8
8
|
<!-- Modal header -->
|
|
@@ -57,10 +57,16 @@
|
|
|
57
57
|
</div>
|
|
58
58
|
</div>
|
|
59
59
|
|
|
60
|
+
<div v-if="errorMessage" class="absolute flex items-center justify-center w-full h-full z-50 bg-white/80 dark:bg-gray-900/80 rounded-lg">
|
|
61
|
+
<div class="pt-20 text-red-500 dark:text-red-400 text-lg font-semibold">
|
|
62
|
+
{{ errorMessage }}
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
60
66
|
|
|
61
67
|
<div id="gallery" class="relative w-full" data-carousel="static">
|
|
62
68
|
<!-- Carousel wrapper -->
|
|
63
|
-
<div class="relative h-56 overflow-hidden rounded-lg md:h-
|
|
69
|
+
<div class="relative h-56 overflow-hidden rounded-lg md:h-[calc(100vh-350px)]">
|
|
64
70
|
<!-- Item 1 -->
|
|
65
71
|
<div v-for="(img, index) in images" :key="index" class="hidden duration-700 ease-in-out" data-carousel-item>
|
|
66
72
|
<img :src="img" class="absolute block max-w-full max-h-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2 object-cover"
|
|
@@ -118,7 +124,7 @@
|
|
|
118
124
|
<!-- Modal footer -->
|
|
119
125
|
<div class="flex items-center p-4 md:p-5 border-t border-gray-200 rounded-b dark:border-gray-600">
|
|
120
126
|
<button type="button" @click="confirmImage"
|
|
121
|
-
:disabled="loading"
|
|
127
|
+
:disabled="loading || images.length === 0"
|
|
122
128
|
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
|
|
123
129
|
dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800
|
|
124
130
|
disabled:opacity-50 disabled:cursor-not-allowed"
|
|
@@ -248,6 +254,8 @@ const loadingTimer: Ref<number | null> = ref(null);
|
|
|
248
254
|
|
|
249
255
|
const historicalRuns: Ref<number[]> = ref([]);
|
|
250
256
|
|
|
257
|
+
const errorMessage: Ref<string | null> = ref(null);
|
|
258
|
+
|
|
251
259
|
const historicalAverage: Ref<number | null> = computed(() => {
|
|
252
260
|
if (historicalRuns.value.length === 0) return null;
|
|
253
261
|
const sum = historicalRuns.value.reduce((a, b) => a + b, 0);
|
|
@@ -262,6 +270,7 @@ function formatTime(seconds: number): string {
|
|
|
262
270
|
|
|
263
271
|
|
|
264
272
|
async function generateImages() {
|
|
273
|
+
errorMessage.value = null;
|
|
265
274
|
loading.value = true;
|
|
266
275
|
loadingTimer.value = 0;
|
|
267
276
|
const start = Date.now();
|
|
@@ -271,7 +280,8 @@ async function generateImages() {
|
|
|
271
280
|
}, 100);
|
|
272
281
|
const currentIndex = caurosel.value?.getActiveItem()?.position || 0;
|
|
273
282
|
|
|
274
|
-
let resp;
|
|
283
|
+
let resp = null;
|
|
284
|
+
let error = null;
|
|
275
285
|
try {
|
|
276
286
|
resp = await callAdminForthApi({
|
|
277
287
|
path: `/plugin/${props.meta.pluginInstanceId}/generate_images`,
|
|
@@ -287,15 +297,25 @@ async function generateImages() {
|
|
|
287
297
|
historicalRuns.value.push(loadingTimer.value);
|
|
288
298
|
clearInterval(ticker);
|
|
289
299
|
loadingTimer.value = null;
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
if (resp.error) {
|
|
293
|
-
adminforth.alert({
|
|
294
|
-
message: $t('Error: {error}', { error: JSON.stringify(resp.error) }),
|
|
295
|
-
variant: 'danger',
|
|
296
|
-
timeout: 15,
|
|
297
|
-
});
|
|
298
300
|
loading.value = false;
|
|
301
|
+
}
|
|
302
|
+
if (resp?.error) {
|
|
303
|
+
error = resp.error;
|
|
304
|
+
}
|
|
305
|
+
if (!resp) {
|
|
306
|
+
error = $t('Error generating images, something went wrong');
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (error) {
|
|
310
|
+
if (images.value.length === 0) {
|
|
311
|
+
errorMessage.value = error;
|
|
312
|
+
} else {
|
|
313
|
+
adminforth.alert({
|
|
314
|
+
message: error,
|
|
315
|
+
variant: 'danger',
|
|
316
|
+
timeout: 'unlimited',
|
|
317
|
+
});
|
|
318
|
+
}
|
|
299
319
|
return;
|
|
300
320
|
}
|
|
301
321
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
<template>
|
|
3
3
|
<!-- Main modal -->
|
|
4
|
-
<div tabindex="-1" class="overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 bottom-0 z-50 flex justify-center items-center w-full md:inset-0 h-
|
|
5
|
-
<div class="relative p-4 w-
|
|
4
|
+
<div tabindex="-1" class="overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 bottom-0 z-50 flex justify-center items-center w-full md:inset-0 h-full max-h-full bg-white bg-opacity-50 dark:bg-gray-900 dark:bg-opacity-50">
|
|
5
|
+
<div class="relative p-4 w-10/12 max-w-full max-h-full ">
|
|
6
6
|
<!-- Modal content -->
|
|
7
7
|
<div class="relative bg-white rounded-lg shadow-xl dark:bg-gray-700">
|
|
8
8
|
<!-- Modal header -->
|
|
@@ -57,10 +57,16 @@
|
|
|
57
57
|
</div>
|
|
58
58
|
</div>
|
|
59
59
|
|
|
60
|
+
<div v-if="errorMessage" class="absolute flex items-center justify-center w-full h-full z-50 bg-white/80 dark:bg-gray-900/80 rounded-lg">
|
|
61
|
+
<div class="pt-20 text-red-500 dark:text-red-400 text-lg font-semibold">
|
|
62
|
+
{{ errorMessage }}
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
60
66
|
|
|
61
67
|
<div id="gallery" class="relative w-full" data-carousel="static">
|
|
62
68
|
<!-- Carousel wrapper -->
|
|
63
|
-
<div class="relative h-56 overflow-hidden rounded-lg md:h-
|
|
69
|
+
<div class="relative h-56 overflow-hidden rounded-lg md:h-[calc(100vh-350px)]">
|
|
64
70
|
<!-- Item 1 -->
|
|
65
71
|
<div v-for="(img, index) in images" :key="index" class="hidden duration-700 ease-in-out" data-carousel-item>
|
|
66
72
|
<img :src="img" class="absolute block max-w-full max-h-full -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2 object-cover"
|
|
@@ -118,7 +124,7 @@
|
|
|
118
124
|
<!-- Modal footer -->
|
|
119
125
|
<div class="flex items-center p-4 md:p-5 border-t border-gray-200 rounded-b dark:border-gray-600">
|
|
120
126
|
<button type="button" @click="confirmImage"
|
|
121
|
-
:disabled="loading"
|
|
127
|
+
:disabled="loading || images.length === 0"
|
|
122
128
|
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
|
|
123
129
|
dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800
|
|
124
130
|
disabled:opacity-50 disabled:cursor-not-allowed"
|
|
@@ -248,6 +254,8 @@ const loadingTimer: Ref<number | null> = ref(null);
|
|
|
248
254
|
|
|
249
255
|
const historicalRuns: Ref<number[]> = ref([]);
|
|
250
256
|
|
|
257
|
+
const errorMessage: Ref<string | null> = ref(null);
|
|
258
|
+
|
|
251
259
|
const historicalAverage: Ref<number | null> = computed(() => {
|
|
252
260
|
if (historicalRuns.value.length === 0) return null;
|
|
253
261
|
const sum = historicalRuns.value.reduce((a, b) => a + b, 0);
|
|
@@ -262,6 +270,7 @@ function formatTime(seconds: number): string {
|
|
|
262
270
|
|
|
263
271
|
|
|
264
272
|
async function generateImages() {
|
|
273
|
+
errorMessage.value = null;
|
|
265
274
|
loading.value = true;
|
|
266
275
|
loadingTimer.value = 0;
|
|
267
276
|
const start = Date.now();
|
|
@@ -271,7 +280,8 @@ async function generateImages() {
|
|
|
271
280
|
}, 100);
|
|
272
281
|
const currentIndex = caurosel.value?.getActiveItem()?.position || 0;
|
|
273
282
|
|
|
274
|
-
let resp;
|
|
283
|
+
let resp = null;
|
|
284
|
+
let error = null;
|
|
275
285
|
try {
|
|
276
286
|
resp = await callAdminForthApi({
|
|
277
287
|
path: `/plugin/${props.meta.pluginInstanceId}/generate_images`,
|
|
@@ -287,15 +297,25 @@ async function generateImages() {
|
|
|
287
297
|
historicalRuns.value.push(loadingTimer.value);
|
|
288
298
|
clearInterval(ticker);
|
|
289
299
|
loadingTimer.value = null;
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
if (resp.error) {
|
|
293
|
-
adminforth.alert({
|
|
294
|
-
message: $t('Error: {error}', { error: JSON.stringify(resp.error) }),
|
|
295
|
-
variant: 'danger',
|
|
296
|
-
timeout: 15,
|
|
297
|
-
});
|
|
298
300
|
loading.value = false;
|
|
301
|
+
}
|
|
302
|
+
if (resp?.error) {
|
|
303
|
+
error = resp.error;
|
|
304
|
+
}
|
|
305
|
+
if (!resp) {
|
|
306
|
+
error = $t('Error generating images, something went wrong');
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (error) {
|
|
310
|
+
if (images.value.length === 0) {
|
|
311
|
+
errorMessage.value = error;
|
|
312
|
+
} else {
|
|
313
|
+
adminforth.alert({
|
|
314
|
+
message: error,
|
|
315
|
+
variant: 'danger',
|
|
316
|
+
timeout: 'unlimited',
|
|
317
|
+
});
|
|
318
|
+
}
|
|
299
319
|
return;
|
|
300
320
|
}
|
|
301
321
|
|
package/index.ts
CHANGED
|
@@ -486,7 +486,6 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
|
|
|
486
486
|
path: `/plugin/${this.pluginInstanceId}/generate_images`,
|
|
487
487
|
handler: async ({ body, adminUser, headers }) => {
|
|
488
488
|
const { prompt, recordId } = body;
|
|
489
|
-
|
|
490
489
|
if (this.options.generation.rateLimit?.limit) {
|
|
491
490
|
// rate limit
|
|
492
491
|
const { error } = RateLimiter.checkRateLimit(
|