diff --git a/server.js b/server.js index e91c8be..72613f8 100644 --- a/server.js +++ b/server.js @@ -68,11 +68,10 @@ 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, 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 "; + "select status, published_at " + + "from Alerts " + + "order by published_at desc " + + "limit 2" db.all(devIndexQry, function(err, rows){ if(err !== null) { console.log(err); @@ -81,15 +80,12 @@ app.get('/', function(req, res){ // Loop over elements in rows array, convert ugly UTC times to pretty local times. rows.forEach(function(row){ - row.MaxPubDate = courtsopenUtils.getLocDateFromUTC(row.MaxPub); - row.MaxPubTime = courtsopenUtils.getLocTimeFromUTC(row.MaxPub); - - if(row.MaxStatus.toLowerCase().indexOf('alert') > -1){ - row.rowClass = 'alert-row'; - } else { row.rowClass = 'non-alert-row'; } + if(row.status.toLowerCase().indexOf('closed') > -1){ + row.statusClass = 'closed'; + } else { row.statusClass = 'open'; } }); - res.render('index', {cores: rows}, function(err, html) { + res.render('index', {values: rows}, function(err, html) { if(err !== null) { console.log(err); } else { diff --git a/views/index.hbs b/views/index.hbs index 6efcb88..9021949 100644 --- a/views/index.hbs +++ b/views/index.hbs @@ -1,43 +1,12 @@ {{!< default}} -

Select a monitor device:

- - - - - - - - - - - - {{#each cores}} - - - - - - - - {{/each}} - -
Device NameLocationLast Update
- {{#if this.coreName}} - {{this.coreName}} - {{else}} - # No Name # -
-
- Edit Details - {{/if}} -
- {{#if this.locationDesc}} - {{this.locationDesc}} - {{else}} - # No Location # -
-
- Edit Details - {{/if}} -
{{this.MaxPubDate}}{{this.MaxPubTime}}{{this.MaxStatus}}
+

TT Tennis Courts Are...

+ +{{! Index-0 is the most recent message. }} +
+

{{values.0.status}}

+
+
+

Update received, {{values.0.published_at}}

+
+

Prior update was, {{values.1.status}} at {{values.1.published_at}}