@opengis/admin 0.1.98 → 0.1.100

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. package/dist/add-page-Dl_bGhPC.js +92 -0
  2. package/dist/admin-interface-Dma-D4A9.js +1351 -0
  3. package/dist/admin-view-TeTAUVK1.js +640 -0
  4. package/dist/admin.js +1 -1
  5. package/dist/admin.umd.cjs +83 -128
  6. package/dist/card-page-D-3aubBo.js +230 -0
  7. package/dist/{card-view-BpcpqR_U.js → card-view-CZjPaUKx.js} +1 -1
  8. package/dist/edit-page-RhKgRai9.js +103 -0
  9. package/dist/{import-file-eH-_Imyb.js → import-file-DgJqxKyF.js} +18308 -19458
  10. package/dist/style.css +1 -1
  11. package/module/settings/card/admin.accounts.table/index.yml +8 -0
  12. package/module/settings/card/admin.accounts.table/rules.hbs +19 -0
  13. package/module/settings/card/admin.accounts.table/users.hbs +14 -0
  14. package/module/settings/card/admin.roles.table/access.hbs +3 -24
  15. package/module/settings/card/admin.roles.table/general_info.hbs +1 -17
  16. package/module/settings/card/admin.roles.table/index.yml +4 -1
  17. package/module/settings/card/admin.roles.table/users.hbs +6 -27
  18. package/module/settings/card/admin.routes.table/general_info.hbs +14 -41
  19. package/module/settings/card/admin.routes.table/groups.hbs +12 -0
  20. package/module/settings/card/admin.routes.table/index.yml +3 -0
  21. package/module/settings/card/admin.routes.table/users.hbs +16 -33
  22. package/module/settings/card/admin.users.table/context.hbs +15 -0
  23. package/module/settings/card/admin.users.table/general_info.hbs +13 -26
  24. package/module/settings/card/admin.users.table/index.yml +17 -7
  25. package/module/settings/card/admin.users.table/last_login.hbs +10 -0
  26. package/module/settings/card/admin.users.table/logs.hbs +11 -31
  27. package/module/settings/card/admin.users.table/routes.hbs +8 -0
  28. package/module/settings/card/admin.users.table/user_roles.hbs +13 -25
  29. package/module/settings/form/admin.accounts.form.json +13 -0
  30. package/module/settings/form/admin.rules.form.json +31 -0
  31. package/module/settings/form/admin.user_roles.form.json +0 -8
  32. package/module/settings/form/admin.user_roles_card.form.json +14 -0
  33. package/module/settings/form/admin.users.form.json +2 -2
  34. package/module/settings/form/context.account_grants.form.json +24 -0
  35. package/module/settings/form/context.account_users.form.json +12 -0
  36. package/module/settings/menu.json +24 -0
  37. package/module/settings/select/core.accounts.sql +1 -0
  38. package/module/settings/select/core.roles.sql +1 -1
  39. package/module/settings/select/core.rules.sql +1 -0
  40. package/module/settings/select/core.user_uid.sql +0 -1
  41. package/module/settings/table/admin.accounts.table.json +42 -0
  42. package/module/settings/table/admin.roles.table.json +1 -1
  43. package/module/settings/table/admin.routes.table.json +9 -4
  44. package/module/settings/table/admin.rules.table.json +77 -0
  45. package/module/settings/table/admin.users.table.json +17 -6
  46. package/module/settings/table/context.account_grants.table.json +68 -0
  47. package/module/settings/table/context.account_users.table.json +38 -0
  48. package/package.json +3 -2
  49. package/server/helpers/core/select.js +4 -6
  50. package/server/helpers/list/tableList.js +9 -6
  51. package/server/routes/access/controllers/access.group.js +1 -1
  52. package/server/routes/access/controllers/access.group.post.js +4 -4
  53. package/server/routes/data/controllers/cardData.js +11 -0
  54. package/server/routes/data/controllers/tableData.js +13 -4
  55. package/server/routes/menu/controllers/getMenu.js +12 -25
  56. package/dist/IconChevronDown-irxwDmQp.js +0 -26
  57. package/dist/add-page-UtwEANeW.js +0 -105
  58. package/dist/admin-interface-PJfd31TQ.js +0 -1600
  59. package/dist/admin-view-BuVQ8ziq.js +0 -383
  60. package/dist/assets/favicon.svg +0 -1
  61. package/dist/assets/logo.svg +0 -42
  62. package/dist/edit-page-Bd6VW9hb.js +0 -120
  63. package/module/settings/select/core.roles.json +0 -3
