diff --git a/js/beestat.js b/js/beestat.js index e820e2d..931d323 100644 --- a/js/beestat.js +++ b/js/beestat.js @@ -62,6 +62,7 @@ window.addEventListener('resize', rocket.throttle(100, function() { 600, 650, 800, + 850, 1000 ]; diff --git a/js/component/card/three_d.js b/js/component/card/three_d.js index d8fe790..9ac0541 100644 --- a/js/component/card/three_d.js +++ b/js/component/card/three_d.js @@ -616,35 +616,41 @@ beestat.component.card.three_d.prototype.decorate_legend_ = function(parent) { let units; let min = this.get_heat_map_min_(); let max = this.get_heat_map_max_(); - if (beestat.setting('visualize.data_type') === 'temperature') { - min = beestat.temperature(min); - max = beestat.temperature(max); - units = beestat.setting('temperature_unit'); - } else { - min *= 100; - max *= 100; - units = '%'; + + if ( + min !== Infinity && + max !== -Infinity + ) { + if (beestat.setting('visualize.data_type') === 'temperature') { + min = beestat.temperature(min); + max = beestat.temperature(max); + units = beestat.setting('temperature_unit'); + } else { + min *= 100; + max *= 100; + units = '%'; + } + + const min_container = document.createElement('div'); + Object.assign(min_container.style, { + 'position': 'absolute', + 'bottom': '0', + 'right': '10px', + 'font-size': beestat.style.font_size.small + }); + min_container.innerText = min + units; + gradient_container.appendChild(min_container); + + const max_container = document.createElement('div'); + Object.assign(max_container.style, { + 'position': 'absolute', + 'top': '0', + 'right': '10px', + 'font-size': beestat.style.font_size.small + }); + max_container.innerText = max + units; + gradient_container.appendChild(max_container); } - - const min_container = document.createElement('div'); - Object.assign(min_container.style, { - 'position': 'absolute', - 'bottom': '0', - 'right': '10px', - 'font-size': beestat.style.font_size.small - }); - min_container.innerText = min + units; - gradient_container.appendChild(min_container); - - const max_container = document.createElement('div'); - Object.assign(max_container.style, { - 'position': 'absolute', - 'top': '0', - 'right': '10px', - 'font-size': beestat.style.font_size.small - }); - max_container.innerText = max + units; - gradient_container.appendChild(max_container); }; /** diff --git a/js/component/card/visualize_intro.js b/js/component/card/visualize_intro.js index 53fbddf..1d2a4ea 100644 --- a/js/component/card/visualize_intro.js +++ b/js/component/card/visualize_intro.js @@ -19,7 +19,7 @@ beestat.component.card.visualize_intro.prototype.decorate_contents_ = function(p const self = this; const p1 = document.createElement('p'); - p1.innerText = 'You now have early access to the new Visualize features. This is a work-in-progress, but you should find it to be mostly stable. More features and improvements are in the works, as well as documentation and videos to help explain the new capabilities.'; + p1.innerText = 'You now have early access to the new Visualize features. This is a work-in-progress, but you should find it to be mostly stable. More features and improvements are in the works.'; parent.appendChild(p1); const p2 = document.createElement('p'); diff --git a/js/component/card/visualize_settings.js b/js/component/card/visualize_settings.js index da45d79..e514b22 100644 --- a/js/component/card/visualize_settings.js +++ b/js/component/card/visualize_settings.js @@ -3,7 +3,11 @@ */ beestat.component.card.visualize_settings = function() { const self = this; - beestat.dispatcher.addEventListener('cache.floor_plan', function() { + beestat.dispatcher.addEventListener([ + 'cache.floor_plan', + 'cache.data.three_d__runtime_sensor' + ], + function() { self.rerender(); }); @@ -45,6 +49,16 @@ beestat.component.card.visualize_settings.prototype.decorate_contents_ = functio const heat_map_type_container = document.createElement('div'); this.decorate_heat_map_type_(heat_map_type_container); grid_2.appendChild(heat_map_type_container); + + // If at least one sensor is on the floor plan and the data is loading. + if ( + beestat.cache.data.three_d__runtime_sensor === undefined && + Object.keys(beestat.floor_plan.get_sensor_ids_map( + beestat.setting('visualize.floor_plan_id') + )).length > 0 + ) { + this.show_loading_('Fetching'); + } }; /** diff --git a/js/component/floor_plan.js b/js/component/floor_plan.js index ddad377..ea780d1 100644 --- a/js/component/floor_plan.js +++ b/js/component/floor_plan.js @@ -74,6 +74,14 @@ beestat.component.floor_plan.prototype.render = function(parent) { }); parent.appendChild(this.toolbar_container_); + this.toolbar_helper_container_ = $.createElement('div'); + this.toolbar_helper_container_.style({ + 'position': 'absolute', + 'top': 55, + 'left': beestat.style.size.gutter * 4 + }); + parent.appendChild(this.toolbar_helper_container_); + this.floors_container_ = $.createElement('div'); this.floors_container_.style({ 'position': 'absolute', @@ -435,6 +443,17 @@ beestat.component.floor_plan.prototype.update_toolbar = function() { }) ); + // Helper + if (beestat.floor_plan.get_area(this.floor_plan_id_) === 0) { + new beestat.component.tile() + .set_text('Start by adding a room') + .set_shadow(false) + .set_background_color(beestat.style.color.green.base) + .set_text_color('#fff') + .set_type('pill') + .render(this.toolbar_helper_container_); + } + // Remove room const remove_room_button = new beestat.component.tile() .set_icon('card_remove_outline') diff --git a/js/component/header.js b/js/component/header.js index 4daa4b0..8f2dd93 100644 --- a/js/component/header.js +++ b/js/component/header.js @@ -38,11 +38,11 @@ beestat.component.header.prototype.decorate_ = function(parent) { 'text': 'Analyze', 'icon': 'home_search' }, - // { - // 'layer': 'visualize', - // 'text': 'Visualize', - // 'icon': 'floor_plan' - // }, + { + 'layer': 'visualize', + 'text': 'Visualize', + 'icon': 'floor_plan' + }, { 'layer': 'compare', 'text': 'Compare', @@ -127,7 +127,7 @@ beestat.component.header.prototype.decorate_ = function(parent) { .set_shadow(false) .set_text_color(beestat.style.color.bluegray.dark); - if (beestat.width > 800) { + if (beestat.width > 850) { button.set_text(page.text); } @@ -229,15 +229,6 @@ beestat.component.header.prototype.decorate_ = function(parent) { (new beestat.layer.settings()).render(); })); - if (beestat.user.has_early_access() === true) { - menu.add_menu_item(new beestat.component.menu_item() - .set_text('Visualize (Early Access)') - .set_icon('floor_plan') - .set_callback(function() { - (new beestat.layer.visualize()).render(); - })); - } - menu.add_menu_item(new beestat.component.menu_item() .set_text('Log Out') .set_icon('exit_to_app')