@adminforth/upload 1.4.3 → 1.4.5
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 +30 -10
- package/dist/custom/imageGenerator.vue +30 -10
- package/dist/index.js +11 -9
- package/index.ts +10 -9
- package/package.json +1 -1
- package/types.ts +5 -0
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,976 bytes received 134 bytes 86,220.00 bytes/sec
|
|
15
|
+
total size is 42,487 speedup is 0.99
|
|
@@ -57,6 +57,12 @@
|
|
|
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 -->
|
|
@@ -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
|
|
|
@@ -57,6 +57,12 @@
|
|
|
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 -->
|
|
@@ -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/dist/index.js
CHANGED
|
@@ -99,7 +99,7 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
|
|
|
99
99
|
modifyResourceConfig: { get: () => super.modifyResourceConfig }
|
|
100
100
|
});
|
|
101
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
102
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
103
103
|
_super.modifyResourceConfig.call(this, adminforth, resourceConfig);
|
|
104
104
|
// after column to store the path of the uploaded file, add new VirtualColumn,
|
|
105
105
|
// show only in edit and create views
|
|
@@ -162,14 +162,16 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
|
|
|
162
162
|
}
|
|
163
163
|
const pathColumn = resourceConfig.columns[pathColumnIndex];
|
|
164
164
|
// add preview column to list
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
165
|
+
if (((_l = this.options.preview) === null || _l === void 0 ? void 0 : _l.usePreviewComponents) !== false) {
|
|
166
|
+
resourceConfig.columns[pathColumnIndex].components.list = {
|
|
167
|
+
file: this.componentPath('preview.vue'),
|
|
168
|
+
meta: pluginFrontendOptions,
|
|
169
|
+
};
|
|
170
|
+
resourceConfig.columns[pathColumnIndex].components.show = {
|
|
171
|
+
file: this.componentPath('preview.vue'),
|
|
172
|
+
meta: pluginFrontendOptions,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
173
175
|
// insert virtual column after path column if it is not already there
|
|
174
176
|
const virtualColumnIndex = resourceConfig.columns.findIndex((column) => column.name === virtualColumn.name);
|
|
175
177
|
if (virtualColumnIndex === -1) {
|
package/index.ts
CHANGED
|
@@ -165,15 +165,17 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
|
|
|
165
165
|
const pathColumn = resourceConfig.columns[pathColumnIndex];
|
|
166
166
|
|
|
167
167
|
// add preview column to list
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
if (this.options.preview?.usePreviewComponents !== false) {
|
|
169
|
+
resourceConfig.columns[pathColumnIndex].components.list = {
|
|
170
|
+
file: this.componentPath('preview.vue'),
|
|
171
|
+
meta: pluginFrontendOptions,
|
|
172
|
+
};
|
|
172
173
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
174
|
+
resourceConfig.columns[pathColumnIndex].components.show = {
|
|
175
|
+
file: this.componentPath('preview.vue'),
|
|
176
|
+
meta: pluginFrontendOptions,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
177
179
|
|
|
178
180
|
// insert virtual column after path column if it is not already there
|
|
179
181
|
const virtualColumnIndex = resourceConfig.columns.findIndex((column: any) => column.name === virtualColumn.name);
|
|
@@ -484,7 +486,6 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
|
|
|
484
486
|
path: `/plugin/${this.pluginInstanceId}/generate_images`,
|
|
485
487
|
handler: async ({ body, adminUser, headers }) => {
|
|
486
488
|
const { prompt, recordId } = body;
|
|
487
|
-
|
|
488
489
|
if (this.options.generation.rateLimit?.limit) {
|
|
489
490
|
// rate limit
|
|
490
491
|
const { error } = RateLimiter.checkRateLimit(
|
package/package.json
CHANGED
package/types.ts
CHANGED