@opengis/gis 0.2.174 → 0.2.176
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/README.md +181 -181
- package/dist/{CardIcon-Cg8bUM4G.js → CardIcon-c1Q2M3wQ.js} +1 -1
- package/dist/{EntityTablePage-DHQGlLRk.js → EntityTablePage-B5gpkH4S.js} +2 -2
- package/dist/{ExtentOutlineLayer.vue_vue_type_script_setup_true_lang-BIL1ocLY.js → ExtentOutlineLayer.vue_vue_type_script_setup_true_lang-DnGSvmMU.js} +1 -1
- package/dist/{HeaderActions.vue_vue_type_script_setup_true_lang-Buff9gTO.js → HeaderActions.vue_vue_type_script_setup_true_lang-C2B61JP6.js} +1 -1
- package/dist/{MapSettings-De-z7r5t.js → MapSettings-6-Xru5Q8.js} +2 -2
- package/dist/{RastersTablePage-Cdgkri9K.js → RastersTablePage-CXNOcTy-.js} +2 -2
- package/dist/{cartocss-BT50SVhy.js → cartocss-BFVqWvfP.js} +6 -6
- package/dist/{import-utils-CMWiuRPp.js → import-utils-uxk4LdUJ.js} +1 -1
- package/dist/{index-CHFLgCGW.js → index-CahlV-Xs.js} +39 -39
- package/dist/index.css +1 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.cjs +19 -19
- package/dist/{raster-dSEb1SIG.js → raster-CEi56f0P.js} +3 -3
- package/dist/{register-D7Puupgo.js → register-NFAGBNa3.js} +3 -3
- package/dist/{service-Cz6T0O3Z.js → service-BYspag8U.js} +829 -832
- package/dist/{vs-datatable-DqVncrSg.js → vs-datatable-CHcBr6zy.js} +2 -2
- package/module/gis/cls/service_type.json +42 -42
- package/module/gis/form/gis.registers.form.json +4 -1
- package/module/test/map/addr.json +302 -302
- package/module/test/map/addr1.yml +23 -23
- package/module/test/select/address.str_id.sql +3 -3
- package/package.json +77 -77
- package/plugin.js +64 -64
- package/server/migrations/array_intersect.sql +13 -13
- package/server/migrations/cartocss.sql +27 -27
- package/server/migrations/group_list.sql +74 -74
- package/server/migrations/maps.sql +30 -30
- package/server/migrations/metadata.sql +415 -415
- package/server/migrations/ogc.sql +106 -106
- package/server/migrations/rasters.sql +265 -265
- package/server/migrations/services.sql +247 -247
- package/server/migrations/services_users_rel.sql +22 -22
- package/server/migrations/widgets.sql +20 -20
- package/server/plugins/crons.js +21 -21
- package/server/plugins/mapnik/funcs/checkRasterFile.js +107 -107
- package/server/plugins/mapnik/funcs/mapnik.js +151 -151
- package/server/plugins/mapnik/funcs/rootFolder.mjs +8 -8
- package/server/plugins/mapnik/map.proto +437 -437
- package/server/plugins/vite.js +74 -74
- package/server/routes/cartocss/cartocss.route.js +31 -31
- package/server/routes/cartocss/cartocss.route.test.js +78 -78
- package/server/routes/cartocss/cartocss.schema.js +73 -73
- package/server/routes/cartocss/functions/add.cartocss.js +39 -39
- package/server/routes/cartocss/functions/get.cartocss.js +57 -57
- package/server/routes/gis/functions/checkXML.js +107 -107
- package/server/routes/gis/functions/dashboard.js +24 -24
- package/server/routes/gis/gis.route.js +26 -26
- package/server/routes/gis/gis.route.test.js +33 -33
- package/server/routes/map/functions/clearTiles.js +35 -35
- package/server/routes/map/functions/geojson.js +187 -187
- package/server/routes/map/functions/gis.convert.js +65 -65
- package/server/routes/map/functions/gis.icon.js +220 -220
- package/server/routes/map/functions/jsonData.js +206 -206
- package/server/routes/map/functions/layerList.js +102 -102
- package/server/routes/map/functions/map.js +122 -122
- package/server/routes/map/functions/mapCatalog.js +72 -72
- package/server/routes/map/functions/mapCatalogAttribute.js +53 -53
- package/server/routes/map/functions/mapFeatures.js +133 -133
- package/server/routes/map/functions/mapFormat.js +232 -231
- package/server/routes/map/functions/mapTiles.js +162 -162
- package/server/routes/map/functions/maps.js +15 -15
- package/server/routes/map/functions/marker_icon.js +43 -43
- package/server/routes/map/functions/parseGeoFile.js +85 -85
- package/server/routes/map/functions/pointHeight.js +51 -51
- package/server/routes/map/functions/vtile.js +174 -174
- package/server/routes/map/functions/vtile1.js +185 -185
- package/server/routes/map/map.route.js +280 -280
- package/server/routes/map/map.route.test.js +503 -503
- package/server/routes/map/map.schema.js +356 -356
- package/server/routes/map/pin/circle1.svg +76 -76
- package/server/routes/map/pin/circle2.svg +18 -18
- package/server/routes/map/pin/none.svg +12 -12
- package/server/routes/map/pin/pin.svg +14 -14
- package/server/routes/map/pin/pin1.svg +16 -16
- package/server/routes/map/pin/pin2.svg +7 -7
- package/server/routes/map/pin/pin3.svg +34 -34
- package/server/routes/map/pin/pin4.svg +14 -14
- package/server/routes/map/pin/pin5.svg +7 -7
- package/server/routes/map/pin/pin6.svg +12 -12
- package/server/routes/map/pin/pin7.svg +12 -12
- package/server/routes/mapnik/functions/cartoBounds.js +32 -32
- package/server/routes/mapnik/functions/clearTiles.js +103 -103
- package/server/routes/mapnik/functions/convertBoundToTile.js +27 -27
- package/server/routes/mapnik/functions/createXml.js +76 -76
- package/server/routes/mapnik/functions/createXmlMulti.js +72 -72
- package/server/routes/mapnik/functions/fileSearch.js +35 -35
- package/server/routes/mapnik/functions/fileStat.js +28 -28
- package/server/routes/mapnik/functions/pretile.js +138 -138
- package/server/routes/mapnik/functions/rasterInfo.js +66 -66
- package/server/routes/mapnik/functions/readDir.js +22 -22
- package/server/routes/mapnik/functions/rtile.js +164 -164
- package/server/routes/mapnik/functions/uploadRaster.js +152 -152
- package/server/routes/mapnik/functions/uploadXML.js +140 -140
- package/server/routes/mapnik/mapnik.route.js +102 -102
- package/server/routes/mapnik/mapnik.route.test.js +370 -370
- package/server/routes/mapnik/mapnik.schema.mjs +195 -195
- package/server/routes/mapnik.prefixless/functions/mapnikLogger.js +31 -31
- package/server/routes/mapnik.prefixless/functions/mapnikStat.js +21 -21
- package/server/routes/mapnik.prefixless/mapnik.prefixless.route.js +20 -20
- package/server/routes/mapnik.prefixless/mapnik.prefixless.route.test.js +91 -91
- package/server/routes/mapnik.prefixless/mapnik.prefixless.schema.mjs +27 -27
- package/server/routes/maps/functions/add.map.js +42 -42
- package/server/routes/maps/functions/del.map.js +17 -17
- package/server/routes/maps/functions/get.map.js +119 -119
- package/server/routes/maps/maps.route.js +58 -58
- package/server/routes/maps/maps.route.test.js +231 -231
- package/server/routes/maps/maps.schema.js +9 -9
- package/server/routes/metadata/functions/editMetadata.js +35 -35
- package/server/routes/metadata/functions/metadataXML.js +19 -19
- package/server/routes/metadata/metadata.route.js +26 -26
- package/server/routes/metadata/metadata.route.test.js +46 -46
- package/server/routes/metadata/metadata.schema.js +53 -53
- package/server/routes/ogc/functions/map.info.point.js +117 -117
- package/server/routes/ogc/ogc.route.js +21 -21
- package/server/routes/ogc/ogc.route.test.js +53 -53
- package/server/routes/ogc/ogc.schema.js +16 -16
- package/server/routes/permissions/functions/catalog.permissions.edit.js +20 -20
- package/server/routes/permissions/functions/catalog.permissions.js +12 -12
- package/server/routes/permissions/functions/get.permissions.js +59 -59
- package/server/routes/permissions/functions/gis.catalog.js +80 -80
- package/server/routes/permissions/permissions.route.js +35 -35
- package/server/routes/permissions/permissions.route.test.js +35 -35
- package/server/routes/permissions/permissions.schema.js +43 -43
- package/server/routes/registers/functions/add.registry.js +37 -37
- package/server/routes/registers/functions/classifiers.js +100 -100
- package/server/routes/registers/functions/columns.js +3 -3
- package/server/routes/registers/functions/content.type.js +9 -9
- package/server/routes/registers/functions/del.registry.js +14 -14
- package/server/routes/registers/functions/get.info.js +93 -93
- package/server/routes/registers/functions/gis.export.js +159 -159
- package/server/routes/registers/functions/gis.registry.js +71 -71
- package/server/routes/registers/functions/gis.registry.list.js +61 -61
- package/server/routes/registers/functions/handleRegistryRequest.js +147 -147
- package/server/routes/registers/functions/map.registry.js +87 -87
- package/server/routes/registers/registers.route.js +80 -80
- package/server/routes/registers/registers.route.test.js +144 -144
- package/server/routes/registers/registers.schema.js +246 -246
- package/server/routes/root.mjs +3 -3
- package/server/routes/services/functions/add.service.js +62 -62
- package/server/routes/services/functions/create.route.js +93 -93
- package/server/routes/services/functions/del.service.js +12 -12
- package/server/routes/services/functions/get.layer.geom.js +27 -27
- package/server/routes/services/functions/get.service.users.js +76 -76
- package/server/routes/services/functions/get.services.col.js +34 -34
- package/server/routes/services/functions/get.services.js +89 -89
- package/server/routes/services/functions/legend.auto.js +77 -77
- package/server/routes/services/services.route.js +76 -76
- package/server/routes/services/services.route.test.js +167 -167
- package/server/routes/services/services.schema.js +278 -278
- package/server/routes/widgets/functions/add.widget.js +38 -38
- package/server/routes/widgets/functions/del.widget.js +17 -17
- package/server/routes/widgets/functions/get.widget.js +41 -41
- package/server/routes/widgets/widgets.route.js +61 -61
- package/server/routes/widgets/widgets.route.test.js +144 -144
- package/server/routes/widgets/widgets.schema.js +24 -24
- package/server/shared/listFiles.js +15 -0
- package/utils.js +13 -13
|
@@ -1,147 +1,147 @@
|
|
|
1
|
-
import { getMeta, getFilterSQL, metaFormat, getFilterSQLParametrized } from "@opengis/fastify-table/utils.js";
|
|
2
|
-
import { populateFilterOptions } from './classifiers.js';
|
|
3
|
-
import { extractVisibleColumns } from './columns.js';
|
|
4
|
-
|
|
5
|
-
const columnType = {
|
|
6
|
-
text: 'text',
|
|
7
|
-
date: 'date',
|
|
8
|
-
bool: 'yes/no',
|
|
9
|
-
numeric: 'number',
|
|
10
|
-
integer: 'number',
|
|
11
|
-
'timestamp without time zone': 'date',
|
|
12
|
-
'timestamp with time zone': 'date',
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// eslint-disable-next-line import/prefer-default-export
|
|
16
|
-
export async function handleRegistryRequest({
|
|
17
|
-
settings, query, object_id, offset = 0, limit = 16, page = 1, pg, sql,
|
|
18
|
-
}) {
|
|
19
|
-
const {
|
|
20
|
-
name, table_name, description, card, columns, filters, query: whereQuery, pk,
|
|
21
|
-
register_id, view, order, is_downloadable, register_key, is_map, is_register, service_id, is_files,
|
|
22
|
-
} = settings;
|
|
23
|
-
const parsedColumns = Array.isArray(columns) ? columns : JSON.parse(columns);
|
|
24
|
-
const parsedCardColumns = Array.isArray(card) ? card : JSON.parse(card);
|
|
25
|
-
const filtersParsed = Array.isArray(filters) ? filters : JSON.parse(filters);
|
|
26
|
-
const activeFilters = (filtersParsed || []).filter((f) => f.disabled !== true).map(el => ({
|
|
27
|
-
...el, id: el.name || el.id, type: el.type, api: `/api/suggest/${table_name}:${el.name}${el.data ? `?sel=${el.data}` : ''}`,
|
|
28
|
-
}));
|
|
29
|
-
const { columns: fields1, geom } = await getMeta({ pg, table: table_name });
|
|
30
|
-
|
|
31
|
-
const fields = fields1?.map?.(({ name, dataTypeID, title }) => ({ name, type: columnType[pg.pgType?.[dataTypeID] || 'text'] || 'text', label: title || name }));
|
|
32
|
-
|
|
33
|
-
const mode = object_id ? "card" : "table";
|
|
34
|
-
const visibleColumns = (mode === 'card' && parsedCardColumns?.length) ? parsedCardColumns : extractVisibleColumns(parsedColumns, mode);
|
|
35
|
-
const selectColumns = visibleColumns.map((col) => col.name);
|
|
36
|
-
/* const columnsInfo = visibleColumns.map((col) => ({
|
|
37
|
-
name: col.name,
|
|
38
|
-
ua: col.ua,
|
|
39
|
-
format: col.format,
|
|
40
|
-
data: col.data,
|
|
41
|
-
view_type: col.view_type
|
|
42
|
-
})); */
|
|
43
|
-
|
|
44
|
-
const classifiers = visibleColumns
|
|
45
|
-
.filter((col) => col.data && ["select", "badge", "tags"].includes(col.format))
|
|
46
|
-
.reduce((acc, curr) => ({ ...acc, [curr.name]: curr.data }), {});
|
|
47
|
-
|
|
48
|
-
if (object_id) {
|
|
49
|
-
const sql = `
|
|
50
|
-
SELECT "${pk}" as id,* ${selectColumns.length ? `, ${selectColumns.join(", ")}` : ''} ${geom ? `, st_asgeojson(${geom})::json as geom` : ''}
|
|
51
|
-
FROM ${table_name}
|
|
52
|
-
WHERE ${pk} = $1
|
|
53
|
-
`;
|
|
54
|
-
const rows = await pg.query(sql, [object_id]).then(el => el.rows || []);
|
|
55
|
-
if (!rows.length) throw new Error('Object not found');
|
|
56
|
-
|
|
57
|
-
await metaFormat({
|
|
58
|
-
rows, table: table_name, cls: classifiers, sufix: true,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
row: rows[0],
|
|
63
|
-
card,
|
|
64
|
-
d: 1,
|
|
65
|
-
columns: visibleColumns,
|
|
66
|
-
is_downloadable,
|
|
67
|
-
register_key,
|
|
68
|
-
register_id,
|
|
69
|
-
service_id,
|
|
70
|
-
name,
|
|
71
|
-
is_files,
|
|
72
|
-
is_map,
|
|
73
|
-
is_register,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const { search, filter } = query || {};
|
|
78
|
-
const { q: sqlFilter, args = [] } = (filter || search)
|
|
79
|
-
? await getFilterSQLParametrized({
|
|
80
|
-
table: table_name,
|
|
81
|
-
search,
|
|
82
|
-
filter,
|
|
83
|
-
filterList: activeFilters,
|
|
84
|
-
})
|
|
85
|
-
: { q: '1=1', args: [] };
|
|
86
|
-
|
|
87
|
-
const whereConditions = [whereQuery, sqlFilter].filter(Boolean).join(' AND ');
|
|
88
|
-
|
|
89
|
-
const sqlBase = `FROM ${table_name} WHERE ${whereConditions || 'true'}`;
|
|
90
|
-
const sqlOrder = order ? `ORDER BY ${order}` : "";
|
|
91
|
-
const sqlLimit = `LIMIT $${args.length + 1}::bigint OFFSET $${args.length + 2}::bigint`;
|
|
92
|
-
|
|
93
|
-
const sqlSelect = `SELECT "${pk}" as id ${selectColumns.length ? `, ${selectColumns.join(", ")}` : ''} ${geom ? `, st_asgeojson(${geom})::json as geom` : ''} ${sqlBase}`;
|
|
94
|
-
const dataQuery = `${sqlSelect} ${sqlOrder} ${sqlLimit}`;
|
|
95
|
-
|
|
96
|
-
if (sql) return dataQuery;
|
|
97
|
-
|
|
98
|
-
const rows = await pg.query(dataQuery, args.concat([limit, offset])).then(el => el.rows || []);
|
|
99
|
-
const total = await pg.query(`SELECT COUNT(*) ${sqlBase}`, args).then(el => +(el.rows[0]?.count || 0));
|
|
100
|
-
|
|
101
|
-
await metaFormat({
|
|
102
|
-
rows, table: table_name, cls: classifiers, sufix: true,
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
const listConfig = {};
|
|
106
|
-
|
|
107
|
-
if (parsedColumns?.length) {
|
|
108
|
-
for (const col of parsedColumns) {
|
|
109
|
-
if (col.view_type === 'title') listConfig.title = col.name;
|
|
110
|
-
if (col.view_type === 'subtitle') listConfig.subtitle = col.name;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
await populateFilterOptions({
|
|
115
|
-
pg,
|
|
116
|
-
table: table_name,
|
|
117
|
-
filters: activeFilters,
|
|
118
|
-
columns,
|
|
119
|
-
whereConditions,
|
|
120
|
-
args
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
total,
|
|
125
|
-
limit,
|
|
126
|
-
page,
|
|
127
|
-
register_id,
|
|
128
|
-
name,
|
|
129
|
-
card,
|
|
130
|
-
table_name,
|
|
131
|
-
register_key,
|
|
132
|
-
description,
|
|
133
|
-
rows,
|
|
134
|
-
service_id,
|
|
135
|
-
columns: visibleColumns,
|
|
136
|
-
filters: activeFilters,
|
|
137
|
-
fields,
|
|
138
|
-
view,
|
|
139
|
-
is_downloadable,
|
|
140
|
-
is_map,
|
|
141
|
-
is_register,
|
|
142
|
-
is_files,
|
|
143
|
-
config: {
|
|
144
|
-
listConfig,
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
}
|
|
1
|
+
import { getMeta, getFilterSQL, metaFormat, getFilterSQLParametrized } from "@opengis/fastify-table/utils.js";
|
|
2
|
+
import { populateFilterOptions } from './classifiers.js';
|
|
3
|
+
import { extractVisibleColumns } from './columns.js';
|
|
4
|
+
|
|
5
|
+
const columnType = {
|
|
6
|
+
text: 'text',
|
|
7
|
+
date: 'date',
|
|
8
|
+
bool: 'yes/no',
|
|
9
|
+
numeric: 'number',
|
|
10
|
+
integer: 'number',
|
|
11
|
+
'timestamp without time zone': 'date',
|
|
12
|
+
'timestamp with time zone': 'date',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
16
|
+
export async function handleRegistryRequest({
|
|
17
|
+
settings, query, object_id, offset = 0, limit = 16, page = 1, pg, sql,
|
|
18
|
+
}) {
|
|
19
|
+
const {
|
|
20
|
+
name, table_name, description, card, columns, filters, query: whereQuery, pk,
|
|
21
|
+
register_id, view, order, is_downloadable, register_key, is_map, is_register, service_id, is_files,
|
|
22
|
+
} = settings;
|
|
23
|
+
const parsedColumns = Array.isArray(columns) ? columns : JSON.parse(columns);
|
|
24
|
+
const parsedCardColumns = Array.isArray(card) ? card : JSON.parse(card);
|
|
25
|
+
const filtersParsed = Array.isArray(filters) ? filters : JSON.parse(filters);
|
|
26
|
+
const activeFilters = (filtersParsed || []).filter((f) => f.disabled !== true).map(el => ({
|
|
27
|
+
...el, id: el.name || el.id, type: el.type, api: `/api/suggest/${table_name}:${el.name}${el.data ? `?sel=${el.data}` : ''}`,
|
|
28
|
+
}));
|
|
29
|
+
const { columns: fields1, geom } = await getMeta({ pg, table: table_name });
|
|
30
|
+
|
|
31
|
+
const fields = fields1?.map?.(({ name, dataTypeID, title }) => ({ name, type: columnType[pg.pgType?.[dataTypeID] || 'text'] || 'text', label: title || name }));
|
|
32
|
+
|
|
33
|
+
const mode = object_id ? "card" : "table";
|
|
34
|
+
const visibleColumns = (mode === 'card' && parsedCardColumns?.length) ? parsedCardColumns : extractVisibleColumns(parsedColumns, mode);
|
|
35
|
+
const selectColumns = visibleColumns.map((col) => col.name);
|
|
36
|
+
/* const columnsInfo = visibleColumns.map((col) => ({
|
|
37
|
+
name: col.name,
|
|
38
|
+
ua: col.ua,
|
|
39
|
+
format: col.format,
|
|
40
|
+
data: col.data,
|
|
41
|
+
view_type: col.view_type
|
|
42
|
+
})); */
|
|
43
|
+
|
|
44
|
+
const classifiers = visibleColumns
|
|
45
|
+
.filter((col) => col.data && ["select", "badge", "tags"].includes(col.format))
|
|
46
|
+
.reduce((acc, curr) => ({ ...acc, [curr.name]: curr.data }), {});
|
|
47
|
+
|
|
48
|
+
if (object_id) {
|
|
49
|
+
const sql = `
|
|
50
|
+
SELECT "${pk}" as id,* ${selectColumns.length ? `, ${selectColumns.join(", ")}` : ''} ${geom ? `, st_asgeojson(${geom})::json as geom` : ''}
|
|
51
|
+
FROM ${table_name}
|
|
52
|
+
WHERE ${pk} = $1
|
|
53
|
+
`;
|
|
54
|
+
const rows = await pg.query(sql, [object_id]).then(el => el.rows || []);
|
|
55
|
+
if (!rows.length) throw new Error('Object not found');
|
|
56
|
+
|
|
57
|
+
await metaFormat({
|
|
58
|
+
rows, table: table_name, cls: classifiers, sufix: true,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
row: rows[0],
|
|
63
|
+
card,
|
|
64
|
+
d: 1,
|
|
65
|
+
columns: visibleColumns,
|
|
66
|
+
is_downloadable,
|
|
67
|
+
register_key,
|
|
68
|
+
register_id,
|
|
69
|
+
service_id,
|
|
70
|
+
name,
|
|
71
|
+
is_files,
|
|
72
|
+
is_map,
|
|
73
|
+
is_register,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const { search, filter } = query || {};
|
|
78
|
+
const { q: sqlFilter, args = [] } = (filter || search)
|
|
79
|
+
? await getFilterSQLParametrized({
|
|
80
|
+
table: table_name,
|
|
81
|
+
search,
|
|
82
|
+
filter,
|
|
83
|
+
filterList: activeFilters,
|
|
84
|
+
})
|
|
85
|
+
: { q: '1=1', args: [] };
|
|
86
|
+
|
|
87
|
+
const whereConditions = [whereQuery, sqlFilter].filter(Boolean).join(' AND ');
|
|
88
|
+
|
|
89
|
+
const sqlBase = `FROM ${table_name} WHERE ${whereConditions || 'true'}`;
|
|
90
|
+
const sqlOrder = order ? `ORDER BY ${order}` : "";
|
|
91
|
+
const sqlLimit = `LIMIT $${args.length + 1}::bigint OFFSET $${args.length + 2}::bigint`;
|
|
92
|
+
|
|
93
|
+
const sqlSelect = `SELECT "${pk}" as id ${selectColumns.length ? `, ${selectColumns.join(", ")}` : ''} ${geom ? `, st_asgeojson(${geom})::json as geom` : ''} ${sqlBase}`;
|
|
94
|
+
const dataQuery = `${sqlSelect} ${sqlOrder} ${sqlLimit}`;
|
|
95
|
+
|
|
96
|
+
if (sql) return dataQuery;
|
|
97
|
+
|
|
98
|
+
const rows = await pg.query(dataQuery, args.concat([limit, offset])).then(el => el.rows || []);
|
|
99
|
+
const total = await pg.query(`SELECT COUNT(*) ${sqlBase}`, args).then(el => +(el.rows[0]?.count || 0));
|
|
100
|
+
|
|
101
|
+
await metaFormat({
|
|
102
|
+
rows, table: table_name, cls: classifiers, sufix: true,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const listConfig = {};
|
|
106
|
+
|
|
107
|
+
if (parsedColumns?.length) {
|
|
108
|
+
for (const col of parsedColumns) {
|
|
109
|
+
if (col.view_type === 'title') listConfig.title = col.name;
|
|
110
|
+
if (col.view_type === 'subtitle') listConfig.subtitle = col.name;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
await populateFilterOptions({
|
|
115
|
+
pg,
|
|
116
|
+
table: table_name,
|
|
117
|
+
filters: activeFilters,
|
|
118
|
+
columns,
|
|
119
|
+
whereConditions,
|
|
120
|
+
args
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
total,
|
|
125
|
+
limit,
|
|
126
|
+
page,
|
|
127
|
+
register_id,
|
|
128
|
+
name,
|
|
129
|
+
card,
|
|
130
|
+
table_name,
|
|
131
|
+
register_key,
|
|
132
|
+
description,
|
|
133
|
+
rows,
|
|
134
|
+
service_id,
|
|
135
|
+
columns: visibleColumns,
|
|
136
|
+
filters: activeFilters,
|
|
137
|
+
fields,
|
|
138
|
+
view,
|
|
139
|
+
is_downloadable,
|
|
140
|
+
is_map,
|
|
141
|
+
is_register,
|
|
142
|
+
is_files,
|
|
143
|
+
config: {
|
|
144
|
+
listConfig,
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
import { pgClients, getFilterSQL, getTemplate } from "@opengis/fastify-table/utils.js";
|
|
2
|
-
|
|
3
|
-
import { BadRequestError, NotFoundError } from "@opengis/fastify-table/errors.js";
|
|
4
|
-
|
|
5
|
-
import { attachClassifiers } from './classifiers.js';
|
|
6
|
-
|
|
7
|
-
export default async function mapRegistry({
|
|
8
|
-
slug, id, filter, limit: queryLimit, page = 1
|
|
9
|
-
}, pg = pgClients.client) {
|
|
10
|
-
if (!slug || !id) {
|
|
11
|
-
throw BadRequestError('Params slug and id is required');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const mapTemplate = await getTemplate('map', slug);
|
|
15
|
-
|
|
16
|
-
if (!mapTemplate) {
|
|
17
|
-
throw NotFoundError('Template not found');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const listWidget = mapTemplate.widgets?.find(w => w.type === 'list' && w.visible !== false && w.id === id);
|
|
21
|
-
|
|
22
|
-
if (!listWidget) {
|
|
23
|
-
throw NotFoundError('List widget not found');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const {
|
|
27
|
-
table,
|
|
28
|
-
pk,
|
|
29
|
-
query: baseQuery = '1=1',
|
|
30
|
-
order,
|
|
31
|
-
config = {},
|
|
32
|
-
name = '',
|
|
33
|
-
} = listWidget;
|
|
34
|
-
|
|
35
|
-
const { columns = [], filters = [], limit: configLimit = 20 } = config;
|
|
36
|
-
const limit = queryLimit || configLimit;
|
|
37
|
-
const offset = limit * (page - 1);
|
|
38
|
-
const selectColumns = columns.map(col => col.name);
|
|
39
|
-
|
|
40
|
-
const classifiers = columns
|
|
41
|
-
.filter(col => col.data && ["select", "badge", "tags"].includes(col.format))
|
|
42
|
-
.map(col => ({ name: col.name, classifier: col.data }));
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const { q: sqlFilter } = filter
|
|
46
|
-
? await getFilterSQL({ table, filter })
|
|
47
|
-
: { q: '1=1' };
|
|
48
|
-
|
|
49
|
-
const whereConditions = [baseQuery, sqlFilter].filter(Boolean).join(" AND ");
|
|
50
|
-
const whereClause = whereConditions ? `WHERE ${whereConditions}` : "";
|
|
51
|
-
|
|
52
|
-
const sqlBase = `FROM ${table} ${whereClause}`;
|
|
53
|
-
const sqlOrder = order ? `ORDER BY ${order}` : "";
|
|
54
|
-
const sqlLimit = `LIMIT $1::bigint OFFSET $2::bigint`;
|
|
55
|
-
const sqlSelect = `SELECT ${pk} as id, ${selectColumns.join(", ")}
|
|
56
|
-
${sqlBase}`;
|
|
57
|
-
const dataQuery = `${sqlSelect} ${sqlOrder} ${sqlLimit}`;
|
|
58
|
-
const totalQuery = `SELECT COUNT(*) ${sqlBase}`;
|
|
59
|
-
|
|
60
|
-
const [dataRes, countRes] = await Promise.all([
|
|
61
|
-
pg.query(dataQuery, [limit, offset]),
|
|
62
|
-
pg.query(totalQuery)
|
|
63
|
-
]);
|
|
64
|
-
|
|
65
|
-
const rows = await attachClassifiers(dataRes?.rows, classifiers);
|
|
66
|
-
const total = parseInt(countRes?.rows[0]?.count || 0, 10);
|
|
67
|
-
|
|
68
|
-
const listViewConfig = {};
|
|
69
|
-
columns.forEach(col => {
|
|
70
|
-
if (col.view_type === 'title') listViewConfig.title = col?.name;
|
|
71
|
-
if (col.view_type === 'subtitle') listViewConfig.subtitle = col?.name;
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
return {
|
|
75
|
-
name,
|
|
76
|
-
rows,
|
|
77
|
-
total,
|
|
78
|
-
columns,
|
|
79
|
-
filters,
|
|
80
|
-
config: {
|
|
81
|
-
...listWidget,
|
|
82
|
-
list: {
|
|
83
|
-
...listViewConfig
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
}
|
|
1
|
+
import { pgClients, getFilterSQL, getTemplate } from "@opengis/fastify-table/utils.js";
|
|
2
|
+
|
|
3
|
+
import { BadRequestError, NotFoundError } from "@opengis/fastify-table/errors.js";
|
|
4
|
+
|
|
5
|
+
import { attachClassifiers } from './classifiers.js';
|
|
6
|
+
|
|
7
|
+
export default async function mapRegistry({
|
|
8
|
+
slug, id, filter, limit: queryLimit, page = 1
|
|
9
|
+
}, pg = pgClients.client) {
|
|
10
|
+
if (!slug || !id) {
|
|
11
|
+
throw BadRequestError('Params slug and id is required');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const mapTemplate = await getTemplate('map', slug);
|
|
15
|
+
|
|
16
|
+
if (!mapTemplate) {
|
|
17
|
+
throw NotFoundError('Template not found');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const listWidget = mapTemplate.widgets?.find(w => w.type === 'list' && w.visible !== false && w.id === id);
|
|
21
|
+
|
|
22
|
+
if (!listWidget) {
|
|
23
|
+
throw NotFoundError('List widget not found');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
table,
|
|
28
|
+
pk,
|
|
29
|
+
query: baseQuery = '1=1',
|
|
30
|
+
order,
|
|
31
|
+
config = {},
|
|
32
|
+
name = '',
|
|
33
|
+
} = listWidget;
|
|
34
|
+
|
|
35
|
+
const { columns = [], filters = [], limit: configLimit = 20 } = config;
|
|
36
|
+
const limit = queryLimit || configLimit;
|
|
37
|
+
const offset = limit * (page - 1);
|
|
38
|
+
const selectColumns = columns.map(col => col.name);
|
|
39
|
+
|
|
40
|
+
const classifiers = columns
|
|
41
|
+
.filter(col => col.data && ["select", "badge", "tags"].includes(col.format))
|
|
42
|
+
.map(col => ({ name: col.name, classifier: col.data }));
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const { q: sqlFilter } = filter
|
|
46
|
+
? await getFilterSQL({ table, filter })
|
|
47
|
+
: { q: '1=1' };
|
|
48
|
+
|
|
49
|
+
const whereConditions = [baseQuery, sqlFilter].filter(Boolean).join(" AND ");
|
|
50
|
+
const whereClause = whereConditions ? `WHERE ${whereConditions}` : "";
|
|
51
|
+
|
|
52
|
+
const sqlBase = `FROM ${table} ${whereClause}`;
|
|
53
|
+
const sqlOrder = order ? `ORDER BY ${order}` : "";
|
|
54
|
+
const sqlLimit = `LIMIT $1::bigint OFFSET $2::bigint`;
|
|
55
|
+
const sqlSelect = `SELECT ${pk} as id, ${selectColumns.join(", ")}
|
|
56
|
+
${sqlBase}`;
|
|
57
|
+
const dataQuery = `${sqlSelect} ${sqlOrder} ${sqlLimit}`;
|
|
58
|
+
const totalQuery = `SELECT COUNT(*) ${sqlBase}`;
|
|
59
|
+
|
|
60
|
+
const [dataRes, countRes] = await Promise.all([
|
|
61
|
+
pg.query(dataQuery, [limit, offset]),
|
|
62
|
+
pg.query(totalQuery)
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
const rows = await attachClassifiers(dataRes?.rows, classifiers);
|
|
66
|
+
const total = parseInt(countRes?.rows[0]?.count || 0, 10);
|
|
67
|
+
|
|
68
|
+
const listViewConfig = {};
|
|
69
|
+
columns.forEach(col => {
|
|
70
|
+
if (col.view_type === 'title') listViewConfig.title = col?.name;
|
|
71
|
+
if (col.view_type === 'subtitle') listViewConfig.subtitle = col?.name;
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
name,
|
|
76
|
+
rows,
|
|
77
|
+
total,
|
|
78
|
+
columns,
|
|
79
|
+
filters,
|
|
80
|
+
config: {
|
|
81
|
+
...listWidget,
|
|
82
|
+
list: {
|
|
83
|
+
...listViewConfig
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import gisRegistry from './functions/gis.registry.js';
|
|
2
|
-
import gisRegistryList from './functions/gis.registry.list.js';
|
|
3
|
-
// import mapRegistry from './functions/map.registry.js';
|
|
4
|
-
import gisExport from './functions/gis.export.js';
|
|
5
|
-
import addGisRegistry from './functions/add.registry.js';
|
|
6
|
-
import deleteGisRegistry from './functions/del.registry.js';
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
gisRegistrySchema,
|
|
10
|
-
gisRegistryListSchema,
|
|
11
|
-
addGisRegistrySchema,
|
|
12
|
-
editGisRegistrySchema,
|
|
13
|
-
deleteGisRegistrySchema,
|
|
14
|
-
gisExportSchema,
|
|
15
|
-
} from './registers.schema.js';
|
|
16
|
-
|
|
17
|
-
const publicParams = { config: { policy: 'L0', package: 'gis' } };
|
|
18
|
-
|
|
19
|
-
async function route(app) {
|
|
20
|
-
app.get('/gis-registry/:slug', { ...publicParams, schema: gisRegistrySchema }, async ({ params, query, pg }) => {
|
|
21
|
-
const result = await gisRegistry({
|
|
22
|
-
slug: params.slug,
|
|
23
|
-
search: query.search,
|
|
24
|
-
filter: query.filter,
|
|
25
|
-
page: query.page,
|
|
26
|
-
limit: query.limit,
|
|
27
|
-
sql: query.sql,
|
|
28
|
-
}, pg);
|
|
29
|
-
return result;
|
|
30
|
-
});
|
|
31
|
-
app.get('/gis-registry/:slug/:objectId', { ...publicParams, schema: gisRegistrySchema }, async ({ params, query, pg }) => {
|
|
32
|
-
const result = await gisRegistry({
|
|
33
|
-
slug: params.slug,
|
|
34
|
-
objectId: params.objectId,
|
|
35
|
-
search: query.search,
|
|
36
|
-
filter: query.filter,
|
|
37
|
-
page: query.page,
|
|
38
|
-
limit: query.limit,
|
|
39
|
-
sql: query.sql,
|
|
40
|
-
}, pg);
|
|
41
|
-
return result;
|
|
42
|
-
});
|
|
43
|
-
app.get('/gis-registry', { ...publicParams, schema: gisRegistryListSchema }, async ({ query, pg }) => {
|
|
44
|
-
const result = await gisRegistryList({
|
|
45
|
-
page: query.page,
|
|
46
|
-
limit: query.limit,
|
|
47
|
-
search: query.search,
|
|
48
|
-
}, pg);
|
|
49
|
-
return result;
|
|
50
|
-
});
|
|
51
|
-
app.post('/gis-registry/:slug?', { ...publicParams, schema: addGisRegistrySchema }, async ({ method, params, body, user, pg }) => {
|
|
52
|
-
const result = await addGisRegistry({
|
|
53
|
-
method, slug: params.slug, body, uid: user?.uid,
|
|
54
|
-
}, pg);
|
|
55
|
-
return result;
|
|
56
|
-
});
|
|
57
|
-
app.put('/gis-registry/:slug', { ...publicParams, schema: editGisRegistrySchema }, async ({ method, params, body, user, pg }) => {
|
|
58
|
-
const result = await addGisRegistry({
|
|
59
|
-
method, slug: params.slug, body, uid: user?.uid,
|
|
60
|
-
}, pg);
|
|
61
|
-
return result;
|
|
62
|
-
});
|
|
63
|
-
app.delete('/gis-registry/:slug', { ...publicParams, schema: deleteGisRegistrySchema }, async ({ params, user, pg }) => {
|
|
64
|
-
const result = await deleteGisRegistry({
|
|
65
|
-
slug: params.slug,
|
|
66
|
-
uid: user?.uid,
|
|
67
|
-
}, pg);
|
|
68
|
-
return result;
|
|
69
|
-
});
|
|
70
|
-
// app.get('/map-registry/:slug/:id', { ...publicParams, schema: mapRegistrySchema }, mapRegistry);
|
|
71
|
-
app.get('/gis-export/:type/:slug', { ...publicParams, schema: gisExportSchema }, async ({ params, query, pg }, reply) => {
|
|
72
|
-
const result = await gisExport({
|
|
73
|
-
slug: params.slug,
|
|
74
|
-
type: params.type,
|
|
75
|
-
format: query.format,
|
|
76
|
-
}, pg);
|
|
77
|
-
return reply.headers(result.headers).send(result.data);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
export default route;
|
|
1
|
+
import gisRegistry from './functions/gis.registry.js';
|
|
2
|
+
import gisRegistryList from './functions/gis.registry.list.js';
|
|
3
|
+
// import mapRegistry from './functions/map.registry.js';
|
|
4
|
+
import gisExport from './functions/gis.export.js';
|
|
5
|
+
import addGisRegistry from './functions/add.registry.js';
|
|
6
|
+
import deleteGisRegistry from './functions/del.registry.js';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
gisRegistrySchema,
|
|
10
|
+
gisRegistryListSchema,
|
|
11
|
+
addGisRegistrySchema,
|
|
12
|
+
editGisRegistrySchema,
|
|
13
|
+
deleteGisRegistrySchema,
|
|
14
|
+
gisExportSchema,
|
|
15
|
+
} from './registers.schema.js';
|
|
16
|
+
|
|
17
|
+
const publicParams = { config: { policy: 'L0', package: 'gis' } };
|
|
18
|
+
|
|
19
|
+
async function route(app) {
|
|
20
|
+
app.get('/gis-registry/:slug', { ...publicParams, schema: gisRegistrySchema }, async ({ params, query, pg }) => {
|
|
21
|
+
const result = await gisRegistry({
|
|
22
|
+
slug: params.slug,
|
|
23
|
+
search: query.search,
|
|
24
|
+
filter: query.filter,
|
|
25
|
+
page: query.page,
|
|
26
|
+
limit: query.limit,
|
|
27
|
+
sql: query.sql,
|
|
28
|
+
}, pg);
|
|
29
|
+
return result;
|
|
30
|
+
});
|
|
31
|
+
app.get('/gis-registry/:slug/:objectId', { ...publicParams, schema: gisRegistrySchema }, async ({ params, query, pg }) => {
|
|
32
|
+
const result = await gisRegistry({
|
|
33
|
+
slug: params.slug,
|
|
34
|
+
objectId: params.objectId,
|
|
35
|
+
search: query.search,
|
|
36
|
+
filter: query.filter,
|
|
37
|
+
page: query.page,
|
|
38
|
+
limit: query.limit,
|
|
39
|
+
sql: query.sql,
|
|
40
|
+
}, pg);
|
|
41
|
+
return result;
|
|
42
|
+
});
|
|
43
|
+
app.get('/gis-registry', { ...publicParams, schema: gisRegistryListSchema }, async ({ query, pg }) => {
|
|
44
|
+
const result = await gisRegistryList({
|
|
45
|
+
page: query.page,
|
|
46
|
+
limit: query.limit,
|
|
47
|
+
search: query.search,
|
|
48
|
+
}, pg);
|
|
49
|
+
return result;
|
|
50
|
+
});
|
|
51
|
+
app.post('/gis-registry/:slug?', { ...publicParams, schema: addGisRegistrySchema }, async ({ method, params, body, user, pg }) => {
|
|
52
|
+
const result = await addGisRegistry({
|
|
53
|
+
method, slug: params.slug, body, uid: user?.uid,
|
|
54
|
+
}, pg);
|
|
55
|
+
return result;
|
|
56
|
+
});
|
|
57
|
+
app.put('/gis-registry/:slug', { ...publicParams, schema: editGisRegistrySchema }, async ({ method, params, body, user, pg }) => {
|
|
58
|
+
const result = await addGisRegistry({
|
|
59
|
+
method, slug: params.slug, body, uid: user?.uid,
|
|
60
|
+
}, pg);
|
|
61
|
+
return result;
|
|
62
|
+
});
|
|
63
|
+
app.delete('/gis-registry/:slug', { ...publicParams, schema: deleteGisRegistrySchema }, async ({ params, user, pg }) => {
|
|
64
|
+
const result = await deleteGisRegistry({
|
|
65
|
+
slug: params.slug,
|
|
66
|
+
uid: user?.uid,
|
|
67
|
+
}, pg);
|
|
68
|
+
return result;
|
|
69
|
+
});
|
|
70
|
+
// app.get('/map-registry/:slug/:id', { ...publicParams, schema: mapRegistrySchema }, mapRegistry);
|
|
71
|
+
app.get('/gis-export/:type/:slug', { ...publicParams, schema: gisExportSchema }, async ({ params, query, pg }, reply) => {
|
|
72
|
+
const result = await gisExport({
|
|
73
|
+
slug: params.slug,
|
|
74
|
+
type: params.type,
|
|
75
|
+
format: query.format,
|
|
76
|
+
}, pg);
|
|
77
|
+
return reply.headers(result.headers).send(result.data);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export default route;
|