@opengis/fastify-table 1.4.26 → 1.4.28
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengis/fastify-table",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "core-plugins",
|
|
6
6
|
"keywords": [
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"uglify-js": "3.19.3"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"eslint": "8.49.0",
|
|
55
|
-
"eslint-config-airbnb": "19.0.4"
|
|
54
|
+
"eslint": "^8.49.0",
|
|
55
|
+
"eslint-config-airbnb": "^19.0.4"
|
|
56
56
|
},
|
|
57
57
|
"author": "Softpro",
|
|
58
58
|
"license": "ISC"
|
|
@@ -50,31 +50,7 @@ export default async function getCardData(req, reply) {
|
|
|
50
50
|
return reply.status(403).send('access restricted: empty rows');
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const { rows = [] } = result;
|
|
54
|
-
|
|
55
|
-
// conditions
|
|
56
|
-
index.panels?.filter(el => el.items).forEach(el1 => {
|
|
57
|
-
el1.items = el1.items?.filter(item => conditions(item.conditions, rows[0]));
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// title, count
|
|
61
|
-
index.panels?.filter(el => el.items).forEach(async el => {
|
|
62
|
-
const filtered = el.items.filter(item => item.count?.toLowerCase?.().includes('select'));
|
|
63
|
-
|
|
64
|
-
const data = await Promise.all(filtered.map(el1 => pg.query(el1.count).then(item => item.rows?.[0] || {})));
|
|
65
|
-
|
|
66
|
-
filtered.forEach((item1, i) => {
|
|
67
|
-
Object.assign(item1, data[i] || {}, data[i].count ? {} : { count: undefined });
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const q = el.items.map((item2) => (item2.component ? components[item2.component] : null)).filter(item2 => item2).join(' union all ');
|
|
71
|
-
|
|
72
|
-
const counts = q && id
|
|
73
|
-
? await pg.query(q, [id])
|
|
74
|
-
.then(e => e.rows.reduce((acc, curr) => Object.assign(acc, { [curr.component]: curr.count }), {}))
|
|
75
|
-
: {};
|
|
76
|
-
el.items?.filter?.(item => item.component)?.forEach(item => Object.assign(item, { count: counts?.[item.component] }));
|
|
77
|
-
});
|
|
53
|
+
const { rows = [], panels } = result;
|
|
78
54
|
|
|
79
55
|
// tokens result
|
|
80
56
|
const tokens = {};
|
|
@@ -137,6 +113,7 @@ export default async function getCardData(req, reply) {
|
|
|
137
113
|
return {
|
|
138
114
|
time: Date.now() - time,
|
|
139
115
|
...index,
|
|
116
|
+
panels,
|
|
140
117
|
tokens,
|
|
141
118
|
vue,
|
|
142
119
|
data,
|
|
@@ -262,6 +262,7 @@ export default async function dataAPI(req, reply, called) {
|
|
|
262
262
|
const { panels = [] } = index;
|
|
263
263
|
|
|
264
264
|
const tokens = {};
|
|
265
|
+
|
|
265
266
|
if (template && objectId) {
|
|
266
267
|
// tokens result
|
|
267
268
|
if (!config.security?.disableToken && index?.tokens && typeof index?.tokens === 'object' && !Array.isArray(index?.tokens)) {
|
|
@@ -293,19 +294,20 @@ export default async function dataAPI(req, reply, called) {
|
|
|
293
294
|
});
|
|
294
295
|
|
|
295
296
|
// title, count
|
|
296
|
-
panels
|
|
297
|
+
await Promise.all(panels.filter(el => el.items).map(async el => {
|
|
297
298
|
const filtered1 = el.items.filter(item => item.count?.toLowerCase?.().includes('select'));
|
|
298
|
-
const data = await Promise.all(filtered1.map(item => pg.query(item.count.replace(/{{id}}/g, params.id)).then(item1 => item1.rows[0] || {})));
|
|
299
|
+
const data = await Promise.all(filtered1.map(async item => pg.query(item.count.replace(/{{id}}/g, params.id)).then(item1 => item1.rows[0] || {})));
|
|
299
300
|
filtered1.forEach((el1, i) => {
|
|
301
|
+
// el1.title = data[i].title;
|
|
300
302
|
Object.assign(el1, data[i] || {}, data[i].count ? {} : { count: undefined });
|
|
301
303
|
});
|
|
302
304
|
const q1 = el.items.map((item) => (item.component ? components[item.component] : null)).filter(item => item).join(' union all ');
|
|
303
305
|
const counts1 = q1 && id
|
|
304
|
-
? await pg.query(
|
|
306
|
+
? await pg.query(q1, [id])
|
|
305
307
|
.then(e => e.rows.reduce((acc, curr) => Object.assign(acc, { [curr.component]: curr.count }), {}))
|
|
306
308
|
: {};
|
|
307
309
|
el.items?.filter?.(item => item.component)?.forEach(item => Object.assign(item, { count: counts1?.[item.component] }));
|
|
308
|
-
});
|
|
310
|
+
}));
|
|
309
311
|
|
|
310
312
|
// data result
|
|
311
313
|
const data = {};
|