From c4c25a5eafd59afa026d6666e4cea02999d0eff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincze=20J=C3=B3zsef?= Date: Thu, 26 Oct 2023 09:09:06 +0200 Subject: [PATCH] =?UTF-8?q?Device,=20Vehicle=20hozz=C3=A1rendel=C3=A9s=20j?= =?UTF-8?q?av=C3=ADtva?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/devices_rfid.js | 43 +++++++++++++++++++++++++++-- views/Modals/modal_oilChangeNew.pug | 2 +- views/device_rfid_list.pug | 8 ++++-- views/vehicles.pug | 8 ++++-- 4 files changed, 53 insertions(+), 8 deletions(-) diff --git a/routes/devices_rfid.js b/routes/devices_rfid.js index 5fcaaed..08f2f16 100644 --- a/routes/devices_rfid.js +++ b/routes/devices_rfid.js @@ -9,7 +9,45 @@ router.get('/list', utils.ensureAuthenticated, function(req, res) { var admin=false; - RfidDevice.find({} ,function(err, rfidDevices){ + /* RfidDevice.find({} ,function(err, rfidDevices){ + if (err) + { + console.log(err); + } + else { + res.render('device_rfid_list', { + title: 'RFID Eszközök', + rfidDevices: rfidDevices, + + // articles: workSign + }); + } + });*/ + RfidDevice.aggregate([ + //{ $match: { bdTable: 'zzzz' } }, + { $lookup: { + from: 'vehicles', + let: { vehicle_id: '$vehicle_id' }, + pipeline: [ + { $match: { + $expr: { + $eq: [ + "$_id", + "$$vehicle_id" + ] + } + } }, + { + $project: { + name: 1, + vehicle_id: 1, + } + } + ], + as: 'vehicle' + } }, + ] + ,function(err, rfidDevices){ if (err) { console.log(err); @@ -24,6 +62,7 @@ router.get('/list', utils.ensureAuthenticated, function(req, res) { } }); + }); // Járművek listázása // RFID Device lista @@ -65,7 +104,7 @@ router.get('/edit/:id', utils.ensureAuthenticated,function (req,res) { }else { res.render('device_rfid_edit', { - title: 'RFID Eszköz Felvétele', + title: 'RFID Eszköz Módosítás', user:req.user, rfidDev:rfidDev, vehicles:vehicle diff --git a/views/Modals/modal_oilChangeNew.pug b/views/Modals/modal_oilChangeNew.pug index 4bf732d..b608a37 100644 --- a/views/Modals/modal_oilChangeNew.pug +++ b/views/Modals/modal_oilChangeNew.pug @@ -43,7 +43,7 @@ link(rel='stylesheet', type='text/css', href='https://unpkg.com/lightpick@latest button#oilChangeSave.btn.btn-primary(type='button' ) i.fa.fa-save | | Mentés - script(src='/bower_components/jquery/dist/jquery.js') + //-script(src='/bower_components/jquery/dist/jquery.js') script(type='text/javascript', src='/bower_components/moment/min/moment.min.js') script(src='https://unpkg.com/lightpick@latest/lightpick.js') diff --git a/views/device_rfid_list.pug b/views/device_rfid_list.pug index 645f220..02d98ba 100644 --- a/views/device_rfid_list.pug +++ b/views/device_rfid_list.pug @@ -7,7 +7,7 @@ block content #darktable.container table.container(style='width:90%;') col(width='5%') - col(width='20%') + col(width='15%') col(width='auto') col(width='15%') col(width='15%') @@ -31,10 +31,14 @@ block content h1(style='text-align:left') FW Rev tbody each rfidDevice, i in rfidDevices + tr.clickable-clientRow(data-href="/devicesrfid/edit/"+rfidDevice._id) td #{i+1} td(style='text-align:left') #{rfidDevice.name} - td(style='text-align:left') #{rfidDevice.assignment} + if(rfidDevice.vehicle.length) + td(style='text-align:left; color: #58D68D') #{rfidDevice.vehicle[0].vehicle_id+' '+rfidDevice.vehicle[0].name} + else + td(style='text-align:left') #{rfidDevice.assignment} td(style='text-align:left') #{rfidDevice.imei} td(style='text-align:left') #{rfidDevice.ccid} td(style='text-align:left') #{rfidDevice.state} diff --git a/views/vehicles.pug b/views/vehicles.pug index 041a36f..574918d 100644 --- a/views/vehicles.pug +++ b/views/vehicles.pug @@ -92,11 +92,13 @@ block content col(width='20%') col(width='8%') col(width='10%') - col(width='8%') - col(width='8%') - col(width='8%') + col(width='6%') + col(width='6%') + col(width='6%') + col(width='8%') col(width='auto') col(width='8%') + thead tr th