@opengis/bi 1.2.31 → 1.2.34
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/dist/bi.js +1 -1
- package/dist/bi.umd.cjs +84 -82
- package/dist/{import-file-BPICIF0w.js → import-file-BwxPX622.js} +2321 -2089
- package/dist/style.css +1 -1
- package/dist/{vs-funnel-bar-C4T5wkBI.js → vs-funnel-bar-BV18EA4K.js} +1 -1
- package/dist/{vs-list-DpQecJFZ.js → vs-list-WrrWQ5KF.js} +1 -1
- package/dist/{vs-map-Dv0Zxj3b.js → vs-map-CYd9vdrd.js} +102 -91
- package/dist/{vs-map-cluster-BZoSRi6v.js → vs-map-cluster-5TnGPuBH.js} +91 -81
- package/dist/{vs-number-CRdeu_TC.js → vs-number-DUeRr7uz.js} +1 -1
- package/dist/{vs-table-BMs9Rxrh.js → vs-table-CZJnXfUv.js} +1 -1
- package/dist/{vs-text-B46_k-vY.js → vs-text-D3nCPkgk.js} +1 -1
- package/package.json +19 -17
- package/plugin.js +6 -7
- package/server/migrations/bi.sql +4 -1
- package/server/plugins/hook.js +5 -5
- package/server/plugins/vite.js +81 -81
- package/server/routes/dashboard/controllers/dashboard.js +3 -2
- package/server/routes/dashboard/controllers/dashboard.list.js +1 -1
- package/server/routes/data/controllers/data.js +1 -0
- package/server/utils/getWidget.js +6 -5
|
@@ -20,14 +20,15 @@ export default async function dashboard({
|
|
|
20
20
|
|
|
21
21
|
const fileDashboard = dashboards.find((el) => el[0] === id);
|
|
22
22
|
if (!fileDashboard) {
|
|
23
|
-
const sql = `select title, description, table_name, panels, grid, widgets, filters, style, words, db, public
|
|
23
|
+
const sql = `select title, description, table_name, panels, grid, widgets, filters, style, words, db, public, updated_at as last_update
|
|
24
24
|
from bi.dashboard where $1 in (dashboard_id, name)`;
|
|
25
25
|
|
|
26
26
|
const data = await pg1.query(sql, [id]).then(el => el.rows?.[0] || {});
|
|
27
27
|
|
|
28
28
|
let pg = pg1;
|
|
29
29
|
try {
|
|
30
|
-
|
|
30
|
+
const db = typeof data.db === 'string' && data.db.startsWith('{') ? JSON.parse(data.db) : { database: data.db };
|
|
31
|
+
pg = data.pg || (data.db ? await getPGAsync(db) : null) || pg1;
|
|
31
32
|
} catch (err) {
|
|
32
33
|
data.error = err.toString();
|
|
33
34
|
}
|
|
@@ -24,7 +24,7 @@ export default async function dashboardList({
|
|
|
24
24
|
const where = [search ? `lower(title) ~ $1` : null, type === 'viewer' ? `left(table_name,5)='demo.'` : null].filter(Boolean).join(' and ') || 'true';
|
|
25
25
|
const q1 = `select count(*)::int as total, count(*) filter(where ${where})::int as filtered from bi.dashboard`;
|
|
26
26
|
|
|
27
|
-
const q = `select dashboard_id as name, 'db' as type, title, description, table_name, words, public from bi.dashboard where ${where} limit ${limit} offset ${offset}`;
|
|
27
|
+
const q = `select dashboard_id as name, 'db' as type, title, description, table_name, words, public, updated_at as last_update from bi.dashboard where ${where} limit ${limit} offset ${offset}`;
|
|
28
28
|
|
|
29
29
|
if (user?.user_type?.includes('admin') && ['db', 'viewer'].includes(type) && sql) {
|
|
30
30
|
return `${q1};${q}`;
|
|
@@ -189,6 +189,7 @@ export default async function dataAPI(req, reply) {
|
|
|
189
189
|
|
|
190
190
|
const res = {
|
|
191
191
|
time: Date.now() - time,
|
|
192
|
+
last_update: widgetData?.last_update,
|
|
192
193
|
error: error || errorSql || (!widgetData.sql ? widgetData.error : undefined),
|
|
193
194
|
dimensions,
|
|
194
195
|
filter: xName,
|
|
@@ -10,7 +10,7 @@ async function getWidget({ pg: pg1 = pgClients.client, dashboard, widget }) {
|
|
|
10
10
|
? await getTemplate('dashboard', dashboard)
|
|
11
11
|
: null;
|
|
12
12
|
|
|
13
|
-
const dashboardData1 = await pg1.query(`select db, table_name, widgets as "dashboardWidgets" from bi.dashboard where dashboard_id=$1`, [dashboard])
|
|
13
|
+
const dashboardData1 = await pg1.query(`select db, table_name, widgets as "dashboardWidgets", updated_at as "updatedAt" from bi.dashboard where dashboard_id=$1`, [dashboard])
|
|
14
14
|
.then(el => el.rows?.[0] || {});
|
|
15
15
|
const { dashboardWidgets = [] } = dashboardData1;
|
|
16
16
|
const dashboardDb = typeof dashboardData1?.db === 'string' && dashboardData1?.db?.startsWith('{') ? JSON.parse(dashboardData1?.db) : dashboardData1?.db;
|
|
@@ -18,9 +18,9 @@ async function getWidget({ pg: pg1 = pgClients.client, dashboard, widget }) {
|
|
|
18
18
|
const dashboardIndex = dashboardData?.find((el) => el[0] == 'index.yml')?.[1]; // dashboardData?.find((el) => el[2] == 'index')?.[1]
|
|
19
19
|
const pg = dashboardDb || dashboardIndex?.db ? await getPGAsync(dashboardDb || dashboardIndex?.db) : pg1;
|
|
20
20
|
|
|
21
|
-
const { id, tableName } =
|
|
21
|
+
const { id, tableName, updatedAt } =
|
|
22
22
|
!dashboardData && !dashboardData1 && pg.pk['bi.dashboard'] && dashboard
|
|
23
|
-
? await pg1.query(`select dashboard_id as id, table_name as "tableName" from bi.dashboard where $1 in (dashboard_id, name)`, [dashboard])
|
|
23
|
+
? await pg1.query(`select dashboard_id as id, table_name as "tableName", updated_at as "updatedAt" from bi.dashboard where $1 in (dashboard_id, name)`, [dashboard])
|
|
24
24
|
.then(el => el.rows?.[0] || {})
|
|
25
25
|
: {};
|
|
26
26
|
|
|
@@ -55,7 +55,8 @@ async function getWidget({ pg: pg1 = pgClients.client, dashboard, widget }) {
|
|
|
55
55
|
controls,
|
|
56
56
|
style,
|
|
57
57
|
options,
|
|
58
|
-
yml
|
|
58
|
+
yml,
|
|
59
|
+
updated_at: widgetUpdatedAt,
|
|
59
60
|
} = widgetData ||
|
|
60
61
|
(await pg
|
|
61
62
|
.query(q, [id || dashboard, widget])
|
|
@@ -104,7 +105,7 @@ async function getWidget({ pg: pg1 = pgClients.client, dashboard, widget }) {
|
|
|
104
105
|
|
|
105
106
|
const columnList = columns.map(col => col.name);
|
|
106
107
|
|
|
107
|
-
const res = { ...main, pg: widgetDb, sql: widgetData?.sql, limit: widgetData?.limit, tableSQL, data, type, text, controls, style, options, yml };
|
|
108
|
+
const res = { ...main, pg: widgetDb, sql: widgetData?.sql, limit: widgetData?.limit, tableSQL, data, type, text, controls, style, options, yml, last_update: { dashboard: dashboardData1?.updatedAt || updatedAt, widget: widgetUpdatedAt || dashboardData1?.updatedAt || updatedAt } };
|
|
108
109
|
if (res.x && !columnList.includes(res.x) && !loadTemplate?.table && !tableSQL?.includes?.(res.x)) {
|
|
109
110
|
Object.assign(res, { x: null, error: `column does not exists: ${res.x} at table ${res.table}` });
|
|
110
111
|
}
|