adminforth 1.0.52 → 1.0.53
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/dataConnectors/postgres.ts +12 -1
- package/dist/dataConnectors/postgres.js +12 -1
- package/dist/index.js +2 -3
- package/dist/modules/codeInjector.js +6 -0
- package/dist/spa/spa/src/App.vue +1 -1
- package/dist/spa/spa/src/components/Filters.vue +1 -1
- package/index.ts +6 -5
- package/modules/codeInjector.ts +16 -10
- package/package.json +1 -1
- package/spa/src/App.vue +1 -1
- package/spa/src/components/Filters.vue +1 -1
|
@@ -83,6 +83,10 @@ class PostgresConnector {
|
|
|
83
83
|
field.type = AdminForthTypes.BOOLEAN;
|
|
84
84
|
field._underlineType = 'bool';
|
|
85
85
|
|
|
86
|
+
} else if (baseType == 'uuid') {
|
|
87
|
+
field.type = AdminForthTypes.STRING;
|
|
88
|
+
field._underlineType = 'uuid';
|
|
89
|
+
|
|
86
90
|
} else if (baseType.includes('character varying')) {
|
|
87
91
|
field.type = AdminForthTypes.STRING;
|
|
88
92
|
field._underlineType = 'varchar';
|
|
@@ -183,6 +187,7 @@ class PostgresConnector {
|
|
|
183
187
|
let totalCounter = 1;
|
|
184
188
|
const where = filters.length ? `WHERE ${filters.map((f, i) => {
|
|
185
189
|
let placeholder = '$'+(totalCounter);
|
|
190
|
+
const fieldData = resource.dataSourceColumns.find((col) => col.name == f.field);
|
|
186
191
|
let field = f.field;
|
|
187
192
|
let operator = this.OperatorsMap[f.operator];
|
|
188
193
|
if (f.operator == AdminForthFilterOperators.IN || f.operator == AdminForthFilterOperators.NIN) {
|
|
@@ -191,7 +196,13 @@ class PostgresConnector {
|
|
|
191
196
|
} else {
|
|
192
197
|
totalCounter += 1;
|
|
193
198
|
}
|
|
194
|
-
|
|
199
|
+
|
|
200
|
+
if (fieldData._underlineType == 'uuid') {
|
|
201
|
+
field = `cast("${field}" as text)`
|
|
202
|
+
} else {
|
|
203
|
+
field = `"${field}"`
|
|
204
|
+
}
|
|
205
|
+
return `${field} ${operator} ${placeholder}`;
|
|
195
206
|
}).join(' AND ')}` : '';
|
|
196
207
|
|
|
197
208
|
const filterValues = [];
|
|
@@ -84,6 +84,10 @@ class PostgresConnector {
|
|
|
84
84
|
field.type = AdminForthTypes.BOOLEAN;
|
|
85
85
|
field._underlineType = 'bool';
|
|
86
86
|
}
|
|
87
|
+
else if (baseType == 'uuid') {
|
|
88
|
+
field.type = AdminForthTypes.STRING;
|
|
89
|
+
field._underlineType = 'uuid';
|
|
90
|
+
}
|
|
87
91
|
else if (baseType.includes('character varying')) {
|
|
88
92
|
field.type = AdminForthTypes.STRING;
|
|
89
93
|
field._underlineType = 'varchar';
|
|
@@ -185,6 +189,7 @@ class PostgresConnector {
|
|
|
185
189
|
let totalCounter = 1;
|
|
186
190
|
const where = filters.length ? `WHERE ${filters.map((f, i) => {
|
|
187
191
|
let placeholder = '$' + (totalCounter);
|
|
192
|
+
const fieldData = resource.dataSourceColumns.find((col) => col.name == f.field);
|
|
188
193
|
let field = f.field;
|
|
189
194
|
let operator = this.OperatorsMap[f.operator];
|
|
190
195
|
if (f.operator == AdminForthFilterOperators.IN || f.operator == AdminForthFilterOperators.NIN) {
|
|
@@ -194,7 +199,13 @@ class PostgresConnector {
|
|
|
194
199
|
else {
|
|
195
200
|
totalCounter += 1;
|
|
196
201
|
}
|
|
197
|
-
|
|
202
|
+
if (fieldData._underlineType == 'uuid') {
|
|
203
|
+
field = `cast("${field}" as text)`;
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
field = `"${field}"`;
|
|
207
|
+
}
|
|
208
|
+
return `${field} ${operator} ${placeholder}`;
|
|
198
209
|
}).join(' AND ')}` : '';
|
|
199
210
|
const filterValues = [];
|
|
200
211
|
filters.length ? filters.forEach((f) => {
|
package/dist/index.js
CHANGED
|
@@ -548,8 +548,8 @@ class AdminForth {
|
|
|
548
548
|
data.data.forEach((item) => {
|
|
549
549
|
item._label = resource.itemLabel(item);
|
|
550
550
|
});
|
|
551
|
-
if ((_p = (_o = resource.hooks) === null || _o === void 0 ? void 0 : _o[source]) === null || _p === void 0 ? void 0 : _p.
|
|
552
|
-
const resp = yield ((_r = (_q = resource.hooks) === null || _q === void 0 ? void 0 : _q[source]) === null || _r === void 0 ? void 0 : _r.
|
|
551
|
+
if ((_p = (_o = resource.hooks) === null || _o === void 0 ? void 0 : _o[source]) === null || _p === void 0 ? void 0 : _p.afterDatasourceResponse) {
|
|
552
|
+
const resp = yield ((_r = (_q = resource.hooks) === null || _q === void 0 ? void 0 : _q[source]) === null || _r === void 0 ? void 0 : _r.afterDatasourceResponse({ resource, response: data.data, adminUser }));
|
|
553
553
|
if (!resp || (!resp.ok && !resp.error)) {
|
|
554
554
|
throw new Error(`Hook must return object with {ok: true} or { error: 'Error' } `);
|
|
555
555
|
}
|
|
@@ -565,7 +565,6 @@ class AdminForth {
|
|
|
565
565
|
}
|
|
566
566
|
});
|
|
567
567
|
});
|
|
568
|
-
console.log('data', data);
|
|
569
568
|
return Object.assign(Object.assign({}, data), { options: resource === null || resource === void 0 ? void 0 : resource.options });
|
|
570
569
|
}),
|
|
571
570
|
});
|
|
@@ -162,6 +162,9 @@ class CodeInjector {
|
|
|
162
162
|
// if file - return, if dir - go recursively
|
|
163
163
|
const customComponents = yield fs.promises.readdir(customComponentsDir);
|
|
164
164
|
for (const filePath of customComponents) {
|
|
165
|
+
if (!filePath.endsWith('.vue')) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
165
168
|
fs.stat(`${customComponentsDir}/${filePath}`, (err, data) => {
|
|
166
169
|
if (err) {
|
|
167
170
|
console.log(err);
|
|
@@ -187,6 +190,9 @@ class CodeInjector {
|
|
|
187
190
|
if (customComponentsDir) {
|
|
188
191
|
const customComponents = yield fs.promises.readdir(customComponentsDir);
|
|
189
192
|
for (const filePath of customComponents) {
|
|
193
|
+
if (!filePath.endsWith('.vue')) {
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
190
196
|
fs.stat(`${customComponentsDir}/${filePath}`, (err, data) => {
|
|
191
197
|
if (err) {
|
|
192
198
|
console.log('Custom components importing error: ', err);
|
package/dist/spa/spa/src/App.vue
CHANGED
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
<div class="h-full px-3 pb-4 overflow-y-auto bg-nav-menu-bg dark:bg-gray-800">
|
|
62
62
|
<div class="flex ms-2 md:me-24 m-4 ">
|
|
63
63
|
<img src="https://flowbite.com/docs/images/logo.svg" class="h-8 me-3" alt="FlowBite Logo" />
|
|
64
|
-
<span class="self-center text-
|
|
64
|
+
<span class="self-center text-header-text-size font-semibold sm:text-header-text-size whitespace-nowrap dark:text-header-text text-header-logo-color">
|
|
65
65
|
{{ coreStore.config?.brandName }}
|
|
66
66
|
</span>
|
|
67
67
|
</div>
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
</div>
|
|
93
93
|
</div>
|
|
94
94
|
|
|
95
|
-
<div v-if="show" drawer-backdrop="" class="bg-gray-900/50 dark:bg-gray-900/80 fixed inset-0 z-
|
|
95
|
+
<div v-if="show" drawer-backdrop="" class="bg-gray-900/50 dark:bg-gray-900/80 fixed inset-0 z-50"
|
|
96
96
|
@click="$emit('hide')">
|
|
97
97
|
</div>
|
|
98
98
|
</template>
|
package/index.ts
CHANGED
|
@@ -629,9 +629,8 @@ class AdminForth {
|
|
|
629
629
|
item._label = resource.itemLabel(item);
|
|
630
630
|
})
|
|
631
631
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
const resp = await resource.hooks?.[source]?.afterDatasourceRequest({ resource, response: data.data, adminUser });
|
|
632
|
+
if (resource.hooks?.[source]?.afterDatasourceResponse) {
|
|
633
|
+
const resp = await resource.hooks?.[source]?.afterDatasourceResponse({ resource, response: data.data, adminUser });
|
|
635
634
|
if (!resp || (!resp.ok && !resp.error)) {
|
|
636
635
|
throw new Error(`Hook must return object with {ok: true} or { error: 'Error' } `);
|
|
637
636
|
}
|
|
@@ -649,9 +648,11 @@ class AdminForth {
|
|
|
649
648
|
}
|
|
650
649
|
})
|
|
651
650
|
});
|
|
652
|
-
console.log('data', data);
|
|
653
651
|
|
|
654
|
-
return {
|
|
652
|
+
return {
|
|
653
|
+
...data,
|
|
654
|
+
options: resource?.options,
|
|
655
|
+
};
|
|
655
656
|
},
|
|
656
657
|
});
|
|
657
658
|
server.endpoint({
|
package/modules/codeInjector.ts
CHANGED
|
@@ -180,6 +180,9 @@ class CodeInjector {
|
|
|
180
180
|
// if file - return, if dir - go recursively
|
|
181
181
|
const customComponents = await fs.promises.readdir(customComponentsDir);
|
|
182
182
|
for (const filePath of customComponents) {
|
|
183
|
+
if (!filePath.endsWith('.vue')) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
183
186
|
fs.stat(`${customComponentsDir}/${filePath}`, (err, data) => {
|
|
184
187
|
if (err) {
|
|
185
188
|
console.log(err);
|
|
@@ -207,16 +210,19 @@ class CodeInjector {
|
|
|
207
210
|
if (customComponentsDir) {
|
|
208
211
|
const customComponents = await fs.promises.readdir(customComponentsDir);
|
|
209
212
|
for (const filePath of customComponents) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
213
|
+
if (!filePath.endsWith('.vue')) {
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
fs.stat(`${customComponentsDir}/${filePath}`, (err, data) => {
|
|
217
|
+
if (err) {
|
|
218
|
+
console.log('Custom components importing error: ', err);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (data.isFile()) {
|
|
222
|
+
const componentName = getComponentNameFromPath(filePath);
|
|
223
|
+
customComponentsComponents += `app.component('${componentName}', ${componentName});\n`;
|
|
224
|
+
}
|
|
225
|
+
})
|
|
220
226
|
}
|
|
221
227
|
}
|
|
222
228
|
|
package/package.json
CHANGED
package/spa/src/App.vue
CHANGED
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
<div class="h-full px-3 pb-4 overflow-y-auto bg-nav-menu-bg dark:bg-gray-800">
|
|
62
62
|
<div class="flex ms-2 md:me-24 m-4 ">
|
|
63
63
|
<img src="https://flowbite.com/docs/images/logo.svg" class="h-8 me-3" alt="FlowBite Logo" />
|
|
64
|
-
<span class="self-center text-
|
|
64
|
+
<span class="self-center text-header-text-size font-semibold sm:text-header-text-size whitespace-nowrap dark:text-header-text text-header-logo-color">
|
|
65
65
|
{{ coreStore.config?.brandName }}
|
|
66
66
|
</span>
|
|
67
67
|
</div>
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
</div>
|
|
93
93
|
</div>
|
|
94
94
|
|
|
95
|
-
<div v-if="show" drawer-backdrop="" class="bg-gray-900/50 dark:bg-gray-900/80 fixed inset-0 z-
|
|
95
|
+
<div v-if="show" drawer-backdrop="" class="bg-gray-900/50 dark:bg-gray-900/80 fixed inset-0 z-50"
|
|
96
96
|
@click="$emit('hide')">
|
|
97
97
|
</div>
|
|
98
98
|
</template>
|