@opengis/bi 1.0.45 → 1.0.47

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.
Files changed (27) hide show
  1. package/config.js +12 -12
  2. package/dist/bi.js +1 -1
  3. package/dist/bi.umd.cjs +126 -139
  4. package/dist/{import-file-n7AnE4rc.js → import-file-XFI3CaVb.js} +11303 -11237
  5. package/dist/style.css +1 -1
  6. package/dist/{vs-donut-Bc9gBhHN.js → vs-donut-al85JwBt.js} +7 -7
  7. package/dist/{vs-funnel-bar-BQLFsh4u.js → vs-funnel-bar-mWZ8lvEq.js} +5 -5
  8. package/dist/{vs-list-D1NHJa-8.js → vs-list-1QDnN3pH.js} +1532 -1535
  9. package/dist/{vs-map-CUF5ZJo4.js → vs-map-CwR6ZYur.js} +8 -8
  10. package/dist/{vs-map-cluster-ZPcu4qhm.js → vs-map-cluster-YdXTBIVf.js} +18 -18
  11. package/dist/{vs-number-Z4ee8Kwo.js → vs-number-CRUhHKym.js} +3 -3
  12. package/dist/{vs-table-BrnSztWP.js → vs-table-OddIdr1s.js} +6 -6
  13. package/dist/{vs-text-Bj9iBISe.js → vs-text-CQ9vn0qO.js} +4 -4
  14. package/package.json +1 -6
  15. package/server/plugins/docs.js +4 -4
  16. package/server/plugins/vite.js +69 -69
  17. package/server/routes/dashboard/controllers/dashboard.list.js +9 -1
  18. package/server/routes/dashboard/controllers/utils/yaml.js +11 -11
  19. package/server/routes/data/controllers/data.js +6 -2
  20. package/server/routes/map/controllers/cluster.js +121 -121
  21. package/server/routes/map/controllers/clusterVtile.js +166 -166
  22. package/server/routes/map/controllers/geojson.js +127 -127
  23. package/server/routes/map/controllers/map.js +67 -67
  24. package/server/routes/map/controllers/utils/downloadClusterData.js +44 -44
  25. package/server/routes/map/controllers/vtile.js +183 -183
  26. package/server/utils/getWidget.js +1 -1
  27. package/utils.js +12 -12
