@adminforth/bulk-ai-flow 1.2.1 → 1.3.0
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/imageGenerationCarousel.vue +2 -2
- package/custom/visionAction.vue +9 -1
- package/dist/custom/imageGenerationCarousel.vue +2 -2
- package/dist/custom/visionAction.vue +9 -1
- package/dist/index.js +37 -32
- package/index.ts +38 -34
- package/package.json +1 -1
- package/types.ts +5 -0
package/build.log
CHANGED
|
@@ -11,5 +11,5 @@ custom/tsconfig.json
|
|
|
11
11
|
custom/visionAction.vue
|
|
12
12
|
custom/visionTable.vue
|
|
13
13
|
|
|
14
|
-
sent 56,
|
|
15
|
-
total size is
|
|
14
|
+
sent 56,599 bytes received 134 bytes 113,466.00 bytes/sec
|
|
15
|
+
total size is 56,099 speedup is 0.99
|
|
@@ -339,7 +339,7 @@ async function getGenerationPrompt() {
|
|
|
339
339
|
if(!resp) {
|
|
340
340
|
emit('error', {
|
|
341
341
|
isError: true,
|
|
342
|
-
errorMessage: "
|
|
342
|
+
errorMessage: "Error getting generation prompts."
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
345
|
return resp?.generationOptions || null;
|
|
@@ -400,7 +400,7 @@ async function generateImages() {
|
|
|
400
400
|
});
|
|
401
401
|
emit('error', {
|
|
402
402
|
isError: true,
|
|
403
|
-
errorMessage:
|
|
403
|
+
errorMessage: "Error re-generating images"
|
|
404
404
|
});
|
|
405
405
|
}
|
|
406
406
|
return;
|
package/custom/visionAction.vue
CHANGED
|
@@ -429,10 +429,18 @@ async function saveData() {
|
|
|
429
429
|
},
|
|
430
430
|
});
|
|
431
431
|
|
|
432
|
-
if(res.ok) {
|
|
432
|
+
if(res.ok === true) {
|
|
433
433
|
confirmDialog.value.close();
|
|
434
434
|
props.updateList();
|
|
435
435
|
props.clearCheckboxes();
|
|
436
|
+
} else if (res.ok === false) {
|
|
437
|
+
adminforth.alert({
|
|
438
|
+
message: 'You are not allowed to save.',
|
|
439
|
+
variant: 'danger',
|
|
440
|
+
timeout: 'unlimited',
|
|
441
|
+
});
|
|
442
|
+
isError.value = true;
|
|
443
|
+
errorMessage.value = `Failed to save data. You are not allowed to save.`;
|
|
436
444
|
} else {
|
|
437
445
|
console.error('Error saving data:', res);
|
|
438
446
|
isError.value = true;
|
|
@@ -339,7 +339,7 @@ async function getGenerationPrompt() {
|
|
|
339
339
|
if(!resp) {
|
|
340
340
|
emit('error', {
|
|
341
341
|
isError: true,
|
|
342
|
-
errorMessage: "
|
|
342
|
+
errorMessage: "Error getting generation prompts."
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
345
|
return resp?.generationOptions || null;
|
|
@@ -400,7 +400,7 @@ async function generateImages() {
|
|
|
400
400
|
});
|
|
401
401
|
emit('error', {
|
|
402
402
|
isError: true,
|
|
403
|
-
errorMessage:
|
|
403
|
+
errorMessage: "Error re-generating images"
|
|
404
404
|
});
|
|
405
405
|
}
|
|
406
406
|
return;
|
|
@@ -429,10 +429,18 @@ async function saveData() {
|
|
|
429
429
|
},
|
|
430
430
|
});
|
|
431
431
|
|
|
432
|
-
if(res.ok) {
|
|
432
|
+
if(res.ok === true) {
|
|
433
433
|
confirmDialog.value.close();
|
|
434
434
|
props.updateList();
|
|
435
435
|
props.clearCheckboxes();
|
|
436
|
+
} else if (res.ok === false) {
|
|
437
|
+
adminforth.alert({
|
|
438
|
+
message: 'You are not allowed to save.',
|
|
439
|
+
variant: 'danger',
|
|
440
|
+
timeout: 'unlimited',
|
|
441
|
+
});
|
|
442
|
+
isError.value = true;
|
|
443
|
+
errorMessage.value = `Failed to save data. You are not allowed to save.`;
|
|
436
444
|
} else {
|
|
437
445
|
console.error('Error saving data:', res);
|
|
438
446
|
isError.value = true;
|
package/dist/index.js
CHANGED
|
@@ -293,44 +293,49 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
293
293
|
method: 'POST',
|
|
294
294
|
path: `/plugin/${this.pluginInstanceId}/update_fields`,
|
|
295
295
|
handler: (body) => __awaiter(this, void 0, void 0, function* () {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
296
|
+
if (this.options.isAllowedToSave !== false) {
|
|
297
|
+
const selectedIds = body.body.selectedIds || [];
|
|
298
|
+
const fieldsToUpdate = body.body.fields || {};
|
|
299
|
+
const outputImageFields = [];
|
|
300
|
+
if (this.options.generateImages) {
|
|
301
|
+
for (const [key, value] of Object.entries(this.options.generateImages)) {
|
|
302
|
+
outputImageFields.push(key);
|
|
303
|
+
}
|
|
302
304
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
305
|
+
const primaryKeyColumn = this.resourceConfig.columns.find((col) => col.primaryKey);
|
|
306
|
+
const updates = selectedIds.map((ID, idx) => __awaiter(this, void 0, void 0, function* () {
|
|
307
|
+
const oldRecord = yield this.adminforth.resource(this.resourceConfig.resourceId).get([Filters.EQ(primaryKeyColumn.name, ID)]);
|
|
308
|
+
for (const [key, value] of Object.entries(outputImageFields)) {
|
|
309
|
+
const columnPlugin = this.adminforth.activatedPlugins.find(p => p.resourceConfig.resourceId === this.resourceConfig.resourceId &&
|
|
310
|
+
p.pluginOptions.pathColumnName === value);
|
|
311
|
+
if (columnPlugin) {
|
|
312
|
+
if (columnPlugin.pluginOptions.storageAdapter.objectCanBeAccesedPublicly()) {
|
|
313
|
+
if (oldRecord[value]) {
|
|
314
|
+
// put tag to delete old file
|
|
315
|
+
try {
|
|
316
|
+
yield columnPlugin.pluginOptions.storageAdapter.markKeyForDeletation(oldRecord[value]);
|
|
317
|
+
}
|
|
318
|
+
catch (e) {
|
|
319
|
+
// file might be e.g. already deleted, so we catch error
|
|
320
|
+
console.error(`Error setting tag to true for object ${oldRecord[value]}. File will not be auto-cleaned up`, e);
|
|
321
|
+
}
|
|
316
322
|
}
|
|
317
|
-
|
|
318
|
-
//
|
|
319
|
-
|
|
323
|
+
if (fieldsToUpdate[idx][key] !== null) {
|
|
324
|
+
// remove tag from new file
|
|
325
|
+
// in this case we let it crash if it fails: this is a new file which just was uploaded.
|
|
326
|
+
yield columnPlugin.pluginOptions.storageAdapter.markKeyForNotDeletation(fieldsToUpdate[idx][value]);
|
|
320
327
|
}
|
|
321
328
|
}
|
|
322
|
-
if (fieldsToUpdate[idx][key] !== null) {
|
|
323
|
-
// remove tag from new file
|
|
324
|
-
// in this case we let it crash if it fails: this is a new file which just was uploaded.
|
|
325
|
-
yield columnPlugin.pluginOptions.storageAdapter.markKeyForNotDeletation(fieldsToUpdate[idx][value]);
|
|
326
|
-
}
|
|
327
329
|
}
|
|
328
330
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
331
|
+
return this.adminforth.resource(this.resourceConfig.resourceId).update(ID, fieldsToUpdate[idx]);
|
|
332
|
+
}));
|
|
333
|
+
yield Promise.all(updates);
|
|
334
|
+
return { ok: true };
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
return { ok: false };
|
|
338
|
+
}
|
|
334
339
|
})
|
|
335
340
|
});
|
|
336
341
|
server.endpoint({
|
package/index.ts
CHANGED
|
@@ -339,45 +339,49 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
339
339
|
method: 'POST',
|
|
340
340
|
path: `/plugin/${this.pluginInstanceId}/update_fields`,
|
|
341
341
|
handler: async ( body ) => {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
342
|
+
if(this.options.isAllowedToSave !== false) {
|
|
343
|
+
const selectedIds = body.body.selectedIds || [];
|
|
344
|
+
const fieldsToUpdate = body.body.fields || {};
|
|
345
|
+
const outputImageFields = [];
|
|
346
|
+
if (this.options.generateImages) {
|
|
347
|
+
for (const [key, value] of Object.entries(this.options.generateImages)) {
|
|
348
|
+
outputImageFields.push(key);
|
|
349
|
+
}
|
|
348
350
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
351
|
+
const primaryKeyColumn = this.resourceConfig.columns.find((col) => col.primaryKey);
|
|
352
|
+
const updates = selectedIds.map(async (ID, idx) => {
|
|
353
|
+
const oldRecord = await this.adminforth.resource(this.resourceConfig.resourceId).get( [Filters.EQ(primaryKeyColumn.name, ID)] );
|
|
354
|
+
for (const [key, value] of Object.entries(outputImageFields)) {
|
|
355
|
+
const columnPlugin = this.adminforth.activatedPlugins.find(p =>
|
|
356
|
+
p.resourceConfig!.resourceId === this.resourceConfig.resourceId &&
|
|
357
|
+
p.pluginOptions.pathColumnName === value
|
|
358
|
+
);
|
|
359
|
+
if (columnPlugin) {
|
|
360
|
+
if(columnPlugin.pluginOptions.storageAdapter.objectCanBeAccesedPublicly()) {
|
|
361
|
+
if (oldRecord[value]) {
|
|
362
|
+
// put tag to delete old file
|
|
363
|
+
try {
|
|
364
|
+
await columnPlugin.pluginOptions.storageAdapter.markKeyForDeletation(oldRecord[value]);
|
|
365
|
+
} catch (e) {
|
|
366
|
+
// file might be e.g. already deleted, so we catch error
|
|
367
|
+
console.error(`Error setting tag to true for object ${oldRecord[value]}. File will not be auto-cleaned up`, e);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (fieldsToUpdate[idx][key] !== null) {
|
|
371
|
+
// remove tag from new file
|
|
372
|
+
// in this case we let it crash if it fails: this is a new file which just was uploaded.
|
|
373
|
+
await columnPlugin.pluginOptions.storageAdapter.markKeyForNotDeletation(fieldsToUpdate[idx][value]);
|
|
367
374
|
}
|
|
368
|
-
}
|
|
369
|
-
if (fieldsToUpdate[idx][key] !== null) {
|
|
370
|
-
// remove tag from new file
|
|
371
|
-
// in this case we let it crash if it fails: this is a new file which just was uploaded.
|
|
372
|
-
await columnPlugin.pluginOptions.storageAdapter.markKeyForNotDeletation(fieldsToUpdate[idx][value]);
|
|
373
375
|
}
|
|
374
376
|
}
|
|
375
377
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
378
|
+
return this.adminforth.resource(this.resourceConfig.resourceId).update(ID, fieldsToUpdate[idx])
|
|
379
|
+
});
|
|
380
|
+
await Promise.all(updates);
|
|
381
|
+
return { ok: true };
|
|
382
|
+
} else {
|
|
383
|
+
return { ok: false }
|
|
384
|
+
}
|
|
381
385
|
}
|
|
382
386
|
});
|
|
383
387
|
|
package/package.json
CHANGED
package/types.ts
CHANGED