@opengis/admin 0.1.16 → 0.1.18
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.
- package/dist/{add-page-DU60zL6t.js → add-page-CUlt8lxo.js} +9 -9
- package/dist/admin-interface-DyDvpW7d.js +961 -0
- package/dist/{admin-view-CfY_rVQ4.js → admin-view-XOPkNJ7Q.js} +146 -113
- package/dist/admin.js +1 -1
- package/dist/admin.umd.cjs +41 -41
- package/dist/card-page-Bq1aDTDR.js +202 -0
- package/dist/{card-view-CwZPYXyJ.js → card-view-CNzIVhiE.js} +1 -1
- package/dist/{edit-page-C6mgpZBS.js → edit-page-tYDkGn_6.js} +21 -21
- package/dist/{import-file-C5Tvx4dB.js → import-file-BdX0j7UB.js} +24577 -24507
- package/dist/style.css +1 -1
- package/module/settings/card/admin.roles.table/access.hbs +26 -0
- package/module/settings/card/admin.roles.table/general_info.hbs +17 -0
- package/module/settings/card/admin.roles.table/index.yml +12 -0
- package/module/settings/card/admin.roles.table/users.hbs +31 -0
- package/module/settings/card/admin.routes.table/general_info.hbs +41 -0
- package/module/settings/card/admin.routes.table/index.yml +8 -0
- package/module/settings/card/admin.routes.table/users.hbs +28 -0
- package/module/settings/card/admin.users.table/general_info.hbs +25 -30
- package/module/settings/card/admin.users.table/index.yml +7 -2
- package/module/settings/card/admin.users.table/logs.hbs +31 -0
- package/module/settings/card/admin.users.table/user_roles.hbs +17 -18
- package/module/settings/form/admin.user_properties.form.json +16 -0
- package/module/settings/form/admin.users.form.json +146 -71
- package/module/settings/menu.json +13 -7
- package/module/settings/table/admin.properties.table.json +8 -7
- package/module/settings/table/admin.user_properties.table.json +29 -0
- package/module/settings/table/admin.users.table.json +92 -31
- package/package.json +3 -3
- package/plugin.js +10 -5
- package/server/plugins/hook.js +71 -4
- package/server/routes/menu/controllers/getMenu.js +2 -2
- package/server/routes/menu/index.mjs +2 -2
- package/server/routes/properties/controllers/admin.properties.get.js +29 -0
- package/server/routes/properties/controllers/admin.properties.post.js +26 -0
- package/server/routes/properties/controllers/user.properties.get.js +34 -0
- package/server/routes/properties/controllers/user.properties.post.js +30 -0
- package/server/routes/properties/funcs/getSettings.js +56 -0
- package/server/routes/properties/funcs/setSettings.js +44 -0
- package/server/routes/properties/funcs/utils/dataInsert.js +26 -0
- package/server/routes/properties/index.mjs +26 -0
- package/dist/admin-interface-gm773DzD.js +0 -919
- package/dist/card-page-ZWU3SEtH.js +0 -194
|
@@ -1,74 +1,146 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
2
|
+
"schema": {
|
|
3
|
+
"d1": {
|
|
4
|
+
"type": "HTML",
|
|
5
|
+
"title": false,
|
|
6
|
+
"text": "<h4 class='text-center'>Акаунт</h4><br>",
|
|
7
|
+
"col": 12
|
|
8
|
+
},
|
|
9
|
+
"user_name": {
|
|
10
|
+
"type": "Text",
|
|
11
|
+
"validators": [
|
|
12
|
+
"required"
|
|
13
|
+
],
|
|
14
|
+
"ua": "Ім'я",
|
|
15
|
+
"i": "Вноситься ім'я користувача, що буде відображатися у системі",
|
|
16
|
+
"ru": "Имя"
|
|
17
|
+
},
|
|
18
|
+
"sur_name": {
|
|
19
|
+
"type": "Text",
|
|
20
|
+
"validators": [
|
|
21
|
+
"required"
|
|
22
|
+
],
|
|
23
|
+
"ua": "Прізвище",
|
|
24
|
+
"i": "Вноситься прізвище користувача, що буде відображатися у системі",
|
|
25
|
+
"ru": "Фамилия"
|
|
26
|
+
},
|
|
27
|
+
"father_name": {
|
|
28
|
+
"ua": "По-батькові",
|
|
29
|
+
"type": "text"
|
|
30
|
+
},
|
|
31
|
+
"phone": {
|
|
32
|
+
"type": "MarkedText",
|
|
33
|
+
"mask": "+389999999999",
|
|
34
|
+
"id": "1",
|
|
35
|
+
"ua": "Телефон",
|
|
36
|
+
"i": "Вноситься телефон користувача",
|
|
37
|
+
"ru": "Телефон"
|
|
38
|
+
},
|
|
39
|
+
"email": {
|
|
40
|
+
"type": "Email",
|
|
41
|
+
"ua": "E-mail",
|
|
42
|
+
"i": "Вноситься електронна адреса користувача",
|
|
43
|
+
"ru": "E-mail"
|
|
44
|
+
},
|
|
45
|
+
"d2": {
|
|
46
|
+
"type": "HTML",
|
|
47
|
+
"title": false,
|
|
48
|
+
"text": "<h4 class='text-center'>Логін / Пароль</h4><br>",
|
|
49
|
+
"col": 12
|
|
50
|
+
},
|
|
51
|
+
"login": {
|
|
52
|
+
"type": "Text",
|
|
53
|
+
"validators": [
|
|
54
|
+
"required"
|
|
55
|
+
],
|
|
56
|
+
"ua": "Логін",
|
|
57
|
+
"i": "Вноситься довільний логін користувача латинськими літерами, що буде використовуватися для входу в систему",
|
|
58
|
+
"ru": "Логин"
|
|
59
|
+
},
|
|
60
|
+
"password": {
|
|
61
|
+
"type": "Password",
|
|
62
|
+
"validators": [
|
|
63
|
+
"required",
|
|
64
|
+
{
|
|
65
|
+
"type": "regexp",
|
|
66
|
+
"regexp": "^.{8,}$",
|
|
67
|
+
"flags": "gm",
|
|
68
|
+
"message": "Пароль повинен бути більше 8 символів"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"ua": "Пароль",
|
|
72
|
+
"i": "Вноситься пароль, що буде використовуватися для входу в систему (рекомендоване використання складних паролів)",
|
|
73
|
+
"ru": "Пароль"
|
|
74
|
+
},
|
|
75
|
+
"d3": {
|
|
76
|
+
"type": "HTML",
|
|
77
|
+
"title": false,
|
|
78
|
+
"text": "<h4 class='text-center'>Доступ</h4><br>",
|
|
79
|
+
"col": 12
|
|
80
|
+
},
|
|
81
|
+
"user_type": {
|
|
82
|
+
"type": "Autocomplete",
|
|
83
|
+
"data": "users.user_type",
|
|
84
|
+
"default": "regular",
|
|
85
|
+
"ua": "Тип користувача"
|
|
86
|
+
},
|
|
87
|
+
"enabled": {
|
|
88
|
+
"type": "Switcher",
|
|
89
|
+
"ua": "Off/On",
|
|
90
|
+
"help": "Off - користувач вимкнутий; On - Користувач увімкнутий"
|
|
91
|
+
},
|
|
92
|
+
"readonly": {
|
|
93
|
+
"type": "Switcher",
|
|
94
|
+
"ua": "Read Only",
|
|
95
|
+
"help": "On - У користувача усі інтерфейси в режимі перегляду, без редагування"
|
|
96
|
+
},
|
|
97
|
+
"d4": {
|
|
98
|
+
"type": "HTML",
|
|
99
|
+
"title": false,
|
|
100
|
+
"text": "<h4 class='text-center'>Профіль</h4><br>",
|
|
101
|
+
"col": 12
|
|
102
|
+
},
|
|
103
|
+
"user_rnokpp": {
|
|
104
|
+
"type": "MarkedText",
|
|
105
|
+
"mask": "9999999999",
|
|
106
|
+
"ua": "РНОКПП",
|
|
107
|
+
"col": 6,
|
|
108
|
+
"validators": [
|
|
109
|
+
{
|
|
110
|
+
"type": "regexp",
|
|
111
|
+
"regexp": "^([0-9]{10,10})$",
|
|
112
|
+
"flags": "g",
|
|
113
|
+
"message": "Лише цифри, 10 символів"
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
"organ_edrpou": {
|
|
118
|
+
"type": "MarkedText",
|
|
119
|
+
"mask": "99999999",
|
|
120
|
+
"ua": "Код ЄДРПОУ",
|
|
121
|
+
"col": 6,
|
|
122
|
+
"validators": [
|
|
123
|
+
{
|
|
124
|
+
"type": "regexp",
|
|
125
|
+
"regexp": "^([0-9]{8,8})$",
|
|
126
|
+
"flags": "g",
|
|
127
|
+
"message": "Лише цифри, 8 символів"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
},
|
|
131
|
+
"avatar": {
|
|
132
|
+
"type": "File",
|
|
133
|
+
"ua": "Аватар",
|
|
134
|
+
"i": "Додається зображення, що буде відображено в системі у якості аватара цього користувача",
|
|
135
|
+
"ru": "Аватар",
|
|
136
|
+
"dir": "avatar"
|
|
137
|
+
},
|
|
138
|
+
"groups": {
|
|
139
|
+
"title": false,
|
|
140
|
+
"type": "DataTable",
|
|
141
|
+
"ua": "Групи доступу",
|
|
142
|
+
"parent_id": "user_uid",
|
|
143
|
+
"table": "admin.user_roles",
|
|
72
144
|
"col": 12,
|
|
73
145
|
"colModel": [
|
|
74
146
|
{
|
|
@@ -86,5 +158,8 @@
|
|
|
86
158
|
"type": "DatePicker"
|
|
87
159
|
}
|
|
88
160
|
]
|
|
89
|
-
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
"label_style": "vertical",
|
|
164
|
+
"width": 900
|
|
90
165
|
}
|
|
@@ -5,12 +5,6 @@
|
|
|
5
5
|
"name": "administration",
|
|
6
6
|
"icon": "fa fa-cogs",
|
|
7
7
|
"menu": [
|
|
8
|
-
{
|
|
9
|
-
"path": "admin.properties",
|
|
10
|
-
"table": "admin.properties.table",
|
|
11
|
-
"ua": "Налаштування",
|
|
12
|
-
"en": "Settings"
|
|
13
|
-
},
|
|
14
8
|
{
|
|
15
9
|
"path": "admin.users",
|
|
16
10
|
"table": "admin.users.table",
|
|
@@ -20,7 +14,7 @@
|
|
|
20
14
|
{
|
|
21
15
|
"path": "admin.roles",
|
|
22
16
|
"table": "admin.roles.table",
|
|
23
|
-
"ua": "
|
|
17
|
+
"ua": "Ролі/Групи",
|
|
24
18
|
"en": "Roles"
|
|
25
19
|
},
|
|
26
20
|
{
|
|
@@ -28,6 +22,18 @@
|
|
|
28
22
|
"table": "admin.routes.table",
|
|
29
23
|
"ua": "Інтерфейси",
|
|
30
24
|
"en": "Routes"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "admin.properties",
|
|
28
|
+
"table": "admin.properties.table",
|
|
29
|
+
"ua": "Налаштування",
|
|
30
|
+
"en": "Settings"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"path": "admin.user_properties",
|
|
34
|
+
"table": "admin.user_properties.table",
|
|
35
|
+
"ua": "Налаштування користувача",
|
|
36
|
+
"en": "Settings"
|
|
31
37
|
}
|
|
32
38
|
]
|
|
33
39
|
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
+
"ua": "Налаштування",
|
|
3
|
+
"key": "property_id",
|
|
4
|
+
"form": "admin.properties.form",
|
|
5
|
+
"table": "admin.properties",
|
|
6
|
+
"order": "cdate desc",
|
|
7
|
+
"meta": {
|
|
8
|
+
"search": "property_key,property_text"
|
|
9
|
+
},
|
|
2
10
|
"columns": [
|
|
3
11
|
{
|
|
4
12
|
"name": "property_key",
|
|
@@ -11,13 +19,6 @@
|
|
|
11
19
|
"format": "text"
|
|
12
20
|
}
|
|
13
21
|
],
|
|
14
|
-
"ua": "Налаштування",
|
|
15
|
-
"form": "admin.properties.form",
|
|
16
|
-
"table": "admin.properties",
|
|
17
|
-
"order": "cdate desc",
|
|
18
|
-
"meta": {
|
|
19
|
-
"search": "property_key,property_text"
|
|
20
|
-
},
|
|
21
22
|
"filters": [
|
|
22
23
|
{
|
|
23
24
|
"ua": "Ключ",
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ua": "Налаштування користувача",
|
|
3
|
+
"key": "property_id",
|
|
4
|
+
"form": "admin.user_properties.form",
|
|
5
|
+
"table": "admin.user_properties",
|
|
6
|
+
"order": "cdate desc",
|
|
7
|
+
"meta": {
|
|
8
|
+
"search": "property_key"
|
|
9
|
+
},
|
|
10
|
+
"columns": [
|
|
11
|
+
{
|
|
12
|
+
"name": "property_key",
|
|
13
|
+
"title": "Ключ",
|
|
14
|
+
"format": "text"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "property_json",
|
|
18
|
+
"title": "Значення",
|
|
19
|
+
"format": "text"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"filters": [
|
|
23
|
+
{
|
|
24
|
+
"ua": "Ключ",
|
|
25
|
+
"name": "property_key",
|
|
26
|
+
"type": "text"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -1,65 +1,126 @@
|
|
|
1
1
|
{
|
|
2
|
+
"key": "uid",
|
|
2
3
|
"ua": "Користувачі",
|
|
3
|
-
"form": "admin.users.form",
|
|
4
4
|
"table": "admin.users",
|
|
5
|
+
"form": "admin.users.form",
|
|
5
6
|
"order": "cdate desc",
|
|
7
|
+
"action": [
|
|
8
|
+
"edit",
|
|
9
|
+
"del"
|
|
10
|
+
],
|
|
11
|
+
"meta": {
|
|
12
|
+
"title": "user_name",
|
|
13
|
+
"search": "sur_name,user_name,uid,father_name,email,phone,login"
|
|
14
|
+
},
|
|
6
15
|
"sql": [
|
|
7
16
|
{
|
|
8
|
-
"sql": "select
|
|
9
|
-
"name": "
|
|
17
|
+
"sql": "select count(*) as group_count from admin.user_group_rel where user_uid=t.uid",
|
|
18
|
+
"name": "group_count_sql"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"sql": "select concat(user_name, ' ', sur_name, ' ', father_name, ' ') as full_name",
|
|
22
|
+
"name": "full_name_sql"
|
|
10
23
|
},
|
|
11
24
|
{
|
|
12
|
-
"sql": "select
|
|
13
|
-
"name": "
|
|
25
|
+
"sql": "select string_agg(group_name,',') as groups from admin.user_group where user_group_id in (select user_group_id from admin.user_group_rel where user_uid=t.uid)",
|
|
26
|
+
"name": "group_list_sql"
|
|
14
27
|
}
|
|
15
28
|
],
|
|
16
29
|
"columns": [
|
|
17
30
|
{
|
|
31
|
+
"ua": "ПІБ",
|
|
18
32
|
"name": "full_name",
|
|
19
|
-
"format": "text"
|
|
20
|
-
"title": "ПІБ"
|
|
33
|
+
"format": "text"
|
|
21
34
|
},
|
|
22
35
|
{
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
36
|
+
"ua": "Логін",
|
|
37
|
+
"name": "login",
|
|
38
|
+
"format": "text"
|
|
26
39
|
},
|
|
27
40
|
{
|
|
41
|
+
"ua": "Email",
|
|
28
42
|
"name": "email",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
43
|
+
"hidden": true,
|
|
44
|
+
"format": "text"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"ua": "РНОКПП",
|
|
48
|
+
"name": "user_rnokpp",
|
|
49
|
+
"hidden": true,
|
|
50
|
+
"format": "text"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"ua": "Код ЄДРПОУ",
|
|
54
|
+
"name": "organ_edrpou",
|
|
55
|
+
"hidden": true,
|
|
56
|
+
"format": "text"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "group_count",
|
|
60
|
+
"ua": "Кількість груп",
|
|
61
|
+
"format": "text"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"name": "groups",
|
|
65
|
+
"ua": "Групи",
|
|
66
|
+
"hidden": true,
|
|
67
|
+
"format": "text"
|
|
31
68
|
},
|
|
32
69
|
{
|
|
33
70
|
"name": "cdate",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
71
|
+
"ua": "Створено",
|
|
72
|
+
"format": "date"
|
|
36
73
|
},
|
|
37
74
|
{
|
|
38
|
-
"name": "
|
|
39
|
-
"
|
|
40
|
-
"
|
|
75
|
+
"name": "editor_date",
|
|
76
|
+
"ua": "Дата останньої активності",
|
|
77
|
+
"format": "date"
|
|
41
78
|
},
|
|
42
79
|
{
|
|
43
80
|
"name": "enabled",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
81
|
+
"ua": "Вимикач",
|
|
82
|
+
"data": "yes_no",
|
|
83
|
+
"format": "select"
|
|
46
84
|
}
|
|
47
85
|
],
|
|
48
|
-
"
|
|
49
|
-
"title": "cdate",
|
|
50
|
-
"search": "login"
|
|
51
|
-
},
|
|
52
|
-
"filters": [
|
|
86
|
+
"filter_list": [
|
|
53
87
|
{
|
|
54
|
-
"ua": "
|
|
55
|
-
"name": "
|
|
56
|
-
"type": "
|
|
88
|
+
"ua": "РНОКПП",
|
|
89
|
+
"name": "user_rnokpp",
|
|
90
|
+
"type": "Text"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"ua": "Код ЄДРПОУ",
|
|
94
|
+
"name": "organ_edrpou",
|
|
95
|
+
"type": "Text"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"ua": "Email",
|
|
99
|
+
"name": "email",
|
|
100
|
+
"type": "Text"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"en": "Group",
|
|
104
|
+
"ua": "Група",
|
|
105
|
+
"name": "groups",
|
|
106
|
+
"type": "Text"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"en": "On/Off",
|
|
110
|
+
"ua": "On/Off",
|
|
111
|
+
"data": "enabled",
|
|
112
|
+
"name": "enabled",
|
|
113
|
+
"type": "Check"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"ua": "Дата створення",
|
|
117
|
+
"name": "cdate",
|
|
118
|
+
"type": "Date"
|
|
57
119
|
},
|
|
58
120
|
{
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"type": "check"
|
|
121
|
+
"name": "editor_date",
|
|
122
|
+
"type": "Date",
|
|
123
|
+
"ua": "Дата останньої активності"
|
|
63
124
|
}
|
|
64
125
|
]
|
|
65
126
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengis/admin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "This project Softpro Admin",
|
|
5
5
|
"main": "dist/admin.js",
|
|
6
6
|
"type": "module",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@opengis/fastify-auth": "^1.0.20",
|
|
35
35
|
"@opengis/fastify-file": "^1.0.17",
|
|
36
|
-
"@opengis/fastify-table": "^1.1.
|
|
36
|
+
"@opengis/fastify-table": "^1.1.16",
|
|
37
37
|
"@opengis/v3-core": "^0.1.92",
|
|
38
38
|
"@opengis/v3-filter": "^0.0.31",
|
|
39
39
|
"@turf/turf": "^7.1.0",
|
|
@@ -63,4 +63,4 @@
|
|
|
63
63
|
"vitepress-plugin-tabs": "^0.5.0",
|
|
64
64
|
"vitepress-sidebar": "^1.22.0"
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
}
|
package/plugin.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import fp from 'fastify-plugin';
|
|
1
2
|
import config from './config.js';
|
|
2
3
|
config.prefix = config.prefix || '/api'
|
|
3
|
-
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
async function plugin(fastify, opts = config) {
|
|
4
7
|
// const prefix = config.prefix || '/api';
|
|
5
8
|
|
|
6
9
|
// core
|
|
7
10
|
|
|
8
11
|
|
|
9
|
-
fastify.register(import('./server/helpers/index.mjs'),
|
|
12
|
+
fastify.register(import('./server/helpers/index.mjs'), opts);
|
|
10
13
|
// fastify.register(import('@opengis/fastify-auth'), config);
|
|
11
14
|
|
|
12
15
|
// fastify.register(import('./server/plugins/vike.js'));
|
|
@@ -14,8 +17,10 @@ export default async function (fastify, opts) {
|
|
|
14
17
|
|
|
15
18
|
// API
|
|
16
19
|
|
|
17
|
-
fastify.register(import('./server/routes/
|
|
18
|
-
fastify.register(import('./server/routes/
|
|
19
|
-
fastify.register(import('./server/routes/
|
|
20
|
+
fastify.register(import('./server/routes/properties/index.mjs'), opts);
|
|
21
|
+
fastify.register(import('./server/routes/templates/index.mjs'), opts);
|
|
22
|
+
fastify.register(import('./server/routes/menu/index.mjs'), opts);
|
|
23
|
+
fastify.register(import('./server/routes/data/index.mjs'), opts);
|
|
20
24
|
|
|
21
25
|
}
|
|
26
|
+
export default fp(plugin)
|
package/server/plugins/hook.js
CHANGED
|
@@ -1,18 +1,85 @@
|
|
|
1
1
|
import fp from 'fastify-plugin';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
2
4
|
|
|
3
|
-
import
|
|
4
|
-
import path from 'path'
|
|
5
|
-
|
|
6
|
-
import config from '../../config.js';
|
|
5
|
+
import { userTemplateDir, getTemplate, pgClients } from '@opengis/fastify-table/utils.js';
|
|
7
6
|
|
|
7
|
+
import getMenu from '../routes/menu/controllers/getMenu.js';
|
|
8
8
|
|
|
9
|
+
import config from '../../config.js';
|
|
9
10
|
|
|
10
11
|
// to export the decorators to the outer scope
|
|
11
12
|
|
|
12
13
|
async function plugin(fastify) {
|
|
13
14
|
fastify.decorate('config', config);
|
|
14
15
|
|
|
16
|
+
fastify.addHook('onListen', async () => {
|
|
17
|
+
const { client } = pgClients;
|
|
18
|
+
const json = await getMenu();
|
|
19
|
+
// insert interface list to db (user access management)
|
|
20
|
+
if (client?.pk?.['admin.routes'] && json?.length) {
|
|
21
|
+
const menuList = json.filter((el) => el?.menu?.length && el?.ua || el?.en || el?.name);
|
|
22
|
+
const interfaces = menuList.reduce((acc, curr) => { curr.menu.forEach((el) => acc.push(el.path)); return acc; }, []);
|
|
23
|
+
await client.query('update admin.routes set enabled=false where not array[route_id] <@ $1::text[]', [interfaces]);
|
|
24
|
+
|
|
25
|
+
const q = `insert into admin.menu(name, ord) values${
|
|
26
|
+
menuList.map((el, i) => `('${(el?.ua || el?.en || el?.name).replace(/'/g, '’')}', ${i}) `).join(',')
|
|
27
|
+
} on conflict (name) do update set ord=excluded.ord, enabled=true returning name, menu_id`;
|
|
28
|
+
const { rows = [] } = await client.query(q);
|
|
29
|
+
await client.query('update admin.menu set enabled=false where not array[menu_id] <@ $1::text[]', [rows.map((el) => el.menu_id)]);
|
|
30
|
+
|
|
31
|
+
const menus = rows.reduce((acc, curr) => Object.assign(acc, { [curr.menu_id]: menuList.find((item) => (item?.ua || item?.en || item?.name) === curr.name) }), {});
|
|
32
|
+
const values = Object.entries(menus).reduce((acc, curr) => { curr[1]?.menu?.forEach((el) => acc.push({ ...el, menuId: curr[0] })); return acc; }, []);
|
|
33
|
+
|
|
34
|
+
await Promise.all(values.filter((el) => el?.table).map(async (el) => Object.assign(el, { table: (await getTemplate('table', el.table))?.table || el.table })));
|
|
35
|
+
|
|
36
|
+
const q1 = `insert into admin.routes(route_id, alias, title, menu_id, table_name) values ${values.map((el) => `('${el.path}', '${el.path}', '${el.title}', '${el.menuId}', '${el.table}')`).join(',')}
|
|
37
|
+
on conflict (route_id) do update set menu_id=excluded.menu_id, title=excluded.title, enabled=true,
|
|
38
|
+
table_name=excluded.table_name returning route_id, table_name`;
|
|
39
|
+
try {
|
|
40
|
+
const { rowCount } = await client.query(q1);
|
|
41
|
+
console.log('interface insert ok', values, rowCount);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
console.log('interface insert error', values, q1, err);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
15
47
|
|
|
48
|
+
fastify.addHook('onListen', async () => {
|
|
49
|
+
const { client: pg } = pgClients;
|
|
50
|
+
const clsQuery = [];
|
|
51
|
+
if (!pg.pk?.['admin.cls']) return;
|
|
52
|
+
|
|
53
|
+
const cls = ['cls', 'select']
|
|
54
|
+
.filter((el) => fs.existsSync(`${userTemplateDir[0]}/${el}`))
|
|
55
|
+
.map((el) => fs.readdirSync(`${userTemplateDir[0]}/${el}`).filter((item) => el === 'cls' ? true : path.extname(item) === '.sql'))
|
|
56
|
+
.reduce((acc, curr) => { curr?.forEach((el) => acc.push(el)); return acc; }, []);
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
await Promise.all(cls.map(async (el) => {
|
|
60
|
+
const { ext, name } = path.parse(el);
|
|
61
|
+
const type = { '.json': 'cls', '.sql': 'select' }[ext];
|
|
62
|
+
const loadTemplate = await getTemplate(type, name);
|
|
63
|
+
console.log(name, type);
|
|
64
|
+
if (type === 'select') {
|
|
65
|
+
clsQuery.push(`insert into admin.cls(name,type,data) values('${name}','sql','${(loadTemplate?.sql || loadTemplate)?.replace(/'/g, "''")}')`);
|
|
66
|
+
} else if (type === 'cls') {
|
|
67
|
+
clsQuery.push(`insert into admin.cls(name,type) values('${name}','json');
|
|
68
|
+
insert into admin.cls(code,name,parent,icon)
|
|
69
|
+
select value->>'id',value->>'text','${name}',value->>'icon'
|
|
70
|
+
from json_array_elements('${JSON.stringify(loadTemplate).replace(/'/g, "''")}'::json)`);
|
|
71
|
+
}
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
await pg.query('truncate admin.cls');
|
|
75
|
+
if (clsQuery.filter((el) => el).length) {
|
|
76
|
+
await pg.query(clsQuery.filter((el) => el).join(';'));
|
|
77
|
+
console.log('cls insert ok', clsQuery?.length);
|
|
78
|
+
}
|
|
79
|
+
} catch (err) {
|
|
80
|
+
console.error('cls insert error', err.toString());
|
|
81
|
+
}
|
|
82
|
+
});
|
|
16
83
|
|
|
17
84
|
// pre Request
|
|
18
85
|
fastify.addHook('onRequest', async (req) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { join } from 'path';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { userTemplateDir } from '@opengis/fastify-table/utils.js';
|
|
4
|
+
|
|
5
5
|
import { existsSync, readdirSync, readFileSync } from 'fs';
|
|
6
6
|
const menuCache = [];
|
|
7
7
|
// check module dir
|