From 62453b6ba1028f34513bb6400fca63bab4d82a73 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sun, 10 Sep 2023 19:36:39 +0300 Subject: [PATCH] report info update --- server.js | 76 +++++++++++++++------------- static/styles/main.css | 37 ++++++++++++-- static/templates/devices/update.html | 2 +- static/templates/live.html | 20 +------- static/templates/reports/report.html | 36 ++++++------- 5 files changed, 95 insertions(+), 76 deletions(-) diff --git a/server.js b/server.js index 2f6b226..4fb743a 100644 --- a/server.js +++ b/server.js @@ -104,17 +104,17 @@ conn.on('error', function(err) { }); -// 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 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 DB_User = "postgres"; -const DB_Password = process.env.POSTGRES_PASSWORD; -const DB_Host = "postgres"; -const DB_Port = "5432"; -const DB_Name = "postgres"; +// const DB_User = "postgres"; +// const DB_Password = process.env.POSTGRES_PASSWORD; +// const DB_Host = "postgres"; +// const DB_Port = "5432"; +// const DB_Name = "postgres"; async function index(req, res) { var templateData = { @@ -925,6 +925,9 @@ app.get('/reports/:id', async (req, res) => { Geo: "", Latitude: "", Longitude: "", + QueryTime: "", + StartTime: "", + EndTime: "", DriverName: "", DriverPhone: "", @@ -1010,6 +1013,32 @@ app.get('/reports/:id', async (req, res) => { return formattedDate.replace(",", ""); } + function formatDateToYYYYMMDD(sqlDate) { + const date = new Date(sqlDate); + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + return `${year}${month}${day}`; + } + + function formatTimeToHHMMSSBefore(sqlDate) { + const date = new Date(sqlDate); + date.setSeconds(date.getSeconds() - 10); + const hours = String(date.getHours()).padStart(2, '0'); + const minutes = String(date.getMinutes()).padStart(2, '0'); + const seconds = String(date.getSeconds()).padStart(2, '0'); + return `${hours}${minutes}${seconds}`; + } + + function formatTimeToHHMMSSAfter(sqlDate) { + const date = new Date(sqlDate); + date.setSeconds(date.getSeconds() + 10); + const hours = String(date.getHours()).padStart(2, '0'); + const minutes = String(date.getMinutes()).padStart(2, '0'); + const seconds = String(date.getSeconds()).padStart(2, '0'); + return `${hours}${minutes}${seconds}`; + } + let type; switch (alarm.st) { case "0": @@ -1123,6 +1152,9 @@ app.get('/reports/:id', async (req, res) => { templateData.Geo = alarm.latitude + "," + alarm.longitude; templateData.Latitude = alarm.latitude templateData.Longitude = alarm.longitude + templateData.QueryTime = formatDateToYYYYMMDD(alarm.time); + templateData.StartTime = formatTimeToHHMMSSBefore(alarm.time); + templateData.EndTime = formatTimeToHHMMSSAfter(alarm.time); templateData.DriverName = alarm.name + " " + alarm.surname; templateData.DriverPhone = alarm.phone; @@ -1142,30 +1174,6 @@ app.get('/reports/:id', async (req, res) => { return speed; } }); - - -let data = { - Id: templateData.Id, - Organisation: templateData.Organisation, - Type: templateData.Type, - Speed: templateData.Speed, - Date: templateData.Date, - Serial: templateData.Serial, - Geo: templateData.Geo, - PrevLongitude: templateData.PrevLongitude, - PrevLatitude: templateData.PrevLatitude, - NextLongitude: templateData.NextLongitude, - NextLatitude: templateData.NextLatitude, - Speeds: templateData.Speeds, -}; - - generatePDF(data) - .then(() => { - console.log('PDF создан успешно.'); - }) - .catch((error) => { - console.error('Ошибка при создании PDF:', error); - }); // console.log(templateData); diff --git a/static/styles/main.css b/static/styles/main.css index 8e510da..98cbcda 100644 --- a/static/styles/main.css +++ b/static/styles/main.css @@ -1917,7 +1917,8 @@ input[type="datetime-local"] { } .video-container div, -.video-container-right div { +.video-container-right div, +.report-video-container div { display: flex; flex-direction: column; align-items: center; @@ -1928,18 +1929,21 @@ input[type="datetime-local"] { } .video-container div:hover, -.video-container-right div:hover { +.video-container-right div:hover, +.report-video-container div:hover { background-color: rgba(0, 0, 0, 0.1); } .video-container div img, -.video-container-right div img { +.video-container-right div img, +.report-video-container div img { height: 32px; width: 32px; } .video-container div span, -.video-container-right div span { +.video-container-right div span, +.report-video-container div span { font-size: 16px; font-weight: 500; margin-top: 15px; @@ -1963,6 +1967,31 @@ input[type="datetime-local"] { } +.report-video-container { + position: absolute; + left: 0; + bottom: 0; + width: 510px; + border-right: 2px solid rgba(245, 245, 250, 1); + display: flex; + height: calc(100% - 266px - 198px - 62px); + flex-wrap: wrap; +} + +.report-video-container div { + height: auto; + box-sizing: border-box; + width: 100%; + padding: 0; + height: 50%; + border: 1px solid rgba(245, 245, 250, 1); + display: flex; + flex-direction: column; + align-items: center; + text-align: center; + justify-content: center; +} + .report video { width: 450px; border-right: 2px solid rgba(245, 245, 250, 1); diff --git a/static/templates/devices/update.html b/static/templates/devices/update.html index 60507a3..5f9ac80 100644 --- a/static/templates/devices/update.html +++ b/static/templates/devices/update.html @@ -50,7 +50,7 @@
- Устройства + В разработке