Add button to go back to device listing; fix query of most recent status; add alert row highlighting to index template, closes issue #30.
This commit is contained in:
parent
8c29423d6d
commit
4c24454041
13
server.js
13
server.js
@ -65,10 +65,11 @@ app.get('/', function(req, res){
|
|||||||
var d = new Date();
|
var d = new Date();
|
||||||
console.log("GET /, " + JSON.stringify(d, 4));
|
console.log("GET /, " + JSON.stringify(d, 4));
|
||||||
var devIndexQry =
|
var devIndexQry =
|
||||||
"select al.coreId, max(co.coreName) as coreName, max(co.locationDesc) as locationDesc, max(published_at) as MaxPub, max(status) as MaxStatus " +
|
"select al.coreId, max(co.coreName) as coreName, max(co.locationDesc) as locationDesc, mpub.MaxPub, al.status as MaxStatus " +
|
||||||
"from Alerts al " +
|
"from Alerts al " +
|
||||||
"left join Cores co on al.coreId = co.coreId " +
|
"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 " +
|
||||||
"group by al.coreId;";
|
"left join Cores co on al.coreId = co.coreId " +
|
||||||
|
"group by al.coreId ";
|
||||||
db.all(devIndexQry, function(err, rows){
|
db.all(devIndexQry, function(err, rows){
|
||||||
if(err !== null) {
|
if(err !== null) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
@ -79,6 +80,10 @@ app.get('/', function(req, res){
|
|||||||
rows.forEach(function(row){
|
rows.forEach(function(row){
|
||||||
row.MaxPubDate = alertmonUtils.getLocDateFromUTC(row.MaxPub);
|
row.MaxPubDate = alertmonUtils.getLocDateFromUTC(row.MaxPub);
|
||||||
row.MaxPubTime = alertmonUtils.getLocTimeFromUTC(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) {
|
res.render('index', {cores: rows}, function(err, html) {
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
</b>
|
</b>
|
||||||
|
|
||||||
<a href="https://particle.kaplon.us/core/edit/{{alerts.0.coreId}}" class="btn btn-primary">Edit Details</a>
|
<a href="https://particle.kaplon.us/core/edit/{{alerts.0.coreId}}" class="btn btn-primary">Edit Details</a>
|
||||||
|
<a href="https://particle.kaplon.us" class="btn btn-primary">Back to Device Listing</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{#each cores}}
|
{{#each cores}}
|
||||||
<tr>
|
<tr class="{{this.rowClass}}">
|
||||||
<td>
|
<td>
|
||||||
{{#if this.coreName}}
|
{{#if this.coreName}}
|
||||||
<a href="https://particle.kaplon.us/core/{{this.coreId}}">{{this.coreName}}</a>
|
<a href="https://particle.kaplon.us/core/{{this.coreId}}">{{this.coreName}}</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user