From c94017820ac27b217f172a495d6cc0a17824b847 Mon Sep 17 00:00:00 2001
From: Ivan
Date: Tue, 18 Jul 2023 04:32:15 +0300
Subject: [PATCH] fetching db errors, devices on map, fix upd page
---
.gitignore | 1 +
package-lock.json | 395 +++++++++++++++++++++++++++
package.json | 1 +
server.js | 280 ++++++++++++++-----
static/img/warning.svg | 11 +
static/styles/main.css | 67 ++++-
static/templates/devices/index.html | 10 +
static/templates/devices/update.html | 312 +++++++++++++++++++++
static/templates/index.html | 10 +
static/templates/live.html | 224 ++++++++++++++-
10 files changed, 1232 insertions(+), 79 deletions(-)
create mode 100644 static/img/warning.svg
create mode 100644 static/templates/devices/update.html
diff --git a/.gitignore b/.gitignore
index 08e7377..58c6b60 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ static/.DS_Store
.env
package-lock.json
package-lock.json
+package-lock.json
diff --git a/package-lock.json b/package-lock.json
index 4ad4090..d0ba5fd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -13,11 +13,68 @@
"express": "^4.18.2",
"fs": "^0.0.1-security",
"handlebars": "^4.7.7",
+ "mapbox-gl": "^2.15.0",
"multer": "^1.4.5-lts.1",
"path": "^0.12.7",
"pg": "^8.11.1"
}
},
+ "node_modules/@mapbox/geojson-rewind": {
+ "version": "0.5.2",
+ "resolved": "https://registry.npmjs.org/@mapbox/geojson-rewind/-/geojson-rewind-0.5.2.tgz",
+ "integrity": "sha512-tJaT+RbYGJYStt7wI3cq4Nl4SXxG8W7JDG5DMJu97V25RnbNg3QtQtf+KD+VLjNpWKYsRvXDNmNrBgEETr1ifA==",
+ "dependencies": {
+ "get-stream": "^6.0.1",
+ "minimist": "^1.2.6"
+ },
+ "bin": {
+ "geojson-rewind": "geojson-rewind"
+ }
+ },
+ "node_modules/@mapbox/jsonlint-lines-primitives": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/@mapbox/jsonlint-lines-primitives/-/jsonlint-lines-primitives-2.0.2.tgz",
+ "integrity": "sha512-rY0o9A5ECsTQRVhv7tL/OyDpGAoUB4tTvLiW1DSzQGq4bvTPhNw1VpSNjDJc5GFZ2XuyOtSWSVN05qOtcD71qQ==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/@mapbox/mapbox-gl-supported": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/@mapbox/mapbox-gl-supported/-/mapbox-gl-supported-2.0.1.tgz",
+ "integrity": "sha512-HP6XvfNIzfoMVfyGjBckjiAOQK9WfX0ywdLubuPMPv+Vqf5fj0uCbgBQYpiqcWZT6cbyyRnTSXDheT1ugvF6UQ=="
+ },
+ "node_modules/@mapbox/point-geometry": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/@mapbox/point-geometry/-/point-geometry-0.1.0.tgz",
+ "integrity": "sha512-6j56HdLTwWGO0fJPlrZtdU/B13q8Uwmo18Ck2GnGgN9PCFyKTZ3UbXeEdRFh18i9XQ92eH2VdtpJHpBD3aripQ=="
+ },
+ "node_modules/@mapbox/tiny-sdf": {
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/@mapbox/tiny-sdf/-/tiny-sdf-2.0.6.tgz",
+ "integrity": "sha512-qMqa27TLw+ZQz5Jk+RcwZGH7BQf5G/TrutJhspsca/3SHwmgKQ1iq+d3Jxz5oysPVYTGP6aXxCo5Lk9Er6YBAA=="
+ },
+ "node_modules/@mapbox/unitbezier": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/@mapbox/unitbezier/-/unitbezier-0.0.1.tgz",
+ "integrity": "sha512-nMkuDXFv60aBr9soUG5q+GvZYL+2KZHVvsqFCzqnkGEf46U2fvmytHaEVc1/YZbiLn8X+eR3QzX1+dwDO1lxlw=="
+ },
+ "node_modules/@mapbox/vector-tile": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/@mapbox/vector-tile/-/vector-tile-1.3.1.tgz",
+ "integrity": "sha512-MCEddb8u44/xfQ3oD+Srl/tNcQoqTw3goGk2oLsrFxOTc3dUp+kAnby3PvAeeBYSMSjSPD1nd1AJA6W49WnoUw==",
+ "dependencies": {
+ "@mapbox/point-geometry": "~0.1.0"
+ }
+ },
+ "node_modules/@mapbox/whoots-js": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/@mapbox/whoots-js/-/whoots-js-3.1.0.tgz",
+ "integrity": "sha512-Es6WcD0nO5l+2BOQS4uLfNPYQaNDfbot3X1XUoloz+x0mPDS3eeORZJl06HXjwBG1fOGwCRnzK88LMdxKRrd6Q==",
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
"node_modules/accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
@@ -135,6 +192,11 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
},
+ "node_modules/csscolorparser": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/csscolorparser/-/csscolorparser-1.0.3.tgz",
+ "integrity": "sha512-umPSgYwZkdFoUrH5hIq5kf0wPSXiro51nPw0j2K/c83KflkPSTBGMz6NJvMB+07VlL0y7VPo6QJcDjcgKTTm3w=="
+ },
"node_modules/debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
@@ -171,6 +233,11 @@
"url": "https://github.com/motdotla/dotenv?sponsor=1"
}
},
+ "node_modules/earcut": {
+ "version": "2.2.4",
+ "resolved": "https://registry.npmjs.org/earcut/-/earcut-2.2.4.tgz",
+ "integrity": "sha512-/pjZsA1b4RPHbeWZQn66SWS8nZZWLQQ23oE3Eam7aroEFGEvwKAsJfZ9ytiEMycfzXWpca4FA9QIOehf7PocBQ=="
+ },
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
@@ -318,6 +385,11 @@
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
+ "node_modules/geojson-vt": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/geojson-vt/-/geojson-vt-3.2.1.tgz",
+ "integrity": "sha512-EvGQQi/zPrDA6zr6BnJD/YhwAkBP8nnJ9emh3EnHQKVMfg/MRVtPbMYdgVy/IaEmn4UfagD2a6fafPDL5hbtwg=="
+ },
"node_modules/get-intrinsic": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz",
@@ -332,6 +404,27 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/get-stream": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
+ "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==",
+ "engines": {
+ "node": ">=10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
+ "node_modules/gl-matrix": {
+ "version": "3.4.3",
+ "resolved": "https://registry.npmjs.org/gl-matrix/-/gl-matrix-3.4.3.tgz",
+ "integrity": "sha512-wcCp8vu8FT22BnvKVPjXa/ICBWRq/zjFfdofZy1WSpQZpphblv12/bOQLBC1rMM7SGOFS9ltVmKOHil5+Ml7gA=="
+ },
+ "node_modules/grid-index": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/grid-index/-/grid-index-1.1.0.tgz",
+ "integrity": "sha512-HZRwumpOGUrHyxO5bqKZL0B0GlUpwtCAzZ42sgxUPniu33R1LSFH5yrIcBCHjkctCAh3mtWKcKd9J4vDDdeVHA=="
+ },
"node_modules/handlebars": {
"version": "4.7.7",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz",
@@ -411,6 +504,25 @@
"node": ">=0.10.0"
}
},
+ "node_modules/ieee754": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
+ "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/feross"
+ },
+ {
+ "type": "patreon",
+ "url": "https://www.patreon.com/feross"
+ },
+ {
+ "type": "consulting",
+ "url": "https://feross.org/support"
+ }
+ ]
+ },
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
@@ -429,6 +541,40 @@
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ=="
},
+ "node_modules/kdbush": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/kdbush/-/kdbush-4.0.2.tgz",
+ "integrity": "sha512-WbCVYJ27Sz8zi9Q7Q0xHC+05iwkm3Znipc2XTlrnJbsHMYktW4hPhXUE8Ys1engBrvffoSCqbil1JQAa7clRpA=="
+ },
+ "node_modules/mapbox-gl": {
+ "version": "2.15.0",
+ "resolved": "https://registry.npmjs.org/mapbox-gl/-/mapbox-gl-2.15.0.tgz",
+ "integrity": "sha512-fjv+aYrd5TIHiL7wRa+W7KjtUqKWziJMZUkK5hm8TvJ3OLeNPx4NmW/DgfYhd/jHej8wWL+QJBDbdMMAKvNC0A==",
+ "dependencies": {
+ "@mapbox/geojson-rewind": "^0.5.2",
+ "@mapbox/jsonlint-lines-primitives": "^2.0.2",
+ "@mapbox/mapbox-gl-supported": "^2.0.1",
+ "@mapbox/point-geometry": "^0.1.0",
+ "@mapbox/tiny-sdf": "^2.0.6",
+ "@mapbox/unitbezier": "^0.0.1",
+ "@mapbox/vector-tile": "^1.3.1",
+ "@mapbox/whoots-js": "^3.1.0",
+ "csscolorparser": "~1.0.3",
+ "earcut": "^2.2.4",
+ "geojson-vt": "^3.2.1",
+ "gl-matrix": "^3.4.3",
+ "grid-index": "^1.1.0",
+ "kdbush": "^4.0.1",
+ "murmurhash-js": "^1.0.0",
+ "pbf": "^3.2.1",
+ "potpack": "^2.0.0",
+ "quickselect": "^2.0.0",
+ "rw": "^1.3.3",
+ "supercluster": "^8.0.0",
+ "tinyqueue": "^2.0.3",
+ "vt-pbf": "^3.1.3"
+ }
+ },
"node_modules/media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@@ -521,6 +667,11 @@
"node": ">= 6.0.0"
}
},
+ "node_modules/murmurhash-js": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/murmurhash-js/-/murmurhash-js-1.0.0.tgz",
+ "integrity": "sha512-TvmkNhkv8yct0SVBSy+o8wYzXjE4Zz3PCesbfs8HiCXXdcTuocApFv11UWlNFWKYsP2okqrhb7JNlSm9InBhIw=="
+ },
"node_modules/negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
@@ -588,6 +739,18 @@
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
},
+ "node_modules/pbf": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/pbf/-/pbf-3.2.1.tgz",
+ "integrity": "sha512-ClrV7pNOn7rtmoQVF4TS1vyU0WhYRnP92fzbfF75jAIwpnzdJXf8iTd4CMEqO4yUenH6NDqLiwjqlh6QgZzgLQ==",
+ "dependencies": {
+ "ieee754": "^1.1.12",
+ "resolve-protobuf-schema": "^2.1.0"
+ },
+ "bin": {
+ "pbf": "bin/pbf"
+ }
+ },
"node_modules/pg": {
"version": "8.11.1",
"resolved": "https://registry.npmjs.org/pg/-/pg-8.11.1.tgz",
@@ -706,6 +869,11 @@
"node": ">=0.10.0"
}
},
+ "node_modules/potpack": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/potpack/-/potpack-2.0.0.tgz",
+ "integrity": "sha512-Q+/tYsFU9r7xoOJ+y/ZTtdVQwTWfzjbiXBDMM/JKUux3+QPP02iUuIoeBQ+Ot6oEDlC+/PGjB/5A3K7KKb7hcw=="
+ },
"node_modules/process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
@@ -719,6 +887,11 @@
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
},
+ "node_modules/protocol-buffers-schema": {
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.6.0.tgz",
+ "integrity": "sha512-TdDRD+/QNdrCGCE7v8340QyuXd4kIWIgapsE2+n/SaGiSSbomYl4TjHlvIoCWRpE7wFt02EpB35VVA2ImcBVqw=="
+ },
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
@@ -745,6 +918,11 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/quickselect": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/quickselect/-/quickselect-2.0.0.tgz",
+ "integrity": "sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw=="
+ },
"node_modules/range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
@@ -772,6 +950,19 @@
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
+ "node_modules/resolve-protobuf-schema": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/resolve-protobuf-schema/-/resolve-protobuf-schema-2.1.0.tgz",
+ "integrity": "sha512-kI5ffTiZWmJaS/huM8wZfEMer1eRd7oJQhDuxeCLe3t7N7mX3z94CN0xPxBQxFYQTSNz9T0i+v6inKqSdK8xrQ==",
+ "dependencies": {
+ "protocol-buffers-schema": "^3.3.1"
+ }
+ },
+ "node_modules/rw": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/rw/-/rw-1.3.3.tgz",
+ "integrity": "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ=="
+ },
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
@@ -901,6 +1092,19 @@
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
+ "node_modules/supercluster": {
+ "version": "8.0.1",
+ "resolved": "https://registry.npmjs.org/supercluster/-/supercluster-8.0.1.tgz",
+ "integrity": "sha512-IiOea5kJ9iqzD2t7QJq/cREyLHTtSmUT6gQsweojg9WH2sYJqZK9SswTu6jrscO6D1G5v5vYZ9ru/eq85lXeZQ==",
+ "dependencies": {
+ "kdbush": "^4.0.2"
+ }
+ },
+ "node_modules/tinyqueue": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/tinyqueue/-/tinyqueue-2.0.3.tgz",
+ "integrity": "sha512-ppJZNDuKGgxzkHihX8v9v9G5f+18gzaTfrukGrq6ueg0lmH4nqVnA2IPG0AEH3jKEk2GRJCUhDoqpoiw3PHLBA=="
+ },
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
@@ -980,6 +1184,16 @@
"node": ">= 0.8"
}
},
+ "node_modules/vt-pbf": {
+ "version": "3.1.3",
+ "resolved": "https://registry.npmjs.org/vt-pbf/-/vt-pbf-3.1.3.tgz",
+ "integrity": "sha512-2LzDFzt0mZKZ9IpVF2r69G9bXaP2Q2sArJCmcCgvfTdCCZzSyz4aCLoQyUilu37Ll56tCblIZrXFIjNUpGIlmA==",
+ "dependencies": {
+ "@mapbox/point-geometry": "0.1.0",
+ "@mapbox/vector-tile": "^1.3.1",
+ "pbf": "^3.2.1"
+ }
+ },
"node_modules/wordwrap": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
@@ -995,6 +1209,53 @@
}
},
"dependencies": {
+ "@mapbox/geojson-rewind": {
+ "version": "0.5.2",
+ "resolved": "https://registry.npmjs.org/@mapbox/geojson-rewind/-/geojson-rewind-0.5.2.tgz",
+ "integrity": "sha512-tJaT+RbYGJYStt7wI3cq4Nl4SXxG8W7JDG5DMJu97V25RnbNg3QtQtf+KD+VLjNpWKYsRvXDNmNrBgEETr1ifA==",
+ "requires": {
+ "get-stream": "^6.0.1",
+ "minimist": "^1.2.6"
+ }
+ },
+ "@mapbox/jsonlint-lines-primitives": {
+ "version": "2.0.2",
+ "resolved": "https://registry.npmjs.org/@mapbox/jsonlint-lines-primitives/-/jsonlint-lines-primitives-2.0.2.tgz",
+ "integrity": "sha512-rY0o9A5ECsTQRVhv7tL/OyDpGAoUB4tTvLiW1DSzQGq4bvTPhNw1VpSNjDJc5GFZ2XuyOtSWSVN05qOtcD71qQ=="
+ },
+ "@mapbox/mapbox-gl-supported": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/@mapbox/mapbox-gl-supported/-/mapbox-gl-supported-2.0.1.tgz",
+ "integrity": "sha512-HP6XvfNIzfoMVfyGjBckjiAOQK9WfX0ywdLubuPMPv+Vqf5fj0uCbgBQYpiqcWZT6cbyyRnTSXDheT1ugvF6UQ=="
+ },
+ "@mapbox/point-geometry": {
+ "version": "0.1.0",
+ "resolved": "https://registry.npmjs.org/@mapbox/point-geometry/-/point-geometry-0.1.0.tgz",
+ "integrity": "sha512-6j56HdLTwWGO0fJPlrZtdU/B13q8Uwmo18Ck2GnGgN9PCFyKTZ3UbXeEdRFh18i9XQ92eH2VdtpJHpBD3aripQ=="
+ },
+ "@mapbox/tiny-sdf": {
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/@mapbox/tiny-sdf/-/tiny-sdf-2.0.6.tgz",
+ "integrity": "sha512-qMqa27TLw+ZQz5Jk+RcwZGH7BQf5G/TrutJhspsca/3SHwmgKQ1iq+d3Jxz5oysPVYTGP6aXxCo5Lk9Er6YBAA=="
+ },
+ "@mapbox/unitbezier": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/@mapbox/unitbezier/-/unitbezier-0.0.1.tgz",
+ "integrity": "sha512-nMkuDXFv60aBr9soUG5q+GvZYL+2KZHVvsqFCzqnkGEf46U2fvmytHaEVc1/YZbiLn8X+eR3QzX1+dwDO1lxlw=="
+ },
+ "@mapbox/vector-tile": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/@mapbox/vector-tile/-/vector-tile-1.3.1.tgz",
+ "integrity": "sha512-MCEddb8u44/xfQ3oD+Srl/tNcQoqTw3goGk2oLsrFxOTc3dUp+kAnby3PvAeeBYSMSjSPD1nd1AJA6W49WnoUw==",
+ "requires": {
+ "@mapbox/point-geometry": "~0.1.0"
+ }
+ },
+ "@mapbox/whoots-js": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/@mapbox/whoots-js/-/whoots-js-3.1.0.tgz",
+ "integrity": "sha512-Es6WcD0nO5l+2BOQS4uLfNPYQaNDfbot3X1XUoloz+x0mPDS3eeORZJl06HXjwBG1fOGwCRnzK88LMdxKRrd6Q=="
+ },
"accepts": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
@@ -1085,6 +1346,11 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
},
+ "csscolorparser": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/csscolorparser/-/csscolorparser-1.0.3.tgz",
+ "integrity": "sha512-umPSgYwZkdFoUrH5hIq5kf0wPSXiro51nPw0j2K/c83KflkPSTBGMz6NJvMB+07VlL0y7VPo6QJcDjcgKTTm3w=="
+ },
"debug": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
@@ -1108,6 +1374,11 @@
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
"integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ=="
},
+ "earcut": {
+ "version": "2.2.4",
+ "resolved": "https://registry.npmjs.org/earcut/-/earcut-2.2.4.tgz",
+ "integrity": "sha512-/pjZsA1b4RPHbeWZQn66SWS8nZZWLQQ23oE3Eam7aroEFGEvwKAsJfZ9ytiEMycfzXWpca4FA9QIOehf7PocBQ=="
+ },
"ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
@@ -1232,6 +1503,11 @@
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
+ "geojson-vt": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/geojson-vt/-/geojson-vt-3.2.1.tgz",
+ "integrity": "sha512-EvGQQi/zPrDA6zr6BnJD/YhwAkBP8nnJ9emh3EnHQKVMfg/MRVtPbMYdgVy/IaEmn4UfagD2a6fafPDL5hbtwg=="
+ },
"get-intrinsic": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz",
@@ -1243,6 +1519,21 @@
"has-symbols": "^1.0.3"
}
},
+ "get-stream": {
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz",
+ "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg=="
+ },
+ "gl-matrix": {
+ "version": "3.4.3",
+ "resolved": "https://registry.npmjs.org/gl-matrix/-/gl-matrix-3.4.3.tgz",
+ "integrity": "sha512-wcCp8vu8FT22BnvKVPjXa/ICBWRq/zjFfdofZy1WSpQZpphblv12/bOQLBC1rMM7SGOFS9ltVmKOHil5+Ml7gA=="
+ },
+ "grid-index": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/grid-index/-/grid-index-1.1.0.tgz",
+ "integrity": "sha512-HZRwumpOGUrHyxO5bqKZL0B0GlUpwtCAzZ42sgxUPniu33R1LSFH5yrIcBCHjkctCAh3mtWKcKd9J4vDDdeVHA=="
+ },
"handlebars": {
"version": "4.7.7",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz",
@@ -1293,6 +1584,11 @@
"safer-buffer": ">= 2.1.2 < 3"
}
},
+ "ieee754": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
+ "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="
+ },
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
@@ -1308,6 +1604,40 @@
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ=="
},
+ "kdbush": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/kdbush/-/kdbush-4.0.2.tgz",
+ "integrity": "sha512-WbCVYJ27Sz8zi9Q7Q0xHC+05iwkm3Znipc2XTlrnJbsHMYktW4hPhXUE8Ys1engBrvffoSCqbil1JQAa7clRpA=="
+ },
+ "mapbox-gl": {
+ "version": "2.15.0",
+ "resolved": "https://registry.npmjs.org/mapbox-gl/-/mapbox-gl-2.15.0.tgz",
+ "integrity": "sha512-fjv+aYrd5TIHiL7wRa+W7KjtUqKWziJMZUkK5hm8TvJ3OLeNPx4NmW/DgfYhd/jHej8wWL+QJBDbdMMAKvNC0A==",
+ "requires": {
+ "@mapbox/geojson-rewind": "^0.5.2",
+ "@mapbox/jsonlint-lines-primitives": "^2.0.2",
+ "@mapbox/mapbox-gl-supported": "^2.0.1",
+ "@mapbox/point-geometry": "^0.1.0",
+ "@mapbox/tiny-sdf": "^2.0.6",
+ "@mapbox/unitbezier": "^0.0.1",
+ "@mapbox/vector-tile": "^1.3.1",
+ "@mapbox/whoots-js": "^3.1.0",
+ "csscolorparser": "~1.0.3",
+ "earcut": "^2.2.4",
+ "geojson-vt": "^3.2.1",
+ "gl-matrix": "^3.4.3",
+ "grid-index": "^1.1.0",
+ "kdbush": "^4.0.1",
+ "murmurhash-js": "^1.0.0",
+ "pbf": "^3.2.1",
+ "potpack": "^2.0.0",
+ "quickselect": "^2.0.0",
+ "rw": "^1.3.3",
+ "supercluster": "^8.0.0",
+ "tinyqueue": "^2.0.3",
+ "vt-pbf": "^3.1.3"
+ }
+ },
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
@@ -1373,6 +1703,11 @@
"xtend": "^4.0.0"
}
},
+ "murmurhash-js": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/murmurhash-js/-/murmurhash-js-1.0.0.tgz",
+ "integrity": "sha512-TvmkNhkv8yct0SVBSy+o8wYzXjE4Zz3PCesbfs8HiCXXdcTuocApFv11UWlNFWKYsP2okqrhb7JNlSm9InBhIw=="
+ },
"negotiator": {
"version": "0.6.3",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
@@ -1425,6 +1760,15 @@
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
"integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
},
+ "pbf": {
+ "version": "3.2.1",
+ "resolved": "https://registry.npmjs.org/pbf/-/pbf-3.2.1.tgz",
+ "integrity": "sha512-ClrV7pNOn7rtmoQVF4TS1vyU0WhYRnP92fzbfF75jAIwpnzdJXf8iTd4CMEqO4yUenH6NDqLiwjqlh6QgZzgLQ==",
+ "requires": {
+ "ieee754": "^1.1.12",
+ "resolve-protobuf-schema": "^2.1.0"
+ }
+ },
"pg": {
"version": "8.11.1",
"resolved": "https://registry.npmjs.org/pg/-/pg-8.11.1.tgz",
@@ -1510,6 +1854,11 @@
"xtend": "^4.0.0"
}
},
+ "potpack": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/potpack/-/potpack-2.0.0.tgz",
+ "integrity": "sha512-Q+/tYsFU9r7xoOJ+y/ZTtdVQwTWfzjbiXBDMM/JKUux3+QPP02iUuIoeBQ+Ot6oEDlC+/PGjB/5A3K7KKb7hcw=="
+ },
"process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
@@ -1520,6 +1869,11 @@
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
},
+ "protocol-buffers-schema": {
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.6.0.tgz",
+ "integrity": "sha512-TdDRD+/QNdrCGCE7v8340QyuXd4kIWIgapsE2+n/SaGiSSbomYl4TjHlvIoCWRpE7wFt02EpB35VVA2ImcBVqw=="
+ },
"proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
@@ -1537,6 +1891,11 @@
"side-channel": "^1.0.4"
}
},
+ "quickselect": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/quickselect/-/quickselect-2.0.0.tgz",
+ "integrity": "sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw=="
+ },
"range-parser": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
@@ -1563,6 +1922,19 @@
}
}
},
+ "resolve-protobuf-schema": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/resolve-protobuf-schema/-/resolve-protobuf-schema-2.1.0.tgz",
+ "integrity": "sha512-kI5ffTiZWmJaS/huM8wZfEMer1eRd7oJQhDuxeCLe3t7N7mX3z94CN0xPxBQxFYQTSNz9T0i+v6inKqSdK8xrQ==",
+ "requires": {
+ "protocol-buffers-schema": "^3.3.1"
+ }
+ },
+ "rw": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/rw/-/rw-1.3.3.tgz",
+ "integrity": "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ=="
+ },
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
@@ -1661,6 +2033,19 @@
}
}
},
+ "supercluster": {
+ "version": "8.0.1",
+ "resolved": "https://registry.npmjs.org/supercluster/-/supercluster-8.0.1.tgz",
+ "integrity": "sha512-IiOea5kJ9iqzD2t7QJq/cREyLHTtSmUT6gQsweojg9WH2sYJqZK9SswTu6jrscO6D1G5v5vYZ9ru/eq85lXeZQ==",
+ "requires": {
+ "kdbush": "^4.0.2"
+ }
+ },
+ "tinyqueue": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/tinyqueue/-/tinyqueue-2.0.3.tgz",
+ "integrity": "sha512-ppJZNDuKGgxzkHihX8v9v9G5f+18gzaTfrukGrq6ueg0lmH4nqVnA2IPG0AEH3jKEk2GRJCUhDoqpoiw3PHLBA=="
+ },
"toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
@@ -1721,6 +2106,16 @@
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg=="
},
+ "vt-pbf": {
+ "version": "3.1.3",
+ "resolved": "https://registry.npmjs.org/vt-pbf/-/vt-pbf-3.1.3.tgz",
+ "integrity": "sha512-2LzDFzt0mZKZ9IpVF2r69G9bXaP2Q2sArJCmcCgvfTdCCZzSyz4aCLoQyUilu37Ll56tCblIZrXFIjNUpGIlmA==",
+ "requires": {
+ "@mapbox/point-geometry": "0.1.0",
+ "@mapbox/vector-tile": "^1.3.1",
+ "pbf": "^3.2.1"
+ }
+ },
"wordwrap": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
diff --git a/package.json b/package.json
index 78471c1..96f03fc 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,7 @@
"express": "^4.18.2",
"fs": "^0.0.1-security",
"handlebars": "^4.7.7",
+ "mapbox-gl": "^2.15.0",
"multer": "^1.4.5-lts.1",
"path": "^0.12.7",
"pg": "^8.11.1"
diff --git a/server.js b/server.js
index 332e3ab..cf27b10 100644
--- a/server.js
+++ b/server.js
@@ -22,26 +22,36 @@ app.get("/devices", devices);
app.get("/devices/drivers", drivers);
app.get("/devices/newdevice", newdevice);
app.get("/devices/newdriver", newdriver);
+app.get("/devices/update", update);
-// const pool = new Pool({
-// user: process.env.DB_USER,
-// host: process.env.DB_HOST,
-// database: process.env.DB_NAME,
-// password: process.env.DB_PASSWORD,
-// port: process.env.DB_PORT,
-// });
+// const DB_User = process.env.DB_USER;
+// const DB_Password = process.env.DB_PASSWORD;
+// const DB_Host = process.env.DB_HOST;
+// const DB_Port = process.env.DB_PORT;
+// const DB_Name = process.env.DB_NAME;
-const pool = new Pool({
- user: "postgres",
- host: "postgres",
- database: "postgres",
- password: "password",
- port: "5432",
-});
+const DB_User = "postgres";
+const DB_Password = "password";
+const DB_Host = "postgres";
+const DB_Port = "5432";
+const DB_Name = "postgres";
async function index(req, res) {
- const client = await pool.connect();
+ var templateData = {
+ Organisation: "Название организации",
+ User: "Тестовое Имя",
+ ifDBError: false,
+ Count: "",
+ };
try {
+ const pool = new Pool({
+ user: DB_User,
+ host: DB_Host,
+ database: DB_Name,
+ password: DB_Password,
+ port: DB_Port,
+ });
+ const client = await pool.connect();
// Выполняем запрос и получаем результат
const query = `
SELECT COUNT(*) AS count
@@ -49,11 +59,7 @@ async function index(req, res) {
`;
const registrars = await client.query(query);
- var templateData = {
- Organisation: "Название организации",
- User: "Тестовое Имя",
- Count: registrars.rows[0].count,
- };
+ templateData.Count = registrars.rows[0].count;
console.log(templateData);
@@ -63,8 +69,14 @@ async function index(req, res) {
const resultT = template(templateData);
res.send(resultT);
- } finally {
- client.release();
+ } catch (error) {
+ console.error(error);
+ templateData.ifDBError = true;
+
+ const source = fs.readFileSync("static/templates/index.html", "utf8");
+ const template = handlebars.compile(source);
+ const resultT = template(templateData);
+ res.send(resultT);
}
// res.sendFile(path.join(__dirname, "static/templates/index.html"));
}
@@ -74,16 +86,118 @@ function login(req, res) {
function register(req, res) {
res.sendFile(path.join(__dirname, "static/templates/register.html"));
}
-function live(req, res) {
- res.sendFile(path.join(__dirname, "static/templates/live.html"));
-}
-async function reports(req, res) {
- const client = await pool.connect();
+
+async function live(req, res) {
+ let templateData = {
+ Organisation: "Название организации",
+ User: "Тестовое Имя",
+ ifDBError: false,
+ Registrars: [],
+ };
+
try {
+ const pool = new Pool({
+ user: DB_User,
+ host: DB_Host,
+ database: DB_Name,
+ password: DB_Password,
+ port: DB_Port,
+ });
+ const client = await pool.connect();
+
+ const query = `
+ SELECT id FROM registrars ORDER BY id ASC
+ `;
+ const registrars = await client.query(query);
+
+ templateData.Registrars = registrars.rows.map((row) => row.id);
+
+ console.log(templateData);
+
+ const source = fs.readFileSync("static/templates/live.html", "utf8");
+ const template = handlebars.compile(source);
+ const resultHTML = template(templateData);
+ res.send(resultHTML);
+
+ client.release();
+ } catch (error) {
+ console.error(error);
+ templateData.ifDBError = true;
+
+ const source = fs.readFileSync("static/templates/live.html", "utf8");
+ const template = handlebars.compile(source);
+ const resultT = template(templateData);
+ res.send(resultT);
+ }
+}
+
+app.post("/devices-geo", async (req, res) => {
+ const selectedDevices = req.body.devices;
+
+ const pool = new Pool({
+ user: DB_User,
+ host: DB_Host,
+ database: DB_Name,
+ password: DB_Password,
+ port: DB_Port,
+ });
+
+ console.log(selectedDevices);
+
+ const placeholders = selectedDevices
+ .map((_, index) => `$${index + 1}`)
+ .join(",");
+ const subquery = `
+ SELECT MAX(time) AS time, serial
+ FROM geo
+ WHERE serial IN (
+ SELECT serial
+ FROM registrars
+ WHERE id IN (${placeholders})
+ )
+ GROUP BY serial
+ `;
+ const query = `
+ SELECT g.serial, g.longitude, g.latitude, g.direction, g.speed
+ FROM geo g
+ INNER JOIN (${subquery}) s
+ ON g.serial = s.serial AND g.time = s.time
+ `;
+
+ pool.query(query, selectedDevices, (err, result) => {
+ if (err) {
+ console.error("Ошибка выполнения запроса:", err);
+ res.status(500).json({ error: "Ошибка сервера" });
+ return;
+ }
+
+ console.log(result.rows);
+
+ const devicesData = result.rows;
+ res.json({ devicesData });
+ });
+});
+
+async function reports(req, res) {
+ try {
+ const pool = new Pool({
+ user: DB_User,
+ host: DB_Host,
+ database: DB_Name,
+ password: DB_Password,
+ port: DB_Port,
+ });
+ const client = await pool.connect();
// Выполняем запрос и получаем результат
const query = `
- SELECT id, cmdno, time, serial, st
- FROM alarms
+ SELECT id, cmdno, time, serial, st
+ FROM (
+ SELECT id, cmdno, time, serial, st
+ FROM alarms
+ ORDER BY time DESC
+ LIMIT 100
+ ) AS subquery
+ ORDER BY time ASC;
`;
const alarms = await client.query(query);
@@ -139,8 +253,17 @@ async function reports(req, res) {
const resultT = template(templateData);
res.send(resultT);
- } finally {
- client.release();
+ } catch (error) {
+ console.error(error);
+ // templateData.ifDBError = true;
+
+ const source = fs.readFileSync(
+ "static/templates/reports/index.html",
+ "utf8"
+ );
+ const template = handlebars.compile(source);
+ const resultT = template(templateData);
+ res.send(resultT);
}
// res.sendFile(path.join(__dirname, "static/templates/reports/index.html"));
}
@@ -148,8 +271,23 @@ function reports346(req, res) {
res.sendFile(path.join(__dirname, "static/templates/reports/346.html"));
}
async function devices(req, res) {
- const client = await pool.connect();
+ let templateData = {
+ Organisation: "Название организации",
+ User: "Тестовое Имя",
+ ifDBError: false,
+ Registrars: [],
+ };
+
try {
+ const pool = new Pool({
+ user: DB_User,
+ host: DB_Host,
+ database: DB_Name,
+ password: DB_Password,
+ port: DB_Port,
+ });
+ const client = await pool.connect();
+
// Выполняем два запроса и получаем результаты
const queryConnected = `
SELECT id, serial, connected, name, "group", plate, sim, ip, port
@@ -166,34 +304,30 @@ async function devices(req, res) {
const connectedRegistrars = await client.query(queryConnected);
const disconnectedRegistrars = await client.query(queryDisconnected);
- const templateData = {
- Organisation: "Название организации",
- User: "Тестовое Имя",
- Registrars: [
- ...connectedRegistrars.rows.map((registrar) => ({
- id: registrar.id,
- serial: registrar.serial,
- status: registrar.connected,
- name: registrar.name,
- group: registrar.group,
- plate: registrar.plate,
- sim: registrar.sim,
- ip: registrar.ip,
- port: registrar.port,
- })),
- ...disconnectedRegistrars.rows.map((registrar) => ({
- id: registrar.id,
- serial: registrar.serial,
- status: registrar.connected,
- name: registrar.name,
- group: registrar.group,
- plate: registrar.plate,
- sim: registrar.sim,
- ip: registrar.ip,
- port: registrar.port,
- })),
- ],
- };
+ templateData.Registrars = [
+ ...connectedRegistrars.rows.map((registrar) => ({
+ id: registrar.id,
+ serial: registrar.serial,
+ status: registrar.connected,
+ name: registrar.name,
+ group: registrar.group,
+ plate: registrar.plate,
+ sim: registrar.sim,
+ ip: registrar.ip,
+ port: registrar.port,
+ })),
+ ...disconnectedRegistrars.rows.map((registrar) => ({
+ id: registrar.id,
+ serial: registrar.serial,
+ status: registrar.connected,
+ name: registrar.name,
+ group: registrar.group,
+ plate: registrar.plate,
+ sim: registrar.sim,
+ ip: registrar.ip,
+ port: registrar.port,
+ })),
+ ];
console.log(templateData);
@@ -201,20 +335,37 @@ async function devices(req, res) {
"static/templates/devices/index.html",
"utf8"
);
-
const template = handlebars.compile(source);
-
const resultT = template(templateData);
res.send(resultT);
- } finally {
+
client.release();
+ } catch (error) {
+ console.error(error);
+ templateData.ifDBError = true;
+
+ const source = fs.readFileSync(
+ "static/templates/devices/index.html",
+ "utf8"
+ );
+ const template = handlebars.compile(source);
+ const resultT = template(templateData);
+ res.send(resultT);
}
}
app.post("/devicedata", async (req, res) => {
const id = req.body.id;
+ const pool = new Pool({
+ user: DB_User,
+ host: DB_Host,
+ database: DB_Name,
+ password: DB_Password,
+ port: DB_Port,
+ });
const client = await pool.connect();
+
try {
// Выполняем запрос и получаем результат
const query = "SELECT * FROM registrars WHERE id = $1;";
@@ -361,6 +512,9 @@ function newdevice(req, res) {
function newdriver(req, res) {
res.sendFile(path.join(__dirname, "static/templates/devices/newdriver.html"));
}
+function update(req, res) {
+ res.sendFile(path.join(__dirname, "static/templates/devices/update.html"));
+}
const port = 8081;
app.listen(port, () => {
diff --git a/static/img/warning.svg b/static/img/warning.svg
new file mode 100644
index 0000000..4ec8e45
--- /dev/null
+++ b/static/img/warning.svg
@@ -0,0 +1,11 @@
+
+
+
+
diff --git a/static/styles/main.css b/static/styles/main.css
index e0f6bdf..8b20155 100644
--- a/static/styles/main.css
+++ b/static/styles/main.css
@@ -18,6 +18,7 @@ body {
margin: 0;
width: 100%;
min-height: 100%;
+ overflow-y: hidden;
}
header {
@@ -751,7 +752,21 @@ tr:nth-child(even) {
transition: 0.1s;
}
-.form button:hover {
+.erorr-container button {
+ font-weight: 500;
+ font-size: 16px;
+ margin-top: 15px;
+ width: auto;
+ background-color: #8086f9;
+ color: white;
+ padding: 10px;
+ border: 1px solid rgba(0, 0, 0, 0.1);
+ border-radius: 5px;
+ transition: 0.1s;
+}
+
+.form button:hover,
+.erorr-container button:hover {
cursor: pointer;
opacity: 80%;
}
@@ -1374,6 +1389,7 @@ video {
transition: 1s;
position: relative;
float: left;
+ z-index: 10;
}
.signals-list.hide {
@@ -1418,8 +1434,10 @@ video {
width: 100%;
list-style: none;
padding: 0;
- overflow-y: scroll;
+ overflow-y: auto;
white-space: nowrap;
+ height: 150px;
+ padding-bottom: 50px;
}
.signals-list li {
@@ -1497,13 +1515,20 @@ video {
}
.map {
- background-color: #ff443a2f;
+ /* background-color: #ff443a2f; */
width: 100%;
height: 100%;
display: block;
/* float: right; */
}
+#map {
+ width: 100%;
+ height: 100%;
+ position: absolute;
+ border-radius: 29px;
+}
+
.edit-container {
position: fixed;
width: 100%;
@@ -1516,6 +1541,7 @@ video {
justify-content: center;
align-items: center;
transition: opacity 0.4s ease-in-out;
+ overflow: hidden;
}
.edit-container.active {
@@ -1559,6 +1585,41 @@ video {
height: 20px;
}
+.dberror {
+ background-color: #00000039;
+ position: fixed;
+ width: 100%;
+ height: 100%;
+ top: 62px;
+ z-index: 1000;
+ overflow: hidden;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
+
+.erorr-container {
+ width: 633px;
+ height: 362px;
+ border-radius: 20px;
+ background: #fff;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ flex-direction: column;
+}
+
+.erorr-container img {
+ width: 110px;
+}
+
+.erorr-container h1 {
+ font-size: 30px;
+ font-weight: 600;
+ margin-top: 5px;
+ margin-bottom: 0;
+}
+
@media (max-width: 1950px) {
/* при разрешении монитора до 1950 пикселей */
diff --git a/static/templates/devices/index.html b/static/templates/devices/index.html
index 3229f43..8ca7449 100644
--- a/static/templates/devices/index.html
+++ b/static/templates/devices/index.html
@@ -49,6 +49,16 @@
+ {{#if ifDBError}}
+
+
+
+
Ошибка
+
Не удалось получить данные из БД
+
+
+
+ {{/if}}
Устройства
diff --git a/static/templates/devices/update.html b/static/templates/devices/update.html
new file mode 100644
index 0000000..05078b1
--- /dev/null
+++ b/static/templates/devices/update.html
@@ -0,0 +1,312 @@
+
+
+
+
+
+
+ Устройства
+
+
+
+
+
+ Аргус
+ / Название организации
+
+
+
+
+
+
+
+
+
+
+
+ Устройства
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Новое обновление
+
+
+
+
+
+
+
+
+
+
Время обновления
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/static/templates/index.html b/static/templates/index.html
index 90b8ceb..19ff391 100644
--- a/static/templates/index.html
+++ b/static/templates/index.html
@@ -51,6 +51,16 @@
+ {{#if ifDBError}}
+
+
+
+
Ошибка
+
Не удалось получить данные из БД
+
+
+
+ {{/if}}
Сводка по {{Count}} ТС
diff --git a/static/templates/live.html b/static/templates/live.html
index 5d173e6..76fefff 100644
--- a/static/templates/live.html
+++ b/static/templates/live.html
@@ -6,6 +6,9 @@
Трансляция
+
+
+
@@ -49,6 +52,16 @@
+ {{#if ifDBError}}
+
+
+
+
Ошибка
+
Не удалось получить данные из БД
+
+
+
+ {{/if}}
Прямые трансляции
@@ -66,11 +79,21 @@
@@ -98,7 +121,7 @@
-
-
+
@@ -250,9 +273,184 @@
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+ -->