Skip to content

Commit 95a81ee

Browse files
committed
fix: streamline AI response handling in analyzeFields functions
1 parent 03ab57f commit 95a81ee

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

custom/visionAction.vue

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,8 @@ async function convertImages(fieldName, img) {
330330
331331
332332
async function analyzeFields() {
333+
isAiResponseReceivedAnalize.value = props.checkboxes.map(() => false);
333334
try {
334-
isAiResponseReceivedAnalize.value = props.checkboxes.map(() => false);
335-
336335
const res = await callAdminForthApi({
337336
path: `/plugin/${props.meta.pluginInstanceId}/analyze`,
338337
method: 'POST',
@@ -341,8 +340,6 @@ async function analyzeFields() {
341340
},
342341
});
343342
344-
isAiResponseReceivedAnalize.value = props.checkboxes.map(() => true);
345-
346343
if (res?.error) {
347344
adminforth.alert({
348345
message: res.error,
@@ -380,23 +377,20 @@ async function analyzeFields() {
380377
//isCriticalError.value = true;
381378
errorMessage.value = res.error;
382379
}
380+
isAiResponseReceivedAnalize.value = props.checkboxes.map(() => true);
383381
}
384382
385383
386384
async function analyzeFieldsNoImages() {
385+
isAiResponseReceivedAnalize.value = props.checkboxes.map(() => false);
387386
try {
388-
isAiResponseReceivedAnalize.value = props.checkboxes.map(() => false);
389-
390387
const res = await callAdminForthApi({
391388
path: `/plugin/${props.meta.pluginInstanceId}/analyze_no_images`,
392389
method: 'POST',
393390
body: {
394391
selectedIds: props.checkboxes,
395392
},
396393
});
397-
if(!props.meta.isFieldsForAnalizeFromImages) {
398-
isAiResponseReceivedAnalize.value = props.checkboxes.map(() => true);
399-
}
400394
if(res?.error) {
401395
adminforth.alert({
402396
message: res.error,
@@ -432,6 +426,9 @@ async function analyzeFieldsNoImages() {
432426
//isCriticalError.value = true;
433427
errorMessage.value = `Failed to analyze fields. Please, try to re-run the action.`;
434428
}
429+
if(!props.meta.isFieldsForAnalizeFromImages) {
430+
isAiResponseReceivedAnalize.value = props.checkboxes.map(() => true);
431+
}
435432
}
436433
437434

custom/visionTable.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
</div>
7979
</div>
8080

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])]">
8282
<div v-if="isInColumnImage(n)">
8383
<div class="mt-2 flex items-center justify-center gap-2">
8484
<img
@@ -102,11 +102,11 @@
102102
</div>
103103
</div>
104104

105-
<div v-else-if="isInColumnImage(n)">
105+
<div v-if="!isAiResponseReceivedImage[tableColumnsIndexes.findIndex(el => el[primaryKey] === item[primaryKey])] && isInColumnImage(n)">
106106
<Skeleton type="image" class="w-20 h-20" />
107107
</div>
108108

109-
<div v-else>
109+
<div v-if="!isAiResponseReceivedAnalize[tableColumnsIndexes.findIndex(el => el[primaryKey] === item[primaryKey])] && !isInColumnImage(n)">
110110
<Skeleton class="w-full h-6" />
111111
</div>
112112
</template>

0 commit comments

Comments
 (0)