diff --git a/js/component/header.js b/js/component/header.js
index af40553..19b915c 100644
--- a/js/component/header.js
+++ b/js/component/header.js
@@ -183,6 +183,11 @@ beestat.component.header.prototype.decorate_logo_ = function(parent) {
* @param {rocket.Elements} parent
*/
beestat.component.header.prototype.decorate_navigation_ = function(parent) {
+ // Disable navigation if you have no thermostats.
+ if (Object.keys(beestat.cache.thermostat).length === 0) {
+ return;
+ }
+
const self = this;
const pages = [
@@ -404,12 +409,14 @@ beestat.component.header.prototype.decorate_menu_ = function(parent) {
}
menu.add_menu_item(announcements_menu_item);
- menu.add_menu_item(new beestat.component.menu_item()
- .set_text('Download Data')
- .set_icon('download')
- .set_callback(function() {
- (new beestat.component.modal.download_data()).render();
- }));
+ if (Object.keys(beestat.cache.thermostat).length > 0) {
+ menu.add_menu_item(new beestat.component.menu_item()
+ .set_text('Download Data')
+ .set_icon('download')
+ .set_callback(function() {
+ (new beestat.component.modal.download_data()).render();
+ }));
+ }
menu.add_menu_item(new beestat.component.menu_item()
.set_text('Settings')
diff --git a/js/js.php b/js/js.php
index bfe39fc..ec29243 100755
--- a/js/js.php
+++ b/js/js.php
@@ -67,6 +67,7 @@ if($setting->get('environment') === 'dev' || $setting->get('environment') === 'd
echo '' . PHP_EOL;
echo '' . PHP_EOL;
echo '' . PHP_EOL;
+ echo '' . PHP_EOL;
// Component
echo '' . PHP_EOL;
diff --git a/js/layer/load.js b/js/layer/load.js
index a171ca9..537589a 100644
--- a/js/layer/load.js
+++ b/js/layer/load.js
@@ -154,6 +154,12 @@ beestat.layer.load.prototype.decorate_ = function(parent) {
beestat.cache.set('runtime_thermostat_summary', response.runtime_thermostat_summary);
beestat.cache.set('stripe_event', response.stripe_event);
+ // Send you to the no thermostats layer if none were returned.
+ if(Object.keys(response.thermostat).length === 0) {
+ (new beestat.layer.no_thermostats()).render();
+ return;
+ }
+
// Set the active thermostat_id if this is your first time visiting.
if (beestat.setting('thermostat_id') === undefined) {
beestat.setting(
diff --git a/js/layer/no_thermostats.js b/js/layer/no_thermostats.js
new file mode 100644
index 0000000..270807e
--- /dev/null
+++ b/js/layer/no_thermostats.js
@@ -0,0 +1,42 @@
+/**
+ * No thermostats layer.
+ */
+beestat.layer.no_thermostats = function() {
+ beestat.layer.apply(this, arguments);
+};
+beestat.extend(beestat.layer.no_thermostats, beestat.layer);
+
+beestat.layer.no_thermostats.prototype.decorate_ = function(parent) {
+ /*
+ * Set the overflow on the body so the scrollbar is always present so
+ * highcharts graphs render properly.
+ */
+ $('body').style({
+ 'overflow-y': 'scroll',
+ 'background': beestat.style.color.bluegray.light,
+ 'padding': '0 ' + beestat.style.size.gutter + 'px'
+ });
+
+ (new beestat.component.header('no_thermostats')).render(parent);
+
+ // All the cards
+ const cards = [];
+
+ // Manage Thermostats
+ cards.push([
+ {
+ 'card': new beestat.component.card.manage_thermostats(),
+ 'size': 12
+ }
+ ]);
+
+ // Footer
+ cards.push([
+ {
+ 'card': new beestat.component.card.footer(),
+ 'size': 12
+ }
+ ]);
+
+ (new beestat.component.layout(cards)).render(parent);
+};