Skip to content

Commit

Permalink
added meaningful page when no devices discovered
Browse files Browse the repository at this point in the history
  • Loading branch information
avgrad committed Apr 14, 2018
1 parent 531964e commit 57f1ac8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 3 additions & 1 deletion public/javascripts/dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ var dash = {
init: function(deviceId) {
this.deviceId = deviceId;

$('.' + deviceId).addClass('active');
if (this.deviceId) {
$('.' + deviceId).addClass('active');
}

this.initRealtimeGauge();
this.initRealtimeTrendChart();
Expand Down
10 changes: 8 additions & 2 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ const deviceManager = require('../services/device-manager');

router.get('/', function(req, res, next) {

let deviceId = sortDevices(deviceManager.getAllDevices())[0].deviceId;
let devices = sortDevices(deviceManager.getAllDevices());

res.redirect('/' + deviceId);
if (devices && devices.length > 0) {
let deviceId = devices[0].deviceId;

res.redirect('/' + deviceId);
} else {
res.render('index', {});
}

});

Expand Down
14 changes: 14 additions & 0 deletions views/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
{{this.alias}}
</a>
</li>
{{else}}
<li>
<a href='index.html'>
<i class="fa fa-info"></i>
no devices discovered yet
</a>
</li>
{{/each}}
</ul>
</div>
Expand All @@ -43,6 +50,13 @@
{{this.alias}}
</a>
</li>
{{else}}
<li>
<a href="index.html">
<i class="fa fa-info"></i>
no devices discovered yet
</a>
</li>
{{/each}}
</ul>
</div>
Expand Down

0 comments on commit 57f1ac8

Please sign in to comment.