@opengis/admin 0.1.62 → 0.1.63
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 +71 -30
- package/server/routes/data/controllers/tableData.js +2 -2
- package/server/routes/templates/controllers/getTemplate.js +3 -2
- 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,71 @@
|
|
1
|
-
import { addHook, getToken, setToken, getTemplate } from '@opengis/fastify-table/utils.js';
|
1
|
+
import { addHook, getToken, setToken, getTemplate, config } from '@opengis/fastify-table/utils.js';
|
2
|
+
|
3
|
+
async function getTokenData({
|
4
|
+
req, mode = 'w', token, uid,
|
5
|
+
}) {
|
6
|
+
if (!req) {
|
7
|
+
return { message: 'not enough params: req', status: 400 };
|
8
|
+
}
|
9
|
+
if (!token) {
|
10
|
+
return { message: 'not enough params: token', status: 400 };
|
11
|
+
}
|
12
|
+
|
13
|
+
if (!uid && !config?.auth?.disable) {
|
14
|
+
return { message: 'access restricted: uid', status: 403 };
|
15
|
+
}
|
16
|
+
|
17
|
+
const opt = await getToken({
|
18
|
+
uid, token, mode, json: 1,
|
19
|
+
});
|
20
|
+
|
21
|
+
if (!opt && !config?.local) {
|
22
|
+
return { message: 'access restricted: edit', status: 403 };
|
23
|
+
}
|
24
|
+
return opt;
|
25
|
+
}
|
2
26
|
|
3
27
|
export default async function plugin(fastify) {
|
4
28
|
|
5
|
-
addHook('preTable', async ({ req }) => {
|
6
|
-
|
7
|
-
const
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
});
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
}
|
17
|
-
|
29
|
+
addHook('preTable', async ({ req, table, user = {} }) => {
|
30
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user || {};
|
31
|
+
const opt = await getTokenData({ req, mode: 'w', token: table, uid });
|
32
|
+
return opt;
|
33
|
+
});
|
34
|
+
addHook('preData', async ({ req, table, id, user = {} }) => {
|
35
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user || {};
|
36
|
+
const opt = await getTokenData({ req, mode: 'w', token: table, uid });
|
37
|
+
return opt;
|
38
|
+
});
|
39
|
+
addHook('preForm', async ({ req, form, user }) => {
|
40
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user || {};
|
41
|
+
const opt = await getTokenData({ req, mode: 'w', token: form, uid });
|
42
|
+
return opt;
|
43
|
+
});
|
44
|
+
addHook('preInsert', async ({ req, table, user }) => {
|
45
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user || {};
|
46
|
+
const opt = await getTokenData({ req, mode: 'a', token: table, uid });
|
47
|
+
return opt;
|
48
|
+
});
|
49
|
+
addHook('preUpdate', async ({ req, table, id, user }) => {
|
50
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user || {};
|
51
|
+
const opt = await getTokenData({ req, mode: 'w', token: table, uid });
|
52
|
+
return opt;
|
53
|
+
});
|
54
|
+
addHook('preDelete', async ({ req, table, id, user }) => {
|
55
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user || {};
|
56
|
+
const opt = await getTokenData({ req, mode: 'w', token: table, uid });
|
57
|
+
return opt;
|
18
58
|
});
|
19
59
|
|
20
|
-
addHook('afterTable', async ({ req = {}, res = {}, rows = [],
|
21
|
-
const { pg
|
22
|
-
const
|
23
|
-
|
60
|
+
addHook('afterTable', async ({ req = {}, table, res = {}, rows = [], user = {} }) => {
|
61
|
+
const { pg } = req;
|
62
|
+
const loadTable = await getTemplate('table', table);
|
63
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user;
|
64
|
+
if (!uid || !table || !pg?.pk?.[table] || !rows.length || !loadTable?.table) return;
|
24
65
|
|
25
66
|
// admin.custom_column - user column data
|
26
67
|
const { rows: properties = [] } = await pg.query(`select column_id, name, title, format, data from admin.custom_column
|
27
|
-
|
68
|
+
where _table and entity=$1 and uid=$2`, [table, uid]);
|
28
69
|
const extraColumnList = properties.map((row) => ({ id: row.column_id, name: row.name, title: row.title, format: row.format, data: row.data }));
|
29
70
|
if (!extraColumnList?.length) return;
|
30
71
|
|
@@ -33,7 +74,7 @@ export default async function plugin(fastify) {
|
|
33
74
|
}
|
34
75
|
|
35
76
|
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
|
-
|
77
|
+
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
78
|
|
38
79
|
if (!extraData?.length) {
|
39
80
|
// Object.assign(rows?.[0] || {}, { ...extraColumnList.reduce((acc, curr) => Object.assign(acc, { [curr.name]: null }), {}) });
|
@@ -60,7 +101,7 @@ export default async function plugin(fastify) {
|
|
60
101
|
});
|
61
102
|
|
62
103
|
// extract table from form token for user columns - p.2 - read (refactor to global token)
|
63
|
-
/* addHook('preTemplate', async ({ req = {} }) => {
|
104
|
+
/* addHook('preTemplate', async ({ req = {}, name, type, user }) => {
|
64
105
|
const { funcs, params = {}, session = {} } = req;
|
65
106
|
const { uid } = funcs?.config?.auth?.disable ? { uid: '1' } : (session?.passport?.user || {});
|
66
107
|
if (!uid || params?.type !== 'form' || !params?.name) return null;
|
@@ -73,9 +114,9 @@ export default async function plugin(fastify) {
|
|
73
114
|
}
|
74
115
|
}); */
|
75
116
|
|
76
|
-
addHook('afterTemplate', async ({ req = {}, data = {} }) => {
|
77
|
-
const { funcs
|
78
|
-
const { uid } = funcs?.config?.auth?.disable ? { uid: '1' } :
|
117
|
+
addHook('afterTemplate', async ({ req = {}, data = {}, user = {} }) => {
|
118
|
+
const { funcs } = req;
|
119
|
+
const { uid } = funcs?.config?.auth?.disable ? { uid: '1' } : user;
|
79
120
|
const { pg, params = {} } = req;
|
80
121
|
// extract table from form token for user columns - p.1 - assign (refactor to global token)
|
81
122
|
/* if (params?.type === 'table') {
|
@@ -100,11 +141,11 @@ export default async function plugin(fastify) {
|
|
100
141
|
}));
|
101
142
|
});
|
102
143
|
|
103
|
-
addHook('afterUpdate', async ({ req, res = {} }) => {
|
144
|
+
addHook('afterUpdate', async ({ req, res = {}, user = {} }) => {
|
104
145
|
const {
|
105
|
-
pg,
|
146
|
+
pg, params = {}, body = {},
|
106
147
|
} = req;
|
107
|
-
const { uid } =
|
148
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user;
|
108
149
|
if (!uid) return null;
|
109
150
|
|
110
151
|
const loadTable = await getTemplate('table', params.table);
|
@@ -125,11 +166,11 @@ export default async function plugin(fastify) {
|
|
125
166
|
return pg.query(q);
|
126
167
|
});
|
127
168
|
|
128
|
-
addHook('afterInsert', async ({ req, res = {} }) => {
|
169
|
+
addHook('afterInsert', async ({ req, res = {}, user = {} }) => {
|
129
170
|
const {
|
130
|
-
pg,
|
171
|
+
pg, params = {}, body = {},
|
131
172
|
} = req;
|
132
|
-
const { uid } =
|
173
|
+
const { uid } = config?.auth?.disable ? { uid: '1' } : user;
|
133
174
|
if (!uid) return null;
|
134
175
|
|
135
176
|
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,7 +1,8 @@
|
|
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 res = await applyHook('preTemplate', { req, name: params?.name, type: params?.type, user });
|
5
6
|
if (res) return res;
|
6
7
|
|
7
8
|
const { funcs, params = {}, session = {} } = req;
|
@@ -16,6 +17,6 @@ export default async function getTemplateApi(req) {
|
|
16
17
|
) {
|
17
18
|
return `access restricted ${name}`;
|
18
19
|
}
|
19
|
-
await applyHook('afterTemplate', { req, data })
|
20
|
+
await applyHook('afterTemplate', { req, data, user })
|
20
21
|
return data?.html || data || `template not found "${name}"`;
|
21
22
|
}
|