@opengis/bi 1.0.23 → 1.0.24

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 (40) hide show
  1. package/dist/bi.js +1 -1
  2. package/dist/bi.umd.cjs +80 -80
  3. package/dist/{import-file-DgBd_UN1.js → import-file-ChpPHgUN.js} +9675 -9246
  4. package/dist/{map-component-mixin-NewmNy_M.js → map-component-mixin-C0Z88c8b.js} +36 -37
  5. package/dist/{vs-calendar-CPXj4hBh.js → vs-calendar-B4_gYR3Q.js} +1 -1
  6. package/dist/{vs-donut-CUmi2ir5.js → vs-donut-BF1K_2LP.js} +40 -38
  7. package/dist/{vs-funnel-bar-B3DpbtUl.js → vs-funnel-bar-Ba0HB6U8.js} +22 -11
  8. package/dist/{vs-heatmap-COwT3bHE.js → vs-heatmap-Bzwa1rgF.js} +1 -1
  9. package/dist/{vs-map-DwyQHLpN.js → vs-map-T9bTjwSG.js} +2 -2
  10. package/dist/{vs-map-cluster-CnZ9g6k-.js → vs-map-cluster-CQik8xir.js} +2 -2
  11. package/dist/{vs-number-LwROg9Oe.js → vs-number-DhACUDku.js} +1 -1
  12. package/dist/vs-table-Df4lMM4d.js +71 -0
  13. package/dist/{vs-text-DgAf3Ids.js → vs-text-D9iYudVA.js} +33 -28
  14. package/package.json +8 -7
  15. package/server/migrations/bi.dataset.sql +1 -0
  16. package/server/migrations/bi.sql +10 -0
  17. package/server/plugins/hook.js +1 -1
  18. package/server/routes/dashboard/controllers/dashboard.import.js +91 -0
  19. package/server/routes/dashboard/controllers/dashboard.js +10 -2
  20. package/server/routes/dashboard/controllers/dashboard.list.js +7 -9
  21. package/server/routes/dashboard/index.mjs +7 -9
  22. package/server/routes/data/controllers/data.js +2 -2
  23. package/server/routes/data/index.mjs +3 -1
  24. package/server/routes/dataset/controllers/bi.dataset.list.js +1 -1
  25. package/server/routes/dataset/controllers/data.js +10 -6
  26. package/server/routes/dataset/controllers/deleteDataset.js +51 -0
  27. package/server/routes/dataset/controllers/editDataset.js +1 -1
  28. package/server/routes/dataset/controllers/table.js +58 -59
  29. package/server/routes/dataset/index.mjs +25 -13
  30. package/server/routes/edit/controllers/dashboard.add.js +21 -22
  31. package/server/routes/edit/controllers/dashboard.delete.js +36 -0
  32. package/server/routes/edit/controllers/dashboard.edit.js +52 -39
  33. package/server/routes/edit/controllers/widget.add.js +46 -55
  34. package/server/routes/edit/controllers/widget.del.js +36 -49
  35. package/server/routes/edit/controllers/widget.edit.js +5 -9
  36. package/server/routes/edit/index.mjs +4 -5
  37. package/server/routes/map/index.mjs +8 -6
  38. package/server/utils/getWidget.js +3 -3
  39. package/dist/vs-table-Dt_MSaCC.js +0 -68
  40. package/server/routes/dashboard/controllers/dashboard.delete.js +0 -38
