@adminforth/bulk-ai-flow 1.5.3 → 1.5.4

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 CHANGED
@@ -11,5 +11,5 @@ custom/tsconfig.json
11
11
  custom/visionAction.vue
12
12
  custom/visionTable.vue
13
13
 
14
- sent 182,050 bytes received 134 bytes 364,368.00 bytes/sec
15
- total size is 181,515 speedup is 1.00
14
+ sent 182,531 bytes received 134 bytes 365,330.00 bytes/sec
15
+ total size is 181,996 speedup is 1.00
@@ -106,6 +106,7 @@ const openGenerationCarousel = ref([]);
106
106
  const isLoading = ref(false);
107
107
  const isError = ref(false);
108
108
  const isCriticalError = ref(false);
109
+ const isImageGenerationError = ref(false);
109
110
  const errorMessage = ref('');
110
111
  const checkedCount = ref(0);
111
112
 
@@ -289,20 +290,21 @@ async function prepareDataForSave() {
289
290
  .filter(item => item.isChecked === true)
290
291
  .map(item => item[primaryKey]);
291
292
 
292
- const promises = [];
293
- for (const item of checkedItems) {
294
- for (const [key, value] of Object.entries(item)) {
295
- if(props.meta.outputImageFields?.includes(key)) {
296
- const p = convertImages(key, value).then(result => {
297
- item[key] = result;
298
- });
299
-
300
- promises.push(p);
293
+ if (isImageGenerationError.value !== true) {
294
+ const promises = [];
295
+ for (const item of checkedItems) {
296
+ for (const [key, value] of Object.entries(item)) {
297
+ if(props.meta.outputImageFields?.includes(key)) {
298
+ const p = convertImages(key, value).then(result => {
299
+ item[key] = result;
300
+ });
301
+
302
+ promises.push(p);
303
+ }
301
304
  }
302
305
  }
306
+ await Promise.all(promises);
303
307
  }
304
- await Promise.all(promises);
305
-
306
308
  return [checkedItemsIDs, checkedItems];
307
309
  }
308
310
 
@@ -328,9 +330,8 @@ async function convertImages(fieldName, img) {
328
330
 
329
331
 
330
332
  async function analyzeFields() {
333
+ isAiResponseReceivedAnalize.value = props.checkboxes.map(() => false);
331
334
  try {
332
- isAiResponseReceivedAnalize.value = props.checkboxes.map(() => false);
333
-
334
335
  const res = await callAdminForthApi({
335
336
  path: `/plugin/${props.meta.pluginInstanceId}/analyze`,
336
337
  method: 'POST',
@@ -339,8 +340,6 @@ async function analyzeFields() {
339
340
  },
340
341
  });
341
342
 
342
- isAiResponseReceivedAnalize.value = props.checkboxes.map(() => true);
343
-
344
343
  if (res?.error) {
345
344
  adminforth.alert({
346
345
  message: res.error,
@@ -350,7 +349,7 @@ async function analyzeFields() {
350
349
 
351
350
  console.error('Failed to analyze image(s):', res.error);
352
351
  isError.value = true;
353
- isCriticalError.value = true;
352
+ //isCriticalError.value = true;
354
353
  errorMessage.value = `Failed to fetch analyze image(s). Please, try to re-run the action.`;
355
354
  } else {
356
355
  res.result.forEach((item, idx) => {
@@ -375,16 +374,16 @@ async function analyzeFields() {
375
374
 
376
375
  console.error('Failed to analyze image(s):', error);
377
376
  isError.value = true;
378
- isCriticalError.value = true;
377
+ //isCriticalError.value = true;
379
378
  errorMessage.value = res.error;
380
379
  }
380
+ isAiResponseReceivedAnalize.value = props.checkboxes.map(() => true);
381
381
  }
382
382
 
383
383
 
384
384
  async function analyzeFieldsNoImages() {
385
+ isAiResponseReceivedAnalize.value = props.checkboxes.map(() => false);
385
386
  try {
386
- isAiResponseReceivedAnalize.value = props.checkboxes.map(() => false);
387
-
388
387
  const res = await callAdminForthApi({
389
388
  path: `/plugin/${props.meta.pluginInstanceId}/analyze_no_images`,
390
389
  method: 'POST',
@@ -392,9 +391,6 @@ async function analyzeFieldsNoImages() {
392
391
  selectedIds: props.checkboxes,
393
392
  },
394
393
  });
395
- if(!props.meta.isFieldsForAnalizeFromImages) {
396
- isAiResponseReceivedAnalize.value = props.checkboxes.map(() => true);
397
- }
398
394
  if(res?.error) {
399
395
  adminforth.alert({
400
396
  message: res.error,
@@ -403,7 +399,7 @@ async function analyzeFieldsNoImages() {
403
399
  });
404
400
  console.error('Failed to analyze fields:', res.error);
405
401
  isError.value = true;
406
- isCriticalError.value = true;
402
+ //isCriticalError.value = true;
407
403
  errorMessage.value = res.error;
408
404
  } else {
409
405
  res.result.forEach((item, idx) => {
@@ -427,9 +423,12 @@ async function analyzeFieldsNoImages() {
427
423
  });
428
424
  console.error('Failed to analyze fields:', error);
429
425
  isError.value = true;
430
- isCriticalError.value = true;
426
+ //isCriticalError.value = true;
431
427
  errorMessage.value = `Failed to analyze fields. Please, try to re-run the action.`;
432
428
  }
429
+ if(!props.meta.isFieldsForAnalizeFromImages) {
430
+ isAiResponseReceivedAnalize.value = props.checkboxes.map(() => true);
431
+ }
433
432
  }
434
433
 
435
434
 
@@ -443,19 +442,20 @@ async function saveData() {
443
442
  try {
444
443
  isLoading.value = true;
445
444
  const [checkedItemsIDs, reqData] = await prepareDataForSave();
446
-
447
- const imagesToUpload = [];
448
- for (const item of reqData) {
449
- for (const [key, value] of Object.entries(item)) {
450
- if(props.meta.outputImageFields?.includes(key)) {
451
- const p = uploadImage(value, item[primaryKey], key).then(result => {
452
- item[key] = result;
453
- });
454
- imagesToUpload.push(p);
445
+ if (isImageGenerationError.value === false) {
446
+ const imagesToUpload = [];
447
+ for (const item of reqData) {
448
+ for (const [key, value] of Object.entries(item)) {
449
+ if(props.meta.outputImageFields?.includes(key)) {
450
+ const p = uploadImage(value, item[primaryKey], key).then(result => {
451
+ item[key] = result;
452
+ });
453
+ imagesToUpload.push(p);
454
+ }
455
455
  }
456
456
  }
457
+ await Promise.all(imagesToUpload);
457
458
  }
458
- await Promise.all(imagesToUpload);
459
459
 
460
460
  const res = await callAdminForthApi({
461
461
  path: `/plugin/${props.meta.pluginInstanceId}/update_fields`,
@@ -463,6 +463,7 @@ async function saveData() {
463
463
  body: {
464
464
  selectedIds: checkedItemsIDs,
465
465
  fields: reqData,
466
+ saveImages: !isImageGenerationError.value
466
467
  },
467
468
  });
468
469
 
@@ -508,7 +509,7 @@ async function generateImages() {
508
509
  } catch (e) {
509
510
  console.error('Error generating images:', e);
510
511
  isError.value = true;
511
- isCriticalError.value = true;
512
+ isImageGenerationError.value = true;
512
513
  errorMessage.value = `Failed to generate images. Please, try to re-run the action.`;
513
514
  }
514
515
  isAiResponseReceivedImage.value = props.checkboxes.map(() => true);
@@ -519,7 +520,7 @@ async function generateImages() {
519
520
  if (!res) {
520
521
  error = 'Error generating images, something went wrong';
521
522
  isError.value = true;
522
- isCriticalError.value = true;
523
+ isImageGenerationError.value = true;
523
524
  errorMessage.value = `Failed to generate images. Please, try to re-run the action.`;
524
525
  }
525
526
 
@@ -528,9 +529,9 @@ async function generateImages() {
528
529
  message: error,
529
530
  variant: 'danger',
530
531
  timeout: 'unlimited',
531
- });;
532
+ });
532
533
  isError.value = true;
533
- isCriticalError.value = true;
534
+ isImageGenerationError.value = true;
534
535
  errorMessage.value = error;
535
536
  } else {
536
537
  res.result.forEach((item, idx) => {
@@ -78,7 +78,7 @@
78
78
  </div>
79
79
  </div>
80
80
 
81
- <div v-else-if="isAiResponseReceivedImage[tableColumnsIndexes.findIndex(el => el[primaryKey] === item[primaryKey])]">
81
+ <div v-if="isAiResponseReceivedImage[tableColumnsIndexes.findIndex(el => el[primaryKey] === item[primaryKey])]">
82
82
  <div v-if="isInColumnImage(n)">
83
83
  <div class="mt-2 flex items-center justify-center gap-2">
84
84
  <img
@@ -102,11 +102,11 @@
102
102
  </div>
103
103
  </div>
104
104
 
105
- <div v-else-if="isInColumnImage(n)">
105
+ <div v-if="!isAiResponseReceivedImage[tableColumnsIndexes.findIndex(el => el[primaryKey] === item[primaryKey])] && isInColumnImage(n)">
106
106
  <Skeleton type="image" class="w-20 h-20" />
107
107
  </div>
108
108
 
109
- <div v-else>
109
+ <div v-if="!isAiResponseReceivedAnalize[tableColumnsIndexes.findIndex(el => el[primaryKey] === item[primaryKey])] && !isInColumnImage(n)">
110
110
  <Skeleton class="w-full h-6" />
111
111
  </div>
112
112
  </template>
@@ -106,6 +106,7 @@ const openGenerationCarousel = ref([]);
106
106
  const isLoading = ref(false);
107
107
  const isError = ref(false);
108
108
  const isCriticalError = ref(false);
109
+ const isImageGenerationError = ref(false);
109
110
  const errorMessage = ref('');
110
111
  const checkedCount = ref(0);
111
112
 
@@ -289,20 +290,21 @@ async function prepareDataForSave() {
289
290
  .filter(item => item.isChecked === true)
290
291
  .map(item => item[primaryKey]);
291
292
 
292
- const promises = [];
293
- for (const item of checkedItems) {
294
- for (const [key, value] of Object.entries(item)) {
295
- if(props.meta.outputImageFields?.includes(key)) {
296
- const p = convertImages(key, value).then(result => {
297
- item[key] = result;
298
- });
299
-
300
- promises.push(p);
293
+ if (isImageGenerationError.value !== true) {
294
+ const promises = [];
295
+ for (const item of checkedItems) {
296
+ for (const [key, value] of Object.entries(item)) {
297
+ if(props.meta.outputImageFields?.includes(key)) {
298
+ const p = convertImages(key, value).then(result => {
299
+ item[key] = result;
300
+ });
301
+
302
+ promises.push(p);
303
+ }
301
304
  }
302
305
  }
306
+ await Promise.all(promises);
303
307
  }
304
- await Promise.all(promises);
305
-
306
308
  return [checkedItemsIDs, checkedItems];
307
309
  }
308
310
 
@@ -328,9 +330,8 @@ async function convertImages(fieldName, img) {
328
330
 
329
331
 
330
332
  async function analyzeFields() {
333
+ isAiResponseReceivedAnalize.value = props.checkboxes.map(() => false);
331
334
  try {
332
- isAiResponseReceivedAnalize.value = props.checkboxes.map(() => false);
333
-
334
335
  const res = await callAdminForthApi({
335
336
  path: `/plugin/${props.meta.pluginInstanceId}/analyze`,
336
337
  method: 'POST',
@@ -339,8 +340,6 @@ async function analyzeFields() {
339
340
  },
340
341
  });
341
342
 
342
- isAiResponseReceivedAnalize.value = props.checkboxes.map(() => true);
343
-
344
343
  if (res?.error) {
345
344
  adminforth.alert({
346
345
  message: res.error,
@@ -350,7 +349,7 @@ async function analyzeFields() {
350
349
 
351
350
  console.error('Failed to analyze image(s):', res.error);
352
351
  isError.value = true;
353
- isCriticalError.value = true;
352
+ //isCriticalError.value = true;
354
353
  errorMessage.value = `Failed to fetch analyze image(s). Please, try to re-run the action.`;
355
354
  } else {
356
355
  res.result.forEach((item, idx) => {
@@ -375,16 +374,16 @@ async function analyzeFields() {
375
374
 
376
375
  console.error('Failed to analyze image(s):', error);
377
376
  isError.value = true;
378
- isCriticalError.value = true;
377
+ //isCriticalError.value = true;
379
378
  errorMessage.value = res.error;
380
379
  }
380
+ isAiResponseReceivedAnalize.value = props.checkboxes.map(() => true);
381
381
  }
382
382
 
383
383
 
384
384
  async function analyzeFieldsNoImages() {
385
+ isAiResponseReceivedAnalize.value = props.checkboxes.map(() => false);
385
386
  try {
386
- isAiResponseReceivedAnalize.value = props.checkboxes.map(() => false);
387
-
388
387
  const res = await callAdminForthApi({
389
388
  path: `/plugin/${props.meta.pluginInstanceId}/analyze_no_images`,
390
389
  method: 'POST',
@@ -392,9 +391,6 @@ async function analyzeFieldsNoImages() {
392
391
  selectedIds: props.checkboxes,
393
392
  },
394
393
  });
395
- if(!props.meta.isFieldsForAnalizeFromImages) {
396
- isAiResponseReceivedAnalize.value = props.checkboxes.map(() => true);
397
- }
398
394
  if(res?.error) {
399
395
  adminforth.alert({
400
396
  message: res.error,
@@ -403,7 +399,7 @@ async function analyzeFieldsNoImages() {
403
399
  });
404
400
  console.error('Failed to analyze fields:', res.error);
405
401
  isError.value = true;
406
- isCriticalError.value = true;
402
+ //isCriticalError.value = true;
407
403
  errorMessage.value = res.error;
408
404
  } else {
409
405
  res.result.forEach((item, idx) => {
@@ -427,9 +423,12 @@ async function analyzeFieldsNoImages() {
427
423
  });
428
424
  console.error('Failed to analyze fields:', error);
429
425
  isError.value = true;
430
- isCriticalError.value = true;
426
+ //isCriticalError.value = true;
431
427
  errorMessage.value = `Failed to analyze fields. Please, try to re-run the action.`;
432
428
  }
429
+ if(!props.meta.isFieldsForAnalizeFromImages) {
430
+ isAiResponseReceivedAnalize.value = props.checkboxes.map(() => true);
431
+ }
433
432
  }
434
433
 
435
434
 
@@ -443,19 +442,20 @@ async function saveData() {
443
442
  try {
444
443
  isLoading.value = true;
445
444
  const [checkedItemsIDs, reqData] = await prepareDataForSave();
446
-
447
- const imagesToUpload = [];
448
- for (const item of reqData) {
449
- for (const [key, value] of Object.entries(item)) {
450
- if(props.meta.outputImageFields?.includes(key)) {
451
- const p = uploadImage(value, item[primaryKey], key).then(result => {
452
- item[key] = result;
453
- });
454
- imagesToUpload.push(p);
445
+ if (isImageGenerationError.value === false) {
446
+ const imagesToUpload = [];
447
+ for (const item of reqData) {
448
+ for (const [key, value] of Object.entries(item)) {
449
+ if(props.meta.outputImageFields?.includes(key)) {
450
+ const p = uploadImage(value, item[primaryKey], key).then(result => {
451
+ item[key] = result;
452
+ });
453
+ imagesToUpload.push(p);
454
+ }
455
455
  }
456
456
  }
457
+ await Promise.all(imagesToUpload);
457
458
  }
458
- await Promise.all(imagesToUpload);
459
459
 
460
460
  const res = await callAdminForthApi({
461
461
  path: `/plugin/${props.meta.pluginInstanceId}/update_fields`,
@@ -463,6 +463,7 @@ async function saveData() {
463
463
  body: {
464
464
  selectedIds: checkedItemsIDs,
465
465
  fields: reqData,
466
+ saveImages: !isImageGenerationError.value
466
467
  },
467
468
  });
468
469
 
@@ -508,7 +509,7 @@ async function generateImages() {
508
509
  } catch (e) {
509
510
  console.error('Error generating images:', e);
510
511
  isError.value = true;
511
- isCriticalError.value = true;
512
+ isImageGenerationError.value = true;
512
513
  errorMessage.value = `Failed to generate images. Please, try to re-run the action.`;
513
514
  }
514
515
  isAiResponseReceivedImage.value = props.checkboxes.map(() => true);
@@ -519,7 +520,7 @@ async function generateImages() {
519
520
  if (!res) {
520
521
  error = 'Error generating images, something went wrong';
521
522
  isError.value = true;
522
- isCriticalError.value = true;
523
+ isImageGenerationError.value = true;
523
524
  errorMessage.value = `Failed to generate images. Please, try to re-run the action.`;
524
525
  }
525
526
 
@@ -528,9 +529,9 @@ async function generateImages() {
528
529
  message: error,
529
530
  variant: 'danger',
530
531
  timeout: 'unlimited',
531
- });;
532
+ });
532
533
  isError.value = true;
533
- isCriticalError.value = true;
534
+ isImageGenerationError.value = true;
534
535
  errorMessage.value = error;
535
536
  } else {
536
537
  res.result.forEach((item, idx) => {
@@ -78,7 +78,7 @@
78
78
  </div>
79
79
  </div>
80
80
 
81
- <div v-else-if="isAiResponseReceivedImage[tableColumnsIndexes.findIndex(el => el[primaryKey] === item[primaryKey])]">
81
+ <div v-if="isAiResponseReceivedImage[tableColumnsIndexes.findIndex(el => el[primaryKey] === item[primaryKey])]">
82
82
  <div v-if="isInColumnImage(n)">
83
83
  <div class="mt-2 flex items-center justify-center gap-2">
84
84
  <img
@@ -102,11 +102,11 @@
102
102
  </div>
103
103
  </div>
104
104
 
105
- <div v-else-if="isInColumnImage(n)">
105
+ <div v-if="!isAiResponseReceivedImage[tableColumnsIndexes.findIndex(el => el[primaryKey] === item[primaryKey])] && isInColumnImage(n)">
106
106
  <Skeleton type="image" class="w-20 h-20" />
107
107
  </div>
108
108
 
109
- <div v-else>
109
+ <div v-if="!isAiResponseReceivedAnalize[tableColumnsIndexes.findIndex(el => el[primaryKey] === item[primaryKey])] && !isInColumnImage(n)">
110
110
  <Skeleton class="w-full h-6" />
111
111
  </div>
112
112
  </template>
package/dist/index.js CHANGED
@@ -315,6 +315,7 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
315
315
  if (isAllowedToSave.ok !== false) {
316
316
  const selectedIds = body.selectedIds || [];
317
317
  const fieldsToUpdate = body.fields || {};
318
+ const saveImages = body.saveImages;
318
319
  const outputImageFields = [];
319
320
  if (this.options.generateImages) {
320
321
  for (const [key, value] of Object.entries(this.options.generateImages)) {
@@ -327,7 +328,7 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
327
328
  for (const [key, value] of Object.entries(outputImageFields)) {
328
329
  const columnPlugin = this.adminforth.activatedPlugins.find(p => p.resourceConfig.resourceId === this.resourceConfig.resourceId &&
329
330
  p.pluginOptions.pathColumnName === value);
330
- if (columnPlugin) {
331
+ if (columnPlugin && saveImages) {
331
332
  if (columnPlugin.pluginOptions.storageAdapter.objectCanBeAccesedPublicly()) {
332
333
  if (oldRecord[value]) {
333
334
  // put tag to delete old file
package/index.ts CHANGED
@@ -360,6 +360,7 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
360
360
  if (isAllowedToSave.ok !== false) {
361
361
  const selectedIds = body.selectedIds || [];
362
362
  const fieldsToUpdate = body.fields || {};
363
+ const saveImages = body.saveImages;
363
364
  const outputImageFields = [];
364
365
  if (this.options.generateImages) {
365
366
  for (const [key, value] of Object.entries(this.options.generateImages)) {
@@ -374,7 +375,7 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
374
375
  p.resourceConfig!.resourceId === this.resourceConfig.resourceId &&
375
376
  p.pluginOptions.pathColumnName === value
376
377
  );
377
- if (columnPlugin) {
378
+ if (columnPlugin && saveImages) {
378
379
  if(columnPlugin.pluginOptions.storageAdapter.objectCanBeAccesedPublicly()) {
379
380
  if (oldRecord[value]) {
380
381
  // put tag to delete old file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/bulk-ai-flow",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },