diff --git a/server.js b/server.js index 0d83d8b..4640135 100644 --- a/server.js +++ b/server.js @@ -45,8 +45,7 @@ app.get("/register", register); app.get("/live", live); app.get("/reports", reports); app.get("/devices", devices); -// app.get("/devices/drivers", drivers); -app.get("/devices/update", update); +// app.get("/devices/update", update); app.get("/devices/groups", groups) app.get("/videos", videos); app.get("/videos/export",videoExport); @@ -1221,11 +1220,6 @@ app.get('/reports/:id', async (req, res) => { QueryTime: "", StartTime: "", EndTime: "", - - DriverName: "", - DriverPhone: "", - DriverEmail: "", - DriverLicense: "", PrevLatitude: "", PrevLongitude: "", @@ -1273,15 +1267,9 @@ app.get('/reports/:id', async (req, res) => { (SELECT g4.longitude FROM alarms a4 LEFT JOIN geo g4 ON a4.geoid = g4.id WHERE a4.evtuuid = a.evtuuid ORDER BY a4.time DESC LIMIT 1) AS next_longitude, g.longitude, g.latitude, - g.speed, - d.name, - d.surname, - d.card, - d.phone, - d.email + g.speed FROM alarms a LEFT JOIN geo g ON a.geoid = g.id - LEFT JOIN drivers d ON a.serial = d.transport WHERE a.id = ${id} LIMIT 1 ), @@ -1465,11 +1453,6 @@ app.get('/reports/:id', async (req, res) => { templateData.StartTime = formatTimeToHHMMSSBefore(alarm.time); templateData.EndTime = formatTimeToHHMMSSAfter(alarm.time); - templateData.DriverName = alarm.name + " " + alarm.surname; - templateData.DriverPhone = alarm.phone; - templateData.DriverEmail = alarm.email; - templateData.DriverLicense = alarm.card; - templateData.PrevLatitude = alarm.prev_latitude; templateData.PrevLongitude = alarm.prev_longitude; templateData.NextLatitude = alarm.next_latitude; @@ -1531,11 +1514,6 @@ app.get('/generate-pdf/:id', async (req, res) => { Geo: "", Latitude: "", Longitude: "", - - DriverName: "", - DriverPhone: "", - DriverEmail: "", - DriverLicense: "", PrevLatitude: "", PrevLongitude: "", @@ -1569,15 +1547,9 @@ app.get('/generate-pdf/:id', async (req, res) => { (SELECT g4.longitude FROM alarms a4 LEFT JOIN geo g4 ON a4.geoid = g4.id WHERE a4.evtuuid = a.evtuuid ORDER BY a4.time DESC LIMIT 1) AS next_longitude, g.longitude, g.latitude, - g.speed, - d.name, - d.surname, - d.card, - d.phone, - d.email + g.speed FROM alarms a LEFT JOIN geo g ON a.geoid = g.id - LEFT JOIN drivers d ON a.serial = d.transport WHERE a.id = ${id} LIMIT 1 ), @@ -1730,11 +1702,6 @@ app.get('/generate-pdf/:id', async (req, res) => { templateData.Latitude = alarm.latitude templateData.Longitude = alarm.longitude - templateData.DriverName = alarm.name + " " + alarm.surname; - templateData.DriverPhone = alarm.phone; - templateData.DriverEmail = alarm.email; - templateData.DriverLicense = alarm.card; - templateData.PrevLatitude = alarm.prev_latitude; templateData.PrevLongitude = alarm.prev_longitude; templateData.NextLatitude = alarm.next_latitude; @@ -2336,179 +2303,6 @@ app.post("/updatedevice", async (req, res) => { } }); -app.post("/updatedriver", upload.single("upload-file"), async (req, res) => { - if (req.session.userId === undefined) { - return res.redirect("/signin"); - } - const pool = new Pool({ - user: DB_User, - host: DB_Host, - database: DB_Name, - password: DB_Password, - port: DB_Port, - }); - const client = await pool.connect(); - - var { - driverName, - driverSurname, - driverCard, - driverGender, - driverLicense, - driverPassport, - driverPhone, - driverEmail, - driverTransport, - driverDescription, - driverID, - } = req.body; - - try { - // Вставка новой строки в таблицу drivers - const query = ` - UPDATE drivers - SET name = $1, - surname = $2, - card = $3, - gender = $4, - license = $5, - passport = $6, - phone = $7, - email = $8, - transport = $9, - description = $10 - WHERE id = $11 - RETURNING *; - `; - - const values = [ - driverName, - driverSurname, - driverCard, - driverGender, - driverLicense, - driverPassport, - driverPhone, - driverEmail, - driverTransport, - driverDescription, - driverID, - ]; - - const result = await client.query(query, values); - - const newRow = result.rows[0]; - // console.log("New driver added:", newRow); - - res.send("Data added successfully"); - } catch (error) { - console.error("Error adding data:", error); - res.status(500).send("An error occurred while adding data"); - } finally { - client.release(); - } -}); - -app.post("/adddriver", upload.single("upload-file"), async (req, res) => { - if (req.session.userId === undefined) { - return res.redirect("/signin"); - } - const pool = new Pool({ - user: DB_User, - host: DB_Host, - database: DB_Name, - password: DB_Password, - port: DB_Port, - }); - const client = await pool.connect(); - - var { - driverName, - driverSurname, - driverCard, - driverGender, - driverLicense, - driverPassport, - driverPhone, - driverEmail, - driverTransport, - driverDescription, - } = req.body; - - try { - // Вставка новой строки в таблицу drivers - const query = ` - INSERT INTO drivers ( - name, - surname, - card, - gender, - license, - passport, - phone, - email, - transport, - description - ) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) - RETURNING *; - `; - - const values = [ - driverName, - driverSurname, - driverCard, - driverGender, - driverLicense, - driverPassport, - driverPhone, - driverEmail, - driverTransport, - driverDescription, - ]; - - const result = await client.query(query, values); - - const newRow = result.rows[0]; - // console.log("New driver added:", newRow); - - res.send("Data added successfully"); - } catch (error) { - console.error("Error adding data:", error); - res.status(500).send("An error occurred while adding data"); - } finally { - client.release(); - } -}); - -app.post("/driverdata", async (req, res) => { - if (req.session.userId === undefined) { - return res.redirect("/signin"); - } - 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 drivers WHERE id = $1;"; - const driverdata = await client.query(query, [id]); - - // Формирование и отправка ответа - const response = driverdata.rows[0]; - res.json(response); - } finally { - client.release(); - } -}); - app.post("/userdata", async (req, res) => { if (req.session.userId === undefined) { return res.redirect("/signin"); @@ -2565,33 +2359,6 @@ app.post("/groupdata", async (req, res) => { } }); -app.post("/deletedriver", async (req, res) => { - if (req.session.userId === undefined) { - return res.redirect("/signin"); - } - 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 = "DELETE FROM drivers WHERE id = $1;"; - const driverdata = await client.query(query, [id]); - - // Формирование и отправка ответа - res.send("Data deleted successfully"); - } finally { - client.release(); - } -}); - app.post("/deletedevice", async (req, res) => { if (req.session.userId === undefined) { return res.redirect("/signin"); @@ -2710,86 +2477,6 @@ app.post("/add-group", async (req, res) => { } }); -async function drivers(req, res) { - if (req.session.userId === undefined) { - return res.redirect("/signin"); - } - const userInfo = await getUserInfo(req.session.userId); - let templateData = { - SERVER_IP: process.env.SERVER_IP, - Organisation: userInfo.Organisation, - User: userInfo.User, - UserInfo: userInfo.Users, - isAdmin: req.session.userId === 'admin', - ifDBError: false, - Drivers: [], - 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(); - - // Выполняем запрос для объединения данных из таблиц drivers и registrars - const queryDrivers = ` - SELECT d.id, d.name, d.surname, d.transport, d.phone, d.email, d.card, r.connected - FROM drivers d - LEFT JOIN registrars r ON d.transport = r.serial - ORDER BY r.connected DESC NULLS LAST, CASE WHEN r.connected = true THEN 0 ELSE 1 END, d.id - `; - const driversResult = await client.query(queryDrivers); - - templateData.Drivers = driversResult.rows.map((driver) => ({ - id: driver.id, - name: driver.name, - surname: driver.surname, - transport: driver.transport, - phone: driver.phone, - email: driver.email, - card: driver.card, - })); - - const queryRegistrars = ` - SELECT serial - FROM registrars - `; - const registrarsResult = await client.query(queryRegistrars); - - templateData.Registrars = registrarsResult.rows.map( - (registrar) => registrar.serial - ); - - // console.log(templateData); - - const source = fs.readFileSync( - "static/templates/devices/drivers.html", - "utf8" - ); - const template = handlebars.compile(source); - const resultT = template(templateData); - res.send(resultT); - - client.release(); - } catch (error) { - console.error(error); - templateData.ifDBError = true; - - const source = fs.readFileSync( - "static/templates/devices/drivers.html", - "utf8" - ); - const template = handlebars.compile(source); - const resultT = template(templateData); - res.send(resultT); - } -} - async function update(req, res) { if (req.session.userId === undefined) { return res.redirect("/signin"); diff --git a/static/scripts/drivers-form.js b/static/scripts/drivers-form.js deleted file mode 100644 index 627de3c..0000000 --- a/static/scripts/drivers-form.js +++ /dev/null @@ -1,114 +0,0 @@ -$("#continue-main").click(function () { - document.getElementById("stage-details").checked = true; -}); - -$("#continue-main-edit").click(function () { - document.getElementById("stage-details-edit").checked = true; -}); - -const container = document.getElementById("new-parameters"); -const content1 = document.getElementById("main"); -const content2 = document.getElementById("details"); -const btn1 = document.getElementById("continue-main"); -const content3 = document.getElementById("main-edit"); -const content4 = document.getElementById("details-edit"); -const btn2 = document.getElementById("continue-main-edit"); -const radioButtons = document.querySelectorAll( - 'input[type="radio"][name="newStage"]' -); -const radioButtonsEdit = document.querySelectorAll( - 'input[type="radio"][name="newStageEdit"]' -); -const duration = 100; - -let activeContent = content1; - -function switchContent(newContent) { - fadeOut(activeContent, () => { - fadeIn(newContent); - activeContent = newContent; - }); -} - -function fadeIn(element) { - element.style.opacity = 0; - element.style.display = "block"; - let start = performance.now(); - - function animate(time) { - let timeFraction = (time - start) / duration; - if (timeFraction > 1) { - element.style.opacity = 1; - } else { - element.style.opacity = timeFraction; - requestAnimationFrame(animate); - } - } - - requestAnimationFrame(animate); -} - -function fadeOut(element, callback) { - element.style.opacity = 1; - let start = performance.now(); - - function animate(time) { - let timeFraction = (time - start) / duration; - if (timeFraction > 1) { - element.style.opacity = 0; - element.style.display = "none"; - if (callback) { - callback(); - } - } else { - element.style.opacity = 1 - timeFraction; - requestAnimationFrame(animate); - } - } - - requestAnimationFrame(animate); -} - -btn1.addEventListener("click", () => { - if (activeContent === content1) { - switchContent(content2); - } else { - switchContent(content1); - } -}); - -btn2.addEventListener("click", () => { - if (activeContent === content3) { - switchContent(content4); - } else { - switchContent(content3); - } -}); - -for (let radioButton of radioButtons) { - radioButton.addEventListener("change", () => { - if (radioButton.value === "main") { - switchContent(content1); - } else if (radioButton.value === "details") { - switchContent(content2); - } - }); -} - -for (let radioButton of radioButtonsEdit) { - radioButton.addEventListener("change", () => { - if (radioButton.value === "main") { - switchContent(content3); - } else if (radioButton.value === "details") { - switchContent(content4); - } - }); -} - -function truncateText(select) { - var maxLength = 30; - var option = select.options[select.selectedIndex]; - if (option.text.length > maxLength) { - option.text = option.text.substring(0, maxLength) + "..."; - } -} diff --git a/static/scripts/index.browser.js b/static/scripts/index.browser.js deleted file mode 100644 index 5243b55..0000000 --- a/static/scripts/index.browser.js +++ /dev/null @@ -1 +0,0 @@ -function renderSA(e,t){var r=create(e,t);if(r.finished)return r.asset;throw new Error("SmartAvatar ERROR: something went wrong.")}function create(e,t){var r=["mp","identicon","monsterid","wavatar","retro","robohash"],a={};switch(!0){case"smart"===t.priority.src1&&t.initials:a.asset=generateEl("initEl",t),a.finished=!0;break;case"smart"===t.priority.src1&&t.icon&&!r.includes(t.icon):a.asset=generateEl("iconEl",t),a.finished=!0;break;case"smart"===t.priority.src1&&t.icon&&r.includes(t.icon):a.asset=generateEl("iconImg",t),a.finished=!0;break;default:a.asset=generateComplexImage(e,t),a.finished=!0}return a}function generateEl(e,t){switch(e){case"iconImg":return generateIconImg(t);case"initEl":return generateInitEl(t);case"iconEl":return generateIconEl(t)}}function generateGravatarIconUrl(e){return"https://www.gravatar.com/avatar?d="+e+"&f=y"}function generateIconImg(e){var t=new Image,r=generateGravatarIconUrl(e.icon);if(t.src=r,e.unstyled||(t.style.cssText=(e.round?"border-radius: 50%;":"")+(e.size?"height:"+e.size+"px;width:"+e.size+"px;":"")+"object-fit:cover;"),t.classList.add("smart-avatar"),e.cssClass){const r=e.cssClass.length;for(let a=0;a"+r+"",a}function generateComplexImage(e,t){var r=parseComplexAssets(t),a=r.asset1,n=r.asset2,s=r.asset3,i=new Image;if(i.src=a.content,t.unstyled||(i.style.cssText=(t.round?"border-radius: 50%;":"")+(t.size?"height:"+t.size+"px;width:"+t.size+"px;":"")+"object-fit:cover;"),i.onerror=function(){handleErrFallback(e,i,n),"el"!==n.type&&(i.onerror=function(){handleErrFallback(e,i,s)})},i.classList.add("smart-avatar"),t.cssClass){const e=t.cssClass.length;for(let r=0;r'}export default function smartAvatar(e,t){var r={};if(arguments[1]||(t={}),!arguments.length)throw new Error("SmartAvatar ERROR: missing 'element' argument.");if("dispose"!==arguments[1]){if(arguments[1]&&"object"!=typeof arguments[1])throw new Error("SmartAvatar ERROR: 'options' argument must be an object.");var a=function(e){return e instanceof Element||e instanceof HTMLDocument};if(!a(e)){var n=typeof e;throw new Error("SmartAvatar ERROR: cannot append asset to "+n+".")}r.parent=e,r.priority=t.priority?parsePriority(t.priority):{src1:"gravatar",src2:"src",src3:"smart"},r.timestamp="boolean"==typeof t.timestamp&&t.timestamp,r.alt=t.alt?t.alt.toString():null,r.icon=t.icon?t.icon.toString():"smartfox",r.size=t.size?parseImgRes(t.size.toString()):null,r.round=!0===t.round,r.initials=t.initials?parseInitials(t.initials.toString()):null,r.color=t.color?parseColor(t.color.toString()):null,r.textColor=t.textColor?parseColor(t.textColor.toString()):null,r.colorScheme=t.colorScheme?parseColorScheme(t.colorScheme):null,r.cssClass=t.cssClass?parseCssClass(t.cssClass.toString()):null,r.email=t.email?parseEmail(t.email.toString()):null,r.hash=!!t.hash&&t.hash.toString()||(r.email?md5(r.email):null),r.protocol=t.protocol?parseProtocol(t.protocol.toString()):"secure",r.format=t.format?parseImgFormat(t.format.toString()):"jpg",r.resolution=t.resolution?parseImgRes(t.resolution.toString()):"80",r.src=t.src?t.src.toString():null,r.unstyled=!0===t.unstyled,!r.unstyled&&t.setDefaults&&(r.color=r.color||"#AAA",r.size=r.size||"48",r.textColor=r.textColor||"#FFF"),r.gravatarUrl=r.hash?generateGravatarUrl(r):"";var s=renderSA(e,r);e.appendChild(s)}else{const t=e.querySelectorAll(".smart-avatar");for(let r=0;r0)throw new Error("SmartAvatar ERROR: could not dispose SmartAvatar nodes."+e.querySelectorAll(".smart-avatar").length+"left.")}}function generateGravatarUrl(e){var t=parseProtocol(e.protocol),r=parseImgFormat(e.format),a="?d=404&"+parseGravatarURIRes(e.resolution);return t+"www.gravatar.com/avatar/"+e.hash+"."+r+a}function md5cycle(e,t){var r=e[0],a=e[1],n=e[2],s=e[3];r=ff(r,a,n,s,t[0],7,-680876936),s=ff(s,r,a,n,t[1],12,-389564586),n=ff(n,s,r,a,t[2],17,606105819),a=ff(a,n,s,r,t[3],22,-1044525330),r=ff(r,a,n,s,t[4],7,-176418897),s=ff(s,r,a,n,t[5],12,1200080426),n=ff(n,s,r,a,t[6],17,-1473231341),a=ff(a,n,s,r,t[7],22,-45705983),r=ff(r,a,n,s,t[8],7,1770035416),s=ff(s,r,a,n,t[9],12,-1958414417),n=ff(n,s,r,a,t[10],17,-42063),a=ff(a,n,s,r,t[11],22,-1990404162),r=ff(r,a,n,s,t[12],7,1804603682),s=ff(s,r,a,n,t[13],12,-40341101),n=ff(n,s,r,a,t[14],17,-1502002290),r=gg(r,a=ff(a,n,s,r,t[15],22,1236535329),n,s,t[1],5,-165796510),s=gg(s,r,a,n,t[6],9,-1069501632),n=gg(n,s,r,a,t[11],14,643717713),a=gg(a,n,s,r,t[0],20,-373897302),r=gg(r,a,n,s,t[5],5,-701558691),s=gg(s,r,a,n,t[10],9,38016083),n=gg(n,s,r,a,t[15],14,-660478335),a=gg(a,n,s,r,t[4],20,-405537848),r=gg(r,a,n,s,t[9],5,568446438),s=gg(s,r,a,n,t[14],9,-1019803690),n=gg(n,s,r,a,t[3],14,-187363961),a=gg(a,n,s,r,t[8],20,1163531501),r=gg(r,a,n,s,t[13],5,-1444681467),s=gg(s,r,a,n,t[2],9,-51403784),n=gg(n,s,r,a,t[7],14,1735328473),r=hh(r,a=gg(a,n,s,r,t[12],20,-1926607734),n,s,t[5],4,-378558),s=hh(s,r,a,n,t[8],11,-2022574463),n=hh(n,s,r,a,t[11],16,1839030562),a=hh(a,n,s,r,t[14],23,-35309556),r=hh(r,a,n,s,t[1],4,-1530992060),s=hh(s,r,a,n,t[4],11,1272893353),n=hh(n,s,r,a,t[7],16,-155497632),a=hh(a,n,s,r,t[10],23,-1094730640),r=hh(r,a,n,s,t[13],4,681279174),s=hh(s,r,a,n,t[0],11,-358537222),n=hh(n,s,r,a,t[3],16,-722521979),a=hh(a,n,s,r,t[6],23,76029189),r=hh(r,a,n,s,t[9],4,-640364487),s=hh(s,r,a,n,t[12],11,-421815835),n=hh(n,s,r,a,t[15],16,530742520),r=ii(r,a=hh(a,n,s,r,t[2],23,-995338651),n,s,t[0],6,-198630844),s=ii(s,r,a,n,t[7],10,1126891415),n=ii(n,s,r,a,t[14],15,-1416354905),a=ii(a,n,s,r,t[5],21,-57434055),r=ii(r,a,n,s,t[12],6,1700485571),s=ii(s,r,a,n,t[3],10,-1894986606),n=ii(n,s,r,a,t[10],15,-1051523),a=ii(a,n,s,r,t[1],21,-2054922799),r=ii(r,a,n,s,t[8],6,1873313359),s=ii(s,r,a,n,t[15],10,-30611744),n=ii(n,s,r,a,t[6],15,-1560198380),a=ii(a,n,s,r,t[13],21,1309151649),r=ii(r,a,n,s,t[4],6,-145523070),s=ii(s,r,a,n,t[11],10,-1120210379),n=ii(n,s,r,a,t[2],15,718787259),a=ii(a,n,s,r,t[9],21,-343485551),e[0]=add32(r,e[0]),e[1]=add32(a,e[1]),e[2]=add32(n,e[2]),e[3]=add32(s,e[3])}function cmn(e,t,r,a,n,s){return t=add32(add32(t,e),add32(a,s)),add32(t<>>32-n,r)}function ff(e,t,r,a,n,s,i){return cmn(t&r|~t&a,e,t,n,s,i)}function gg(e,t,r,a,n,s,i){return cmn(t&a|r&~a,e,t,n,s,i)}function hh(e,t,r,a,n,s,i){return cmn(t^r^a,e,t,n,s,i)}function ii(e,t,r,a,n,s,i){return cmn(r^(t|~a),e,t,n,s,i)}function md51(e){var t,r=e.length,a=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=e.length;t+=64)md5cycle(a,md5blk(e.substring(t-64,t)));e=e.substring(t-64);var n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t>2]|=e.charCodeAt(t)<<(t%4<<3);if(n[t>>2]|=128<<(t%4<<3),t>55)for(md5cycle(a,n),t=0;t<16;t++)n[t]=0;return n[14]=8*r,md5cycle(a,n),a}function md5blk(e){var t,r=[];for(t=0;t<64;t+=4)r[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return r}var hex_chr="0123456789abcdef".split("");function rhex(e){for(var t="",r=0;r<4;r++)t+=hex_chr[e>>8*r+4&15]+hex_chr[e>>8*r&15];return t}function hex(e){for(var t=0;t1&&-1!=e.indexOf(" ")){var r=e.split(" ");t=r[0][0]+r[1][0]}else t=e.length>1?e[0]+e[1]:e;return t.toUpperCase()}function parsePriority(e){var t=["gravatar","src","smart"],r={};for(let a=0;a { - const table = document.getElementById("deviceTable"); - const tbody = table.querySelector("tbody"); - // Очищаем таблицу - tbody.innerHTML = ""; - - // Добавляем строки таблицы - const startIndex = (currentPage - 1) * rowsPerPage; - const endIndex = startIndex + rowsPerPage; - const devicesToDisplay = filteredDevices.slice(startIndex, endIndex); - - devicesToDisplay.forEach((device) => { - const row = document.createElement("tr"); - // Добавляем чекбокс перед каждым рядом - const checkboxCell = document.createElement("td"); - const checkbox = document.createElement("input"); - checkbox.type = "checkbox"; - checkbox.value = `device-${device.id}`; - checkbox.id = `device-${device.id}`; - - const checkboxLabel = document.createElement("label"); - checkboxLabel.setAttribute("for", `device-${device.id}`); - - const checkboxDiv = document.createElement("div"); - checkboxDiv.setAttribute("class", "checkmark"); - checkboxLabel.appendChild(checkboxDiv); - - checkboxCell.appendChild(checkbox); - checkboxCell.appendChild(checkboxLabel); - row.appendChild(checkboxCell); - - // Добавляем ячейки с данными - const driverID = document.createElement("td"); - driverID.textContent = device.id; - row.appendChild(driverID); - const name = document.createElement("td"); - name.textContent = device.name; - row.appendChild(name); - const surname = document.createElement("td"); - surname.textContent = device.surname; - row.appendChild(surname); - const numberTS = document.createElement("td"); - numberTS.textContent = device.numberTS; - row.appendChild(numberTS); - const phone = document.createElement("td"); - phone.textContent = device.phone; - row.appendChild(phone); - const mail = document.createElement("td"); - mail.textContent = device.mail; - row.appendChild(mail); - const driverCard = document.createElement("td"); - driverCard.textContent = device.driverCard; - row.appendChild(driverCard); - - // Добавляем кнопку удаления после каждого ряда - const trashCell = document.createElement("td"); - trashCell.setAttribute("class", "optionsCell"); - const trashButton = document.createElement("button"); - trashButton.setAttribute("class", "trash"); - trashButton.setAttribute("onclick", `deleteDriver(${device.id})`); - trashButton.value = `delete-device-${device.id}`; - trashButton.id = `delete-device-${device.id}`; - const optionsButton = document.createElement("button"); - optionsButton.setAttribute("onclick", `openEdit(${device.id})`); - optionsButton.setAttribute("class", "options"); - optionsButton.value = `options-device-${device.id}`; - optionsButton.id = `options-device-${device.id}`; - - trashCell.appendChild(optionsButton); - trashCell.appendChild(trashButton); - - row.appendChild(trashCell); - tbody.appendChild(row); - }); -}; - -window.addEventListener("resize", function (event) { - tableHeight = document.getElementById("table-area").offsetHeight; - rowHeight = 60; - rowsPerPage = Math.floor(tableHeight / rowHeight) - 2; - createTable(); - createPagination(); -}); - -const createPagination = () => { - const count = document.getElementById("count"); - count.textContent = `Всего результатов: ${filteredDevices.length}`; - - const pagination = document.getElementById("pagination"); - pagination.innerHTML = ""; - - const pageCount = Math.ceil(filteredDevices.length / rowsPerPage); - for (let i = 1; i <= pageCount; i++) { - const pageLink = document.createElement("a"); - pageLink.href = "#"; - if (i === currentPage) { - document.querySelector("#device-all").checked = false; - pageLink.classList.add("active"); - } - pageLink.textContent = i; - pageLink.addEventListener("click", (event) => { - event.preventDefault(); - currentPage = i - 1; - currentPage = i; - createTable(); - createPagination(); - }); - pagination.appendChild(pageLink); - } - - // var currentPageSpan = document.createElement("span"); - // currentPageSpan.textContent = currentPage; - // pagination.appendChild(currentPageSpan); - - // Добавляем кнопки "Next" и "Previous" - - // const prevButton = document.createElement("button"); - // prevButton.innerText = "Previous"; - // prevButton.onclick = () => { - // if (currentPage === 1) return; - // currentPage--; - // createTable(); - // }; - // pagination.appendChild(prevButton); - - // const nextButton = document.createElement("button"); - // nextButton.innerText = "Next"; - // nextButton.onclick = () => { - // if (currentPage === pageCount) return; - // currentPage++; - // createTable(); - // }; - // pagination.appendChild(nextButton); -}; - -const applyFilterAndSearch = () => { - const searchValue = searchInput.value.toLowerCase(); - const groupFilters = Array.from( - document.querySelectorAll('input[type="checkbox"].device-filter:checked') - ).map((checkbox) => checkbox.value); - - filteredDevices = devices.filter((device) => { - const searchString = - `${device.group} ${device.driverID} ${device.name} ${device.number} ${device.surname} ${device.numberTS} ${device.phone} ${device.mail} ${device.driverCard}`.toLowerCase(); - const matchGroup = - groupFilters.length === 0 || groupFilters.includes(device.group); - const matchSearch = !searchValue || searchString.includes(searchValue); - return matchGroup && matchSearch; - }); - - currentPage = 1; - createTable(); - createPagination(); -}; - -const searchInput = document.getElementById("table-search"); -searchInput.addEventListener("input", applyFilterAndSearch); - -const filterCheckboxes = Array.from( - document.querySelectorAll('input[type="checkbox"].device-filter') -); -filterCheckboxes.forEach((checkbox) => { - checkbox.addEventListener("change", applyFilterAndSearch); -}); - -createTable(); -createPagination(); diff --git a/static/scripts/table-reports.js b/static/scripts/table-reports.js index 80f2f89..18699b1 100644 --- a/static/scripts/table-reports.js +++ b/static/scripts/table-reports.js @@ -21,23 +21,6 @@ const createTable = () => { devicesToDisplay.forEach((device) => { const row = document.createElement("tr"); - // Добавляем чекбокс перед каждым рядом - const checkboxCell = document.createElement("td"); - const checkbox = document.createElement("input"); - checkbox.type = "checkbox"; - checkbox.value = `device-${device.id}`; - checkbox.id = `device-${device.id}`; - - const checkboxLabel = document.createElement("label"); - checkboxLabel.setAttribute("for", `device-${device.id}`); - - const checkboxDiv = document.createElement("div"); - checkboxDiv.setAttribute("class", "checkmark"); - checkboxLabel.appendChild(checkboxDiv); - - checkboxCell.appendChild(checkbox); - checkboxCell.appendChild(checkboxLabel); - row.appendChild(checkboxCell); // Добавляем ячейки с данными const name = document.createElement("td"); diff --git a/static/scripts/table.js b/static/scripts/table.js index f020039..c0d7614 100644 --- a/static/scripts/table.js +++ b/static/scripts/table.js @@ -19,23 +19,6 @@ const createTable = () => { devicesToDisplay.forEach((device) => { const row = document.createElement("tr"); - // Добавляем чекбокс перед каждым рядом - const checkboxCell = document.createElement("td"); - const checkbox = document.createElement("input"); - checkbox.type = "checkbox"; - checkbox.value = `device-${device.id}`; - checkbox.id = `device-${device.id}`; - - const checkboxLabel = document.createElement("label"); - checkboxLabel.setAttribute("for", `device-${device.id}`); - - const checkboxDiv = document.createElement("div"); - checkboxDiv.setAttribute("class", "checkmark"); - checkboxLabel.appendChild(checkboxDiv); - - checkboxCell.appendChild(checkbox); - checkboxCell.appendChild(checkboxLabel); - row.appendChild(checkboxCell); // Добавляем ячейки с данными const name = document.createElement("td"); diff --git a/static/styles/main.css b/static/styles/main.css index 4e03600..1908465 100644 --- a/static/styles/main.css +++ b/static/styles/main.css @@ -880,13 +880,14 @@ td { } .optionsCell { - min-width: 60px; + min-width: 75px; } table tr th:first-child, table td:first-child { position: sticky; left: 0; + padding-left: 30px; z-index: 10; } diff --git a/static/templates/devices/drivers.html b/static/templates/devices/drivers.html deleted file mode 100644 index f689e50..0000000 --- a/static/templates/devices/drivers.html +++ /dev/null @@ -1,801 +0,0 @@ - - - - - - - Водители - - - - -
- -

