@opengis/admin 0.2.125 → 0.2.127
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/package.json
CHANGED
package/server/plugins/hook.js
CHANGED
@@ -89,14 +89,14 @@ export default async function plugin(fastify) {
|
|
89
89
|
printTemplates[el[0]] = settings;
|
90
90
|
});
|
91
91
|
if (client?.pk?.['admin.templates']) {
|
92
|
-
const arr = Object.keys(printTemplates || {}).map(el => ({ name: el, ...printTemplates?.[el] || {} }));
|
92
|
+
const arr = Object.keys(printTemplates || {}).map(el => ({ name: el, ...printTemplates?.[el] || {} })).filter(el => el.name && el.route && el.html);
|
93
93
|
|
94
94
|
const { rowsCount = 0 } = await pgClients.client.query(`delete from admin.templates where not (name=any($1::text[])) and type = 'demo'`, [arr.map(el => el.name)]);
|
95
95
|
console.log('delete deprecated templates', 'ok', rowsCount);
|
96
96
|
const { rowsCount: empty = 0 } = await pgClients.client.query('delete from admin.templates where body is null');
|
97
97
|
console.log('delete empty templates', 'ok', empty);
|
98
98
|
|
99
|
-
const q = arr.map(el => `insert into admin.templates(name, route_id, title, type, body) values ('${el.name.replace(/'/g, "''")}', '${el.route.replace(/'/g, "''")}', '${el.title.replace(/'/g, "''")}', 'demo', '${(el.html || '').replace(/'/g, "''")}') on conflict(name, type) do update set route_id=excluded.route_id, title=excluded.title`).join(';');
|
99
|
+
const q = arr.map(el => `insert into admin.templates(name, route_id, title, type, body) values ('${el.name.replace(/'/g, "''")}', '${el.route.replace(/'/g, "''")}', '${(el.title || el.name).replace(/'/g, "''")}', 'demo', '${(el.html || '').replace(/'/g, "''")}') on conflict(name, type) do update set route_id=excluded.route_id, title=excluded.title`).join(';');
|
100
100
|
const res = await pgClients.client.query(q);
|
101
101
|
console.log('insert print templates', 'ok', (Array.isArray(res) ? res : [res]).length);
|
102
102
|
}
|
@@ -65,6 +65,7 @@ export default async function getCardData(req) {
|
|
65
65
|
.filter(key => index?.tokens[key]?.public
|
66
66
|
|| access.actions?.includes?.('edit')
|
67
67
|
|| access.actions?.includes?.('add')
|
68
|
+
|| !index?.tokens[key]?.table
|
68
69
|
)
|
69
70
|
.forEach(key => {
|
70
71
|
const item = index?.tokens[key];
|
@@ -36,7 +36,7 @@ export default async function adminMenu({ user = {}, session, pg = pgClients.cli
|
|
36
36
|
|
37
37
|
// update user access
|
38
38
|
|
39
|
-
if (session && user?.uid && !
|
39
|
+
if (session && user?.uid && !user.user_type?.includes?.('admin') && !user.type?.includes?.('admin') && pg.pk['admin.role_access']) {
|
40
40
|
const { type, gl = [], routes = [] } = await pg.query(`select user_type as type, b.gl,routes from admin.users a
|
41
41
|
left join lateral (
|
42
42
|
select array_agg(role_id) as gl from admin.user_roles
|