@opengis/bi 1.0.47 → 1.0.49

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.
@@ -1,8 +1,8 @@
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";
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-BsSJxqJM.js";
2
+ import { _ as C, c as P } from "./import-file-0V4hdOl6.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";
4
4
  const A = {
5
- components: { legendIcon: $, closeIcon: L },
5
+ components: { legendIcon: L, closeIcon: $ },
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: F,
136
- VsMapSlotLayers: O,
135
+ VsMapSetting: B,
136
+ VsMapSlotLayers: H,
137
137
  VsMapLegend: te,
138
- VsMapGoHome: H,
139
- VsList: B
138
+ VsMapGoHome: O,
139
+ VsList: F
140
140
  },
141
141
  data() {
142
142
  return {
@@ -1,8 +1,8 @@
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";
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-BsSJxqJM.js";
2
+ import { _ as V, c as W, V as J, I as Q, e as U, g as X } from "./import-file-0V4hdOl6.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";
4
4
  const $ = {
5
- components: { legendIcon: A, closeIcon: G },
5
+ components: { legendIcon: G, closeIcon: A },
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: [J, K],
103
+ mixins: [W, P],
104
104
  components: {
105
- VsMapSetting: D,
105
+ VsMapSetting: Z,
106
106
  VsClusterLegend: ae,
107
107
  VsMapGoHome: q,
108
- VsList: Z,
109
- VsMapSlotLayers: P,
108
+ VsList: D,
109
+ VsMapSlotLayers: K,
110
110
  // VsListbar,
111
- VsBar: W
111
+ VsBar: J
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: U },
120
- { id: "chart", text: "Віджет", component: X }
119
+ { id: "table", text: "Таблиця", component: Q },
120
+ { id: "chart", text: "Віджет", component: U }
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 Q.get(
145
+ const t = await X.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(), M(j(r == null ? void 0 : r.component), {
251
+ (p(), z(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
- z(l("div", {
258
+ M(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(), M(d, {
266
+ e.showSetting ? (p(), z(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
- z(w(u, {
289
+ M(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
- z(l("div", ve, [
299
- (E = (L = e.data) == null ? void 0 : L.rows) != null && E.length ? (p(), M(_, {
298
+ M(l("div", ve, [
299
+ (E = (L = e.data) == null ? void 0 : L.rows) != null && E.length ? (p(), z(_, {
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-XFI3CaVb.js";
2
- import { createElementBlock as i, openBlock as m, toDisplayString as s } from "vue";
1
+ import { _ as c, c as o, f as n } from "./import-file-0V4hdOl6.js";
2
+ import { openBlock as i, createElementBlock 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 m(), i("div", h, s(a.prefix) + s(a.formattedNumber), 1);
50
+ return i(), m("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-XFI3CaVb.js";
2
- import { createElementBlock as a, openBlock 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-0V4hdOl6.js";
2
+ import { openBlock as a, createElementBlock 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 r(), a("div", y, [
42
+ return a(), r("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
- (r(!0), a(n, null, c(t.dimensions, (i) => (r(), a("th", $, [
48
+ (a(!0), r(n, null, c(t.dimensions, (i) => (a(), r("th", $, [
49
49
  s("div", F, d(i), 1)
50
50
  ]))), 256))
51
51
  ])
52
52
  ]),
53
53
  s("tbody", T, [
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", {
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", {
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-XFI3CaVb.js";
2
- import { createElementBlock as r, openBlock as n, createCommentVNode as a } from "vue";
1
+ import { _ as o, c as s, m as i } from "./import-file-0V4hdOl6.js";
2
+ import { openBlock as r, createElementBlock 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 n(), r("div", {
27
+ return r(), n("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 ? (n(), r("div", {
31
+ e.markedText ? (r(), n("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.47",
3
+ "version": "1.0.49",
4
4
  "description": "BI data visualization module",
5
5
  "main": "dist/bi.js",
6
6
  "browser": "dist/bi.umd.cjs",
@@ -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;
@@ -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;
@@ -4,6 +4,7 @@ import {
4
4
  config,
5
5
  autoIndex,
6
6
  pgClients,
7
+ getSelect,
7
8
  getSelectVal,
8
9
  getFilterSQL,
9
10
  getMeta,
@@ -43,7 +44,7 @@ export default async function dataAPI(req, reply) {
43
44
  }));
44
45
 
45
46
  // data param
46
- const { x, cls, metric, table, where, tableSQL, groupby, xName, yName, xType, yType, error } =
47
+ const { x, cls, groupbyCls, metric, table, where, tableSQL, groupby, xName, yName, xType, yType, error } =
47
48
  normalizeData(widgetData, query, columnTypes);
48
49
 
49
50
  if (error) { return reply.status(400).send(error); }
@@ -106,7 +107,7 @@ export default async function dataAPI(req, reply) {
106
107
  }
107
108
 
108
109
  const sql = widgetData.sql ? optimizedSQL : (chartSQL[type] || chartSQL.chart)({
109
- where,
110
+ where: config.local && user?.user_type === 'superadmin' ? 'true' : where, // test
110
111
  metric,
111
112
  yType, // metric type
112
113
  columns: widgetData.columns,
@@ -147,6 +148,21 @@ export default async function dataAPI(req, reply) {
147
148
  return { errorSql: err.toString() };
148
149
  }); // test with limit
149
150
 
151
+ if (groupbyCls) {
152
+ const { arr = [] } = await getSelect(groupbyCls, pg) || {};
153
+ if (arr.length) {
154
+ const ids = arr.map(el => el.id);
155
+ const text = arr.reduce((acc, curr) => ({ ...acc, [curr.id]: curr.text }), {});
156
+ rows.forEach(row => {
157
+ ids.reduce((acc, curr) => {
158
+ Object.assign(row, { [text[curr]]: row[curr] });
159
+ delete row[curr];
160
+ return acc;
161
+ }, {});
162
+ });
163
+ }
164
+ }
165
+
150
166
  if (cls) {
151
167
  const values = rows
152
168
  .map((row) => row[x])
@@ -45,7 +45,7 @@ function normalizeData(data, query = {}, columnTypes = []) {
45
45
  const yName = metrics?.[0]?.name || metrics?.[0];
46
46
  const yType = columnTypes.find((el) => el.name == yName)?.type;
47
47
 
48
- const { cls, table, filterCustom } = data;
48
+ const { cls, groupbyCls, table, filterCustom } = data;
49
49
  const groupby = (query.groupby || data.groupby) === 'null' ? null : (query.groupby || data.groupby);
50
50
  // const orderby = query.orderby || data.orderby || 'count(*)';
51
51
 
@@ -60,6 +60,6 @@ function normalizeData(data, query = {}, columnTypes = []) {
60
60
  ? `(select * from ${data?.table} t ${data.tableSQL || ''} where ${where})q`
61
61
  : undefined;
62
62
 
63
- return { x, cls, metric, table, where, tableSQL, groupby, xName, xType, yName, yType, error: skip.length ? skip.join(',') : undefined };
63
+ return { x, cls, groupbyCls, metric, table, where, tableSQL, groupby, xName, xType, yName, yType, error: skip.length ? skip.join(',') : undefined };
64
64
  }
65
65
  export default normalizeData;