Аргус

-

/ {{Organisation}}

-
- - - - - - - - -
- {{#if ifDBError}} -
-
-
-

Ошибка


- Не удалось получить данные из БД - -
-
- {{/if}} - -
-
- - -
- -
-

Организация

- -
    - -
- - - -
- - - -
-

Список водителей

- - - - - - - - - - - - - - - - - - - - -
IDИмяФамилияНомер ТСНомер телефонаПочтаКарта водителя
- - - - -
- -
- -
- - - - -
- -
-
-
- -
- -
-
- -
- -
- -
-
-
- - -
- - -
- -

Основная информация

-

Сперва самое необходимое

- -
- - -
- - - Временно недоступно редактирование фотографии - Остальная информация изменяется -
- - -
- - - - - - - - - -
- -
- - - -
- -
- -

Детальная информация

-

Для удобства в идентификации

- -
- -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- - - - -
- -
- - - -
- -
- -
- - - -
- -
-
- -
- -
- -
-
-
- - -
- -
- -

Основная информация

-

Сперва самое необходимое

- -
- - -
- - Загрузить фотографию водителя - PNG, JPG (макс 20 мб) -
- - - -
- - - - - - - - - -
- -
- - - -
- -
- -

Детальная информация

-

Для удобства в идентификации

- -
- -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- - - - -
- -
- - - -
- -
- -
- - - -
- - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/static/templates/devices/groups.html b/static/templates/devices/groups.html index 4f91fc1..4dc543d 100644 --- a/static/templates/devices/groups.html +++ b/static/templates/devices/groups.html @@ -101,7 +101,7 @@ Группы {{#if Update}} - Обновление ПО + {{/if}}
diff --git a/static/templates/devices/index.html b/static/templates/devices/index.html index b34045b..bec192c 100644 --- a/static/templates/devices/index.html +++ b/static/templates/devices/index.html @@ -75,7 +75,7 @@ {{#if Update}} - Обновление ПО + {{/if}}
@@ -122,7 +122,6 @@ - diff --git a/static/templates/live.html b/static/templates/live.html index 4c3818f..f2b388a 100644 --- a/static/templates/live.html +++ b/static/templates/live.html @@ -473,7 +473,7 @@ const selectedDevices = Array.from(checkboxes) if (serial === $("input[name=camera-serial]:checked").val()) { var marker = L.divIcon({ className: 'marker', - html: `
${number !== null ? number : serial}
+ html: `
${number !== null && number !== "" ? number : serial}
@@ -482,7 +482,7 @@ const selectedDevices = Array.from(checkboxes) } else { var marker = L.divIcon({ className: 'marker', - html: `
${number !== null ? number : serial}
+ html: `
${number !== null && number !== "" ? number : serial}
diff --git a/static/templates/reports/index.html b/static/templates/reports/index.html index 64f577a..a150d2c 100644 --- a/static/templates/reports/index.html +++ b/static/templates/reports/index.html @@ -115,7 +115,6 @@
Группа Код Номерной знак
- diff --git a/static/templates/reports/report.html b/static/templates/reports/report.html index 50c336b..9161cd2 100644 --- a/static/templates/reports/report.html +++ b/static/templates/reports/report.html @@ -122,24 +122,6 @@ - - -

Скорость

км/ч @@ -148,28 +130,8 @@
- - - -
@@ -254,69 +216,6 @@ - -
Наименование ID Номерной знак