@@ -1,8 +1,8 @@
1
- import { l as L, c as $, p as T, V as B, a as H, b as O, d as F, m as S, e as N } from "./vs-list-D1NHJa-8.js";
2
- import { _ as C, c as P } from "./import-file-n7AnE4rc.js";
3
- import { resolveComponent as u, openBlock as i, createElementBlock as p, Fragment as v, createElementVNode as r, createVNode as f, createBlock as E, Teleport as R, toDisplayString as b, createCommentVNode as m, renderList as k, normalizeStyle as I, normalizeClass as V } from "vue";
1
+ import { c as L, l as $, p as T, V as B, a as H, b as O, d as F, m as S, e as N } from "./vs-list-1QDnN3pH.js";
2
+ import { _ as C, c as P } from "./import-file-XFI3CaVb.js";
3
+ import { resolveComponent as u, createElementBlock as p, openBlock as i, Fragment as v, createElementVNode as r, createBlock as E, createCommentVNode as m, createVNode as f, Teleport as R, toDisplayString as b, renderList as k, normalizeStyle as I, normalizeClass as V } from "vue";
4
4
  const A = {
5
- components: { legendIcon: L, closeIcon: $ },
5
+ components: { legendIcon: $, closeIcon: L },
6
6
  props: {
7
7
  mapId: { type: String },
8
8
  colors: { type: Array },
@@ -132,11 +132,11 @@ function ee(e, t, s, o, l, a) {
132
132
  }
133
133
  const te = /* @__PURE__ */ C(A, [["render", ee]]), se = {
134
134
  components: {
135
- VsMapSetting: B,
136
- VsMapSlotLayers: H,
135
+ VsMapSetting: F,
136
+ VsMapSlotLayers: O,
137
137
  VsMapLegend: te,
138
- VsMapGoHome: O,
139
- VsList: F
138
+ VsMapGoHome: H,
139
+ VsList: B
140
140
  },
141
141
  data() {
142
142
  return {
@@ -1,8 +1,8 @@
1
- import { l as G, c as A, p as R, e as P, V as Z, b as q, d as D, a as K, m as H } from "./vs-list-D1NHJa-8.js";
2
- import { _ as V, c as W, V as J, I as Q, e as U, g as X } from "./import-file-n7AnE4rc.js";
3
- import { openBlock as p, createElementBlock as m, createElementVNode as l, normalizeClass as I, Fragment as N, renderList as O, toDisplayString as F, normalizeStyle as Y, createCommentVNode as S, resolveComponent as g, createBlock as z, resolveDynamicComponent as j, withDirectives as M, createVNode as w, vShow as C } from "vue";
1
+ import { c as G, l as A, p as R, b as P, V as Z, a as q, d as D, e as K, m as H } from "./vs-list-1QDnN3pH.js";
2
+ import { _ as V, V as W, c as J, e as Q, I as U, g as X } from "./import-file-XFI3CaVb.js";
3
+ import { createElementBlock as m, createCommentVNode as S, openBlock as p, createElementVNode as l, normalizeClass as I, Fragment as N, renderList as O, toDisplayString as F, normalizeStyle as Y, resolveComponent as g, withDirectives as z, createBlock as M, resolveDynamicComponent as j, createVNode as w, vShow as C } from "vue";
4
4
  const $ = {
5
- components: { legendIcon: G, closeIcon: A },
5
+ components: { legendIcon: A, closeIcon: G },
6
6
  props: {
7
7
  mapId: { type: String },
8
8
  colors: { type: Array },
@@ -100,15 +100,15 @@ function ie(t, s) {
100
100
  ]));
101
101
  }
102
102
  const pe = /* @__PURE__ */ V(ne, [["render", ie]]), ce = {
103
- mixins: [W, P],
103
+ mixins: [J, K],
104
104
  components: {
105
- VsMapSetting: Z,
105
+ VsMapSetting: D,
106
106
  VsClusterLegend: ae,
107
107
  VsMapGoHome: q,
108
- VsList: D,
109
- VsMapSlotLayers: K,
108
+ VsList: Z,
109
+ VsMapSlotLayers: P,
110
110
  // VsListbar,
111
- VsBar: J
111
+ VsBar: W
112
112
  },
113
113
  data() {
114
114
  return {
@@ -116,8 +116,8 @@ const pe = /* @__PURE__ */ V(ne, [["render", ie]]), ce = {
116
116
  kattotg: "",
117
117
  options: [
118
118
  { id: "map", text: "Карта", component: pe },
119
- { id: "table", text: "Таблиця", component: Q },
120
- { id: "chart", text: "Віджет", component: U }
119
+ { id: "table", text: "Таблиця", component: U },
120
+ { id: "chart", text: "Віджет", component: X }
121
121
  ],
122
122
  activeTab: "map",
123
123
  mapId: `map-${Math.floor(Math.random() * 1e3)}`,
@@ -142,7 +142,7 @@ const pe = /* @__PURE__ */ V(ne, [["render", ie]]), ce = {
142
142
  },
143
143
  methods: {
144
144
  async getMapData() {
145
- const t = await X.get(
145
+ const t = await Q.get(
146
146
  `/bi-cluster?widget=${this.widget}&dashboard=${this.dashboard}`
147
147
  );
148
148
  this.data = t.data, this.$emit("update:widgetData", this.data), setTimeout(() => {
@@ -248,14 +248,14 @@ function xe(t, s, n, a, e, o) {
248
248
  class: I(["p-1 text-gray-700 border rounded", [e.activeTab === (r == null ? void 0 : r.id) ? "ring-2 ring-blue-500" : ""]]),
249
249
  onClick: (_e) => e.activeTab = r == null ? void 0 : r.id
250
250
  }, [
251
- (p(), z(j(r == null ? void 0 : r.component), {
251
+ (p(), M(j(r == null ? void 0 : r.component), {
252
252
  height: "16",
253
253
  width: "16"
254
254
  }))
255
255
  ], 10, ge))), 256))
256
256
  ])
257
257
  ]),
258
- M(l("div", {
258
+ z(l("div", {
259
259
  class: "relative w-full h-[calc(100%-40px)]",
260
260
  id: `wrapper-${e.mapId}`
261
261
  }, [
@@ -263,7 +263,7 @@ function xe(t, s, n, a, e, o) {
263
263
  id: e.mapId,
264
264
  class: "h-[calc(100%-40px)] w-full flex items-end min-h-[250px]"
265
265
  }, null, 8, fe),
266
- e.showSetting ? (p(), z(d, {
266
+ e.showSetting ? (p(), M(d, {
267
267
  key: 0,
268
268
  map: e.map,
269
269
  coordinates: e.coordinatesByMouse
@@ -286,7 +286,7 @@ function xe(t, s, n, a, e, o) {
286
286
  ], 8, ye), [
287
287
  [C, e.activeTab == "map"]
288
288
  ]),
289
- M(w(u, {
289
+ z(w(u, {
290
290
  mapId: e.mapId,
291
291
  source: (v = e.data) == null ? void 0 : v.rows,
292
292
  total: ((x = e.data) == null ? void 0 : x.total) || 0,
@@ -295,8 +295,8 @@ function xe(t, s, n, a, e, o) {
295
295
  }, null, 8, ["mapId", "source", "total", "count"]), [
296
296
  [C, e.activeTab == "table"]
297
297
  ]),
298
- M(l("div", ve, [
299
- (E = (L = e.data) == null ? void 0 : L.rows) != null && E.length ? (p(), z(_, {
298
+ z(l("div", ve, [
299
+ (E = (L = e.data) == null ? void 0 : L.rows) != null && E.length ? (p(), M(_, {
300
300
  key: 0,
301
301
  source: (T = (B = e.data) == null ? void 0 : B.rows) == null ? void 0 : T.map((r) => ({
302
302
  title: r == null ? void 0 : r.title,
@@ -1,5 +1,5 @@
1
- import { _ as c, c as o, f as n } from "./import-file-n7AnE4rc.js";
2
- import { openBlock as i, createElementBlock as m, toDisplayString as s } from "vue";
1
+ import { _ as c, c as o, f as n } from "./import-file-XFI3CaVb.js";
2
+ import { createElementBlock as i, openBlock as m, toDisplayString as s } from "vue";
3
3
  const u = {
4
4
  name: "VsNumber",
5
5
  mixins: [o],
@@ -47,7 +47,7 @@ const u = {
47
47
  }
48
48
  }, h = { class: "text-lg lg:text-xl xl:text-2xl text-gray-800 h-[32px] flex items-center" };
49
49
  function x(e, t, r, f, l, a) {
50
- return i(), m("div", h, s(a.prefix) + s(a.formattedNumber), 1);
50
+ return m(), i("div", h, s(a.prefix) + s(a.formattedNumber), 1);
51
51
  }
52
52
  const b = /* @__PURE__ */ c(u, [["render", x]]);
53
53
  export {
@@ -1,5 +1,5 @@
1
- import { _ as m, c as f, d as _, a as b } from "./import-file-n7AnE4rc.js";
2
- import { openBlock as a, createElementBlock as r, createElementVNode as s, Fragment as n, renderList as c, toDisplayString as d } from "vue";
1
+ import { _ as m, c as f, d as _, a as b } from "./import-file-XFI3CaVb.js";
2
+ import { createElementBlock as a, openBlock as r, createElementVNode as s, Fragment as n, renderList as c, toDisplayString as d } from "vue";
3
3
  const x = {
4
4
  name: "VsTable",
5
5
  mixins: [f],
@@ -39,20 +39,20 @@ const x = {
39
39
  class: "xl:min-w-[120px] min-w-48"
40
40
  }, F = { class: "flex items-center px-1 py-3 font-medium text-gray-800 text-start gap-x-1" }, T = { class: "divide-y divide-gray-200" }, B = { class: "text-gray-600" };
41
41
  function E(t, e, o, l, N, S) {
42
- return a(), r("div", y, [
42
+ return r(), a("div", y, [
43
43
  s("div", g, [
44
44
  s("div", w, [
45
45
  s("table", k, [
46
46
  s("thead", v, [
47
47
  s("tr", D, [
48
- (a(!0), r(n, null, c(t.dimensions, (i) => (a(), r("th", $, [
48
+ (r(!0), a(n, null, c(t.dimensions, (i) => (r(), a("th", $, [
49
49
  s("div", F, d(i), 1)
50
50
  ]))), 256))
51
51
  ])
52
52
  ]),
53
53
  s("tbody", T, [
54
- (a(!0), r(n, null, c(t.sourceData, (i, p) => (a(), r("tr", { key: p }, [
55
- (a(!0), r(n, null, c(t.dimensions, (u, h) => (a(), r("td", {
54
+ (r(!0), a(n, null, c(t.sourceData, (i, p) => (r(), a("tr", { key: p }, [
55
+ (r(!0), a(n, null, c(t.dimensions, (u, h) => (r(), a("td", {
56
56
  key: h,
57
57
  class: "py-3 whitespace-nowrap"
58
58
  }, [
@@ -1,5 +1,5 @@
1
- import { _ as o, c as s, m as i } from "./import-file-n7AnE4rc.js";
2
- import { openBlock as r, createElementBlock as n, createCommentVNode as a } from "vue";
1
+ import { _ as o, c as s, m as i } from "./import-file-XFI3CaVb.js";
2
+ import { createElementBlock as r, openBlock as n, createCommentVNode as a } from "vue";
3
3
  const c = {
4
4
  name: "VsText",
5
5
  mixins: [s],
@@ -24,11 +24,11 @@ const c = {
24
24
  }
25
25
  }, u = ["id"], d = ["innerHTML"];
26
26
  function l(t, m, x, h, e, _) {
27
- return r(), n("div", {
27
+ return n(), r("div", {
28
28
  id: e.uniqueID,
29
29
  class: "relative select-auto h-full rounded-xl text-[12px] box-border bg-white custom-scrollbar text-widget"
30
30
  }, [
31
- e.markedText ? (r(), n("div", {
31
+ e.markedText ? (n(), r("div", {
32
32
  key: 0,
33
33
  innerHTML: e.markedText
34
34
  }, null, 8, d)) : a("", !0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengis/bi",
3
- "version": "1.0.45",
3
+ "version": "1.0.47",
4
4
  "description": "BI data visualization module",
5
5
  "main": "dist/bi.js",
6
6
  "browser": "dist/bi.umd.cjs",
@@ -24,14 +24,9 @@
24
24
  "test21": "node --test ./test/plugins/*",
25
25
  "start": "node server.js",
26
26
  "prod": "cross-env NODE_ENV=production npm run start",
27
- "docs:local": "cross-env docs=local vitepress build docs",
28
27
  "docs:dev": "vitepress dev docs",
29
28
  "docs:build": "vitepress build docs",
30
29
  "docs:preview": "vitepress preview docs",
31
- "docs-dev:local": "cross-env docs=local vitepress build docs-dev",
32
- "docs-dev:dev": "vitepress dev docs-dev",
33
- "docs-dev:build": "vitepress build docs-dev",
34
- "docs-dev:preview": "vitepress preview docs-dev",
35
30
  "adduser": "node script/adduser.js"
36
31
  },
37
32
  "keywords": [
@@ -6,8 +6,8 @@ const dir = dirname(fileURLToPath(import.meta.url));
6
6
  const root = `${dir}/../../`;
7
7
 
8
8
  async function plugin(fastify, opts) {
9
- fastify.get('/docs-dev*', async (req, reply) => {
10
- if (!fs.existsSync(path.join(root, 'docs-dev/.vitepress/dist/'))) {
9
+ fastify.get('/docs*', async (req, reply) => {
10
+ if (!fs.existsSync(path.join(root, 'docs/.vitepress/dist/'))) {
11
11
  return reply.status(404).send('docs not exists');
12
12
  }
13
13
 
@@ -16,8 +16,8 @@ async function plugin(fastify, opts) {
16
16
 
17
17
  const filePath =
18
18
  url && url[url.length - 1] !== '/'
19
- ? path.join(root, 'docs-dev/.vitepress/dist/', url)
20
- : path.join(root, 'docs-dev/.vitepress/dist/', url, 'index.html');
19
+ ? path.join(root, 'docs/.vitepress/dist/', url)
20
+ : path.join(root, 'docs/.vitepress/dist/', url, 'index.html');
21
21
 
22
22
  if (!fs.existsSync(filePath)) {
23
23
  return reply.status(404).send('File not found');
@@ -1,69 +1,69 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import config from '../../config.js';
4
-
5
- const { disableAuth } = config;
6
- const isProduction = process.env.NODE_ENV === 'production';
7
-
8
- async function plugin(fastify) {
9
- // vite server
10
- if (!isProduction) {
11
- const vite = await import('vite');
12
-
13
- const viteServer = await vite.createServer({
14
- server: {
15
- middlewareMode: true,
16
- },
17
- });
18
- // hot reload
19
- viteServer.watcher.on('all', (d, t) => {
20
- if (!t.includes('module') && !t.includes('templates')) return;
21
- // console.log(d, t);
22
- viteServer.ws.send({ type: 'full-reload' });
23
- });
24
-
25
- // this is middleware for vite's dev servert
26
- fastify.addHook('onRequest', async (req, reply) => {
27
- // const { user } = req.session?.passport || {};
28
- const next = () => new Promise((resolve) => {
29
- viteServer.middlewares(req.raw, reply.raw, () => resolve());
30
- });
31
- await next();
32
- });
33
- fastify.get('*', async () => {});
34
- return;
35
- }
36
-
37
- // From Build
38
- fastify.get('*', async (req, reply) => {
39
- // console.log(disableAuth)
40
- if (!req.user && !disableAuth) return reply.redirect('/login');
41
- const stream = fs.createReadStream('dist/index.html');
42
- return reply
43
- .headers({ 'Cache-Control': 'public, no-cache' })
44
- .type('text/html')
45
- .send(stream);
46
- });
47
- fastify.get('/assets/:file', async (req, reply) => {
48
- const stream = fs.createReadStream(`dist/assets/${req.params.file}`);
49
- const ext = path.extname(req.params.file);
50
- const mime = {
51
- '.js': 'text/javascript',
52
- '.css': 'text/css',
53
- '.woff2': 'application/font-woff',
54
- '.png': 'image/png',
55
- }[ext];
56
- // reply.cacheControl('max-age', '1d');
57
- return mime
58
- ? reply
59
- .headers({
60
- 'Cache-Control': 'public, max-age=3600',
61
- 'Content-Encoding': 'identity',
62
- })
63
- .type(mime)
64
- .send(stream)
65
- : stream;
66
- });
67
- }
68
-
69
- export default plugin;
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import config from '../../config.js';
4
+
5
+ const { disableAuth } = config;
6
+ const isProduction = process.env.NODE_ENV === 'production';
7
+
8
+ async function plugin(fastify) {
9
+ // vite server
10
+ if (!isProduction) {
11
+ const vite = await import('vite');
12
+
13
+ const viteServer = await vite.createServer({
14
+ server: {
15
+ middlewareMode: true,
16
+ },
17
+ });
18
+ // hot reload
19
+ viteServer.watcher.on('all', (d, t) => {
20
+ if (!t.includes('module') && !t.includes('templates')) return;
21
+ // console.log(d, t);
22
+ viteServer.ws.send({ type: 'full-reload' });
23
+ });
24
+
25
+ // this is middleware for vite's dev servert
26
+ fastify.addHook('onRequest', async (req, reply) => {
27
+ // const { user } = req.session?.passport || {};
28
+ const next = () => new Promise((resolve) => {
29
+ viteServer.middlewares(req.raw, reply.raw, () => resolve());
30
+ });
31
+ await next();
32
+ });
33
+ fastify.get('*', async () => {});
34
+ return;
35
+ }
36
+
37
+ // From Build
38
+ fastify.get('*', async (req, reply) => {
39
+ // console.log(disableAuth)
40
+ if (!req.user && !disableAuth) return reply.redirect('/login');
41
+ const stream = fs.createReadStream('dist/index.html');
42
+ return reply
43
+ .headers({ 'Cache-Control': 'public, no-cache' })
44
+ .type('text/html')
45
+ .send(stream);
46
+ });
47
+ fastify.get('/assets/:file', async (req, reply) => {
48
+ const stream = fs.createReadStream(`dist/assets/${req.params.file}`);
49
+ const ext = path.extname(req.params.file);
50
+ const mime = {
51
+ '.js': 'text/javascript',
52
+ '.css': 'text/css',
53
+ '.woff2': 'application/font-woff',
54
+ '.png': 'image/png',
55
+ }[ext];
56
+ // reply.cacheControl('max-age', '1d');
57
+ return mime
58
+ ? reply
59
+ .headers({
60
+ 'Cache-Control': 'public, max-age=3600',
61
+ 'Content-Encoding': 'identity',
62
+ })
63
+ .type(mime)
64
+ .send(stream)
65
+ : stream;
66
+ });
67
+ }
68
+
69
+ export default plugin;
@@ -19,7 +19,15 @@ export default async function data({
19
19
  })
20
20
  ) : [];
21
21
 
22
- const { rows = [] } = type === 'db' ? await pg.query(q) : {};
22
+ const { rows = [] } = ['db', 'viewer'].includes(type) ? await pg.query(q) : {};
23
+
24
+ if (type === 'viewer') {
25
+ return {
26
+ time: Date.now() - time,
27
+ db: pg.options?.database,
28
+ rows: rows.filter(el => el.table_name && !el.table_name.startsWith('demo.')),
29
+ };
30
+ }
23
31
 
24
32
  const list = dir.concat(rows);
25
33
 
@@ -1,11 +1,11 @@
1
- import yaml from 'js-yaml';
2
-
3
- yaml.loadSafe = (yml) => {
4
- try {
5
- return yaml.load(yml);
6
- } catch (err) {
7
- return { error: err.toString() };
8
- }
9
- };
10
-
11
- export default yaml;
1
+ import yaml from 'js-yaml';
2
+
3
+ yaml.loadSafe = (yml) => {
4
+ try {
5
+ return yaml.load(yml);
6
+ } catch (err) {
7
+ return { error: err.toString() };
8
+ }
9
+ };
10
+
11
+ export default yaml;
@@ -7,6 +7,7 @@ import {
7
7
  getSelectVal,
8
8
  getFilterSQL,
9
9
  getMeta,
10
+ logger,
10
11
  } from '@opengis/fastify-table/utils.js';
11
12
 
12
13
  import chartSQL from './util/chartSQL.js';
@@ -141,7 +142,10 @@ export default async function dataAPI(req, reply) {
141
142
 
142
143
  if (config.trace) console.log(sql, user?.uid);
143
144
 
144
- const { rows, fields } = await pg.query(sql.replace('{{uid}}', user?.uid)); // test with limit
145
+ const { rows = [], fields = [], errorSql } = await pg.query(sql.replace('{{uid}}', user?.uid)).catch(err => {
146
+ logger.file('bi/data', { error: err.toString(), sql });
147
+ return { errorSql: err.toString() };
148
+ }); // test with limit
145
149
 
146
150
  if (cls) {
147
151
  const values = rows
@@ -167,7 +171,7 @@ export default async function dataAPI(req, reply) {
167
171
 
168
172
  const res = {
169
173
  time: Date.now() - time,
170
- error,
174
+ error: errorSql || (!widgetData.sql ? widgetData.error : undefined),
171
175
  dimensions,
172
176
  filter: xName,
173
177
  dimensionsType: [xType, yType].filter((el) => el)?.length