@@ -6,8 +6,7 @@ export default async function widgetEdit({ pg, body, params, }) {
6
6
  const { widget: widgetName, name: dashboardName } = params;
7
7
  const data = body.yml && !body.style ? yamlSafe.load(body.yml) : body;
8
8
  const yml = body.yml ?? yamlSafe.dump(body.data);
9
- console.log(body.data, data, body.yml, yml);
10
-
9
+ // console.log(body.data, data, body.yml, yml);
11
10
 
12
11
  if (!widgetName || !dashboardName) {
13
12
  return {
@@ -27,7 +26,9 @@ export default async function widgetEdit({ pg, body, params, }) {
27
26
  return { message: `widget not found ${widgetName}`, status: 404 };
28
27
  }
29
28
 
30
- const widgetData = ['style', 'data', 'type', 'title', 'controls'].filter(el => data[el]).reduce((p, el) => ({ ...p, [el]: data[el] }), {});
29
+ const widgetData = ['style', 'data', 'type', 'title', 'controls']
30
+ .filter(el => data[el])
31
+ .reduce((p, el) => ({ ...p, [el]: data[el] }), {});
31
32
 
32
33
  //console.log(templateData)
33
34
  // get table
@@ -65,10 +66,5 @@ export default async function widgetEdit({ pg, body, params, }) {
65
66
  data: { widgets },
66
67
  });
67
68
 
68
- return {
69
- message: rows,
70
- status: 200,
71
-
72
- };
73
-
69
+ return { message: rows, status: 200 };
74
70
  }
@@ -4,6 +4,7 @@ import widgetEdit from './controllers/widget.edit.js';
4
4
  import widgetDel from './controllers/widget.del.js';
5
5
  import dashboardEdit from './controllers/dashboard.edit.js';
6
6
  import dashboardAdd from './controllers/dashboard.add.js';
7
+ import dashboardDelete from './controllers/dashboard.delete.js';
7
8
 
8
9
  const biSchema = {
9
10
  querystring: {
@@ -21,11 +22,9 @@ const biSchema = {
21
22
  export default async function route(fastify) {
22
23
  fastify.post(`/bi-dashboard/:name`, { schema: biSchema }, widgetAdd);
23
24
  fastify.put(`/bi-dashboard/:name/:widget`, { schema: biSchema }, widgetEdit);
24
- fastify.delete(
25
- `/bi-dashboard/:name/:widget`,
26
- { schema: biSchema },
27
- widgetDel
28
- );
25
+ fastify.delete(`/bi-dashboard/:name/:widget`, { schema: biSchema }, widgetDel);
26
+
29
27
  fastify.post(`/bi-dashboard`, { schema: biSchema }, dashboardAdd);
30
28
  fastify.put(`/bi-dashboard/:name`, { schema: biSchema }, dashboardEdit);
29
+ fastify.delete(`/bi-dashboard/:id`, {}, dashboardDelete);
31
30
  }
@@ -17,11 +17,13 @@ const biSchema = {
17
17
  },
18
18
  };
19
19
 
20
+ const policy = ['public'];
21
+
20
22
  export default async function route(fastify, opts) {
21
- fastify.get('/bi-map', { schema: biSchema }, map);
22
- fastify.get('/bi-geojson', { schema: biSchema }, geojson);
23
- fastify.get('/bi-vtile/:z/:y/:x', { schema: biSchema }, vtile);
24
- fastify.get('/bi-cluster', { schema: biSchema }, cluster);
25
- fastify.get('/bi-cluster-vtile/:z/:y/:x', { schema: biSchema }, clusterVtile);
26
- fastify.get('/bi-heatmap', {}, heatmap);
23
+ fastify.get('/bi-map', { config: { policy }, schema: biSchema }, map);
24
+ fastify.get('/bi-geojson', { config: { policy }, schema: biSchema }, geojson);
25
+ fastify.get('/bi-vtile/:z/:y/:x', { config: { policy }, schema: biSchema }, vtile);
26
+ fastify.get('/bi-cluster', { config: { policy }, schema: biSchema }, cluster);
27
+ fastify.get('/bi-cluster-vtile/:z/:y/:x', { config: { policy }, schema: biSchema }, clusterVtile);
28
+ fastify.get('/bi-heatmap', { config: { policy } }, heatmap);
27
29
  }
@@ -20,7 +20,7 @@ async function getWidget({ dashboard, widget }) {
20
20
  `select dashboard_id as id, table_name as "tableName" from bi.dashboard where $1 in (dashboard_id, name)`,
21
21
  [dashboard]
22
22
  )
23
- .then((res1) => res1.rows?.[0] || {})
23
+ .then(el => el.rows?.[0] || {})
24
24
  : {};
25
25
 
26
26
  if (!dashboardData && dashboard && !id) {
@@ -42,7 +42,7 @@ async function getWidget({ dashboard, widget }) {
42
42
  return { message: `not found ${widget} ${dashboard}`, status: 404 };
43
43
  }
44
44
 
45
- const q = `select *, coalesce(data::jsonb, '{}'::jsonb) || jsonb_build_object('table', table_name) as data from bi.widget where dashboard_id=$1 and name=$2`;
45
+ const q = `select *, title as text, coalesce(data::jsonb, '{}'::jsonb) || jsonb_build_object('table', table_name) as data from bi.widget where dashboard_id=$1 and name=$2`;
46
46
 
47
47
  const {
48
48
  type,
@@ -55,7 +55,7 @@ async function getWidget({ dashboard, widget }) {
55
55
  } = widgetData ||
56
56
  (await pg
57
57
  .query(q, [id || dashboard, widget])
58
- .then((res1) => res1.rows?.[0] || {}));
58
+ .then(el => el.rows?.[0] || {}));
59
59
 
60
60
  if (!type) {
61
61
  return { message: `widget not found: ${widget}`, status: 404 };
@@ -1,68 +0,0 @@
1
- import { _ as p, c as h, d as m, a as f } from "./import-file-DgBd_UN1.js";
2
- import { openBlock as a, createElementBlock as r, createElementVNode as s, Fragment as n, renderList as c, toDisplayString as d } from "vue";
3
- const _ = {
4
- name: "VsTable",
5
- mixins: [h],
6
- data() {
7
- return {
8
- values: null,
9
- xs: null,
10
- products: null
11
- };
12
- },
13
- async mounted() {
14
- await this.getData(), this.prepareData();
15
- },
16
- methods: {
17
- onChangedData() {
18
- try {
19
- this.sourceData && this.prepareData();
20
- } catch {
21
- }
22
- },
23
- prepareData() {
24
- try {
25
- const t = Array.from(
26
- new Set(this.sourceData.map((e) => e[this.dimensions[0]]))
27
- );
28
- this.dimensions[0].includes("date") ? this.xs = t.map((e) => m(e)) : this.xs = [...t], this.products = this.dimensions.filter((e, o) => o != 0), this.values = this.products.map((e, o) => ({
29
- name: e,
30
- data: this.sourceData.filter((l) => parseFloat(l[e])).map((l) => f(parseFloat(l[e])))
31
- }));
32
- } catch (t) {
33
- console.error(t);
34
- }
35
- }
36
- }
37
- }, x = { class: "flex flex-col h-full pt-[16px] pb-[16px] space-y-4 rounded-xl custom-scrollbar" }, b = { class: "overflow-x-auto [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 custom-scrollbar" }, y = { class: "inline-block min-w-full align-middle" }, g = { class: "relative min-w-full divide-y divide-gray-200" }, v = { class: "sticky top-0 bg-white w-full after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200" }, w = { class: "space-x-2" }, k = {
38
- scope: "col",
39
- class: "xl:min-w-[120px] min-w-48"
40
- }, D = { class: "flex items-center px-1 py-3 font-medium text-gray-800 text-start gap-x-1 dark:text-neutral-200" }, $ = { class: "divide-y divide-gray-200" }, F = { class: "py-3 size-px whitespace-nowrap" }, T = { class: "text-sm text-gray-600" };
41
- function B(t, e, o, l, E, N) {
42
- return a(), r("div", x, [
43
- s("div", b, [
44
- s("div", y, [
45
- s("table", g, [
46
- s("thead", v, [
47
- s("tr", w, [
48
- (a(!0), r(n, null, c(t.dimensions, (i) => (a(), r("th", k, [
49
- s("div", D, d(i), 1)
50
- ]))), 256))
51
- ])
52
- ]),
53
- (a(!0), r(n, null, c(t.sourceData, (i) => (a(), r("tbody", $, [
54
- s("tr", null, [
55
- (a(!0), r(n, null, c(t.dimensions, (u, S) => (a(), r("td", F, [
56
- s("span", T, d(i == null ? void 0 : i[u]), 1)
57
- ]))), 256))
58
- ])
59
- ]))), 256))
60
- ])
61
- ])
62
- ])
63
- ]);
64
- }
65
- const A = /* @__PURE__ */ p(_, [["render", B]]);
66
- export {
67
- A as default
68
- };
@@ -1,38 +0,0 @@
1
- import { existsSync, readdirSync } from 'fs';
2
- import path from 'path';
3
-
4
- import { pgClients } from '@opengis/fastify-table/utils.js';
5
-
6
- const cwd = process.cwd();
7
- const dashboardDir = path.join(cwd, 'server/templates/dashboard');
8
-
9
- export default async function data({ pg = pgClients.client, params = {} }) {
10
- const { id } = params;
11
-
12
- if (!id) {
13
- return { message: 'not enough params: id', status: 400 };
14
- }
15
-
16
- const dirContent = existsSync(dashboardDir) ? readdirSync(dashboardDir) : [];
17
-
18
- if (dirContent.includes(id)) {
19
- return { message: `access restricted: ${id}`, status: 403 };
20
- }
21
- try {
22
- const { rowCount } = await pg.query(
23
- `select * from bi.dashboard where $1 in (dashboard_id,name)`,
24
- [id]
25
- );
26
-
27
- if (rowCount === 0) {
28
- return { message: `not found ${id}`, status: 404 };
29
- }
30
- await pg.query(`delete from bi.widget where $1 in (dashboard_id)`, [id]);
31
- await pg.query(`delete from bi.dashboard where $1 in (dashboard_id,name)`, [
32
- id,
33
- ]);
34
- return { message: 'successfully deleted', status: 200 };
35
- } catch (err) {
36
- return { error: err.toString(), status: 500 };
37
- }
38
- }