diff --git a/js/component/card/runtime_sensor_detail.js b/js/component/card/runtime_sensor_detail.js index 1a0a0dd..cf04bf7 100644 --- a/js/component/card/runtime_sensor_detail.js +++ b/js/component/card/runtime_sensor_detail.js @@ -251,74 +251,76 @@ beestat.component.card.runtime_sensor_detail.prototype.decorate_top_right_ = fun var menu = (new beestat.component.menu()).render(parent); - menu.add_menu_item(new beestat.component.menu_item() - .set_text('Past 1 Day') - .set_icon('numeric_1_box') - .set_callback(function() { - if ( - beestat.setting('runtime_sensor_detail_range_dynamic') !== 1 || - beestat.setting('runtime_sensor_detail_range_type') !== 'dynamic' - ) { - beestat.cache.delete('runtime_sensor'); - beestat.setting({ - 'runtime_sensor_detail_range_dynamic': 1, - 'runtime_sensor_detail_range_type': 'dynamic' - }); - } - })); + if (this.has_data_() === true) { + menu.add_menu_item(new beestat.component.menu_item() + .set_text('Past 1 Day') + .set_icon('numeric_1_box') + .set_callback(function() { + if ( + beestat.setting('runtime_sensor_detail_range_dynamic') !== 1 || + beestat.setting('runtime_sensor_detail_range_type') !== 'dynamic' + ) { + beestat.cache.delete('runtime_sensor'); + beestat.setting({ + 'runtime_sensor_detail_range_dynamic': 1, + 'runtime_sensor_detail_range_type': 'dynamic' + }); + } + })); - menu.add_menu_item(new beestat.component.menu_item() - .set_text('Past 3 Days') - .set_icon('numeric_3_box') - .set_callback(function() { - if ( - beestat.setting('runtime_sensor_detail_range_dynamic') !== 3 || - beestat.setting('runtime_sensor_detail_range_type') !== 'dynamic' - ) { - beestat.cache.delete('runtime_sensor'); - beestat.setting({ - 'runtime_sensor_detail_range_dynamic': 3, - 'runtime_sensor_detail_range_type': 'dynamic' - }); - } - })); + menu.add_menu_item(new beestat.component.menu_item() + .set_text('Past 3 Days') + .set_icon('numeric_3_box') + .set_callback(function() { + if ( + beestat.setting('runtime_sensor_detail_range_dynamic') !== 3 || + beestat.setting('runtime_sensor_detail_range_type') !== 'dynamic' + ) { + beestat.cache.delete('runtime_sensor'); + beestat.setting({ + 'runtime_sensor_detail_range_dynamic': 3, + 'runtime_sensor_detail_range_type': 'dynamic' + }); + } + })); - menu.add_menu_item(new beestat.component.menu_item() - .set_text('Past 7 Days') - .set_icon('numeric_7_box') - .set_callback(function() { - if ( - beestat.setting('runtime_sensor_detail_range_dynamic') !== 7 || - beestat.setting('runtime_sensor_detail_range_type') !== 'dynamic' - ) { - beestat.cache.delete('runtime_sensor'); - beestat.setting({ - 'runtime_sensor_detail_range_dynamic': 7, - 'runtime_sensor_detail_range_type': 'dynamic' - }); - } - })); + menu.add_menu_item(new beestat.component.menu_item() + .set_text('Past 7 Days') + .set_icon('numeric_7_box') + .set_callback(function() { + if ( + beestat.setting('runtime_sensor_detail_range_dynamic') !== 7 || + beestat.setting('runtime_sensor_detail_range_type') !== 'dynamic' + ) { + beestat.cache.delete('runtime_sensor'); + beestat.setting({ + 'runtime_sensor_detail_range_dynamic': 7, + 'runtime_sensor_detail_range_type': 'dynamic' + }); + } + })); - menu.add_menu_item(new beestat.component.menu_item() - .set_text('Custom') - .set_icon('calendar_edit') - .set_callback(function() { - (new beestat.component.modal.runtime_sensor_detail_custom()).render(); - })); + menu.add_menu_item(new beestat.component.menu_item() + .set_text('Custom') + .set_icon('calendar_edit') + .set_callback(function() { + (new beestat.component.modal.runtime_sensor_detail_custom()).render(); + })); - menu.add_menu_item(new beestat.component.menu_item() - .set_text('Download Chart') - .set_icon('download') - .set_callback(function() { - self.charts_.temperature.export(); - })); + menu.add_menu_item(new beestat.component.menu_item() + .set_text('Download Chart') + .set_icon('download') + .set_callback(function() { + self.charts_.temperature.export(); + })); - menu.add_menu_item(new beestat.component.menu_item() - .set_text('Reset Zoom') - .set_icon('magnify_minus') - .set_callback(function() { - self.charts_.temperature.reset_zoom(); - })); + menu.add_menu_item(new beestat.component.menu_item() + .set_text('Reset Zoom') + .set_icon('magnify_minus') + .set_callback(function() { + self.charts_.temperature.reset_zoom(); + })); + } menu.add_menu_item(new beestat.component.menu_item() .set_text('Help') diff --git a/js/component/card/runtime_thermostat_summary.js b/js/component/card/runtime_thermostat_summary.js index 3bfb011..d765be6 100755 --- a/js/component/card/runtime_thermostat_summary.js +++ b/js/component/card/runtime_thermostat_summary.js @@ -507,92 +507,94 @@ beestat.component.card.runtime_thermostat_summary.prototype.decorate_top_right_ var menu = (new beestat.component.menu()).render(parent); - menu.add_menu_item(new beestat.component.menu_item() - .set_text('Past 3 Months') - .set_icon('calendar_range') - .set_callback(function() { - if ( - beestat.setting('runtime_thermostat_summary_time_count') !== 3 || - beestat.setting('runtime_thermostat_summary_time_period') !== 'month' || - beestat.setting('runtime_thermostat_summary_group_by') !== 'day' - ) { - beestat.setting({ - 'runtime_thermostat_summary_time_count': 3, - 'runtime_thermostat_summary_time_period': 'month', - 'runtime_thermostat_summary_group_by': 'day' - }); - } - })); - - menu.add_menu_item(new beestat.component.menu_item() - .set_text('Past 12 Months') - .set_icon('calendar_range') - .set_callback(function() { - if ( - beestat.setting('runtime_thermostat_summary_time_count') !== 12 || - beestat.setting('runtime_thermostat_summary_time_period') !== 'month' || - beestat.setting('runtime_thermostat_summary_group_by') !== 'week' - ) { - beestat.setting({ - 'runtime_thermostat_summary_time_count': 12, - 'runtime_thermostat_summary_time_period': 'month', - 'runtime_thermostat_summary_group_by': 'week' - }); - } - })); - - menu.add_menu_item(new beestat.component.menu_item() - .set_text('All Time') - .set_icon('calendar_range') - .set_callback(function() { - if ( - beestat.setting('runtime_thermostat_summary_time_count') !== 0 || - beestat.setting('runtime_thermostat_summary_time_period') !== 'all' || - beestat.setting('runtime_thermostat_summary_group_by') !== 'month' - ) { - beestat.setting({ - 'runtime_thermostat_summary_time_count': 0, - 'runtime_thermostat_summary_time_period': 'all', - 'runtime_thermostat_summary_group_by': 'month' - }); - } - })); - - menu.add_menu_item(new beestat.component.menu_item() - .set_text('Custom') - .set_icon('calendar_edit') - .set_callback(function() { - (new beestat.component.modal.runtime_thermostat_summary_custom()).render(); - })); - - menu.add_menu_item(new beestat.component.menu_item() - .set_text('Download Chart') - .set_icon('download') - .set_callback(function() { - self.chart_.export(); - })); - - menu.add_menu_item(new beestat.component.menu_item() - .set_text('Reset Zoom') - .set_icon('magnify_minus') - .set_callback(function() { - self.chart_.reset_zoom(); - })); - - if (beestat.setting('runtime_thermostat_summary_gap_fill') === true) { + if (beestat.thermostat.get_sync_progress(this.thermostat_id_) !== null) { menu.add_menu_item(new beestat.component.menu_item() - .set_text('Disable Gap-Fill') - .set_icon('basket_unfill') + .set_text('Past 3 Months') + .set_icon('calendar_range') .set_callback(function() { - beestat.setting('runtime_thermostat_summary_gap_fill', false); + if ( + beestat.setting('runtime_thermostat_summary_time_count') !== 3 || + beestat.setting('runtime_thermostat_summary_time_period') !== 'month' || + beestat.setting('runtime_thermostat_summary_group_by') !== 'day' + ) { + beestat.setting({ + 'runtime_thermostat_summary_time_count': 3, + 'runtime_thermostat_summary_time_period': 'month', + 'runtime_thermostat_summary_group_by': 'day' + }); + } })); - } else { + menu.add_menu_item(new beestat.component.menu_item() - .set_text('Enable Gap-Fill') - .set_icon('basket_fill') + .set_text('Past 12 Months') + .set_icon('calendar_range') .set_callback(function() { - beestat.setting('runtime_thermostat_summary_gap_fill', true); + if ( + beestat.setting('runtime_thermostat_summary_time_count') !== 12 || + beestat.setting('runtime_thermostat_summary_time_period') !== 'month' || + beestat.setting('runtime_thermostat_summary_group_by') !== 'week' + ) { + beestat.setting({ + 'runtime_thermostat_summary_time_count': 12, + 'runtime_thermostat_summary_time_period': 'month', + 'runtime_thermostat_summary_group_by': 'week' + }); + } })); + + menu.add_menu_item(new beestat.component.menu_item() + .set_text('All Time') + .set_icon('calendar_range') + .set_callback(function() { + if ( + beestat.setting('runtime_thermostat_summary_time_count') !== 0 || + beestat.setting('runtime_thermostat_summary_time_period') !== 'all' || + beestat.setting('runtime_thermostat_summary_group_by') !== 'month' + ) { + beestat.setting({ + 'runtime_thermostat_summary_time_count': 0, + 'runtime_thermostat_summary_time_period': 'all', + 'runtime_thermostat_summary_group_by': 'month' + }); + } + })); + + menu.add_menu_item(new beestat.component.menu_item() + .set_text('Custom') + .set_icon('calendar_edit') + .set_callback(function() { + (new beestat.component.modal.runtime_thermostat_summary_custom()).render(); + })); + + menu.add_menu_item(new beestat.component.menu_item() + .set_text('Download Chart') + .set_icon('download') + .set_callback(function() { + self.chart_.export(); + })); + + menu.add_menu_item(new beestat.component.menu_item() + .set_text('Reset Zoom') + .set_icon('magnify_minus') + .set_callback(function() { + self.chart_.reset_zoom(); + })); + + if (beestat.setting('runtime_thermostat_summary_gap_fill') === true) { + menu.add_menu_item(new beestat.component.menu_item() + .set_text('Disable Gap-Fill') + .set_icon('basket_unfill') + .set_callback(function() { + beestat.setting('runtime_thermostat_summary_gap_fill', false); + })); + } else { + menu.add_menu_item(new beestat.component.menu_item() + .set_text('Enable Gap-Fill') + .set_icon('basket_fill') + .set_callback(function() { + beestat.setting('runtime_thermostat_summary_gap_fill', true); + })); + } } menu.add_menu_item(new beestat.component.menu_item()