@opengis/admin 0.2.74 → 0.2.76
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-C6hbAhxE.js → add-page-CTy_NggO.js} +1 -1
- package/dist/{admin-interface-DhGbitPV.js → admin-interface-CfgzeOND.js} +77 -74
- package/dist/{admin-view-DNhhKVrA.js → admin-view-BAHi7pmQ.js} +5 -5
- package/dist/admin.js +1 -1
- package/dist/admin.umd.cjs +39 -39
- package/dist/{card-view-BPIFkAME.js → card-view-aAJYwQCe.js} +1 -1
- package/dist/{edit-page-DUjvZCQy.js → edit-page-DBOeMNPO.js} +1 -1
- package/dist/{import-file-DOALml4S.js → import-file-DbQlaJ6F.js} +2611 -2608
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/server/helpers/index.js +2 -0
- package/server/routes/print/controllers/cardPrint.js +28 -10
- package/server/templates/pt/card-print.pt.hbs +33 -8
@@ -5,8 +5,7 @@ import { fileURLToPath } from 'url';
|
|
5
5
|
import { createHash } from 'crypto';
|
6
6
|
|
7
7
|
import {
|
8
|
-
config, getTemplate, pgClients, handlebars,
|
9
|
-
metaFormat,
|
8
|
+
config, getTemplate, pgClients, handlebars, getFilterSQL, logger, metaFormat, getMeta,
|
10
9
|
} from '@opengis/fastify-table/utils.js';
|
11
10
|
import { grpc } from '@opengis/fastify-file/utils.js';
|
12
11
|
|
@@ -14,6 +13,14 @@ const { htmlToPdf } = grpc();
|
|
14
13
|
const filename = fileURLToPath(import.meta.url);
|
15
14
|
const dirname = path.dirname(filename);
|
16
15
|
|
16
|
+
// printMap
|
17
|
+
const host = 'https://data.gki.com.ua';
|
18
|
+
const width = 850;
|
19
|
+
const height = 400;
|
20
|
+
const geomBuffer = 0.001;
|
21
|
+
const layers = '';
|
22
|
+
const basemap = 'voyager';
|
23
|
+
|
17
24
|
export default async function cardPrint(req, reply) {
|
18
25
|
const { pg = pgClients.client, params = {}, query = {}, user = {} } = req;
|
19
26
|
const { table, id } = params;
|
@@ -40,6 +47,7 @@ export default async function cardPrint(req, reply) {
|
|
40
47
|
}
|
41
48
|
|
42
49
|
const body = await getTemplate('table', table);
|
50
|
+
const { geom } = await getMeta({ pg, table: body?.table });
|
43
51
|
|
44
52
|
if (!body?.table) {
|
45
53
|
return { message: 'table nof found', status: 404 };
|
@@ -56,7 +64,7 @@ export default async function cardPrint(req, reply) {
|
|
56
64
|
table,
|
57
65
|
query: where,
|
58
66
|
})
|
59
|
-
const { rows = [] } = await pg.query(`select * from (${optimizedSQL})q where ${where}`, [id]);
|
67
|
+
const { rows = [] } = await pg.query(`select * ${geom ? `, st_asgeojson(${geom})::json as geom` : ''} from (${optimizedSQL})q where ${where}`, [id]);
|
60
68
|
|
61
69
|
const cls = body?.columns?.filter(el => el.data)?.reduce((acc, curr) => Object.assign(acc, { [curr.name]: curr.data }), {});
|
62
70
|
await metaFormat({ rows, cls, sufix: false });
|
@@ -66,6 +74,12 @@ export default async function cardPrint(req, reply) {
|
|
66
74
|
return { message: 'data not found', status: 404 };
|
67
75
|
}
|
68
76
|
|
77
|
+
Object.assign(data, { id: data[body.key || pg.pk?.[body.table]] });
|
78
|
+
|
79
|
+
const mapUrl = `${host}/api-user/print-map?basemap=${basemap}&layers=${layers || ''}&geojson=${JSON.stringify(data['geom'])}&base64=1&height=${height}&width=${width}&buffer=${geomBuffer}&nocache=1`;
|
80
|
+
const resp = data['geom'] ? await fetch(mapUrl) : null;
|
81
|
+
const printMap = data['geom'] ? await resp.text() : '';
|
82
|
+
|
69
83
|
const pt = await getTemplate('pt', template)
|
70
84
|
|| await readFile(path.join(dirname, '../../../templates/pt/card-print.pt.hbs'), 'utf8');
|
71
85
|
|
@@ -73,14 +87,17 @@ export default async function cardPrint(req, reply) {
|
|
73
87
|
const qrCode = `<img src="${await qr.toDataURL(url, { type: 'png', ec_level: 'M', size: 5, margin: 4 })}" alt="qrcode">`;
|
74
88
|
|
75
89
|
const cardTemplates = await getTemplate('card', table);
|
76
|
-
const
|
77
|
-
?.reduce((acc, curr) => curr.items?.reduce?.((acc1, curr1) => Object.assign(acc, { [curr1.name]: curr1.title })), {});
|
90
|
+
const index = cardTemplates?.find(el => el[0] === 'index.yml')?.[1];
|
78
91
|
const cardHbsTabs = cardTemplates.filter(el => el[0].endsWith('hbs'));
|
79
92
|
|
80
|
-
const
|
81
|
-
|
82
|
-
|
83
|
-
|
93
|
+
const orderedTabs = index?.panels?.flatMap(panel => panel.items?.map(item => {
|
94
|
+
const body = cardHbsTabs.find(el => el[0] === `${item.name}.hbs`)?.[1];
|
95
|
+
return { ...item, body };
|
96
|
+
})).filter(el => el.name && el.body);
|
97
|
+
|
98
|
+
const tabData = await Promise.all(orderedTabs.map(async (el) => {
|
99
|
+
const html = await handlebars.compile(el.body.replace(/\{\{\{button[^\}]*\}\}\}/g, ''))(data);
|
100
|
+
return { name: el.name, title: el.title, html };
|
84
101
|
}));
|
85
102
|
|
86
103
|
const title = data?.[body.meta.title || ''];
|
@@ -89,6 +106,7 @@ export default async function cardPrint(req, reply) {
|
|
89
106
|
const obj = {
|
90
107
|
title,
|
91
108
|
table_title: body.ua || body.title,
|
109
|
+
printMap,
|
92
110
|
rows: tabData,
|
93
111
|
data: Object.keys(data).filter(el => columnTitles[el]).reduce((acc, curr) => Object.assign(acc, { [columnTitles[curr] || curr]: data[curr] }), {}),
|
94
112
|
rawData: data,
|
@@ -108,6 +126,6 @@ export default async function cardPrint(req, reply) {
|
|
108
126
|
// await mkdir(path.dirname(filepath), { recursive: true });
|
109
127
|
// await writeFile(filepath, buffer);
|
110
128
|
|
111
|
-
logger.file('
|
129
|
+
logger.file('cardPrint', { table, id, format, uid: user?.uid });
|
112
130
|
return reply.headers(headers).send(buffer);
|
113
131
|
}
|
@@ -1,14 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
<div style="display:flex; flex-direction: row; align-items: start; justify-content:space-between">
|
2
|
+
<div
|
3
|
+
style=" display: flex; flex-direction:column; text-align: center; align-items: center; justify-content: center; width:100%;">
|
4
|
+
{{#if table_title}}<h2 style="text-align: center;">{{table_title}}</h2>{{/if}}
|
5
|
+
{{#if title}}<h3>{{title}}</h3>{{/if}}
|
6
|
+
<p>{{formatDate 0 format="dd.mm.yy / hh:mi"}}</p>
|
7
|
+
</div>
|
8
|
+
<div class="qr-wrapper" style=" width:180px; height:180px;">{{{qr}}}</div>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="print-map">
|
12
|
+
{{{printMap}}}
|
13
|
+
</div>
|
14
|
+
|
4
15
|
{{#each rows}}
|
5
|
-
<
|
6
|
-
<
|
16
|
+
<div style="margin-bottom:30px">
|
17
|
+
<h3>{{title}}</h3>
|
18
|
+
<div>{{{html}}}</div>
|
19
|
+
</div>
|
20
|
+
|
7
21
|
{{/each}}
|
8
|
-
<div style="margin-top: 50px">
|
22
|
+
<div style="margin-top: 50px;">
|
9
23
|
<hr />
|
10
|
-
{{{url}}}
|
11
|
-
|
24
|
+
<div style="word-break: break-all;">{{{url}}}</div>
|
25
|
+
|
12
26
|
</div>
|
13
27
|
|
14
28
|
<style>
|
@@ -87,6 +101,12 @@
|
|
87
101
|
color: #374151;
|
88
102
|
}
|
89
103
|
|
104
|
+
div.bg-gray-200.text-center.p-6.rounded-xl h3 {
|
105
|
+
color: #374151;
|
106
|
+
font-weight: 400;
|
107
|
+
font-size: 14px;
|
108
|
+
}
|
109
|
+
|
90
110
|
button {
|
91
111
|
display: none;
|
92
112
|
}
|
@@ -118,6 +138,11 @@
|
|
118
138
|
border-radius: 4px;
|
119
139
|
}
|
120
140
|
|
141
|
+
.qr-wrapper img {
|
142
|
+
width: 100%;
|
143
|
+
object-fit: cover;
|
144
|
+
}
|
145
|
+
|
121
146
|
.text-sm {
|
122
147
|
font-size: 14px;
|
123
148
|
}
|