@opengis/admin 0.1.62 → 0.1.64
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{add-page-CFNh7Zxz.js → add-page-LONm322L.js} +1 -1
- package/dist/{admin-interface-CniNlJEa.js → admin-interface-eocB4uF3.js} +44 -44
- package/dist/admin-view-CEePX3t5.js +640 -0
- package/dist/admin.js +1 -1
- package/dist/admin.umd.cjs +110 -308
- package/dist/{card-page-B16E7Q7m.js → card-page-CnQufGpK.js} +10 -10
- package/dist/{card-view-Fw8T0Ddm.js → card-view-MKU1ijjK.js} +1 -1
- package/dist/{edit-page-BCPO83LG.js → edit-page-C1wXXuPF.js} +1 -1
- package/dist/{import-file-D6JQHFSe.js → import-file-BkyTVz51.js} +14 -16
- package/package.json +1 -1
- package/server/plugins/hook.js +72 -29
- package/server/routes/data/controllers/tableData.js +2 -2
- package/server/routes/templates/controllers/getTemplate.js +5 -3
- package/dist/admin-view-Dw9tWMxP.js +0 -41685
@@ -1,5 +1,5 @@
|
|
1
|
-
import {
|
2
|
-
import { computed as q, resolveComponent as $, openBlock as s, createElementBlock as a, createElementVNode as p, toDisplayString as
|
1
|
+
import { g as L, h as R, _ as V, u as H, a as A } from "./import-file-BkyTVz51.js";
|
2
|
+
import { computed as q, resolveComponent as $, openBlock as s, createElementBlock as a, createElementVNode as p, toDisplayString as j, createVNode as z, withCtx as B, createTextVNode as N, createBlock as m, createCommentVNode as v, normalizeClass as M, Fragment as w, renderList as D, resolveDynamicComponent as T } from "vue";
|
3
3
|
const E = { class: "h-[76px] bg-white border rounded-xl flex items-center justify-between px-[15px] mb-[16px]" }, S = { class: "text-lg font-semibold md:text-xl text-stone-800 dark:text-neutral-200" }, G = { class: "flex items-center gap-[6px]" }, O = {
|
4
4
|
__name: "admin-card-header",
|
5
5
|
props: {
|
@@ -28,7 +28,7 @@ const E = { class: "h-[76px] bg-white border rounded-xl flex items-center justif
|
|
28
28
|
onClick: r,
|
29
29
|
class: "text-sm h-[20px] text-blue-600 font-medium hover:border-b hover:border-b-2 hover:border-b-blue-500"
|
30
30
|
}, " До таблиці "),
|
31
|
-
p("h2", S,
|
31
|
+
p("h2", S, j(t.title), 1)
|
32
32
|
]),
|
33
33
|
p("div", G, [
|
34
34
|
z(b, {
|
@@ -153,26 +153,26 @@ function se(t, n, c, l, r, u) {
|
|
153
153
|
p("div", {
|
154
154
|
class: M(["grid gap-[20px]", u.getGridClass()])
|
155
155
|
}, [
|
156
|
-
(s(!0), a(w, null,
|
156
|
+
(s(!0), a(w, null, D((b = r.objectData) == null ? void 0 : b.panels, (o, i) => {
|
157
157
|
var C;
|
158
158
|
return s(), a("div", {
|
159
159
|
key: i,
|
160
160
|
class: M(u.getColClass(o.col))
|
161
161
|
}, [
|
162
162
|
o != null && o.name ? (s(), a("div", P, [
|
163
|
-
p("h2", J,
|
163
|
+
p("h2", J, j((o == null ? void 0 : o.title) || "Панель"), 1),
|
164
164
|
p("div", {
|
165
165
|
class: "p-[20px] border-t",
|
166
166
|
innerHTML: (C = r.objectData) == null ? void 0 : C.data[o == null ? void 0 : o.name]
|
167
167
|
}, null, 8, K)
|
168
168
|
])) : o.type === "container" ? (s(), a("div", Q, [
|
169
|
-
(s(!0), a(w, null,
|
169
|
+
(s(!0), a(w, null, D(o.items, (e, k) => {
|
170
170
|
var _, x, g, f, y;
|
171
171
|
return s(), a("div", {
|
172
172
|
key: k,
|
173
173
|
class: "border rounded-xl bg-white mb-[20px]"
|
174
174
|
}, [
|
175
|
-
p("h2", U,
|
175
|
+
p("h2", U, j((e == null ? void 0 : e.title) || "Панель"), 1),
|
176
176
|
e != null && e.component ? (s(), a("div", W, [
|
177
177
|
(s(), m(T(e.component), {
|
178
178
|
geometry: (x = (_ = r.objectData) == null ? void 0 : _.rows[0]) == null ? void 0 : x.geom,
|
@@ -190,16 +190,16 @@ function se(t, n, c, l, r, u) {
|
|
190
190
|
])) : v("", !0),
|
191
191
|
(o == null ? void 0 : o.type) === "tabs" ? (s(), a(w, { key: 2 }, [
|
192
192
|
p("nav", Z, [
|
193
|
-
(s(!0), a(w, null,
|
193
|
+
(s(!0), a(w, null, D(o == null ? void 0 : o.items, (e) => (s(), a("button", {
|
194
194
|
key: (e == null ? void 0 : e.name) || (e == null ? void 0 : e.component),
|
195
195
|
onClick: (k) => r.component = (e == null ? void 0 : e.component) || (e == null ? void 0 : e.name),
|
196
196
|
class: M(["px-2.5 h-[30px] py-1.5 relative inline-flex items-center gap-x-2 text-gray-500 hover:bg-gray-100 focus:bg-gray-100 hover:text-gray-800 text-sm whitespace-nowrap rounded-lg focus:outline-none", {
|
197
197
|
" font-semibold after:absolute after:bottom-[-14px] after:left-2.5 after:right-2.5 after:z-10 after:h-0.5 after:bg-gray-800": r.component === (e == null ? void 0 : e.component) || r.component === (e == null ? void 0 : e.name),
|
198
198
|
"": r.component !== (e == null ? void 0 : e.component) && r.component !== (e == null ? void 0 : e.name)
|
199
199
|
}])
|
200
|
-
},
|
200
|
+
}, j(e == null ? void 0 : e.title), 11, ee))), 128))
|
201
201
|
]),
|
202
|
-
(s(!0), a(w, null,
|
202
|
+
(s(!0), a(w, null, D(o.items, (e, k) => {
|
203
203
|
var _, x, g, f, y;
|
204
204
|
return s(), a(w, { key: k }, [
|
205
205
|
r.component === (e == null ? void 0 : e.component) || r.component === (e == null ? void 0 : e.name) ? (s(), a("div", te, [
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { _ as b, u as h, a as c } from "./import-file-
|
1
|
+
import { _ as b, u as h, a as c } from "./import-file-BkyTVz51.js";
|
2
2
|
import { resolveComponent as d, openBlock as m, createElementBlock as p, createElementVNode as l, createBlock as f, createCommentVNode as g } from "vue";
|
3
3
|
const x = {
|
4
4
|
data() {
|
@@ -3590,17 +3590,17 @@ function eq(t) {
|
|
3590
3590
|
}
|
3591
3591
|
const jI = [
|
3592
3592
|
// { name: 'profile', path: '/profile', component: () => import('../components/profile/vs-profile.vue') },
|
3593
|
-
{ name: "edit", path: "/edit", component: () => import("./edit-page-
|
3594
|
-
{ name: "add", path: "/add", component: () => import("./add-page-
|
3593
|
+
{ name: "edit", path: "/edit", component: () => import("./edit-page-C1wXXuPF.js") },
|
3594
|
+
{ name: "add", path: "/add", component: () => import("./add-page-LONm322L.js") },
|
3595
3595
|
{
|
3596
3596
|
name: "card-view",
|
3597
3597
|
path: "/card",
|
3598
|
-
component: () => import("./card-view-
|
3598
|
+
component: () => import("./card-view-MKU1ijjK.js"),
|
3599
3599
|
children: [{
|
3600
3600
|
name: "table",
|
3601
3601
|
path: ":table",
|
3602
|
-
component: () => import("./card-view-
|
3603
|
-
children: [{ name: "card", path: ":id", component: () => import("./card-page-
|
3602
|
+
component: () => import("./card-view-MKU1ijjK.js"),
|
3603
|
+
children: [{ name: "card", path: ":id", component: () => import("./card-page-CnQufGpK.js") }]
|
3604
3604
|
}]
|
3605
3605
|
}
|
3606
3606
|
], UI = {}, HI = { class: "bg-gray-200 w-full px-16 md:px-0 h-screen flex items-center justify-center" }, qI = { class: "bg-white border border-gray-200 flex flex-col items-center justify-center px-4 md:px-8 lg:px-24 py-8 rounded-lg shadow-2xl" };
|
@@ -3648,14 +3648,14 @@ const GI = /* @__PURE__ */ Rt(UI, [["render", WI]]), ZI = (t) => {
|
|
3648
3648
|
{
|
3649
3649
|
path: "/",
|
3650
3650
|
name: "home",
|
3651
|
-
component: () => import("./admin-view-
|
3651
|
+
component: () => import("./admin-view-CEePX3t5.js"),
|
3652
3652
|
children: [
|
3653
3653
|
...e,
|
3654
3654
|
...t,
|
3655
3655
|
// { path: '/', redirect: '/home' },
|
3656
3656
|
{
|
3657
3657
|
path: "/:catchAll(.*)",
|
3658
|
-
component: () => import("./admin-interface-
|
3658
|
+
component: () => import("./admin-interface-eocB4uF3.js")
|
3659
3659
|
}
|
3660
3660
|
]
|
3661
3661
|
}
|
@@ -47510,14 +47510,12 @@ export {
|
|
47510
47510
|
Rt as _,
|
47511
47511
|
Bt as a,
|
47512
47512
|
T8 as b,
|
47513
|
-
|
47514
|
-
|
47515
|
-
|
47516
|
-
|
47517
|
-
|
47518
|
-
|
47519
|
-
|
47520
|
-
eq as j,
|
47521
|
-
iq as k,
|
47513
|
+
vH as c,
|
47514
|
+
vU as d,
|
47515
|
+
PF as e,
|
47516
|
+
HB as f,
|
47517
|
+
QH as g,
|
47518
|
+
eq as h,
|
47519
|
+
iq as i,
|
47522
47520
|
YH as u
|
47523
47521
|
};
|
package/package.json
CHANGED
package/server/plugins/hook.js
CHANGED
@@ -1,30 +1,73 @@
|
|
1
|
+
import config from '../../config.js'
|
1
2
|
import { addHook, getToken, setToken, getTemplate } from '@opengis/fastify-table/utils.js';
|
2
3
|
|
4
|
+
async function getTokenData({
|
5
|
+
req, mode = 'w', token, uid,
|
6
|
+
}) {
|
7
|
+
if (!req) {
|
8
|
+
return { message: 'not enough params: req', status: 400 };
|
9
|
+
}
|
10
|
+
if (!token) {
|
11
|
+
return { message: 'not enough params: token', status: 400 };
|
12
|
+
}
|
13
|
+
|
14
|
+
if (!uid && !config?.auth?.disable) {
|
15
|
+
return { message: 'access restricted: uid', status: 403 };
|
16
|
+
}
|
17
|
+
|
18
|
+
const opt = await getToken({
|
19
|
+
uid, token, mode, json: 1,
|
20
|
+
});
|
21
|
+
|
22
|
+
if (!opt && !config?.local) {
|
23
|
+
return { message: 'access restricted: edit', status: 403 };
|
24
|
+
}
|
25
|
+
return opt;
|
26
|
+
}
|
27
|
+
|
3
28
|
export default async function plugin(fastify) {
|
4
29
|
|
5
|
-
addHook('preTable', async ({ req }) => {
|
6
|
-
|
7
|
-
|
8
|
-
const {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
30
|
+
addHook('preTable', async ({ req, table, user = {} }) => {
|
31
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user || {};
|
32
|
+
|
33
|
+
//const opt = await getTokenData({ req, mode: 'w', token: table, uid });
|
34
|
+
// return opt;
|
35
|
+
});
|
36
|
+
addHook('preData', async ({ req, table, id, user = {} }) => {
|
37
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user || {};
|
38
|
+
const opt = await getTokenData({ req, mode: 'w', token: table, uid });
|
39
|
+
return opt;
|
40
|
+
});
|
41
|
+
addHook('preForm', async ({ req, form, user }) => {
|
42
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user || {};
|
43
|
+
const opt = await getTokenData({ req, mode: 'w', token: form, uid });
|
44
|
+
return opt;
|
45
|
+
});
|
46
|
+
addHook('preInsert', async ({ req, table, user }) => {
|
47
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user || {};
|
48
|
+
const opt = await getTokenData({ req, mode: 'a', token: table, uid });
|
49
|
+
return opt;
|
50
|
+
});
|
51
|
+
addHook('preUpdate', async ({ req, table, id, user }) => {
|
52
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user || {};
|
53
|
+
const opt = await getTokenData({ req, mode: 'w', token: table, uid });
|
54
|
+
return opt;
|
55
|
+
});
|
56
|
+
addHook('preDelete', async ({ req, table, id, user }) => {
|
57
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user || {};
|
58
|
+
const opt = await getTokenData({ req, mode: 'w', token: table, uid });
|
59
|
+
return opt;
|
18
60
|
});
|
19
61
|
|
20
|
-
addHook('afterTable', async ({ req = {}, res = {}, rows = [],
|
21
|
-
const { pg
|
22
|
-
const
|
23
|
-
|
62
|
+
addHook('afterTable', async ({ req = {}, table, res = {}, rows = [], user = {} }) => {
|
63
|
+
const { pg } = req;
|
64
|
+
const loadTable = await getTemplate('table', table);
|
65
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user;
|
66
|
+
if (!uid || !table || !pg?.pk?.[table] || !rows.length || !loadTable?.table) return;
|
24
67
|
|
25
68
|
// admin.custom_column - user column data
|
26
69
|
const { rows: properties = [] } = await pg.query(`select column_id, name, title, format, data from admin.custom_column
|
27
|
-
|
70
|
+
where _table and entity=$1 and uid=$2`, [table, uid]);
|
28
71
|
const extraColumnList = properties.map((row) => ({ id: row.column_id, name: row.name, title: row.title, format: row.format, data: row.data }));
|
29
72
|
if (!extraColumnList?.length) return;
|
30
73
|
|
@@ -33,7 +76,7 @@ export default async function plugin(fastify) {
|
|
33
76
|
}
|
34
77
|
|
35
78
|
const { rows: extraData = [] } = await pg.query(`select object_id, json_object_agg( property_id, coalesce(value_date::text,value_text) ) as extra from crm.extra_data
|
36
|
-
|
79
|
+
where property_entity=$1 and property_id=any($2) and object_id=any($3) group by object_id`, [table, extraColumnList?.map((el) => el.id), rows.map((el) => el.id)]);
|
37
80
|
|
38
81
|
if (!extraData?.length) {
|
39
82
|
// Object.assign(rows?.[0] || {}, { ...extraColumnList.reduce((acc, curr) => Object.assign(acc, { [curr.name]: null }), {}) });
|
@@ -60,7 +103,7 @@ export default async function plugin(fastify) {
|
|
60
103
|
});
|
61
104
|
|
62
105
|
// extract table from form token for user columns - p.2 - read (refactor to global token)
|
63
|
-
/* addHook('preTemplate', async ({ req = {} }) => {
|
106
|
+
/* addHook('preTemplate', async ({ req = {}, name, type, user }) => {
|
64
107
|
const { funcs, params = {}, session = {} } = req;
|
65
108
|
const { uid } = funcs?.config?.auth?.disable ? { uid: '1' } : (session?.passport?.user || {});
|
66
109
|
if (!uid || params?.type !== 'form' || !params?.name) return null;
|
@@ -73,9 +116,9 @@ export default async function plugin(fastify) {
|
|
73
116
|
}
|
74
117
|
}); */
|
75
118
|
|
76
|
-
addHook('afterTemplate', async ({ req = {}, data = {} }) => {
|
77
|
-
const { funcs
|
78
|
-
const { uid } = funcs?.config?.auth?.disable ? { uid: '1' } :
|
119
|
+
addHook('afterTemplate', async ({ req = {}, data = {}, user = {} }) => {
|
120
|
+
const { funcs } = req;
|
121
|
+
const { uid } = funcs?.config?.auth?.disable ? { uid: '1' } : user;
|
79
122
|
const { pg, params = {} } = req;
|
80
123
|
// extract table from form token for user columns - p.1 - assign (refactor to global token)
|
81
124
|
/* if (params?.type === 'table') {
|
@@ -100,11 +143,11 @@ export default async function plugin(fastify) {
|
|
100
143
|
}));
|
101
144
|
});
|
102
145
|
|
103
|
-
addHook('afterUpdate', async ({ req, res = {} }) => {
|
146
|
+
addHook('afterUpdate', async ({ req, res = {}, user = {} }) => {
|
104
147
|
const {
|
105
|
-
pg,
|
148
|
+
pg, params = {}, body = {},
|
106
149
|
} = req;
|
107
|
-
const { uid } =
|
150
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user;
|
108
151
|
if (!uid) return null;
|
109
152
|
|
110
153
|
const loadTable = await getTemplate('table', params.table);
|
@@ -125,11 +168,11 @@ export default async function plugin(fastify) {
|
|
125
168
|
return pg.query(q);
|
126
169
|
});
|
127
170
|
|
128
|
-
addHook('afterInsert', async ({ req, res = {} }) => {
|
171
|
+
addHook('afterInsert', async ({ req, res = {}, user = {} }) => {
|
129
172
|
const {
|
130
|
-
pg,
|
173
|
+
pg, params = {}, body = {},
|
131
174
|
} = req;
|
132
|
-
const { uid } =
|
175
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user;
|
133
176
|
if (!uid) return null;
|
134
177
|
|
135
178
|
const loadTable = await getTemplate('table', params.table);
|
@@ -14,7 +14,7 @@ export default async function getTableData(req) {
|
|
14
14
|
const time = Date.now();
|
15
15
|
|
16
16
|
const {
|
17
|
-
pg, params, funcs = {}, query = {}, opt = {}, session = {},
|
17
|
+
pg, params, funcs = {}, query = {}, opt = {}, session = {},
|
18
18
|
} = req;
|
19
19
|
const { uid } = session.passport?.user || {};
|
20
20
|
|
@@ -99,7 +99,7 @@ export default async function getTableData(req) {
|
|
99
99
|
time: Date.now() - time, card: loadTable.card, actions: loadTable.actions, access, total, count: rows.length, pk, form, meta, columns,
|
100
100
|
};
|
101
101
|
|
102
|
-
await applyHook('afterTable', { req,
|
102
|
+
await applyHook('afterTable', { req, table: params?.table, res, rows, user: session?.passport?.user });
|
103
103
|
await metaFormat({ funcs, rows, table: params.table });
|
104
104
|
|
105
105
|
|
@@ -1,10 +1,12 @@
|
|
1
1
|
import { applyHook, getTemplate } from "@opengis/fastify-table/utils.js";
|
2
2
|
|
3
3
|
export default async function getTemplateApi(req) {
|
4
|
-
const
|
4
|
+
const { user } = req?.session?.passport || {};
|
5
|
+
const { funcs, params = {}, session = {} } = req;
|
6
|
+
const res = await applyHook('preTemplate', { req, name: params?.name, type: params?.type, user });
|
5
7
|
if (res) return res;
|
6
8
|
|
7
|
-
|
9
|
+
|
8
10
|
const { type, name } = params;
|
9
11
|
|
10
12
|
const data = await getTemplate(type, name);
|
@@ -16,6 +18,6 @@ export default async function getTemplateApi(req) {
|
|
16
18
|
) {
|
17
19
|
return `access restricted ${name}`;
|
18
20
|
}
|
19
|
-
await applyHook('afterTemplate', { req, data })
|
21
|
+
await applyHook('afterTemplate', { req, data, user })
|
20
22
|
return data?.html || data || `template not found "${name}"`;
|
21
23
|
}
|