@opengis/admin 0.2.85 → 0.2.87

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 (26) hide show
  1. package/dist/{add-page-DjV6f_jT.js → add-page-DQ70Si9f.js} +1 -1
  2. package/dist/{admin-interface-DAyLdquZ.js → admin-interface-CgXFerXl.js} +205 -205
  3. package/dist/{admin-view-DooY0sff.js → admin-view-t-gzhVnl.js} +1 -1
  4. package/dist/admin.js +1 -1
  5. package/dist/admin.umd.cjs +56 -56
  6. package/dist/{card-view-58mVfI5f.js → card-view-Dtf6Ap9G.js} +1 -1
  7. package/dist/{edit-page-Bg2NgUpM.js → edit-page-BWRXfML4.js} +1 -1
  8. package/dist/{import-file-BHcTcjJq.js → import-file-CztGvKRc.js} +14361 -14035
  9. package/dist/style.css +1 -1
  10. package/module/settings/menu.json +58 -59
  11. package/package.json +2 -2
  12. package/server/helpers/list/utils/button.js +5 -5
  13. package/server/routes/data/controllers/utils/conditions.js +20 -20
  14. package/server/routes/properties/controllers/admin.properties.get.js +17 -14
  15. package/server/routes/properties/controllers/admin.properties.post.js +1 -1
  16. package/server/routes/properties/controllers/table.properties.get.js +120 -0
  17. package/server/routes/properties/controllers/table.properties.post.js +115 -0
  18. package/server/routes/properties/controllers/user.properties.get.js +2 -2
  19. package/server/routes/properties/controllers/user.properties.post.js +1 -1
  20. package/server/routes/properties/funcs/setSettings.js +1 -1
  21. package/server/routes/properties/index.mjs +15 -8
  22. package/server/routes/properties/utils/getColumnMetaData.js +17 -0
  23. package/server/routes/properties/utils/refreshData.js +128 -0
  24. package/server/routes/widget/controllers/widget.get.js +2 -1
  25. package/server/templates/setting/test.json +20 -0
  26. /package/server/routes/properties/{funcs/utils → utils}/dataInsert.js +0 -0
