diff --git a/server.js b/server.js index 0653318..5599a89 100644 --- a/server.js +++ b/server.js @@ -65,10 +65,11 @@ app.get('/', function(req, res){ var d = new Date(); console.log("GET /, " + JSON.stringify(d, 4)); var devIndexQry = - "select al.coreId, max(co.coreName) as coreName, max(co.locationDesc) as locationDesc, max(published_at) as MaxPub, max(status) as MaxStatus " + - "from Alerts al " + - "left join Cores co on al.coreId = co.coreId " + - "group by al.coreId;"; + "select al.coreId, max(co.coreName) as coreName, max(co.locationDesc) as locationDesc, mpub.MaxPub, al.status as MaxStatus " + + "from Alerts al " + + "inner join (select coreId, max(published_at) as MaxPub from Alerts group by coreId) mpub on al.coreId = mpub.coreId and al.published_at = mpub.MaxPub " + + "left join Cores co on al.coreId = co.coreId " + + "group by al.coreId "; db.all(devIndexQry, function(err, rows){ if(err !== null) { console.log(err); @@ -79,6 +80,10 @@ app.get('/', function(req, res){ rows.forEach(function(row){ row.MaxPubDate = alertmonUtils.getLocDateFromUTC(row.MaxPub); row.MaxPubTime = alertmonUtils.getLocTimeFromUTC(row.MaxPub); + + if(row.MaxStatus.toLowerCase().indexOf('alert') > -1){ + row.rowClass = 'alert-row'; + } else { row.rowClass = 'non-alert-row'; } }); res.render('index', {cores: rows}, function(err, html) { diff --git a/views/core.hbs b/views/core.hbs index 9ad6751..4f297fb 100644 --- a/views/core.hbs +++ b/views/core.hbs @@ -11,6 +11,7 @@ Edit Details + Back to Device Listing

diff --git a/views/index.hbs b/views/index.hbs index 8d85bae..6efcb88 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -13,7 +13,7 @@ {{#each cores}} - +
{{#if this.coreName}} {{this.coreName}}