@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,93 +1,93 @@
|
|
|
1
|
-
const ROUTE_URL = process.env.ROUTE_URL || 'https://data.gki.com.ua/api/osrm-routes';
|
|
2
|
-
|
|
3
|
-
function parseCoordPair(raw) {
|
|
4
|
-
const [lngRaw, latRaw] = String(raw || '').split(',');
|
|
5
|
-
const lng = Number(lngRaw);
|
|
6
|
-
const lat = Number(latRaw);
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
!Number.isFinite(lng)
|
|
10
|
-
|| !Number.isFinite(lat)
|
|
11
|
-
|| lng < -180
|
|
12
|
-
|| lng > 180
|
|
13
|
-
|| lat < -90
|
|
14
|
-
|| lat > 90
|
|
15
|
-
) {
|
|
16
|
-
throw new Error('invalid coordinate')
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return [lng, lat];
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function buildRoutePoints(from, to, via) {
|
|
23
|
-
const points = [parseCoordPair(from)];
|
|
24
|
-
if (via) {
|
|
25
|
-
for (const segment of String(via).split(';')) {
|
|
26
|
-
const trimmed = segment.trim();
|
|
27
|
-
if (trimmed) {
|
|
28
|
-
points.push(parseCoordPair(trimmed));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
points.push(parseCoordPair(to));
|
|
33
|
-
return points;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function routeOptionsQuery(query) {
|
|
37
|
-
const params = new URLSearchParams()
|
|
38
|
-
for (const key of ['optimize', 'surface', 'weight', 'mode']) {
|
|
39
|
-
const value = typeof query?.[key] === 'string' ? query[key].trim() : '';
|
|
40
|
-
if (value) {
|
|
41
|
-
params.set(key, value);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const qs = params.toString();
|
|
45
|
-
return qs ? `&${qs}` : '';
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function buildSegmentsBody(points) {
|
|
49
|
-
const segments = [];
|
|
50
|
-
for (let i = 0; i < points.length - 1; i += 1) {
|
|
51
|
-
segments.push([
|
|
52
|
-
[points[i][0], points[i][1]],
|
|
53
|
-
[points[i + 1][0], points[i + 1][1]],
|
|
54
|
-
]);
|
|
55
|
-
}
|
|
56
|
-
return JSON.stringify(segments);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export default async function createRouteHandler({ from, to, via, mode, alternatives, steps, optimize, surface, weight }) {
|
|
60
|
-
const points = buildRoutePoints(from, to, via);
|
|
61
|
-
const query = { from, to, via, mode, alternatives, steps, optimize, surface, weight };
|
|
62
|
-
const url = `${ROUTE_URL}?steps=true&alternatives=true${routeOptionsQuery(query)}`;
|
|
63
|
-
|
|
64
|
-
const response = await fetch(url, {
|
|
65
|
-
method: 'POST',
|
|
66
|
-
headers: {
|
|
67
|
-
'Content-Type': 'application/json',
|
|
68
|
-
Accept: 'application/json',
|
|
69
|
-
},
|
|
70
|
-
body: buildSegmentsBody(points),
|
|
71
|
-
signal: AbortSignal.timeout(10_000),
|
|
72
|
-
}).catch(error => ({
|
|
73
|
-
ok: false,
|
|
74
|
-
status: 502,
|
|
75
|
-
headers: new Headers({ 'content-type': 'application/json' }),
|
|
76
|
-
text: async () => JSON.stringify({ error: String(error), code: 502 }),
|
|
77
|
-
}))
|
|
78
|
-
|
|
79
|
-
const contentType = response.headers?.get?.('content-type') || 'application/json';
|
|
80
|
-
const text = await response.text();
|
|
81
|
-
|
|
82
|
-
let payload = text
|
|
83
|
-
|
|
84
|
-
if (contentType.includes('application/json')) {
|
|
85
|
-
try {
|
|
86
|
-
payload = text ? JSON.parse(text) : null
|
|
87
|
-
} catch {
|
|
88
|
-
payload = text
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return payload;
|
|
93
|
-
}
|
|
1
|
+
const ROUTE_URL = process.env.ROUTE_URL || 'https://data.gki.com.ua/api/osrm-routes';
|
|
2
|
+
|
|
3
|
+
function parseCoordPair(raw) {
|
|
4
|
+
const [lngRaw, latRaw] = String(raw || '').split(',');
|
|
5
|
+
const lng = Number(lngRaw);
|
|
6
|
+
const lat = Number(latRaw);
|
|
7
|
+
|
|
8
|
+
if (
|
|
9
|
+
!Number.isFinite(lng)
|
|
10
|
+
|| !Number.isFinite(lat)
|
|
11
|
+
|| lng < -180
|
|
12
|
+
|| lng > 180
|
|
13
|
+
|| lat < -90
|
|
14
|
+
|| lat > 90
|
|
15
|
+
) {
|
|
16
|
+
throw new Error('invalid coordinate')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return [lng, lat];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function buildRoutePoints(from, to, via) {
|
|
23
|
+
const points = [parseCoordPair(from)];
|
|
24
|
+
if (via) {
|
|
25
|
+
for (const segment of String(via).split(';')) {
|
|
26
|
+
const trimmed = segment.trim();
|
|
27
|
+
if (trimmed) {
|
|
28
|
+
points.push(parseCoordPair(trimmed));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
points.push(parseCoordPair(to));
|
|
33
|
+
return points;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function routeOptionsQuery(query) {
|
|
37
|
+
const params = new URLSearchParams()
|
|
38
|
+
for (const key of ['optimize', 'surface', 'weight', 'mode']) {
|
|
39
|
+
const value = typeof query?.[key] === 'string' ? query[key].trim() : '';
|
|
40
|
+
if (value) {
|
|
41
|
+
params.set(key, value);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const qs = params.toString();
|
|
45
|
+
return qs ? `&${qs}` : '';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function buildSegmentsBody(points) {
|
|
49
|
+
const segments = [];
|
|
50
|
+
for (let i = 0; i < points.length - 1; i += 1) {
|
|
51
|
+
segments.push([
|
|
52
|
+
[points[i][0], points[i][1]],
|
|
53
|
+
[points[i + 1][0], points[i + 1][1]],
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
return JSON.stringify(segments);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default async function createRouteHandler({ from, to, via, mode, alternatives, steps, optimize, surface, weight }) {
|
|
60
|
+
const points = buildRoutePoints(from, to, via);
|
|
61
|
+
const query = { from, to, via, mode, alternatives, steps, optimize, surface, weight };
|
|
62
|
+
const url = `${ROUTE_URL}?steps=true&alternatives=true${routeOptionsQuery(query)}`;
|
|
63
|
+
|
|
64
|
+
const response = await fetch(url, {
|
|
65
|
+
method: 'POST',
|
|
66
|
+
headers: {
|
|
67
|
+
'Content-Type': 'application/json',
|
|
68
|
+
Accept: 'application/json',
|
|
69
|
+
},
|
|
70
|
+
body: buildSegmentsBody(points),
|
|
71
|
+
signal: AbortSignal.timeout(10_000),
|
|
72
|
+
}).catch(error => ({
|
|
73
|
+
ok: false,
|
|
74
|
+
status: 502,
|
|
75
|
+
headers: new Headers({ 'content-type': 'application/json' }),
|
|
76
|
+
text: async () => JSON.stringify({ error: String(error), code: 502 }),
|
|
77
|
+
}))
|
|
78
|
+
|
|
79
|
+
const contentType = response.headers?.get?.('content-type') || 'application/json';
|
|
80
|
+
const text = await response.text();
|
|
81
|
+
|
|
82
|
+
let payload = text
|
|
83
|
+
|
|
84
|
+
if (contentType.includes('application/json')) {
|
|
85
|
+
try {
|
|
86
|
+
payload = text ? JSON.parse(text) : null
|
|
87
|
+
} catch {
|
|
88
|
+
payload = text
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return payload;
|
|
93
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { dataDelete, pgClients } from "@opengis/fastify-table/utils.js";
|
|
2
|
-
|
|
3
|
-
export default async function deleteService({
|
|
4
|
-
id, uid,
|
|
5
|
-
}, pg = pgClients.client) {
|
|
6
|
-
const row = await dataDelete({
|
|
7
|
-
pg,
|
|
8
|
-
id,
|
|
9
|
-
table: 'gis.services',
|
|
10
|
-
uid,
|
|
11
|
-
});
|
|
12
|
-
return row;
|
|
1
|
+
import { dataDelete, pgClients } from "@opengis/fastify-table/utils.js";
|
|
2
|
+
|
|
3
|
+
export default async function deleteService({
|
|
4
|
+
id, uid,
|
|
5
|
+
}, pg = pgClients.client) {
|
|
6
|
+
const row = await dataDelete({
|
|
7
|
+
pg,
|
|
8
|
+
id,
|
|
9
|
+
table: 'gis.services',
|
|
10
|
+
uid,
|
|
11
|
+
});
|
|
12
|
+
return row;
|
|
13
13
|
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
export default async function getLayerGeom(req) {
|
|
2
|
-
const { pg, params, query } = req;
|
|
3
|
-
|
|
4
|
-
const { id } = params;
|
|
5
|
-
if (!id) return { message: 'id is empty', status: 403 };
|
|
6
|
-
|
|
7
|
-
const selectTable = `select source_path,geometry_column from gis.services where service_id='${id}'`;
|
|
8
|
-
const { source_path: table, geometry_column: geometryColumn = 'geom' } = await pg.one(selectTable);
|
|
9
|
-
if (!table) return;
|
|
10
|
-
const selectGeom = `
|
|
11
|
-
SELECT 'FeatureCollection' As type,
|
|
12
|
-
json_agg(q) as features
|
|
13
|
-
FROM (
|
|
14
|
-
SELECT 'Feature' as type,
|
|
15
|
-
row_number() over() as id, st_asgeojson(
|
|
16
|
-
st_force2d(${geometryColumn}),
|
|
17
|
-
6,
|
|
18
|
-
0
|
|
19
|
-
) :: json as geometry
|
|
20
|
-
from ${table}
|
|
21
|
-
where ${geometryColumn} is not null) q`;
|
|
22
|
-
if (query?.sql) return selectGeom;
|
|
23
|
-
const { rows } = await pg.query(selectGeom);
|
|
24
|
-
|
|
25
|
-
return { message: rows, status: 200 };
|
|
26
|
-
|
|
27
|
-
}
|
|
1
|
+
export default async function getLayerGeom(req) {
|
|
2
|
+
const { pg, params, query } = req;
|
|
3
|
+
|
|
4
|
+
const { id } = params;
|
|
5
|
+
if (!id) return { message: 'id is empty', status: 403 };
|
|
6
|
+
|
|
7
|
+
const selectTable = `select source_path,geometry_column from gis.services where service_id='${id}'`;
|
|
8
|
+
const { source_path: table, geometry_column: geometryColumn = 'geom' } = await pg.one(selectTable);
|
|
9
|
+
if (!table) return;
|
|
10
|
+
const selectGeom = `
|
|
11
|
+
SELECT 'FeatureCollection' As type,
|
|
12
|
+
json_agg(q) as features
|
|
13
|
+
FROM (
|
|
14
|
+
SELECT 'Feature' as type,
|
|
15
|
+
row_number() over() as id, st_asgeojson(
|
|
16
|
+
st_force2d(${geometryColumn}),
|
|
17
|
+
6,
|
|
18
|
+
0
|
|
19
|
+
) :: json as geometry
|
|
20
|
+
from ${table}
|
|
21
|
+
where ${geometryColumn} is not null) q`;
|
|
22
|
+
if (query?.sql) return selectGeom;
|
|
23
|
+
const { rows } = await pg.query(selectGeom);
|
|
24
|
+
|
|
25
|
+
return { message: rows, status: 200 };
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import { BadRequestError } from '@opengis/fastify-table/errors.js';
|
|
2
|
-
import { pgClients } from '@opengis/fastify-table/utils.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Апі повертає перелік користувачів, які мають доступ до георесурсу
|
|
6
|
-
*
|
|
7
|
-
* @method GET
|
|
8
|
-
* @summary Апі повертає перелік користувачів, які мають доступ до георесурсу
|
|
9
|
-
* @alias getServiceUsers
|
|
10
|
-
* @tag services
|
|
11
|
-
* @param {String} id Ідентифікатор георесурсу (service_id)
|
|
12
|
-
* @param {Number} query.limit Кількість записів на сторінці (макс. 100, за замовчуванням 20)
|
|
13
|
-
* @param {Number} query.offset Зміщення для пагінації
|
|
14
|
-
* @param {String} query.search Текстовий пошук за прізвищем, іменем, по-батькові або логіном
|
|
15
|
-
* @type api
|
|
16
|
-
*
|
|
17
|
-
* @example /api/gis-service-users/3054579335420708639?limit=8&offset=0
|
|
18
|
-
*/
|
|
19
|
-
export default async function getServiceUsers({ id, search: querySearch = '', limit: queryLimit = 10, offset = 0 }, pg = pgClients.client) {
|
|
20
|
-
const limit = Math.min(queryLimit, 100);
|
|
21
|
-
|
|
22
|
-
const search = querySearch?.trim() || '';
|
|
23
|
-
|
|
24
|
-
if (!id) {
|
|
25
|
-
throw BadRequestError('service_id is required');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const args = search ? [id, `%${search}%`] : [id];
|
|
29
|
-
|
|
30
|
-
const searchFilter = search
|
|
31
|
-
? `and (
|
|
32
|
-
coalesce(b.sur_name,'') || ' ' || coalesce(b.user_name,'') || ' ' || coalesce(b.father_name,'') ilike $2
|
|
33
|
-
or b.login ilike $2
|
|
34
|
-
or b.uid::text ilike $2
|
|
35
|
-
)`
|
|
36
|
-
: '';
|
|
37
|
-
|
|
38
|
-
const sql = `
|
|
39
|
-
select
|
|
40
|
-
a.user_id,
|
|
41
|
-
a.actions,
|
|
42
|
-
coalesce(
|
|
43
|
-
nullif(
|
|
44
|
-
coalesce(b.sur_name,'') || coalesce(' ' || b.user_name,'') || coalesce(' ' || b.father_name,''),
|
|
45
|
-
''
|
|
46
|
-
),
|
|
47
|
-
b.login,
|
|
48
|
-
b.uid::text,
|
|
49
|
-
a.user_id
|
|
50
|
-
) as user_full_name
|
|
51
|
-
from gis.services_users_rel a
|
|
52
|
-
left join admin.users b on b.uid = a.user_id
|
|
53
|
-
where a.service_id = $1
|
|
54
|
-
${searchFilter}
|
|
55
|
-
order by user_full_name
|
|
56
|
-
limit $${args.length + 1}::bigint offset $${args.length + 2}::bigint
|
|
57
|
-
`;
|
|
58
|
-
|
|
59
|
-
const countSql = `
|
|
60
|
-
select count(*)::int as total
|
|
61
|
-
from gis.services_users_rel a
|
|
62
|
-
left join admin.users b on b.uid = a.user_id
|
|
63
|
-
where a.service_id = $1
|
|
64
|
-
${searchFilter}
|
|
65
|
-
`;
|
|
66
|
-
|
|
67
|
-
const [{ rows }, countResult] = await Promise.all([
|
|
68
|
-
pg.query(sql, args.concat([limit, offset])),
|
|
69
|
-
pg.query(countSql, args).then((r) => r.rows?.[0]?.total ?? 0),
|
|
70
|
-
]);
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
rows,
|
|
74
|
-
count: countResult,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
1
|
+
import { BadRequestError } from '@opengis/fastify-table/errors.js';
|
|
2
|
+
import { pgClients } from '@opengis/fastify-table/utils.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Апі повертає перелік користувачів, які мають доступ до георесурсу
|
|
6
|
+
*
|
|
7
|
+
* @method GET
|
|
8
|
+
* @summary Апі повертає перелік користувачів, які мають доступ до георесурсу
|
|
9
|
+
* @alias getServiceUsers
|
|
10
|
+
* @tag services
|
|
11
|
+
* @param {String} id Ідентифікатор георесурсу (service_id)
|
|
12
|
+
* @param {Number} query.limit Кількість записів на сторінці (макс. 100, за замовчуванням 20)
|
|
13
|
+
* @param {Number} query.offset Зміщення для пагінації
|
|
14
|
+
* @param {String} query.search Текстовий пошук за прізвищем, іменем, по-батькові або логіном
|
|
15
|
+
* @type api
|
|
16
|
+
*
|
|
17
|
+
* @example /api/gis-service-users/3054579335420708639?limit=8&offset=0
|
|
18
|
+
*/
|
|
19
|
+
export default async function getServiceUsers({ id, search: querySearch = '', limit: queryLimit = 10, offset = 0 }, pg = pgClients.client) {
|
|
20
|
+
const limit = Math.min(queryLimit, 100);
|
|
21
|
+
|
|
22
|
+
const search = querySearch?.trim() || '';
|
|
23
|
+
|
|
24
|
+
if (!id) {
|
|
25
|
+
throw BadRequestError('service_id is required');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const args = search ? [id, `%${search}%`] : [id];
|
|
29
|
+
|
|
30
|
+
const searchFilter = search
|
|
31
|
+
? `and (
|
|
32
|
+
coalesce(b.sur_name,'') || ' ' || coalesce(b.user_name,'') || ' ' || coalesce(b.father_name,'') ilike $2
|
|
33
|
+
or b.login ilike $2
|
|
34
|
+
or b.uid::text ilike $2
|
|
35
|
+
)`
|
|
36
|
+
: '';
|
|
37
|
+
|
|
38
|
+
const sql = `
|
|
39
|
+
select
|
|
40
|
+
a.user_id,
|
|
41
|
+
a.actions,
|
|
42
|
+
coalesce(
|
|
43
|
+
nullif(
|
|
44
|
+
coalesce(b.sur_name,'') || coalesce(' ' || b.user_name,'') || coalesce(' ' || b.father_name,''),
|
|
45
|
+
''
|
|
46
|
+
),
|
|
47
|
+
b.login,
|
|
48
|
+
b.uid::text,
|
|
49
|
+
a.user_id
|
|
50
|
+
) as user_full_name
|
|
51
|
+
from gis.services_users_rel a
|
|
52
|
+
left join admin.users b on b.uid = a.user_id
|
|
53
|
+
where a.service_id = $1
|
|
54
|
+
${searchFilter}
|
|
55
|
+
order by user_full_name
|
|
56
|
+
limit $${args.length + 1}::bigint offset $${args.length + 2}::bigint
|
|
57
|
+
`;
|
|
58
|
+
|
|
59
|
+
const countSql = `
|
|
60
|
+
select count(*)::int as total
|
|
61
|
+
from gis.services_users_rel a
|
|
62
|
+
left join admin.users b on b.uid = a.user_id
|
|
63
|
+
where a.service_id = $1
|
|
64
|
+
${searchFilter}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
const [{ rows }, countResult] = await Promise.all([
|
|
68
|
+
pg.query(sql, args.concat([limit, offset])),
|
|
69
|
+
pg.query(countSql, args).then((r) => r.rows?.[0]?.total ?? 0),
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
rows,
|
|
74
|
+
count: countResult,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { NotFoundError } from '@opengis/fastify-table/errors.js';
|
|
2
|
-
import { metaFormat, pgClients, getTemplate } from '@opengis/fastify-table/utils.js';
|
|
3
|
-
|
|
4
|
-
export default async function getServicesCol({ id, column }, pg = pgClients.client) {
|
|
5
|
-
const row = await getTemplate('layer', id) || await pg.query(`
|
|
6
|
-
SELECT
|
|
7
|
-
service_id, source_path, attributes
|
|
8
|
-
FROM gis.services where ${id ? 'service_id=$1' : '1=1'}
|
|
9
|
-
`, [id].filter(Boolean)).then(r => r.rows[0] || {});
|
|
10
|
-
|
|
11
|
-
if (!row.source_path) {
|
|
12
|
-
throw NotFoundError('source not found');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const fields = await pg.query(`SELECT * FROM ${row.source_path} limit 0`).then(r => r.fields);
|
|
16
|
-
const field = fields.find(el => el.name === column);
|
|
17
|
-
|
|
18
|
-
if (!field) {
|
|
19
|
-
throw NotFoundError('column not found: ' + column);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const rows = await pg.query(`SELECT ${column}::text as id, ${column}, count(*) FROM ${row.source_path}
|
|
23
|
-
where ${column} is not null group by ${column} order by count(*) desc limit 10`).then(r => r.rows || []);
|
|
24
|
-
|
|
25
|
-
const cls = row.attributes?.filter?.((col) => col.name && col.data && ['select', 'badge', 'tags'].includes(col.format)).reduce((acc, curr) => ({ ...acc, [curr.name]: curr.data }), {}) || {};
|
|
26
|
-
|
|
27
|
-
await metaFormat({ rows, table: row.source_path, cls });
|
|
28
|
-
|
|
29
|
-
const rows1 = rows.map(row => ({
|
|
30
|
-
...row[`${column}_data`], ...row, [`${column}_data`]: undefined, [column]: undefined,
|
|
31
|
-
}));
|
|
32
|
-
|
|
33
|
-
return { rows: rows1, field, fields };
|
|
34
|
-
}
|
|
1
|
+
import { NotFoundError } from '@opengis/fastify-table/errors.js';
|
|
2
|
+
import { metaFormat, pgClients, getTemplate } from '@opengis/fastify-table/utils.js';
|
|
3
|
+
|
|
4
|
+
export default async function getServicesCol({ id, column }, pg = pgClients.client) {
|
|
5
|
+
const row = await getTemplate('layer', id) || await pg.query(`
|
|
6
|
+
SELECT
|
|
7
|
+
service_id, source_path, attributes
|
|
8
|
+
FROM gis.services where ${id ? 'service_id=$1' : '1=1'}
|
|
9
|
+
`, [id].filter(Boolean)).then(r => r.rows[0] || {});
|
|
10
|
+
|
|
11
|
+
if (!row.source_path) {
|
|
12
|
+
throw NotFoundError('source not found');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const fields = await pg.query(`SELECT * FROM ${row.source_path} limit 0`).then(r => r.fields);
|
|
16
|
+
const field = fields.find(el => el.name === column);
|
|
17
|
+
|
|
18
|
+
if (!field) {
|
|
19
|
+
throw NotFoundError('column not found: ' + column);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const rows = await pg.query(`SELECT ${column}::text as id, ${column}, count(*) FROM ${row.source_path}
|
|
23
|
+
where ${column} is not null group by ${column} order by count(*) desc limit 10`).then(r => r.rows || []);
|
|
24
|
+
|
|
25
|
+
const cls = row.attributes?.filter?.((col) => col.name && col.data && ['select', 'badge', 'tags'].includes(col.format)).reduce((acc, curr) => ({ ...acc, [curr.name]: curr.data }), {}) || {};
|
|
26
|
+
|
|
27
|
+
await metaFormat({ rows, table: row.source_path, cls });
|
|
28
|
+
|
|
29
|
+
const rows1 = rows.map(row => ({
|
|
30
|
+
...row[`${column}_data`], ...row, [`${column}_data`]: undefined, [column]: undefined,
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
return { rows: rows1, field, fields };
|
|
34
|
+
}
|