@opengis/gis 0.0.5 → 0.0.7

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.
@@ -15,8 +15,7 @@
15
15
  Тематична категорія ресурсу, {{select topic_category data='topic_category'}},
16
16
  Код суб'єкта; що є власником ресурсу, {{data_owner_code}},
17
17
  Код виробника даних, {{data_producer_code}},
18
- Ключові слова, {{keywords}},
19
- Тип сервісу, {{select service_type data='meta.service_type'}}
18
+ Ключові слова, {{keywords}}
20
19
  "
21
20
  }}}
22
21
  </div>
@@ -4,7 +4,6 @@
4
4
  comma=";"
5
5
  columns="
6
6
  Інформація про відповідність метаданих стандартам, {{select standards data='standarts'}},
7
- Тип сервісу, {{select service_type data='meta.service_type'}},
8
7
  Експорт, <div class='flex'>
9
8
  <a
10
9
  href='/api/xml/{{metadata_id}}'
@@ -17,3 +17,5 @@ panels:
17
17
  title: Фільтри
18
18
  - name: cls
19
19
  title: Класифікатори
20
+ - component: vs-widget-history
21
+ title: Історія редагування
@@ -17,10 +17,19 @@
17
17
  Утримувач,holder,
18
18
  Ключові слова,{{#each keywords}}<span class=\"bg-gray-200 px-1 py-0.5 rounded-lg\">{{this}}</span>{{/each}},
19
19
  Чи публічний реєстр?,{{{badge is_public data='yes_no'}}},
20
- Чи активний?,{{{badge is_public data='yes_no'}}},
21
- Фото,{{{buttonFilePreview image}}}
20
+ Чи активний?,{{{badge is_active data='yes_no'}}},
21
+ Фото,{{{buttonFilePreview image}}},
22
+ Чи відображати віджет файлів?,{{{badge is_files data='yes_no'}}},
23
+ Користувач; який створив запис, {{select created_by data='user_id'}},
24
+ Дата створення, {{formatDate created_at}}
22
25
  "
23
26
  }}}