@@ -0,0 +1,128 @@
1
+ import { randomUUID, createHash } from 'crypto';
2
+
3
+ import { dataInsert, pgClients } from '@opengis/fastify-table/utils.js';
4
+
5
+ function prepareResult(res) {
6
+ const arr = (res.rows || (Array.isArray(res) ? res : Object.values(res || {})));
7
+ return {
8
+ command: 'INSERT',
9
+ count: arr.filter((el) => el.command === 'INSERT')
10
+ ?.map((el) => ({ result: 'success', count: el.rowCount }))
11
+ ?.reduce((acc, curr) => acc + curr.count, 0),
12
+ };
13
+ }
14
+
15
+ export default async function refreshData({
16
+ pg = pgClients.client, entity, table, uid, data,
17
+ }) {
18
+ if (!['filter', 'column', 'customQuery', 'customColumn'].includes(entity)) {
19
+ return { message: 'invalid params: entity', status: 400 };
20
+ }
21
+
22
+ const client = await pg.connect();
23
+
24
+ /* getMeta support */
25
+ client.options = pg.options;
26
+ client.tlist = pg.tlist;
27
+ client.pgType = pg.pgType;
28
+ client.pk = pg.pk;
29
+ client.relkinds = pg.relkinds;
30
+
31
+ const result = {};
32
+
33
+ try {
34
+ await client.query('BEGIN');
35
+
36
+ if (['filter', 'column'].includes(entity)) {
37
+ data?.forEach((el) => Object.assign(el, { id: el.id || randomUUID() }));
38
+ await client.query('delete from setting.property where object_id=$1 and property_entity=$2', [table, entity]);
39
+
40
+ const res = dataInsert({
41
+ pg: client,
42
+ table: 'setting.property',
43
+ data: {
44
+ property_entity: entity,
45
+ object_id: table,
46
+ property_json: JSON.stringify(data)?.replace(/'/g, "''"),
47
+ },
48
+ uid,
49
+ });
50
+ Object.assign(result, res);
51
+ }
52
+
53
+ if (['customQuery'].includes(entity)) {
54
+ await client.query('delete from setting.property where object_id=$1 and property_entity=$2', [table, entity]);
55
+
56
+ const res = await Promise.all(data?.map(async (el) => dataInsert({
57
+ pg: client,
58
+ table: 'setting.property',
59
+ data: {
60
+ property_entity: entity,
61
+ object_id: table,
62
+ property_key: el.name,
63
+ property_text: el.query,
64
+ property_json: { disabled: el.disabled },
65
+ },
66
+ uid,
67
+ })));
68
+ Object.assign(result, res);
69
+ }
70
+
71
+ if (entity === 'customColumn') {
72
+ const prefix = createHash('md5').update(table).digest('hex').substr(0, 10);
73
+ const data1 = [];
74
+
75
+ await Promise.all(data.map(async (el, index) => {
76
+ const obj = {
77
+ cf_id: `col_${prefix}_${index}`,
78
+ cf_name: el.title || el.ua || el.name,
79
+ cf_type: el.format || el.type,
80
+ cf_default: el.default,
81
+ cf_notnull: el.notnull,
82
+ object_id: table,
83
+ tablename: table,
84
+ };
85
+
86
+ data1.push({
87
+ name: obj.cf_id,
88
+ title: obj.cf_name,
89
+ format: obj.cf_type,
90
+ option: data[index]?.option,
91
+ hidden: data[index]?.hidden,
92
+ custom: true,
93
+ });
94
+
95
+ await dataInsert({
96
+ pg: client,
97
+ table: 'setting.custom_field',
98
+ data: obj,
99
+ uid,
100
+ });
101
+ }));
102
+
103
+ await client.query('delete from setting.custom_field where $1 in (tablename, object_id)', [table]);
104
+ await client.query('delete from setting.property where object_id=$1 and property_entity=$2', [table, entity]);
105
+
106
+ const data2 = JSON.stringify(data1?.filter((value, index, array) => array.indexOf(value) === index))?.replace(/'/g, "''");
107
+ const res = await dataInsert({
108
+ pg: client,
109
+ table: 'setting.property',
110
+ data: {
111
+ property_entity: 'customColumn',
112
+ object_id: table,
113
+ property_json: data2,
114
+ },
115
+ uid,
116
+ });
117
+ Object.assign(result, res);
118
+ }
119
+ await client.query('COMMIT');
120
+ return prepareResult(result);
121
+ } catch (err) {
122
+ await client.query('ROLLBACK');
123
+ return { error: err.toString(), status: 500 };
124
+ }
125
+ finally {
126
+ client.release();
127
+ }
128
+ };
@@ -1,7 +1,7 @@
1
1
  import { getMeta, getToken, pgClients } from '@opengis/fastify-table/utils.js';
2
2
 
3
3
  const galleryExtList = ['png', 'svg', 'jpg', 'jpeg', 'gif', 'mp4', 'mov', 'avi'];
4
- const username = `coalesce(u.sur_name,'')||coalesce(' '||u.user_name,'') ||coalesce(' '||u.father_name,'') as username`;
4
+ const username = `coalesce(u.sur_name,'')||coalesce(' '||u.user_name,'') ||coalesce(' '||u.father_name,'')`;
5
5
 
6
6
  /**
7
7
  * Дістає CRM для widget
@@ -85,6 +85,7 @@ export default async function widgetGet({
85
85
 
86
86
  const q = tableName && pg.pk['admin.users'] ? `select ${username} as author, u.login, a.cdate, a.editor_date from ${tableName} a
87
87
  left join admin.users u on a.uid=u.uid where a.${pk}=$1 limit 1` : undefined;
88
+
88
89
  const data = pk && q ? await pg.one(q, [objectid]) : {};
89
90
 
90
91
  if (query.debug && user?.user_type === 'admin') {
@@ -0,0 +1,20 @@
1
+ {
2
+ "login": {
3
+ "ru": "Логин",
4
+ "type": "Text",
5
+ "ua": "Логін"
6
+ },
7
+ "password": {
8
+ "ru": "Пароль",
9
+ "type": "Password",
10
+ "ua": "Пароль",
11
+ "validators": [
12
+ {
13
+ "flags": "gm",
14
+ "message": "Пароль повинен бути більше 8 символів",
15
+ "regexp": "^.{8,}$",
16
+ "type": "regexp"
17
+ }
18
+ ]
19
+ }
20
+ }