@@ -35,34 +35,21 @@ export default async function adminMenu({ user = {}, session, pg = pgClients.cli
35
35
  const menus = isProduction && menuCache.length ? menuCache : await readMenu();
36
36
 
37
37
  // update user access
38
- if (session && user?.uid) {
39
- const { type, gl = [] } = await pg.query(`select user_type as type, b.gl from admin.users a
40
- left join lateral (
41
- select array_agg(role_id) as gl from admin.user_roles where user_uid=a.uid
42
- )b on 1=1 where uid=$1`, [user.uid]).then(el => el.rows[0] || {});
43
- /* const { interfaces = [] } = await pg.query(`select array_agg(route_id) as interfaces from admin.access
38
+ if (session && user?.uid && user.type !== 'admin' && pg.pk['admin.role_access']) {
39
+ const { type, gl = [], routes = [] } = await pg.query(`select user_type as type, b.gl,routes from admin.users a
40
+ left join lateral ( select array_agg(role_id) as gl from admin.user_roles where user_uid=a.uid)b on 1=1
41
+ left join lateral ( select array_agg(route_id) as routes from admin.role_access where role_id=any(b.gl))r on 1=1
42
+ where uid=$1`, [user.uid]).then(el => el.rows[0] || {});
43
+ /* const { interfaces = [] } = await pg.query(`select array_agg(route_id) as interfaces from admin.role_access
44
44
  where user_uid=$1 or role_id=any($2::text[])`, [user.uid, gl]).then((res) => res.rows?.[0] || {}); */
45
- Object.assign(user, { type, group_list: gl });
45
+
46
+ Object.assign(user, { type, group_list: gl, routes });
46
47
  session?.set?.('passport', { user });
48
+ const userMenus = menus.map(el => (el.menu ? { ...el, menu: el.menu.filter(item => routes.includes(item.path)) } : el))
49
+ return userMenus.filter(el => el.menu?.length || routes.includes(el.path))
47
50
  }
48
- return menus;
49
51
 
50
- if (req) {
51
- const user = req?.session?.passport?.user || {};
52
- const userMenu = await Promise.all(menus.map(async (menu) => {
53
- if (menu?.menu?.length) {
54
- const submenu = await Promise.all(menu.menu?.map(async (submenu) => {
55
- const access = await getAccess({ table: submenu?.table, user });
56
- return { ...submenu, access };
57
- }));
58
- return { ...menu, menu: submenu.filter((e) => e?.access), access: submenu.filter((e) => e?.access?.actions?.includes('get'))?.length };
59
- } else if (menu?.table) {
60
- const access = await getAccess({ table: menu?.table, user });
61
- return { ...menu, access };
62
- }
63
- return menu;
64
- }));
65
- return userMenu.filter((e) => e?.access)?.map((e) => ({ ...e, menu: e?.menu ? e?.menu?.filter((el) => el?.access?.actions?.includes('get')) : undefined }));
66
- }
67
52
  return menus;
53
+
54
+
68
55
  }
@@ -1,26 +0,0 @@
1
- import { openBlock as e, createElementBlock as t, createElementVNode as n } from "vue";
2
- import { _ as r } from "./import-file-eH-_Imyb.js";
3
- const l = {}, s = {
4
- xmlns: "http://www.w3.org/2000/svg",
5
- viewBox: "0 0 24 24",
6
- fill: "none",
7
- stroke: "currentColor",
8
- "stroke-width": "2",
9
- "stroke-linecap": "round",
10
- "stroke-linejoin": "round",
11
- class: "icon icon-tabler icons-tabler-outline icon-tabler-chevron-down"
12
- };
13
- function c(i, o, a, p, d, u) {
14
- return e(), t("svg", s, o[0] || (o[0] = [
15
- n("path", {
16
- stroke: "none",
17
- d: "M0 0h24v24H0z",
18
- fill: "none"
19
- }, null, -1),
20
- n("path", { d: "M6 9l6 6l6 -6" }, null, -1)
21
- ]));
22
- }
23
- const m = /* @__PURE__ */ r(l, [["render", c]]);
24
- export {
25
- m as I
26
- };
@@ -1,105 +0,0 @@
1
- import { _ as g, u as f, c as u } from "./import-file-eH-_Imyb.js";
2
- import { resolveComponent as x, openBlock as d, createElementBlock as w, createElementVNode as n, createBlock as k, createCommentVNode as y } from "vue";
3
- const v = {
4
- data() {
5
- return {
6
- formValues: {},
7
- scheme: null,
8
- table: "",
9
- token: "",
10
- api: ""
11
- };
12
- },
13
- mounted() {
14
- this.getFormScheme();
15
- },
16
- methods: {
17
- flattenMenu(t) {
18
- const e = [];
19
- return t.forEach((o) => {
20
- o.menu ? e.push(...this.flattenMenu(o.menu)) : e.push(o);
21
- }), e;
22
- },
23
- async getFormScheme() {
24
- var i, a;
25
- const t = this.flattenMenu(f.value);
26
- t != null && t.length || this.$router.replace("/404");
27
- const e = t == null ? void 0 : t.find((r) => {
28
- var s, l;
29
- return (r == null ? void 0 : r.path) == ((l = (s = this.$route) == null ? void 0 : s.query) == null ? void 0 : l.table);
30
- });
31
- e || this.$router.replace("/404");
32
- const o = e == null ? void 0 : e.table;
33
- this.table = o;
34
- try {
35
- const r = await u.get(`/api/table-data/${o}`), { data: s } = await u.get(
36
- `/api/template/form/${(i = r == null ? void 0 : r.data) == null ? void 0 : i.form}`
37
- );
38
- this.scheme = (s == null ? void 0 : s.schema) || s, this.api = (s == null ? void 0 : s.api) || "", this.token = (a = r == null ? void 0 : r.data) == null ? void 0 : a.addToken;
39
- } catch {
40
- }
41
- },
42
- async createObject() {
43
- var e, o, i, a, r, s, l, m, b;
44
- const t = this.$refs.form;
45
- try {
46
- await t.doValidation(), await u.post(
47
- this.api || `/api/table/${this.token}`,
48
- this.formValues
49
- ), await this.$router.back(), await this.$notify({
50
- title: "Успішно!",
51
- message: "Об'єкт успішно створено",
52
- type: "success"
53
- });
54
- } catch (c) {
55
- const h = ((e = c == null ? void 0 : c.response) == null ? void 0 : e.data) || "";
56
- let p = ((r = (a = (i = (o = Object.entries(t == null ? void 0 : t.formErrors)) == null ? void 0 : o[0]) == null ? void 0 : i[1]) == null ? void 0 : a[0]) == null ? void 0 : r.message) === "Це поле обов'язкове" ? "Заповніть обов'язкові поля" : (b = (m = (l = (s = Object.entries(t == null ? void 0 : t.formErrors)) == null ? void 0 : s[0]) == null ? void 0 : l[1]) == null ? void 0 : m[0]) == null ? void 0 : b.message;
57
- this.$notify({
58
- title: "Помилка!",
59
- message: h || p || "Сталася помилка валідаціі",
60
- type: "error"
61
- });
62
- }
63
- }
64
- }
65
- }, V = {
66
- style: { width: "calc(100vw - 260px)" },
67
- class: "bg-gray-50"
68
- }, _ = { class: "h-[76px] mt-[15px] flex items-center justify-between mx-[20px] px-[20px] bg-white border rounded-xl" }, $ = { class: "flex items-center gap-[6px]" }, j = {
69
- style: { height: "calc(100vh - 165px)", width: "calc(100vw - 260px)" },
70
- class: "bg-gray-50 p-[20px] flex"
71
- }, E = { class: "bg-white w-full rounded-xl border p-[20px] overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500" };
72
- function O(t, e, o, i, a, r) {
73
- const s = x("VsForm");
74
- return d(), w("div", V, [
75
- n("div", _, [
76
- e[3] || (e[3] = n("h2", { class: "text-xl font-medium" }, "Створити", -1)),
77
- n("div", $, [
78
- n("button", {
79
- onClick: e[0] || (e[0] = (l) => t.$router.back()),
80
- class: "flex items-center px-3 py-2 text-sm font-medium text-gray-800 duration-300 bg-white border border-gray-100 rounded-lg shadow gap-x-2 focus:outline-none hover:bg-gray-50 hover:border-gray-100"
81
- }, " Скасувати "),
82
- n("button", {
83
- onClick: e[1] || (e[1] = (...l) => r.createObject && r.createObject(...l)),
84
- class: "inline-flex items-center px-3 py-2 text-sm font-medium text-white duration-300 bg-blue-600 border border-transparent rounded-lg gap-x-2 hover:bg-blue-700 hover:text-white"
85
- }, " Зберегти ")
86
- ])
87
- ]),
88
- n("div", j, [
89
- n("div", E, [
90
- a.scheme ? (d(), k(s, {
91
- key: 0,
92
- ref: "form",
93
- scheme: a.scheme,
94
- modelValue: a.formValues,
95
- "onUpdate:modelValue": e[2] || (e[2] = (l) => a.formValues = l),
96
- class: "p-0 mt-[20px]"
97
- }, null, 8, ["scheme", "modelValue"])) : y("", !0)
98
- ])
99
- ])
100
- ]);
101
- }
102
- const M = /* @__PURE__ */ g(v, [["render", O]]);
103
- export {
104
- M as default
105
- };