@opengis/bi 1.0.40 → 1.0.42
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 +78 -69
- package/dist/{import-file-DXZLuS8B.js → import-file-XtDaxS3X.js} +9946 -9886
- package/dist/style.css +1 -1
- package/dist/{vs-donut-Bxx4DZLr.js → vs-donut-DsuDQZ3C.js} +1 -1
- package/dist/{vs-funnel-bar-Cx4xuD8D.js → vs-funnel-bar-CQAgEcLe.js} +1 -1
- package/dist/{map-component-mixin-C1bMsX3E.js → vs-list-C-gFvDvr.js} +4832 -5060
- package/dist/vs-map-cluster-B9kG91Ge.js +312 -0
- package/dist/vs-map-uUiqdNLp.js +283 -0
- package/dist/{vs-number-Bg_z0D1y.js → vs-number-BuOWTFVp.js} +1 -1
- package/dist/{vs-table-DqJ9ioWo.js → vs-table-BG9nb7R0.js} +1 -1
- package/dist/{vs-text-BLhX4iot.js → vs-text-BEb3W2ua.js} +8 -8
- package/package.json +1 -1
- package/server/routes/dashboard/controllers/dashboard.js +16 -6
- package/server/routes/data/controllers/data.js +8 -7
- package/server/routes/data/controllers/util/normalizeData.js +65 -61
- package/server/routes/edit/controllers/widget.add.js +9 -2
- package/server/routes/edit/controllers/widget.edit.js +12 -2
- package/server/routes/map/controllers/map.js +2 -2
- package/server/utils/getWidget.js +18 -3
- package/dist/vs-map-CNz_KPjD.js +0 -79
- package/dist/vs-map-cluster-CSDStbmR.js +0 -104
|
@@ -31,6 +31,7 @@ export default async function dashboard({
|
|
|
31
31
|
} catch (err) {
|
|
32
32
|
data.error = err.toString();
|
|
33
33
|
}
|
|
34
|
+
|
|
34
35
|
data.type = 'bd';
|
|
35
36
|
const { table_name: table } = data;
|
|
36
37
|
|
|
@@ -38,7 +39,16 @@ export default async function dashboard({
|
|
|
38
39
|
return { message: 'not enough params: table required', status: 400 };
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
const
|
|
42
|
+
const loadTemplate = pg.pk?.['admin.doc_template'] ? await pg.query(
|
|
43
|
+
'select body from admin.doc_template where doc_type=5 and title=$1',
|
|
44
|
+
[table]
|
|
45
|
+
).then(el => el.rows?.[0]?.body) : null;
|
|
46
|
+
|
|
47
|
+
const sqlList = loadTemplate?.sql ? loadTemplate?.sql
|
|
48
|
+
?.filter?.(el => !el.disabled && el?.sql?.replace)
|
|
49
|
+
?.map?.((el, i) => `left join lateral (${el.sql.replace(/limit 1/ig, '')}) t${i} on 1=1`)?.join?.(' ') : '';
|
|
50
|
+
|
|
51
|
+
const { fields = [] } = table && pg.pk?.[loadTemplate?.table || table] ? await pg.query(`select * from ${loadTemplate?.table || table} t ${sqlList || ''} limit 0`) : {};
|
|
42
52
|
|
|
43
53
|
data?.widgets?.forEach?.(el => {
|
|
44
54
|
const { style, data = {}, type, title, x, metrics } = el;
|
|
@@ -51,11 +61,10 @@ export default async function dashboard({
|
|
|
51
61
|
Object.assign(el, { title, type });
|
|
52
62
|
});
|
|
53
63
|
|
|
54
|
-
const meta = table ? await getMeta({ pg, table }) : {};
|
|
64
|
+
const meta = table ? await getMeta({ pg, table: loadTemplate?.table || table }) : {};
|
|
65
|
+
const columnIndexes = meta?.columns?.reduce((acc, curr, idx) => Object.assign(acc, { [curr.name]: idx }), {}) || [];
|
|
55
66
|
|
|
56
|
-
const columns = meta?.columns
|
|
57
|
-
?.filter(el => fields.map(field => field.name).includes(el.name))
|
|
58
|
-
?.map(el => ({ name: el.name, title: el.title, type: pg.pgType?.[el.dataTypeID] }));
|
|
67
|
+
const columns = fields?.map(el => ({ name: el.name, title: meta?.columns[columnIndexes[el.name]]?.title || el.name, type: pg.pgType?.[el.dataTypeID] }));
|
|
59
68
|
|
|
60
69
|
return {
|
|
61
70
|
...data || {},
|
|
@@ -63,8 +72,9 @@ export default async function dashboard({
|
|
|
63
72
|
panels: data?.panels?.filter?.(el => el?.widget) || [],
|
|
64
73
|
geom: !meta?.geom,
|
|
65
74
|
error:
|
|
66
|
-
table && !pg.pk?.[table] ? `table pkey not found: ${table}` : undefined,
|
|
75
|
+
table && !pg.pk?.[loadTemplate?.table || table] ? `table pkey not found: ${loadTemplate?.table || table}` : undefined,
|
|
67
76
|
table_name: table,
|
|
77
|
+
templateTable: loadTemplate?.table,
|
|
68
78
|
time: Date.now() - time,
|
|
69
79
|
columns,
|
|
70
80
|
};
|
|
@@ -19,7 +19,7 @@ const maxLimit = 100;
|
|
|
19
19
|
export default async function dataAPI(req, reply) {
|
|
20
20
|
const time = Date.now();
|
|
21
21
|
|
|
22
|
-
const { query = {}, unittest } = req;
|
|
22
|
+
const { query = {}, user = {}, unittest } = req;
|
|
23
23
|
|
|
24
24
|
query.metric = Array.isArray(query.metric) ? query.metric.pop() : query.metric;
|
|
25
25
|
|
|
@@ -34,7 +34,7 @@ export default async function dataAPI(req, reply) {
|
|
|
34
34
|
const pg = widgetData.pg || req.pg || pgClients.client;
|
|
35
35
|
|
|
36
36
|
const { fields: cols } = await pg.query(
|
|
37
|
-
`select * from ${data.table} limit 0`
|
|
37
|
+
`select * from ${data.table} t ${widgetData.tableSQL || data.tableSQL || ''} limit 0`
|
|
38
38
|
);
|
|
39
39
|
const columnTypes = cols.map((el) => ({
|
|
40
40
|
name: el.name,
|
|
@@ -65,8 +65,8 @@ export default async function dataAPI(req, reply) {
|
|
|
65
65
|
return { message: `table not found: ${data.table} (${pg.options?.database})`, status: 404 };
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const columnList = columns.map(col => col.name);
|
|
69
|
-
const groupbyColumnNotExists = groupby?.split?.(',')?.filter?.(el => !
|
|
68
|
+
// const columnList = columns.map(col => col.name);
|
|
69
|
+
const groupbyColumnNotExists = groupby?.split?.(',')?.filter?.(el => !columnTypes.map(el => el.name).includes(el.trim()));
|
|
70
70
|
|
|
71
71
|
if (groupby && groupbyColumnNotExists?.length) {
|
|
72
72
|
return { message: `groupby column not found: ${groupbyColumnNotExists} (${data.table}/${pg.options?.database})`, status: 404 };
|
|
@@ -83,7 +83,7 @@ export default async function dataAPI(req, reply) {
|
|
|
83
83
|
|
|
84
84
|
if (query.sql === '2') return { x, metric, table, tableSQL, data, groupData };
|
|
85
85
|
|
|
86
|
-
const order = data.order || (type === 'listbar' ? 'metric desc' : null);
|
|
86
|
+
const order = data.order || (type === 'listbar' && cols.find(el => el.name === 'metric') ? 'metric desc' : null);
|
|
87
87
|
|
|
88
88
|
const fData =
|
|
89
89
|
filter || search
|
|
@@ -139,8 +139,9 @@ export default async function dataAPI(req, reply) {
|
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
if (config.
|
|
143
|
-
|
|
142
|
+
if (config.trace) console.log(sql, user?.uid);
|
|
143
|
+
|
|
144
|
+
const { rows, fields } = await pg.query(sql.replace('{{uid}}', user?.uid)); // test with limit
|
|
144
145
|
|
|
145
146
|
if (cls) {
|
|
146
147
|
const values = rows
|
|
@@ -1,61 +1,65 @@
|
|
|
1
|
-
function normalizeData(data, query = {}, columnTypes = []) {
|
|
2
|
-
const skip = [];
|
|
3
|
-
['x', 'groupby', 'granularity'].forEach((el) => {
|
|
4
|
-
// console.log(el, query[el], columnTypes.find(col => col.name == query[el]))
|
|
5
|
-
if (!columnTypes.find((col) => col.name == query[el])) {
|
|
6
|
-
if (query[el] && query[el] !== 'null')
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
1
|
+
function normalizeData(data, query = {}, columnTypes = []) {
|
|
2
|
+
const skip = [];
|
|
3
|
+
['x', 'groupby', 'granularity'].forEach((el) => {
|
|
4
|
+
// console.log(el, query[el], columnTypes.find(col => col.name == query[el]))
|
|
5
|
+
if (!columnTypes.find((col) => col.name == query[el])) {
|
|
6
|
+
if (query[el] && query[el] !== 'null') {
|
|
7
|
+
if (el === 'granularity' && !['week', 'month', 'quarter', 'year'].includes(query[el])) {
|
|
8
|
+
skip.push(`invalid granularity option: ${query[el]}`);
|
|
9
|
+
} else if (el !== 'granularity') { skip.push(`column not found: ${query[el]}`); }
|
|
10
|
+
}
|
|
11
|
+
if (!(el === 'granularity' || (el === 'groupby' && query[el] === 'null'))) delete query[el];
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
if (
|
|
16
|
+
!columnTypes.find(
|
|
17
|
+
(col) => col.type === 'numeric' && col.name == query.metric
|
|
18
|
+
)
|
|
19
|
+
) {
|
|
20
|
+
delete query.metric;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const xName = query.x || (Array.isArray(data.x) ? data.x[0] : data.x);
|
|
24
|
+
const xType = columnTypes.find((el) => el.name == xName)?.type;
|
|
25
|
+
|
|
26
|
+
const granularity =
|
|
27
|
+
xType === 'date' || xType?.includes('timestamp')
|
|
28
|
+
? query.granularity || data.granularity || 'year'
|
|
29
|
+
: null;
|
|
30
|
+
|
|
31
|
+
const x =
|
|
32
|
+
(granularity
|
|
33
|
+
? `date_trunc('${granularity}',${xName})::date::text`
|
|
34
|
+
: null) || xName;
|
|
35
|
+
|
|
36
|
+
const metrics = Array.isArray(data.metrics || data.metric) ? (data.metrics || data.metric) : [data.metrics || data.metric];
|
|
37
|
+
const metric =
|
|
38
|
+
(query.metric ? `sum(${query.metric})` : null) ||
|
|
39
|
+
(metrics.length
|
|
40
|
+
? (metrics
|
|
41
|
+
?.filter((el) => el && columnTypes.find((col) => col.name == (el?.name || el)))
|
|
42
|
+
?.map((el) => el.fx || `${el.operator || 'sum'}(${el.name || el})`)?.join(',') || 'count(*)')
|
|
43
|
+
: 'count(*)');
|
|
44
|
+
|
|
45
|
+
const yName = metrics?.[0]?.name || metrics?.[0];
|
|
46
|
+
const yType = columnTypes.find((el) => el.name == yName)?.type;
|
|
47
|
+
|
|
48
|
+
const { cls, table, filterCustom } = data;
|
|
49
|
+
const groupby = (query.groupby || data.groupby) === 'null' ? null : (query.groupby || data.groupby);
|
|
50
|
+
// const orderby = query.orderby || data.orderby || 'count(*)';
|
|
51
|
+
|
|
52
|
+
const custom = query?.filterCustom
|
|
53
|
+
?.split(',')
|
|
54
|
+
?.map((el) => filterCustom?.find((item) => item?.name === el)?.sql)
|
|
55
|
+
?.filter((el) => el)
|
|
56
|
+
?.join(' and ');
|
|
57
|
+
const where = `${data.query || '1=1'} and ${custom || 'true'}`;
|
|
58
|
+
|
|
59
|
+
const tableSQL = data.tableSQL?.length
|
|
60
|
+
? `(select * from ${data?.table} t ${data.tableSQL || ''} where ${where})q`
|
|
61
|
+
: undefined;
|
|
62
|
+
|
|
63
|
+
return { x, cls, metric, table, where, tableSQL, groupby, xName, xType, yName, yType, error: skip.length ? skip.join(',') : undefined };
|
|
64
|
+
}
|
|
65
|
+
export default normalizeData;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { dataInsert, dataUpdate, pgClients } from "@opengis/fastify-table/utils.js";
|
|
2
|
+
import { dataInsert, dataUpdate, getPGAsync, pgClients } from "@opengis/fastify-table/utils.js";
|
|
3
3
|
|
|
4
4
|
/* eslint-disable import/extensions */
|
|
5
5
|
import { yamlSafe } from '../../../../utils.js';
|
|
@@ -20,12 +20,19 @@ export default async function widgetAdd({ pg = pgClients.client, params = {}, bo
|
|
|
20
20
|
const row = await pg.query(`select dashboard_id, widgets, panels, table_name, db from bi.dashboard
|
|
21
21
|
where $1 in (dashboard_id,name)`, [dashboardName]).then(el => el.rows?.[0] || {});
|
|
22
22
|
|
|
23
|
+
const pg1 = row?.db ? await getPGAsync(row.db) : pg;
|
|
24
|
+
|
|
23
25
|
const tableName = data.data?.table
|
|
24
26
|
|| data?.table
|
|
25
27
|
|| data.table_name
|
|
26
28
|
|| row.table_name;
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
const loadTemplate = pg1.pk?.['admin.doc_template'] ? await pg1.query(
|
|
31
|
+
'select body from admin.doc_template where doc_type=5 and title=$1',
|
|
32
|
+
[tableName]
|
|
33
|
+
).then(el => el.rows?.[0]?.body) : null;
|
|
34
|
+
|
|
35
|
+
if (!tableName || !(pg.pk?.[loadTemplate?.table || tableName] || pgClients[data.db || row.db || 'client']?.pk?.[loadTemplate?.table || tableName])) {
|
|
29
36
|
return { message: 'bad params: table', status: 400 };
|
|
30
37
|
}
|
|
31
38
|
|
|
@@ -37,8 +37,18 @@ export default async function widgetEdit({ pg = pgClients.client, body, params }
|
|
|
37
37
|
.reduce((p, el) => ({ ...p, [el]: data[el] }), {});
|
|
38
38
|
|
|
39
39
|
// get table
|
|
40
|
-
const tableName = body.table
|
|
41
|
-
|
|
40
|
+
const tableName = body.table
|
|
41
|
+
|| widgetData.data?.table_name
|
|
42
|
+
|| widgetData.data?.table
|
|
43
|
+
|| widgetData?.table_name
|
|
44
|
+
|| templateData.table;
|
|
45
|
+
|
|
46
|
+
const loadTemplate = pg.pk?.['admin.doc_template'] ? await pg.query(
|
|
47
|
+
'select body from admin.doc_template where doc_type=5 and title=$1',
|
|
48
|
+
[tableName]
|
|
49
|
+
).then(el => el.rows?.[0]?.body) : null;
|
|
50
|
+
|
|
51
|
+
if (!tableName || !(pg.pk?.[loadTemplate?.table || tableName] || pgClients[widgetData?.data?.db || templateData?.db || 'client']?.pk?.[loadTemplate?.table || tableName])) {
|
|
42
52
|
return { message: 'bad params: table ' + tableName, status: 400 };
|
|
43
53
|
}
|
|
44
54
|
|
|
@@ -31,9 +31,9 @@ export default async function map(req) {
|
|
|
31
31
|
);
|
|
32
32
|
if (data?.cls) {
|
|
33
33
|
const vals = await getSelectVal({
|
|
34
|
-
pg, name: data.cls, values: rows.map(el => el.val),
|
|
34
|
+
pg, name: data.cls, values: rows.map(el => el.val), ar: true,
|
|
35
35
|
});
|
|
36
|
-
rows.forEach(row => Object.assign(row, {
|
|
36
|
+
rows.forEach(row => Object.assign(row, { ...vals?.find?.(el => el.id === row.val) || { text: row.val } }));
|
|
37
37
|
}
|
|
38
38
|
Object.assign(res, { colors: rows }); // кольори для легенди
|
|
39
39
|
}
|
|
@@ -85,10 +85,15 @@ async function getWidget({ pg: pg1 = pgClients.client, dashboard, widget }) {
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const
|
|
88
|
+
const loadTemplate = pg.pk?.['admin.doc_template'] ? await pg.query(
|
|
89
|
+
'select body from admin.doc_template where doc_type=5 and title=$1',
|
|
90
|
+
[main.table]
|
|
91
|
+
).then(el => el.rows?.[0]?.body) : null;
|
|
92
|
+
|
|
93
|
+
const { pk, view, columns = [] } = await getMeta({ pg: widgetDb, table: loadTemplate?.table || main?.table });
|
|
89
94
|
if (!pk && !view) {
|
|
90
95
|
return {
|
|
91
|
-
message: /* json.error || */ `invalid ${widget ? 'widget' : 'dashboard'}: table not found (${main?.table})`,
|
|
96
|
+
message: /* json.error || */ `invalid ${widget ? 'widget' : 'dashboard'}: table not found (${loadTemplate?.table || main?.table})`,
|
|
92
97
|
status: 404,
|
|
93
98
|
};
|
|
94
99
|
}
|
|
@@ -97,6 +102,16 @@ async function getWidget({ pg: pg1 = pgClients.client, dashboard, widget }) {
|
|
|
97
102
|
(el, i) => `left join lateral(${el})t${i + 1} on 1=1`
|
|
98
103
|
);
|
|
99
104
|
|
|
100
|
-
|
|
105
|
+
const columnList = columns.map(col => col.name);
|
|
106
|
+
|
|
107
|
+
const res = { ...main, pg: widgetDb, sql: widgetData?.sql, limit: widgetData?.limit, tableSQL, data, type, text, controls, style, options, yml };
|
|
108
|
+
if (res.x && !columnList.includes(res.x) && !loadTemplate?.table) {
|
|
109
|
+
Object.assign(res, { x: null, error: `column does not exists: ${res.x} at table ${res.table}` });
|
|
110
|
+
}
|
|
111
|
+
if (loadTemplate?.table) {
|
|
112
|
+
Object.assign(res.data || {}, { table: loadTemplate?.table });
|
|
113
|
+
Object.assign(res, { table: loadTemplate?.table, table_name: loadTemplate?.table, tableSQL: loadTemplate.sql?.filter?.(el => !el.disabled && el?.sql?.replace)?.map?.((el, i) => `left join lateral(${el.sql})t${i + 1} on 1=1`)?.join?.(' ') });
|
|
114
|
+
}
|
|
115
|
+
return res;
|
|
101
116
|
}
|
|
102
117
|
export default getWidget;
|
package/dist/vs-map-CNz_KPjD.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { l as M, m as w } from "./map-component-mixin-C1bMsX3E.js";
|
|
2
|
-
import { _ as b, c as y } from "./import-file-DXZLuS8B.js";
|
|
3
|
-
import { resolveComponent as i, createElementBlock as V, openBlock as u, createElementVNode as d, createBlock as _, createCommentVNode as v, createVNode as c } from "vue";
|
|
4
|
-
const $ = {
|
|
5
|
-
mixins: [y, M, w],
|
|
6
|
-
name: "VsMap",
|
|
7
|
-
async mounted() {
|
|
8
|
-
await this.getMapData(), await this.createMap();
|
|
9
|
-
},
|
|
10
|
-
methods: {
|
|
11
|
-
async getMapData() {
|
|
12
|
-
const s = await (await fetch(
|
|
13
|
-
`/api/bi-map?widget=${this.widget}&dashboard=${this.dashboard}`
|
|
14
|
-
)).json();
|
|
15
|
-
this.data = s;
|
|
16
|
-
},
|
|
17
|
-
async loadHandler() {
|
|
18
|
-
const a = ["#69D2E7", "yellow", "#FE4365"], s = this.data.colors ? ["match", ["get", "x"]].concat(
|
|
19
|
-
this.data.colors.reduce(
|
|
20
|
-
(o, t, r) => o.concat(t.val, a[r]),
|
|
21
|
-
[]
|
|
22
|
-
)
|
|
23
|
-
).concat(["gray"]) : "blue", p = [5, 7, 9, 11, 13], e = this.data.sizes ? ["case"] : 5;
|
|
24
|
-
this.data.sizes && (this.data.sizes.reverse().forEach((o, t) => {
|
|
25
|
-
e.push([">", ["get", "metric"], o]), e.push(p[t]);
|
|
26
|
-
}), e.push(5));
|
|
27
|
-
const n = {
|
|
28
|
-
type: "circle",
|
|
29
|
-
color: s,
|
|
30
|
-
width: 2,
|
|
31
|
-
radius: e,
|
|
32
|
-
stroke: "#eee"
|
|
33
|
-
};
|
|
34
|
-
Object.assign(n, this.data.style || {}), this.addVtileLayer({
|
|
35
|
-
id: "bi",
|
|
36
|
-
url: `${window.top.location.origin}/api/bi-vtile/{z}/{x}/{y}.vmt?widget=${this.widget}&dashboard=${this.dashboard}&nocache=1`,
|
|
37
|
-
style: n
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}, z = ["id"], I = ["id"], k = { ref: "popup" }, x = { class: "absolute flex flex-col right-[10px] top-[105px] gap-1" };
|
|
42
|
-
function E(a, s, p, e, n, o) {
|
|
43
|
-
var l, m, h;
|
|
44
|
-
const t = i("VsMapSetting"), r = i("VsMapSlotLayers"), f = i("VsMapLegend"), g = i("VsMapGoHome");
|
|
45
|
-
return u(), V("div", {
|
|
46
|
-
class: "relative w-full h-full",
|
|
47
|
-
id: `wrapper-${a.mapId}`
|
|
48
|
-
}, [
|
|
49
|
-
d("div", {
|
|
50
|
-
id: a.mapId,
|
|
51
|
-
class: "w-full flex items-end relative h-[250px]"
|
|
52
|
-
}, [
|
|
53
|
-
d("div", k, null, 512)
|
|
54
|
-
], 8, I),
|
|
55
|
-
a.showSetting ? (u(), _(t, {
|
|
56
|
-
key: 0,
|
|
57
|
-
map: a.map,
|
|
58
|
-
coordinates: a.coordinatesByMouse
|
|
59
|
-
}, null, 8, ["map", "coordinates"])) : v("", !0),
|
|
60
|
-
c(r, { map: a.map }, null, 8, ["map"]),
|
|
61
|
-
d("div", x, [
|
|
62
|
-
c(f, {
|
|
63
|
-
mapId: a.mapId,
|
|
64
|
-
colors: (l = a.data) == null ? void 0 : l.colors,
|
|
65
|
-
sizes: (m = a.data) == null ? void 0 : m.sizes,
|
|
66
|
-
color: a.color,
|
|
67
|
-
resizeItem: "true"
|
|
68
|
-
}, null, 8, ["mapId", "colors", "sizes", "color"]),
|
|
69
|
-
c(g, {
|
|
70
|
-
map: a.map,
|
|
71
|
-
bbox: (h = a.data) == null ? void 0 : h.bounds
|
|
72
|
-
}, null, 8, ["map", "bbox"])
|
|
73
|
-
])
|
|
74
|
-
], 8, z);
|
|
75
|
-
}
|
|
76
|
-
const C = /* @__PURE__ */ b($, [["render", E]]);
|
|
77
|
-
export {
|
|
78
|
-
C as default
|
|
79
|
-
};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { l as v, m as k, p as L } from "./map-component-mixin-C1bMsX3E.js";
|
|
2
|
-
import { _ as C, c as I } from "./import-file-DXZLuS8B.js";
|
|
3
|
-
import { resolveComponent as e, createElementBlock as S, openBlock as g, createElementVNode as u, createBlock as _, createCommentVNode as $, createVNode as i } from "vue";
|
|
4
|
-
const z = {
|
|
5
|
-
mixins: [I, v, k],
|
|
6
|
-
data() {
|
|
7
|
-
return {
|
|
8
|
-
baseColor: "pink",
|
|
9
|
-
kattotg: ""
|
|
10
|
-
};
|
|
11
|
-
},
|
|
12
|
-
async mounted() {
|
|
13
|
-
await this.getMapData(), await this.createMap();
|
|
14
|
-
},
|
|
15
|
-
watch: {
|
|
16
|
-
kattotg() {
|
|
17
|
-
this.loadHandler();
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
methods: {
|
|
21
|
-
async getMapData() {
|
|
22
|
-
const t = await fetch(
|
|
23
|
-
`/api/bi-cluster?widget=${this.widget}&dashboard=${this.dashboard}`
|
|
24
|
-
);
|
|
25
|
-
this.data = await t.json();
|
|
26
|
-
},
|
|
27
|
-
async loadHandler() {
|
|
28
|
-
var r;
|
|
29
|
-
this.baseColor = ((r = this.data.style) == null ? void 0 : r.color) || "blue";
|
|
30
|
-
const t = ["case"];
|
|
31
|
-
this.data.sizes.reverse().forEach((s, n) => {
|
|
32
|
-
t.push([">", ["get", "metric"], s]), t.push(L[this.baseColor][n]), n++;
|
|
33
|
-
}), t.push("gray");
|
|
34
|
-
const a = {
|
|
35
|
-
type: "polygon",
|
|
36
|
-
color: t,
|
|
37
|
-
opacity: 0.4
|
|
38
|
-
};
|
|
39
|
-
Object.assign(a, this.data.style || {}), this.map.getSource("bi") || this.addVtileLayer({
|
|
40
|
-
id: "bi",
|
|
41
|
-
url: `${window.location.origin}/api/bi-cluster-vtile/{z}/{x}/{y}.vmt?widget=${this.widget}&dashboard=${this.dashboard}&nocache=1`,
|
|
42
|
-
style: a
|
|
43
|
-
}), this.map.getLayer("highlighted") && this.map.removeLayer("highlighted"), this.map.getSource("highlighted") && this.map.removeSource("highlighted");
|
|
44
|
-
const o = ["case"];
|
|
45
|
-
this.kattotg && o.push(
|
|
46
|
-
["==", ["to-string", ["get", "name"]], String(this.kattotg)],
|
|
47
|
-
"red"
|
|
48
|
-
), o.push("transparent"), this.map.addLayer({
|
|
49
|
-
id: "highlighted",
|
|
50
|
-
type: "fill",
|
|
51
|
-
source: "bi",
|
|
52
|
-
"source-layer": "bi",
|
|
53
|
-
paint: {
|
|
54
|
-
"fill-color": o,
|
|
55
|
-
"fill-opacity": 0.6
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}, B = ["id"], H = ["id"], E = { class: "absolute flex flex-col right-[10px] top-[105px] gap-1" };
|
|
61
|
-
function N(t, a, o, r, s, n) {
|
|
62
|
-
var l, p, d, c, h, m;
|
|
63
|
-
const y = e("VsMapSetting"), f = e("VsMapSlotLayers"), b = e("VsMapLegend"), w = e("VsMapGoHome"), M = e("VsList");
|
|
64
|
-
return g(), S("div", {
|
|
65
|
-
class: "relative w-full h-full",
|
|
66
|
-
id: `wrapper-${t.mapId}`
|
|
67
|
-
}, [
|
|
68
|
-
u("div", {
|
|
69
|
-
id: t.mapId,
|
|
70
|
-
class: "h-[96%] w-full flex items-end min-h-[250px]"
|
|
71
|
-
}, null, 8, H),
|
|
72
|
-
t.showSetting ? (g(), _(y, {
|
|
73
|
-
key: 0,
|
|
74
|
-
map: t.map,
|
|
75
|
-
coordinates: t.coordinatesByMouse
|
|
76
|
-
}, null, 8, ["map", "coordinates"])) : $("", !0),
|
|
77
|
-
i(f, { map: t.map }, null, 8, ["map"]),
|
|
78
|
-
u("div", E, [
|
|
79
|
-
i(b, {
|
|
80
|
-
mapId: t.mapId,
|
|
81
|
-
colors: (l = t.data) == null ? void 0 : l.colors,
|
|
82
|
-
sizes: (p = t.data) == null ? void 0 : p.sizes,
|
|
83
|
-
color: s.baseColor,
|
|
84
|
-
changeOpacityItem: "true",
|
|
85
|
-
cluster: "true"
|
|
86
|
-
}, null, 8, ["mapId", "colors", "sizes", "color"]),
|
|
87
|
-
i(w, {
|
|
88
|
-
map: t.map,
|
|
89
|
-
bbox: (d = t.data) == null ? void 0 : d.bounds
|
|
90
|
-
}, null, 8, ["map", "bbox"]),
|
|
91
|
-
i(M, {
|
|
92
|
-
mapId: t.mapId,
|
|
93
|
-
source: (c = t.data) == null ? void 0 : c.rows,
|
|
94
|
-
total: ((h = t.data) == null ? void 0 : h.total) || 0,
|
|
95
|
-
count: ((m = t.data) == null ? void 0 : m.count) || 0,
|
|
96
|
-
onKattotg: a[0] || (a[0] = (V) => s.kattotg = V)
|
|
97
|
-
}, null, 8, ["mapId", "source", "total", "count"])
|
|
98
|
-
])
|
|
99
|
-
], 8, B);
|
|
100
|
-
}
|
|
101
|
-
const O = /* @__PURE__ */ C(z, [["render", N]]);
|
|
102
|
-
export {
|
|
103
|
-
O as default
|
|
104
|
-
};
|