24
-
25
-
27
+ {{#contentList table="(select count(*) as total from {{table_name}})"}}
28
+ {{#with rows.[0]}}
29
+ {{{descriptionList
30
+ this
31
+ columns="Кількість об'єктів в наборі,{{total}}"
32
+ }}}
33
+ {{/with}}
34
+ {{/contentList}}
26
35
  </div>
@@ -16,8 +16,7 @@
16
16
  Група; в якій буде відображатися набір даних,{{select group_id data='gis.group_list'}},
17
17
  Утримувач,holder,
18
18
  Ключові слова,{{#each keywords}}<span class=\"bg-gray-200 px-1 py-0.5 rounded-lg\">{{this}}</span>{{/each}},
19
- Тип сервісу,{{{badge service_type data='service_type'}}},
20
- Чи є сервіс публічним?,{{{badge is_public data='yes_no'}}},
19
+ Чи є набір даних публічним?,{{{badge is_public data='yes_no'}}},
21
20
  Чи активний?,{{{badge is_public data='yes_no'}}},
22
21
  Чи можна завантажити дані?,{{{badge is_downloadable data='yes_no'}}},
23
22
  Фото,{{{buttonFilePreview image}}}
@@ -4,23 +4,22 @@
4
4
  this
5
5
  comma=";"
6
6
  columns="
7
- Тип джерела, {{select source_type data='source_type'}},
8
- Таблиця в базі даних,{{select source_path data='pg.table_name'}},
9
- Умова для відображення,query,
10
- Назва колонки геометрії,geometry_column,
11
- Тип геометрії в шарі,{{select geom_type data='geom_type'}},
12
- Просторова референтна система,{{select srid data='gis.srid_from_setting'}}
7
+ Тип джерела, {{select source_type data='source_type'}},
8
+ Таблиця в базі даних,{{select source_path data='pg.table_name'}},
9
+ Умова для відображення,query,
10
+ Назва колонки геометрії,geometry_column,
11
+ Тип геометрії в шарі,{{select geom_type data='geom_type'}},
12
+ Просторова референтна система,{{select srid data='gis.srid_from_setting'}}
13
13
  "
14
14
  }}}
15
15
  {{^}}
16
16
  {{{descriptionList
17
- this
18
- comma=";"
19
- columns="
20
- Тип джерела, {{select source_type data='source_type'}},
21
- Поислання на сервіс, service_url,
22
- Просторова референтна система,{{select srid data='gis.srid_from_setting'}}
23
- "
17
+ this
18
+ comma=";"
19
+ columns="
20
+ Тип джерела, {{select source_type data='source_type'}},
21
+ Посилання на набір даних, service_url
22
+ "
24
23
  }}}
25
24
  {{/ifCond}}
26
25
  </div>
@@ -0,0 +1,22 @@
1
+ [
2
+ {
3
+ "id": "tms",
4
+ "text": "TMS"
5
+ },
6
+ {
7
+ "id": "wms",
8
+ "text": "WMS"
9
+ },
10
+ {
11
+ "id": "wfs",
12
+ "text": "WFS"
13
+ },
14
+ {
15
+ "id": "wtms",
16
+ "text": "WTMS"
17
+ },
18
+ {
19
+ "id": "wcs",
20
+ "text": "WCS"
21
+ }
22
+ ]
@@ -0,0 +1,36 @@
1
+ {
2
+ "schema": {
3
+ "name": {
4
+ "type": "Text",
5
+ "ua": "Назва",
6
+ "col": 8
7
+ },
8
+ "enabled": {
9
+ "type": "Switcher",
10
+ "ua": "On / Off",
11
+ "col": 2
12
+ },
13
+ "ispublic": {
14
+ "type": "Switcher",
15
+ "ua": "Чи є сервіс публічним?",
16
+ "col": 2
17
+ },
18
+ "group_id": {
19
+ "type": "Autocomplete",
20
+ "data": "gis.group_list",
21
+ "ua": "Група"
22
+ },
23
+ "service": {
24
+ "type": "Autocomplete",
25
+ "data": "ogc.service",
26
+ "defaultValue": "tms",
27
+ "ua": "Сервіси",
28
+ "col": 4
29
+ },
30
+ "url": {
31
+ "type": "Text",
32
+ "ua": "Посилання",
33
+ "col": 8
34
+ }
35
+ }
36
+ }
@@ -67,10 +67,7 @@
67
67
  "image": {
68
68
  "ua": "Фото",
69
69
  "col": 12,
70
- "type": "Dropzone",
71
- "validators": [
72
- "required"
73
- ]
70
+ "type": "Dropzone"
74
71
  },
75
72
  "d1": {
76
73
  "type": "HTML",
@@ -99,6 +96,12 @@
99
96
  "syntax": "sql",
100
97
  "col": 6
101
98
  },
99
+ "is_files": {
100
+ "ua": "Чи відображати віджет файлів?",
101
+ "col": 12,
102
+ "type": "Switcher",
103
+ "defaultValue": false
104
+ },
102
105
  "sql_list": {
103
106
  "ua": "Перелік sql підзапитів для додаткової інформації",
104
107
  "type": "DataTable",
@@ -6,7 +6,7 @@
6
6
  "d0": {
7
7
  "type": "HTML",
8
8
  "title": "Загальна інформація",
9
- "text": "<h2 class='text-xl font-bold text-left'>Загальна інформація про реєстр</h2>",
9
+ "text": "<h2 class='text-xl font-bold text-left'>Загальна інформація про набір надих</h2>",
10
10
  "col": 12
11
11
  },
12
12
  "name": {
@@ -45,15 +45,6 @@
45
45
  "type": "Tags",
46
46
  "col": 6
47
47
  },
48
- "service_type": {
49
- "ua": "Тип сервісу",
50
- "data": "service_type",
51
- "col": 6,
52
- "type": "Autocomplete",
53
- "validators": [
54
- "required"
55
- ]
56
- },
57
48
  "holder": {
58
49
  "ua": "Власник/Утримувач/Відповідальний",
59
50
  "col": 6,
@@ -61,13 +52,13 @@
61
52
  },
62
53
 
63
54
  "is_public": {
64
- "ua": "Чи є сервіс публічним?",
55
+ "ua": "Чи є набір даних публічним?",
65
56
  "col": 6,
66
57
  "type": "Switcher",
67
58
  "data": "bool.yes_no"
68
59
  },
69
60
  "is_active": {
70
- "ua": "Чи включений сервіс?",
61
+ "ua": "Чи включений набір даних?",
71
62
  "col": 6,
72
63
  "type": "Switcher",
73
64
  "data": "bool.yes_no"
@@ -120,7 +111,7 @@
120
111
  "col": 12
121
112
  },
122
113
  "service_url": {
123
- "ua": "Поислання на сервіс",
114
+ "ua": "Поислання на набір даних",
124
115
  "conditions": ["source_type","==","url"],
125
116
  "type": "Text",
126
117
  "col": 12,
@@ -16,13 +16,18 @@
16
16
  {
17
17
  "path": "gis.services",
18
18
  "table": "gis.services.table",
19
- "ua": "Сервіси"
19
+ "ua": "Набори даних"
20
20
  },
21
21
  {
22
22
  "path": "gis.group_list",
23
23
  "table": "gis.group_list.table",
24
24
  "ua": "Групи шарів"
25
25
  },
26
+ {
27
+ "path": "gis.ogc_service",
28
+ "table": "gis.ogc_service.table",
29
+ "ua": "Сервіси"
30
+ },
26
31
  {
27
32
  "path": "gis.metadata",
28
33
  "table": "gis.metadata.table",
@@ -0,0 +1,81 @@
1
+ {
2
+ "key": "service_id",
3
+ "model": "gis.ogc_service",
4
+ "table": "gis.ogc_service",
5
+ "orderby": "cdate desc",
6
+ "meta": {
7
+ "title": "name",
8
+ "search": "name"
9
+ },
10
+ "card": false,
11
+ "actions": [
12
+ "edit",
13
+ "del",
14
+ "add"
15
+ ],
16
+ "setting": [
17
+ "card",
18
+ "export",
19
+ "add"
20
+ ],
21
+ "form": "gis.ogc_service.form",
22
+ "columns": [
23
+ {
24
+ "ua": "Назва",
25
+ "name": "name",
26
+ "width": 200,
27
+ "format": "text"
28
+ },
29
+ {
30
+ "ua": "Тип сервісу",
31
+ "name": "service",
32
+ "data": "ogc.service",
33
+ "format": "select"
34
+ },
35
+ {
36
+ "ua": "Шлях",
37
+ "name": "url",
38
+ "width": 300,
39
+ "format": "text"
40
+ },
41
+ {
42
+ "ua": "On / off",
43
+ "name": "enabled",
44
+ "data": "yes_no",
45
+ "format": "badge"
46
+ },
47
+ {
48
+ "ua": "Чи є сервіс публічним?",
49
+ "name": "ispublic",
50
+ "hidden": true,
51
+ "data": "yes_no",
52
+ "format": "badge"
53
+ }
54
+ ],
55
+ "title": "Сервіси",
56
+ "filterList": [
57
+ {
58
+ "ua": "Назва",
59
+ "name": "name",
60
+ "type": "Text"
61
+ },
62
+ {
63
+ "ua": "On / Off",
64
+ "name": "enabled",
65
+ "data": "yes_no",
66
+ "type": "Check"
67
+ },
68
+ {
69
+ "ua": "Чи є сервіс публічним",
70
+ "name": "ispublic",
71
+ "data": "yes_no",
72
+ "type": "Check"
73
+ },
74
+ {
75
+ "ua": "Тип сервісу",
76
+ "name": "service",
77
+ "data": "ogc.service",
78
+ "type": "Check"
79
+ }
80
+ ]
81
+ }
@@ -17,7 +17,7 @@
17
17
  "title": "name",
18
18
  "search": "name,description,source_path"
19
19
  },
20
- "title":"Сервіси",
20
+ "title":"Набори даних",
21
21
  "form": "gis.services.form",
22
22
  "sqlColumns": "*",
23
23
  "columns": [
@@ -50,12 +50,6 @@
50
50
  "content": "<div><span v-if=\"data?.source_type==='url'\"><a :href=\"data?.service_url\" class=\"text-blue-500\">{{data?.service_url}}</a></span><span v-else-if=\"data?.source_type==='database'\">{{data?.source_path}}</span></div>"
51
51
  }
52
52
  },
53
- {
54
- "ua": "Тип сервісу",
55
- "name": "service_type",
56
- "data": "service_type",
57
- "format": "badge"
58
- },
59
53
  {
60
54
  "ua": "Публічний",
61
55
  "name": "is_public",
@@ -97,7 +91,7 @@
97
91
  "type": "Text"
98
92
  },
99
93
  {
100
- "ua": "Тип сервісу",
94
+ "ua": "Тип набору",
101
95
  "name": "service_type",
102
96
  "data": "service_type",
103
97
  "type": "Check"
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@opengis/gis",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "author": "Softpro",
6
- "main": "index.js",
6
+ "main": "plugin.js",
7
7
  "files": [
8
8
  "dist/*",
9
9
  "module/*",
@@ -12,7 +12,6 @@
12
12
  "utils.js",
13
13
  "config.js",
14
14
  "README.md",
15
- "index.js",
16
15
  "LICENSE"
17
16
  ],
18
17
  "scripts": {
@@ -48,4 +47,4 @@
48
47
  "eslint": "^8.49.0",
49
48
  "eslint-config-airbnb": "^19.0.4"
50
49
  }
51
- }
50
+ }
package/plugin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import fp from 'fastify-plugin';
2
2
 
3
- import config from './config.js';
3
+ import { config } from '@opengis/fastify-table/utils.js';
4
4
 
5
5
  config.prefix = config.prefix || '/api';
6
6
 
@@ -2,7 +2,7 @@ import path from 'path';
2
2
  import { randomUUID as uuidv4 } from 'crypto';
3
3
  import mapnik from './mapnik.js';
4
4
 
5
- import config from '../../../config.js';
5
+ import { config } from '@opengis/fastify-table/utils.js';
6
6
 
7
7
  const { mapServerAddress } = mapnik();
8
8
 
@@ -1,78 +1,101 @@
1
1
  /* eslint-disable consistent-return */
2
- import path from 'path';
2
+ import path from 'node:path';
3
+
3
4
  import grpc from '@grpc/grpc-js';
4
5
  import protoLoader from '@grpc/proto-loader';
5
- import config from '../../../config.js';
6
6
 
7
- function getMapnik() {
8
- const { mapServerAddress } = config || {};
7
+ import { config, logger } from '@opengis/fastify-table/utils.js';
9
8
 
10
- if (!mapServerAddress) {
11
- throw new Error('mapServerAddress not set in config');
12
- }
9
+ config.ready = config.ready || {};
10
+
11
+ const { mapServerAddress } = config || {};
12
+
13
+ if (!mapServerAddress) {
14
+ throw new Error('mapServerAddress not set in config');
15
+ }
16
+
17
+ const proto = grpc.loadPackageDefinition(
18
+ protoLoader.loadSync(path.join(process.cwd(), '/server/plugins/mapnik/utils/map.proto'), {
19
+ keepCase: true,
20
+ longs: String,
21
+ enums: String,
22
+ defaults: true,
23
+ oneofs: true,
24
+ }),
25
+ );
13
26
 
14
- const proto = grpc.loadPackageDefinition(
15
- protoLoader.loadSync(path.join(process.cwd(), '/server/plugins/mapnik/utils/map.proto'), {
16
- keepCase: true,
17
- longs: String,
18
- enums: String,
19
- defaults: true,
20
- oneofs: true,
21
- }),
22
- );
27
+ const mapClient = mapServerAddress ? new proto.Map(
28
+ mapServerAddress,
29
+ grpc.credentials.createInsecure(),
30
+ ) : null;
23
31
 
24
- const mapClient = mapServerAddress ? new proto.Map(
25
- mapServerAddress,
26
- grpc.credentials.createInsecure(),
27
- ) : null;
32
+ mapClient.waitForReady(Date.now() + 5000, (err) => {
33
+ if (err) {
34
+ config.ready.mapnik = false;
35
+ console.error('Mapnik client connection timeout or failure:', err);
36
+ }
37
+ else {
38
+ config.ready.mapnik = true;
39
+ console.log('Mapnik client connected successfully.');
40
+ // You can now make RPC calls safely
41
+ }
42
+ });
28
43
 
29
- const fsFuncsList = ['uploadFile', 'deleteFiles', 'downloadFile', 'checkFiles', 'fileList', 'readDir'];
44
+ const fsFuncsList = ['uploadFile', 'deleteFiles', 'downloadFile', 'checkFiles', 'fileList', 'readDir'];
30
45
 
31
- const funcs1 = [
32
- 'render', 'renderXML', 'loadXML', 'markerIcon', 'gdal',
33
- 'printMap', 'log', 'sqlToShp', 'uploadFile', 'deleteFiles',
34
- 'downloadFile', 'checkFiles', 'fileList', 'readDir', 'renderStatus',
35
- ].reduce((p, el) => {
46
+ const funcs1 = [
47
+ 'render', 'renderXML', 'loadXML', 'markerIcon', 'gdal',
48
+ 'printMap', 'log', 'sqlToShp', 'uploadFile', 'deleteFiles',
49
+ 'downloadFile', 'checkFiles', 'fileList', 'readDir', 'renderStatus',
50
+ ].reduce((p, el) => {
51
+ // eslint-disable-next-line no-param-reassign
52
+ p[el] = mapServerAddress ? async (data) => new Promise((res, rej) => {
53
+ const capitalized = fsFuncsList.includes(el) ? el : el.charAt(0).toUpperCase() + el.slice(1);
36
54
  // eslint-disable-next-line no-param-reassign
37
- p[el] = mapServerAddress ? async (data) => new Promise((res, rej) => {
38
- const capitalized = fsFuncsList.includes(el) ? el : el.charAt(0).toUpperCase() + el.slice(1);
39
- // eslint-disable-next-line no-param-reassign
40
- if (data) {
41
- if (data?.path && data.path?.[0] !== '"') {
42
- // eslint-disable-next-line no-param-reassign
43
- data.path = `"${data.path}"`;
44
- }
55
+ if (data) {
56
+ if (data?.path && data.path?.[0] !== '"') {
57
+ // eslint-disable-next-line no-param-reassign
58
+ data.path = `"${data.path}"`;
45
59
  }
60
+ }
46
61
 
47
- if (el === 'downloadFile') {
48
- const downloadBuffer = [];
49
- const download = mapClient[capitalized].call(mapClient, data, (err, data1) => {
50
- if (err || data1?.result?.startsWith?.('Usage:')) {
51
- return rej(err || data1?.result);
62
+ if (el === 'downloadFile') {
63
+ const downloadBuffer = [];
64
+ const download = mapClient[capitalized].call(mapClient, data, (err, data1) => {
65
+ if (err || data1?.result?.startsWith?.('Usage:')) {
66
+ logger.file('grpc/mapnik', { error: err.toString(), stack: err.stack, ready: config.ready.mapnik });
67
+ if (!config.ready.mapnik) {
68
+ return rej(new Error('no grpc mapnik connection'));
52
69
  }
53
- res(data1);
54
- });
55
- download.on('data', (resp) => {
56
- downloadBuffer.push(...resp.chunk_data);
57
- });
58
- download.on('end', () => res({ data: Buffer.from(downloadBuffer) }));
59
- }
60
- else {
61
- mapClient[capitalized].call(mapClient, data, (err, data1) => {
62
- if (err || data1?.result?.startsWith?.('Usage:')) {
63
- return rej(err || data1?.result);
70
+ return rej(err || data1?.result);
71
+ }
72
+ res(data1);
73
+ });
74
+ download.on('data', (resp) => {
75
+ downloadBuffer.push(...resp.chunk_data);
76
+ });
77
+ download.on('end', () => res({ data: Buffer.from(downloadBuffer) }));
78
+ }
79
+ else {
80
+ mapClient[capitalized].call(mapClient, data, (err, data1) => {
81
+ if (err || data1?.result?.startsWith?.('Usage:')) {
82
+ logger.file('grpc/mapnik', { error: err.toString(), stack: err.stack, ready: config.ready.mapnik });
83
+ if (!config.ready.mapnik) {
84
+ return rej(new Error('no grpc mapnik connection'));
64
85
  }
65
- res(data1);
66
- });
67
- }
68
- }) : null;
69
- return p;
70
- }, {});
86
+ return rej(err || data1?.result);
87
+ }
88
+ res(data1);
89
+ });
90
+ }
91
+ }) : null;
92
+ return p;
93
+ }, {});
71
94
 
72
- return {
73
- ...funcs1,
74
- mapServerAddress,
75
- };
76
- }
95
+
96
+ const getMapnik = () => ({
97
+ ...funcs1,
98
+ mapServerAddress,
99
+ });
77
100
 
78
101
  export default getMapnik;
@@ -5,8 +5,8 @@ import mapnik from './funcs/mapnik.js';
5
5
  import gdalWrapper from './funcs/gdalWrapper.js';
6
6
 
7
7
  async function plugin(fastify, opts) {
8
- fastify.decorate('mapnik', mapnik);
9
- fastify.decorate('gdalWrapper', gdalWrapper);
8
+ // fastify.decorate('mapnik', mapnik);
9
+ // fastify.decorate('gdalWrapper', gdalWrapper);
10
10
  }
11
11
 
12
12
  export default fp(plugin);
@@ -3,7 +3,7 @@ import { extractVisibleColumns } from './columns.js';
3
3
  import { getMeta, getFilterSQL } from "@opengis/fastify-table/utils.js";
4
4
 
5
5
  export async function handleRegistryRequest({ settings, query, object_id, offset, limit, page, pg }) {
6
- const { name, table_name, columns, filters, query: whereQuery, order, pk, register_id } = settings;
6
+ const { name, table_name, columns, filters, query: whereQuery, order, pk, register_id, is_files } = settings;
7
7
  const parsedColumns = Array.isArray(columns) ? columns : JSON.parse(columns);
8
8
  const filtersParsed = Array.isArray(filters) ? filters : JSON.parse(filters);
9
9
  const activeFilters = filtersParsed.filter((f) => f.disabled !== true);
@@ -44,6 +44,7 @@ export async function handleRegistryRequest({ settings, query, object_id, offset
44
44
  columns: columnsInfo,
45
45
  register_id,
46
46
  name,
47
+ is_files,
47
48
  };
48
49
  }
49
50
 
@@ -14,7 +14,7 @@ export default async function gisRegistry(req = {}) {
14
14
  const {
15
15
  rows: [registry],
16
16
  } = await pg.query(
17
- `SELECT register_id, name, table_name, columns, filters, query, "order", pk, register_key
17
+ `SELECT register_id, name, table_name, columns, filters, query, "order", pk, register_key, is_files
18
18
  FROM gis.registers
19
19
  WHERE register_key = $1`,
20
20
  [slug]
package/config.js DELETED
@@ -1,11 +0,0 @@
1
- import fs from 'fs';
2
-
3
- const fileName = ['config.json', '/data/local/config.json'].find(el => (fs.existsSync(el) ? el : null));
4
- const config = fileName ? JSON.parse(fs.readFileSync(fileName)) : {};
5
-
6
- Object.assign(config, {
7
- allTemplates: config?.allTemplates || {},
8
- skipCheckPolicyRoutes: [],
9
- });
10
-
11
- export default config;
package/index.js DELETED
@@ -1,11 +0,0 @@
1
- import fp from 'fastify-plugin';
2
- import config from './config.js';
3
-
4
- import gisRouter from './server/routes/gis/index.mjs';
5
- import mapRouter from './server/routes/map/index.mjs';
6
-
7
- async function plugin(fastify, opts) {
8
- fastify.register(gisRouter, config);
9
- fastify.register(mapRouter, config);
10
- }
11
- export default fp(plugin);
package/server/config.js DELETED
@@ -1,6 +0,0 @@
1
- import { readFile } from 'fs/promises';
2
- import fs from 'fs';
3
-
4
- const config = fs.existsSync('config.json') ? JSON.parse(await readFile('config.json')) : {};
5
-
6
- export default config;