From f914926417c416e4813c19986bbe57485b2647c0 Mon Sep 17 00:00:00 2001 From: Filippo Stella Date: Mon, 3 Aug 2020 15:09:22 +0200 Subject: [PATCH] Merging Changes --- app.js | 2 +- public/js/dash.js | 3 +-- public/stylesheets/dashStyle.css | 8 ++++++++ routes/api.js | 5 +++-- routes/login.js | 2 +- views/dash.ejs | 20 ++++++++++---------- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/app.js b/app.js index 014568b..3fed0ad 100644 --- a/app.js +++ b/app.js @@ -47,7 +47,7 @@ app.use(session({ cookie: { secure: false, //change to true with HTTPS sameSite: true, - maxAge: 600000 // Time is in miliseconds + maxAge: 1000 * 60 * 60 * 2// Time is in miliseconds }, })); diff --git a/public/js/dash.js b/public/js/dash.js index 7604dde..541b4df 100644 --- a/public/js/dash.js +++ b/public/js/dash.js @@ -39,9 +39,8 @@ function sidenavEventsListeners() { for (let i = 0; i < data.products.length; i++) { let tr = tbody.insertRow(); tr.insertCell().appendChild(document.createTextNode(data.products[i].Name)); - tr.insertCell().appendChild(document.createTextNode(data.products[i].Price + value)); + tr.insertCell().appendChild(document.createTextNode(data.products[i].Price+value+" ("+data.products[i].shop+")")); tr.insertCell().appendChild(document.createTextNode(data.products[i].LastUpdate.toString())); - //tr.insertCell().appendChild(document.createTextNode(data.products[i].Barcode)); tr.insertCell().innerHTML = 'read_more'; } } else { diff --git a/public/stylesheets/dashStyle.css b/public/stylesheets/dashStyle.css index b0d8e51..a94698d 100644 --- a/public/stylesheets/dashStyle.css +++ b/public/stylesheets/dashStyle.css @@ -69,4 +69,12 @@ nav.top-nav { .dropdown_offset { top: 55px !important; +} + +.scrollable{ + overflow: auto; +} + +.minWidth{ + min-width: 600px; } \ No newline at end of file diff --git a/routes/api.js b/routes/api.js index 5f45324..f209fe5 100644 --- a/routes/api.js +++ b/routes/api.js @@ -177,7 +177,7 @@ router.get('/productslistcomplete', chechAuth, function (req, res, next) { } }); - connection.query("SELECT product.Barcode, product.Name, sold.Price, sold.LastUpdate FROM product, sold WHERE product.Barcode = sold.ProductBarcode GROUP BY product.Barcode HAVING sold.Price = MIN(sold.Price)", function (err, result) { + connection.query("SELECT product.Barcode, product.Name, sold.Price, DATE_FORMAT(sold.LastUpdate,'%d-%m-%Y') AS LastUpdate, shop.Name AS 'shopName', shop.City FROM product, sold, shop WHERE sold.ShopID = shop.ID AND product.Barcode = sold.ProductBarcode GROUP BY product.Barcode HAVING sold.Price = MIN(sold.Price)", function (err, result) { if (err) { return res.json({ "status": false, @@ -194,7 +194,8 @@ router.get('/productslistcomplete', chechAuth, function (req, res, next) { 'Barcode': result[i].Barcode, 'Name': result[i].Name, 'Price': result[i].Price, - 'LastUpdate': result[i].LastUpdate + 'LastUpdate': result[i].LastUpdate, + 'shop': result[i].shopName + ", " + result[i].City }); } res.json(ris); diff --git a/routes/login.js b/routes/login.js index d4feeb2..5240b32 100644 --- a/routes/login.js +++ b/routes/login.js @@ -41,7 +41,7 @@ router.post('/login', redirectDash, function (req, res, next) { ], function (err, result) { if (err) { console.log("Query Error" + err); - res.json({ + return res.json({ "status": false, "message": err }); diff --git a/views/dash.ejs b/views/dash.ejs index efde367..883a0ee 100644 --- a/views/dash.ejs +++ b/views/dash.ejs @@ -86,7 +86,7 @@

Products List

- +
@@ -107,7 +107,7 @@

Shops List

-
Name
+
@@ -115,7 +115,7 @@ - +
NameDetails
@@ -261,13 +261,13 @@

Details

- +

Sold in

- +
@@ -292,13 +292,13 @@

Details

-
Name
+

Products Sold In This Shop

- +
@@ -322,7 +322,7 @@

Select a Product From The List

-
Barcode
+
@@ -350,7 +350,7 @@

Select a Shop From The List

-
Select
+
@@ -378,7 +378,7 @@

List of Currently Active Api Keys

-
Select
+
Api Key