@opengis/admin 0.2.131 → 0.2.133

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 (31) hide show
  1. package/dist/add-page-DQ70Si9f.js +104 -0
  2. package/dist/{admin-interface-CFR2WRun.js → admin-interface-CgXFerXl.js} +348 -323
  3. package/dist/{admin-view-CE-4P8V-.js → admin-view-t-gzhVnl.js} +231 -291
  4. package/dist/admin.js +1 -1
  5. package/dist/admin.umd.cjs +82 -82
  6. package/dist/{card-view-BbBU9cWN.js → card-view-Dtf6Ap9G.js} +1 -1
  7. package/dist/edit-page-BWRXfML4.js +125 -0
  8. package/dist/{import-file-C1vBdCEv.js → import-file-CztGvKRc.js} +25610 -26789
  9. package/dist/style.css +1 -1
  10. package/package.json +5 -5
  11. package/server/helpers/list/utils/button.js +5 -5
  12. package/server/routes/data/controllers/utils/conditions.js +20 -20
  13. package/server/routes/menu/controllers/getMenu.js +11 -3
  14. package/server/routes/menu/controllers/interfaces.js +19 -0
  15. package/server/routes/menu/index.mjs +2 -0
  16. package/server/routes/print/controllers/printTemplate.js +4 -3
  17. package/server/routes/print/controllers/printTemplatePreview.js +15 -9
  18. package/server/routes/properties/controllers/admin.properties.get.js +6 -8
  19. package/server/routes/properties/controllers/admin.properties.post.js +28 -7
  20. package/server/routes/properties/controllers/user.properties.get.js +2 -13
  21. package/server/routes/properties/controllers/user.properties.post.js +2 -22
  22. package/server/routes/properties/index.mjs +4 -4
  23. package/server/routes/properties/utils/refreshData.js +4 -4
  24. package/utils.js +2 -5
  25. package/dist/add-page-B5Yx_gil.js +0 -119
  26. package/dist/edit-page-D3q9Dp_D.js +0 -138
  27. package/dist/profile-page-CVV-ZW1M.js +0 -78
  28. package/dist/user-B_2kh6ic.js +0 -5
  29. package/module/settings/setting/test.json +0 -6
  30. package/server/routes/properties/funcs/getSettings.js +0 -56
  31. package/server/routes/properties/funcs/setSettings.js +0 -44
