@adminforth/bulk-ai-flow 1.3.0 → 1.4.1
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/visionAction.vue +2 -3
- package/dist/custom/visionAction.vue +2 -3
- package/dist/index.js +17 -10
- package/index.ts +19 -12
- package/package.json +1 -1
- package/types.ts +11 -1
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 56,
|
|
14
|
+
sent 56,553 bytes received 134 bytes 113,374.00 bytes/sec
|
|
15
|
+
total size is 56,046 speedup is 0.99
|
package/custom/visionAction.vue
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
<Dialog ref="confirmDialog">
|
|
9
9
|
<div
|
|
10
10
|
class="fixed inset-0 z-20 flex items-center justify-center bg-black/40"
|
|
11
|
-
@click="closeDialog"
|
|
12
11
|
>
|
|
13
12
|
<div
|
|
14
13
|
class="bulk-vision-dialog flex items-center justify-center relative max-w-[95vw] min-w-[640px] max-h-[90vh] bg-white dark:bg-gray-900 rounded-md shadow-2xl overflow-hidden"
|
|
@@ -73,7 +72,7 @@ import VisionTable from './visionTable.vue'
|
|
|
73
72
|
import adminforth from '@/adminforth';
|
|
74
73
|
import { useI18n } from 'vue-i18n';
|
|
75
74
|
import { useRoute } from 'vue-router';
|
|
76
|
-
import {
|
|
75
|
+
import { AdminUser, type AdminForthResourceCommon } from '@/types';
|
|
77
76
|
|
|
78
77
|
const route = useRoute();
|
|
79
78
|
const { t } = useI18n();
|
|
@@ -435,7 +434,7 @@ async function saveData() {
|
|
|
435
434
|
props.clearCheckboxes();
|
|
436
435
|
} else if (res.ok === false) {
|
|
437
436
|
adminforth.alert({
|
|
438
|
-
message:
|
|
437
|
+
message: res.error,
|
|
439
438
|
variant: 'danger',
|
|
440
439
|
timeout: 'unlimited',
|
|
441
440
|
});
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
<Dialog ref="confirmDialog">
|
|
9
9
|
<div
|
|
10
10
|
class="fixed inset-0 z-20 flex items-center justify-center bg-black/40"
|
|
11
|
-
@click="closeDialog"
|
|
12
11
|
>
|
|
13
12
|
<div
|
|
14
13
|
class="bulk-vision-dialog flex items-center justify-center relative max-w-[95vw] min-w-[640px] max-h-[90vh] bg-white dark:bg-gray-900 rounded-md shadow-2xl overflow-hidden"
|
|
@@ -73,7 +72,7 @@ import VisionTable from './visionTable.vue'
|
|
|
73
72
|
import adminforth from '@/adminforth';
|
|
74
73
|
import { useI18n } from 'vue-i18n';
|
|
75
74
|
import { useRoute } from 'vue-router';
|
|
76
|
-
import {
|
|
75
|
+
import { AdminUser, type AdminForthResourceCommon } from '@/types';
|
|
77
76
|
|
|
78
77
|
const route = useRoute();
|
|
79
78
|
const { t } = useI18n();
|
|
@@ -435,7 +434,7 @@ async function saveData() {
|
|
|
435
434
|
props.clearCheckboxes();
|
|
436
435
|
} else if (res.ok === false) {
|
|
437
436
|
adminforth.alert({
|
|
438
|
-
message:
|
|
437
|
+
message: res.error,
|
|
439
438
|
variant: 'danger',
|
|
440
439
|
timeout: 'unlimited',
|
|
441
440
|
});
|
package/dist/index.js
CHANGED
|
@@ -172,13 +172,16 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
172
172
|
isImageGeneration: this.options.generateImages ? Object.keys(this.options.generateImages).length > 0 : false
|
|
173
173
|
}
|
|
174
174
|
};
|
|
175
|
-
if (!
|
|
176
|
-
|
|
175
|
+
if (!resourceConfig.options.pageInjections) {
|
|
176
|
+
resourceConfig.options.pageInjections = {};
|
|
177
177
|
}
|
|
178
|
-
if (!
|
|
179
|
-
|
|
178
|
+
if (!resourceConfig.options.pageInjections.list) {
|
|
179
|
+
resourceConfig.options.pageInjections.list = {};
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
if (!resourceConfig.options.pageInjections.list.threeDotsDropdownItems) {
|
|
182
|
+
resourceConfig.options.pageInjections.list.threeDotsDropdownItems = [];
|
|
183
|
+
}
|
|
184
|
+
resourceConfig.options.pageInjections.list.threeDotsDropdownItems.push(pageInjection);
|
|
182
185
|
});
|
|
183
186
|
}
|
|
184
187
|
validateConfigAfterDiscover(adminforth, resourceConfig) {
|
|
@@ -292,10 +295,14 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
292
295
|
server.endpoint({
|
|
293
296
|
method: 'POST',
|
|
294
297
|
path: `/plugin/${this.pluginInstanceId}/update_fields`,
|
|
295
|
-
handler: (
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
298
|
+
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, headers }) {
|
|
299
|
+
let isAllowedToSave = { ok: true, error: '' };
|
|
300
|
+
if (this.options.isAllowedToSave) {
|
|
301
|
+
isAllowedToSave = yield this.options.isAllowedToSave({ record: {}, adminUser: adminUser, resource: this.resourceConfig });
|
|
302
|
+
}
|
|
303
|
+
if (isAllowedToSave.ok !== false) {
|
|
304
|
+
const selectedIds = body.selectedIds || [];
|
|
305
|
+
const fieldsToUpdate = body.fields || {};
|
|
299
306
|
const outputImageFields = [];
|
|
300
307
|
if (this.options.generateImages) {
|
|
301
308
|
for (const [key, value] of Object.entries(this.options.generateImages)) {
|
|
@@ -334,7 +341,7 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
334
341
|
return { ok: true };
|
|
335
342
|
}
|
|
336
343
|
else {
|
|
337
|
-
return { ok: false };
|
|
344
|
+
return { ok: false, error: isAllowedToSave.error };
|
|
338
345
|
}
|
|
339
346
|
})
|
|
340
347
|
});
|
package/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AdminForthPlugin, Filters } from "adminforth";
|
|
2
|
-
import type { IAdminForth, IHttpServer,
|
|
2
|
+
import type { IAdminForth, IHttpServer, AdminForthComponentDeclaration, AdminForthResourceColumn, AdminForthDataTypes, AdminForthResource } from "adminforth";
|
|
3
3
|
import type { PluginOptions } from './types.js';
|
|
4
4
|
import { json } from "stream/consumers";
|
|
5
5
|
import Handlebars, { compile } from 'handlebars';
|
|
@@ -192,15 +192,18 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
192
192
|
isImageGeneration: this.options.generateImages ? Object.keys(this.options.generateImages).length > 0 : false
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
|
|
196
|
-
if (!
|
|
197
|
-
|
|
195
|
+
|
|
196
|
+
if (!resourceConfig.options.pageInjections) {
|
|
197
|
+
resourceConfig.options.pageInjections = {};
|
|
198
|
+
}
|
|
199
|
+
if (!resourceConfig.options.pageInjections.list) {
|
|
200
|
+
resourceConfig.options.pageInjections.list = {};
|
|
198
201
|
}
|
|
199
|
-
if (!
|
|
200
|
-
|
|
202
|
+
if (!resourceConfig.options.pageInjections.list.threeDotsDropdownItems) {
|
|
203
|
+
resourceConfig.options.pageInjections.list.threeDotsDropdownItems = [];
|
|
201
204
|
}
|
|
202
205
|
|
|
203
|
-
|
|
206
|
+
(resourceConfig.options.pageInjections.list.threeDotsDropdownItems as AdminForthComponentDeclaration[]).push(pageInjection);
|
|
204
207
|
}
|
|
205
208
|
|
|
206
209
|
validateConfigAfterDiscover(adminforth: IAdminForth, resourceConfig: AdminForthResource) {
|
|
@@ -338,10 +341,14 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
338
341
|
server.endpoint({
|
|
339
342
|
method: 'POST',
|
|
340
343
|
path: `/plugin/${this.pluginInstanceId}/update_fields`,
|
|
341
|
-
handler: async ( body ) => {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
344
|
+
handler: async ({ body, adminUser, headers }) => {
|
|
345
|
+
let isAllowedToSave: any = { ok: true, error: '' };
|
|
346
|
+
if(this.options.isAllowedToSave) {
|
|
347
|
+
isAllowedToSave = await this.options.isAllowedToSave({ record: {}, adminUser: adminUser, resource: this.resourceConfig });
|
|
348
|
+
}
|
|
349
|
+
if (isAllowedToSave.ok !== false) {
|
|
350
|
+
const selectedIds = body.selectedIds || [];
|
|
351
|
+
const fieldsToUpdate = body.fields || {};
|
|
345
352
|
const outputImageFields = [];
|
|
346
353
|
if (this.options.generateImages) {
|
|
347
354
|
for (const [key, value] of Object.entries(this.options.generateImages)) {
|
|
@@ -380,7 +387,7 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
|
|
|
380
387
|
await Promise.all(updates);
|
|
381
388
|
return { ok: true };
|
|
382
389
|
} else {
|
|
383
|
-
return { ok: false }
|
|
390
|
+
return { ok: false, error: isAllowedToSave.error };
|
|
384
391
|
}
|
|
385
392
|
}
|
|
386
393
|
});
|
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -51,5 +51,15 @@ export interface PluginOptions {
|
|
|
51
51
|
/**
|
|
52
52
|
* Whether the user is allowed to save the generated images
|
|
53
53
|
*/
|
|
54
|
-
isAllowedToSave?:
|
|
54
|
+
isAllowedToSave?: ({ record, adminUser, resource }: {
|
|
55
|
+
record: any;
|
|
56
|
+
adminUser: any;
|
|
57
|
+
resource: any;
|
|
58
|
+
}) => Promise<{
|
|
59
|
+
ok: boolean;
|
|
60
|
+
error: string;
|
|
61
|
+
} | {
|
|
62
|
+
ok: boolean;
|
|
63
|
+
error?: undefined;
|
|
64
|
+
}>
|
|
55
65
|
}
|