@@ -1,138 +0,0 @@
1
- import { _ as g, u as f, e as m } from "./import-file-C1vBdCEv.js";
2
- import { resolveComponent as y, openBlock as h, createElementBlock as x, createElementVNode as c, createBlock as w, normalizeStyle as k, createCommentVNode as v } from "vue";
3
- const $ = {
4
- data() {
5
- return {
6
- formValues: {},
7
- scheme: null,
8
- table: "",
9
- token: "",
10
- style: null
11
- };
12
- },
13
- mounted() {
14
- this.getFormScheme();
15
- },
16
- methods: {
17
- flattenMenu(e) {
18
- const t = [];
19
- return e.forEach((r) => {
20
- r.menu ? t.push(...this.flattenMenu(r.menu)) : t.push(r);
21
- }), t;
22
- },
23
- async getFormScheme() {
24
- var i, o;
25
- const e = this.flattenMenu(f.value);
26
- e != null && e.length || this.$router.replace("/404");
27
- const t = e == null ? void 0 : e.find((a) => {
28
- var n, s;
29
- return (a == null ? void 0 : a.path) == ((s = (n = this.$route) == null ? void 0 : n.query) == null ? void 0 : s.table);
30
- });
31
- t || this.$router.replace("/404");
32
- const r = t == null ? void 0 : t.table;
33
- this.table = r;
34
- try {
35
- const {
36
- data: { form: a }
37
- } = await m.get(`/api/template/table/${r}`), { data: n } = await m.get(
38
- `/api/table/${this.table}/${(o = (i = this.$route) == null ? void 0 : i.query) == null ? void 0 : o.id}`
39
- );
40
- this.token = (n == null ? void 0 : n.token) || "", this.formValues = n || {};
41
- const { data: s } = await m.get(`/api/template/form/${a}`);
42
- this.scheme = (s == null ? void 0 : s.schema) || s, this.style = (s == null ? void 0 : s.style) || null;
43
- } catch {
44
- }
45
- },
46
- async onlyEditObject() {
47
- var t, r, i, o, a, n, s, l, u;
48
- const e = this.$refs.form;
49
- try {
50
- await e.doValidation(), await m.put(`/api/table/${this.token}`, this.formValues), await this.$notify({
51
- title: "Успішно!",
52
- message: "Об'єкт успішно створено",
53
- type: "success"
54
- });
55
- } catch (b) {
56
- const d = ((t = b == null ? void 0 : b.response) == null ? void 0 : t.data) || "";
57
- let p = ((a = (o = (i = (r = Object.entries(e == null ? void 0 : e.formErrors)) == null ? void 0 : r[0]) == null ? void 0 : i[1]) == null ? void 0 : o[0]) == null ? void 0 : a.message) === "Це поле обов'язкове" ? "Заповніть обов'язкові поля" : (u = (l = (s = (n = Object.entries(e == null ? void 0 : e.formErrors)) == null ? void 0 : n[0]) == null ? void 0 : s[1]) == null ? void 0 : l[0]) == null ? void 0 : u.message;
58
- this.$notify({
59
- title: "Помилка!",
60
- message: d || p || "Сталася помилка валідаціі",
61
- type: "error"
62
- });
63
- }
64
- },
65
- getGroupedErrorNotification(e, t) {
66
- if (!e || !t) return "";
67
- const r = {};
68
- return Object.entries(e).forEach(([o, a]) => {
69
- var s;
70
- const n = ((s = t[o]) == null ? void 0 : s.ua) || o;
71
- a.forEach((l) => {
72
- const u = l.message;
73
- r[u] || (r[u] = []), r[u].push(`"${n}"`);
74
- });
75
- }), Object.entries(r).map(([o, a]) => `<b>${o}:</b> ${a.join(", ")}`).join("<br>") || "Сталася помилка валідації";
76
- },
77
- async editObjectAndRedirect() {
78
- const e = this.$refs.form;
79
- try {
80
- await e.doValidation(), await m.put(`/api/table/${this.token}`, this.formValues), await this.$router.back(), await this.$notify({
81
- title: "Успішно!",
82
- message: "Об'єкт успішно створено",
83
- type: "success"
84
- });
85
- } catch {
86
- const r = this.getGroupedErrorNotification(
87
- e == null ? void 0 : e.formErrors,
88
- e == null ? void 0 : e.scheme
89
- );
90
- this.$notify({
91
- title: "Помилка!",
92
- message: r,
93
- type: "error"
94
- });
95
- }
96
- }
97
- }
98
- }, V = { class: "bg-gray-50 lg:w-[calc(100vw-260px)] w-[100vw]" }, _ = { class: "h-[76px] mt-[15px] flex items-center justify-between mx-[20px] px-[20px] bg-white border rounded-xl" }, j = { class: "flex items-center gap-[6px]" }, E = {
99
- style: { height: "calc(100vh - 155px)" },
100
- class: "bg-gray-50 p-[20px] flex lg:w-[calc(100vw-260px)] w-[100vw]"
101
- }, O = { 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" };
102
- function M(e, t, r, i, o, a) {
103
- var s;
104
- const n = y("VsForm");
105
- return h(), x("div", V, [
106
- c("div", _, [
107
- t[3] || (t[3] = c("h2", { class: "text-xl font-medium" }, "Редагувати", -1)),
108
- c("div", j, [
109
- c("button", {
110
- onClick: t[0] || (t[0] = (l) => e.$router.back()),
111
- 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"
112
- }, " Скасувати "),
113
- c("button", {
114
- onClick: t[1] || (t[1] = (...l) => a.editObjectAndRedirect && a.editObjectAndRedirect(...l)),
115
- 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"
116
- }, " Зберегти ")
117
- ])
118
- ]),
119
- c("div", E, [
120
- c("div", O, [
121
- o.scheme ? (h(), w(n, {
122
- key: 0,
123
- ref: "form",
124
- scheme: o.scheme,
125
- columns: (s = o.style) == null ? void 0 : s.columns,
126
- style: k(o.style),
127
- modelValue: o.formValues,
128
- "onUpdate:modelValue": t[2] || (t[2] = (l) => o.formValues = l),
129
- class: "p-0 mt-[20px]"
130
- }, null, 8, ["scheme", "columns", "style", "modelValue"])) : v("", !0)
131
- ])
132
- ])
133
- ]);
134
- }
135
- const N = /* @__PURE__ */ g($, [["render", M]]);
136
- export {
137
- N as default
138
- };
@@ -1,78 +0,0 @@
1
- import { _ as n, e as m } from "./import-file-C1vBdCEv.js";
2
- import { u as p } from "./user-B_2kh6ic.js";
3
- import { resolveComponent as d, openBlock as u, createElementBlock as f, createElementVNode as o, createBlock as h, createCommentVNode as b } from "vue";
4
- const x = {
5
- data() {
6
- return {
7
- formScheme: null,
8
- formValues: {}
9
- };
10
- },
11
- mounted() {
12
- this.getFormScheme();
13
- },
14
- computed: {
15
- userData() {
16
- return p.value;
17
- }
18
- },
19
- methods: {
20
- async updateUser() {
21
- var r;
22
- try {
23
- await m.put(`/user/${(r = this.userData.user) == null ? void 0 : r.uid}`, this.formValues), await this.$notify({
24
- title: "Успішно!",
25
- message: "Дані успішно оновлені",
26
- type: "success"
27
- });
28
- } catch {
29
- this.$notify({
30
- title: "Помилка!",
31
- message: "Сталася помилка",
32
- type: "error"
33
- });
34
- }
35
- },
36
- async getFormScheme() {
37
- var r, t, a, l;
38
- try {
39
- const { data: e } = await m.get(
40
- "/api/template/form/admin.profile.form"
41
- );
42
- console.log(this.userData);
43
- for (const s in e == null ? void 0 : e.schema)
44
- (t = (r = this.userData) == null ? void 0 : r.user) != null && t[s] && (this.formValues[s] = (l = (a = this.userData) == null ? void 0 : a.user) == null ? void 0 : l[s]);
45
- this.formScheme = e.schema;
46
- } catch (e) {
47
- console.error(e);
48
- }
49
- }
50
- }
51
- }, g = { class: "flex justify-center pt-[20px] pb-[20px] pl-[20px] h-[calc(100vh-58px)]" }, k = { class: "bg-white rounded-xl border p-[20px]" }, y = { class: "flex-1 overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-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" }, w = { class: "flex" };
52
- function _(r, t, a, l, e, s) {
53
- const i = d("VsForm");
54
- return u(), f("div", g, [
55
- o("div", k, [
56
- t[2] || (t[2] = o("h2", { class: "mb-[20px] text-center" }, "Профіль", -1)),
57
- o("div", y, [
58
- e.formScheme ? (u(), h(i, {
59
- key: 0,
60
- scheme: e.formScheme,
61
- modelValue: e.formValues,
62
- "onUpdate:modelValue": t[0] || (t[0] = (c) => e.formValues = c),
63
- class: "pb-0"
64
- }, null, 8, ["scheme", "modelValue"])) : b("", !0),
65
- o("div", w, [
66
- o("button", {
67
- onClick: t[1] || (t[1] = (...c) => s.updateUser && s.updateUser(...c)),
68
- class: "ml-auto text-[18px] bg-blue-500 text-white px-[8px] py-[4px] rounded hover:bg-blue-700 duration-300"
69
- }, " Зберегти ")
70
- ])
71
- ])
72
- ])
73
- ]);
74
- }
75
- const D = /* @__PURE__ */ n(x, [["render", _]]);
76
- export {
77
- D as default
78
- };
@@ -1,5 +0,0 @@
1
- import { ref as r } from "vue";
2
- const e = r(null);
3
- export {
4
- e as u
5
- };
@@ -1,6 +0,0 @@
1
- {
2
- "admin.title": {
3
- "type": "Text",
4
- "ua": "Назва"
5
- }
6
- }
@@ -1,56 +0,0 @@
1
- import { getMeta } from '@opengis/fastify-table/utils.js';
2
-
3
- const match = {
4
- property_key: 'key',
5
- property_json: 'json',
6
- property_int: 'int',
7
- property_text: 'text',
8
- };
9
-
10
- function getQuery({
11
- table, columns = [], key, uid,
12
- }) {
13
- const columnList = columns?.filter((el) => match[el?.name]).map((el) => el?.name).map((el) => `${el} as ${match[el]}`);
14
- const sql = `select ${columnList.join(',')} from ${table} where 1=1`;
15
-
16
- if (table === 'admin.user_properties') {
17
- const args = [uid, key].filter((el) => el);
18
- const q = sql + (uid ? ' and uid=$1' : '') + (key ? ` and property_key=$${args.indexOf(key) + 1}` : '');
19
- return { q, args };
20
- }
21
- const args = [key].filter((el) => el);
22
- const q = sql + (key ? ` and property_key=$${args.indexOf(key) + 1}` : '');
23
- return { q, args };
24
- }
25
-
26
- export default async function getSettings({
27
- pg, redis, json, key, table = 'admin.properties', uid,
28
- }) {
29
- const { columns = [] } = await getMeta({ table });
30
-
31
- const { q, args } = getQuery({
32
- table, columns, key, uid,
33
- });
34
-
35
- const { rows } = await pg.query(q, args);
36
- const data = rows?.reduce((acc, curr) => Object.assign(acc, { [curr.key]: curr.json || curr.int || curr.text }), {});
37
-
38
- const jsonData = Object.keys(data || {}).reduce((acc, curr) => {
39
- const [ckey, csubkey] = curr.split('.');
40
- if (!csubkey) return Object.assign(acc, { [curr]: data[curr] });
41
- if (!acc[ckey]) Object.assign(acc, { [ckey]: {} });
42
- Object.assign(acc[ckey], { [csubkey]: data[curr] });
43
- return acc;
44
- }, {});
45
-
46
- // save both
47
- if (redis) {
48
- const keyCacheJSON = `${pg.options?.database}:settings:${key || 'all'}:json:${table}`;
49
- await redis.set(keyCacheJSON, JSON.stringify(jsonData));
50
-
51
- const keyCachePlain = `${pg.options?.database}:settings:${key || 'all'}:plain:${table}`;
52
- await redis.set(keyCachePlain, JSON.stringify(data));
53
- }
54
-
55
- return json ? jsonData : data;
56
- }
@@ -1,44 +0,0 @@
1
- import { getRedis } from '@opengis/fastify-table/utils.js';
2
-
3
- import { getSettings } from '../../../../utils.js';
4
- import dataInsert from '../utils/dataInsert.js';
5
-
6
- function checkValueType(val) {
7
- if (val) {
8
- if (typeof val === 'object') {
9
- return 'property_json';
10
- }
11
- if (typeof val === 'number' && (!/\D/.test(val.toString()) && val.toString().length < 10)) {
12
- return 'property_int';
13
- }
14
- }
15
- return 'property_text';
16
- }
17
-
18
- export default async function setSettings({
19
- pg, key, val, body = {}, table = 'admin.properties', uid,
20
- }) {
21
- const body1 = key && val ? { [key]: val } : body;
22
- const keys = Object.keys(body1);
23
- try {
24
- const redis = getRedis();
25
- await pg.query(`delete from ${table} where property_key=any($1)`, [keys]);
26
-
27
- await Promise.all(keys.map(async (el) => {
28
- const columnType = table === 'admin.user_properties' ? 'property_json' : checkValueType(body1[el]);
29
- const data = { property_key: el, [columnType]: body1[el], uid };
30
- const { rows } = await dataInsert({
31
- pg, table, data, uid,
32
- });
33
- return { key: el, rows: { val: body[el], data: rows?.[0] } };
34
- }));
35
-
36
- const res = await getSettings({
37
- pg, redis, table, uid,
38
- });
39
- return res;
40
- }
41
- catch (err) {
42
- return { error: err.toString(), status: 500 };
43
- }
44
- }