From dd05aa8c179d6244ccd26cfbb314d9c17141444d Mon Sep 17 00:00:00 2001 From: Generoso Martello Date: Sat, 7 Nov 2015 16:58:23 +0100 Subject: [PATCH] fixed stats page not showing correct temperature unit; added about popup with hg plus link --- BaseFiles/Common/html/index.html | 34 +- .../Common/html/js/api/homegenie.webapp.js | 28 ++ .../Common/html/pages/analyze/_statistics.js | 300 ++++++++++-------- BaseFiles/Common/html/pages/analyze/main.html | 3 +- .../configure/interfaces/configlet/upnp.html | 2 +- .../widgets/homegenie/generic/timetable.html | 2 +- BaseFiles/Common/html/pages/events/_events.js | 2 +- HomeGenie/Service/Logging/StatisticsLogger.cs | 1 - HomeGenie/release_info.xml | 2 +- HomeGenie_Linux/Packager/DEBIAN/md5sums | 56 ++-- 10 files changed, 252 insertions(+), 178 deletions(-) diff --git a/BaseFiles/Common/html/index.html b/BaseFiles/Common/html/index.html index ba9c5f5e1..7bb9b41cf 100644 --- a/BaseFiles/Common/html/index.html +++ b/BaseFiles/Common/html/index.html @@ -467,9 +467,9 @@

  • Settings
  • Maintenance
  • About
  • -
  • Version ?
  • -
  • Users Guide
  • -
  • Programming Guide
  • +
  • About HomeGenie
  • +
  • Users Guide
  • +
  • Programming Guide
  • Users Forum
  • Keep HomeGenie Up!
  • @@ -496,5 +496,33 @@

    + +
    +
    +

    About

    +
    +
    +

    HomeGenie Version ?

    +
    +

    What's hot

    +

    + Don't miss the new client for Android! +

    +
    + HomeGenie Plus +
    +
    + + +
    + + diff --git a/BaseFiles/Common/html/js/api/homegenie.webapp.js b/BaseFiles/Common/html/js/api/homegenie.webapp.js index 05b3601a4..bb60c054b 100644 --- a/BaseFiles/Common/html/js/api/homegenie.webapp.js +++ b/BaseFiles/Common/html/js/api/homegenie.webapp.js @@ -113,6 +113,11 @@ HG.WebApp.InitializePage = function () HG.WebApp.Locales.Localize(document, './locales/' + userLang.toLowerCase().substring(0, 2) + '.json', function(success){ HG.WebApp.Locales.Localize(document, './locales/' + userLang.toLowerCase().substring(0, 2) + '.programs.json', function(success){ $('#homegenie_overlay').fadeOut(200); + // Show about popup + if (!dataStore.get('UI.AboutPopupShown')) { + dataStore.set('UI.AboutPopupShown', true); + setTimeout(HG.WebApp.Home.About, 3000); + } }); }); HG.VoiceControl.Initialize(); @@ -224,9 +229,16 @@ HG.WebApp.InitializePage = function () element.enhanceWithin().popup(); HG.Ui.Popup.CronWizard = handler; }); + + $('#homegenie_about').enhanceWithin().popup(); + $('#about_popup_updatebutton').on('click', function(){ + HG.System.UpdateManager.UpdateCheck(); + $('#homegenie_about').popup('close'); + }); }; + // // namespace : HG.WebApp.Events // info : - @@ -298,6 +310,11 @@ HG.WebApp.InitializePage = function () // info : - // HG.WebApp.Home = HG.WebApp.Home || {}; +HG.WebApp.Home.About = function() +{ + $('#homegenie_about').popup('open'); +}; +// HG.WebApp.Home.UpdateHeaderStatus = function() { HG.WebApp.Home.UpdateInterfacesStatus(); @@ -572,6 +589,17 @@ HG.WebApp.Utility.GetCommandFromEvent = function (module, event) return commandobj; }; +HG.WebApp.Utility.GetLocaleTemperature = function (temp) { + var temperatureUnit = dataStore.get('UI.TemperatureUnit'); + if (temperatureUnit != 'C' && (temperatureUnit == 'F' || HG.WebApp.Locales.GetDateEndianType() == 'M')) { + // display as Fahrenheit + temp = Math.round((temp * 1.8 + 32) * 10) / 10; + } else { + // display as Celsius + temp = Math.round(temp * 10) / 10; + } + return (temp * 1).toFixed(2); +}; HG.WebApp.Utility.FormatTemperature = function (temp) { var displayvalue = ''; var temperatureUnit = dataStore.get('UI.TemperatureUnit'); diff --git a/BaseFiles/Common/html/pages/analyze/_statistics.js b/BaseFiles/Common/html/pages/analyze/_statistics.js index c4d88d8a2..c916ddf83 100644 --- a/BaseFiles/Common/html/pages/analyze/_statistics.js +++ b/BaseFiles/Common/html/pages/analyze/_statistics.js @@ -24,16 +24,16 @@ HG.WebApp.Statistics.InitializePage = function () { $('#page_analyze_param').on('change', function () { HG.WebApp.Statistics.RefreshModules(); }); - $('#page_analyze_graphtype').on('change', function () { - //... - }); + //$('#page_analyze_graphtype').on('change', function () { + // //... + //}); // $('#page_analyze_renderbutton').bind('click', function () { var selected = $('#page_analyze_source').find('option:selected'); HG.WebApp.Statistics._CurrentModule = selected.attr('data-context-domain') + ':' + selected.attr('data-context-address'); if (HG.WebApp.Statistics._CurrentModule == ':') HG.WebApp.Statistics._CurrentModule = ''; HG.WebApp.Statistics._CurrentParameter = $('#page_analyze_param').val(); - HG.WebApp.Statistics._CurrentGraphType = $('#page_analyze_graphtype').val(); + //HG.WebApp.Statistics._CurrentGraphType = $('#page_analyze_graphtype').val(); HG.WebApp.Statistics._CurrentType = $('#page_analyze_type').val(); // if (HG.WebApp.Statistics._CurrentParameter.substring(0, 6) == 'Meter.' || HG.WebApp.Statistics._CurrentParameter.substring(0, 13) == 'PowerMonitor.') { @@ -114,11 +114,11 @@ HG.WebApp.Statistics.InitializePage = function () { { if( HG.WebApp.Statistics._SelItemObject == false ) { - $("#page_delete_stat").html("Delete Value : "+item.datapoint[1]); + $("#page_delete_stat").html("Delete Value : "+item.datapoint[1]); HG.WebApp.Statistics._ItemObject = item.datapoint[0]+'/'+item.datapoint[1]; - api.elements.tooltip.stop(1, 1); - api.show(item); - } + api.elements.tooltip.stop(1, 1); + api.show(item); + } } else { @@ -169,23 +169,23 @@ HG.WebApp.Statistics.InitializePage = function () { $("#page_delete_stat").on('click', function () { if( HG.WebApp.Statistics._SelItemObject == true ) { - $.ajax({ - url: '/' + HG.WebApp.Data.ServiceKey + '/' + HG.WebApp.Data.ServiceDomain + '/Statistics/Parameter.StatDelete/' + HG.WebApp.Statistics._ItemObject, - type: 'GET', - success: function (data) { - var stats = eval(data); -// $("#page_analyze_title").html(data) ; - $.mobile.loading('hide'); - }, - error: function(xhr, status, error) { - console.log('STATISTICS ERROR: '+xhr.status+':'+xhr.statusText); - $.mobile.loading('hide'); - } - }); + $.ajax({ + url: '/' + HG.WebApp.Data.ServiceKey + '/' + HG.WebApp.Data.ServiceDomain + '/Statistics/Parameter.StatDelete/' + HG.WebApp.Statistics._ItemObject, + type: 'GET', + success: function (data) { + var stats = eval(data); +// $("#page_analyze_title").html(data) ; + $.mobile.loading('hide'); + }, + error: function(xhr, status, error) { + console.log('STATISTICS ERROR: '+xhr.status+':'+xhr.statusText); + $.mobile.loading('hide'); + } + }); HG.WebApp.Statistics._ItemObject = ''; } HG.WebApp.Statistics._SelItemObject = false; - $("#page_delete_stat").hide(); + $("#page_delete_stat").hide(); }); $("#statshour").on('click', function () { if( HG.WebApp.Statistics._SelItemObject == false ) @@ -193,14 +193,14 @@ HG.WebApp.Statistics.InitializePage = function () { if( HG.WebApp.Statistics._ItemObject != '' ) { HG.WebApp.Statistics._SelItemObject = true; - $("#page_delete_stat").show(); - } + $("#page_delete_stat").show(); + } } else { HG.WebApp.Statistics._ItemObject = ''; HG.WebApp.Statistics._SelItemObject = false; - $("#page_delete_stat").hide(); + $("#page_delete_stat").hide(); } }); }; @@ -257,9 +257,9 @@ HG.WebApp.Statistics.RefreshModules = function () { var saddress = coption.attr('data-context-address'); // $('#page_analyze_source').empty(); - $('#page_analyze_source').append(''); + $('#page_analyze_source').append(''); var allSelected = (sdomain == "All"); - $('#page_analyze_source').append(''); + $('#page_analyze_source').append(''); // var datasources = ''; @@ -302,7 +302,7 @@ HG.WebApp.Statistics.Refresh = function () { if(HG.WebApp.Statistics._CurrentTab == 1) { if(HG.WebApp.Statistics._SelItemObject == false) - $("#page_delete_stat").hide(); + $("#page_delete_stat").hide(); HG.Statistics.ServiceCall('Global.TimeRange', '', '', function (trange) { var start = new Date(parseFloat(trange.StartTime)); var end = new Date(parseFloat(trange.EndTime)); @@ -324,104 +324,122 @@ HG.WebApp.Statistics.Refresh = function () { dto.setHours(23, 59, 59, 0); if(HG.WebApp.Statistics._CurrentModule !="All:") { - if(showtype == true) - { - $.ajax({ - url: '/' + HG.WebApp.Data.ServiceKey + '/' + HG.WebApp.Data.ServiceDomain + '/Statistics/Parameter.StatsHour/' + HG.WebApp.Statistics._CurrentParameter + '/' + HG.WebApp.Statistics._CurrentModule + '/' + dfrom.getTime() + '/' + dto.getTime(), - type: 'GET', - success: function (data) { - var stats = eval(data); - try { - $.plot($("#statshour"), [ - { label: 'Max', data: stats[1], bars: { show: showbars, barWidth: (30 * 60 * 1000), align: 'center', steps: true } }, - { label: 'Avg', data: stats[2], bars: { show: showbars, barWidth: (30 * 60 * 1000), align: 'center', steps: true } }, - { label: 'Min', data: stats[0], bars: { show: showbars, barWidth: (30 * 60 * 1000), align: 'center', steps: true } }, - { label: 'Today Avg', data: stats[3], bars: { show: showbars, barWidth: (10 * 60 * 1000), align: 'center', steps: false } }, - { label: 'Today Detail', data: stats[4], lines: { show: true, lineWidth: 2.0 }, bars: { show: false }, splines: { show: false }, points: { show: false } } - ], - { - yaxis: { show: true }, - xaxis: { mode: "time", timeformat: "%H:00", minTickSize: [1, "hour"], tickSize: [1, "hour"] }, - legend: { position: "nw", noColumns: 5, backgroundOpacity: 0.3 }, - lines: { show: showlines, lineWidth: 1.0 }, - series: { - splines: { show: showsplines } - }, - grid: { - backgroundColor: { colors: ["#fff", "#ddd"] }, - hoverable: true - }, - colors: ["rgba(200, 255, 0, 0.5)", "rgba(120, 160, 0, 0.5)", "rgba(40, 70, 0, 0.5)", "rgba(110, 80, 255, 0.5)", "rgba(200, 30, 0, 1.0)"], //"rgba(0, 30, 180, 1.0)" - points: { show: true }, - zoom: { - interactive: true - }, - pan: { - interactive: true - } - }); - } catch (e) { } - $.mobile.loading('hide'); - }, - error: function(xhr, status, error) { - console.log('STATISTICS ERROR: '+xhr.status+':'+xhr.statusText); - $.mobile.loading('hide'); - } - }); - } - else - { - $.ajax({ - url: '/' + HG.WebApp.Data.ServiceKey + '/' + HG.WebApp.Data.ServiceDomain + '/Statistics/Parameter.StatsDay/' + HG.WebApp.Statistics._CurrentParameter + '/' + HG.WebApp.Statistics._CurrentModule + '/' + dfrom.getTime() + '/' + dto.getTime(), - type: 'GET', - success: function (data) { - var stats = eval(data); - try { - $.plot($("#statshour"), [ - { label: $('#page_analyze_title').text(), data: stats[0], lines: { show: true, lineWidth: 1.0 }, bars: { show: false }, splines: { show: false }, points: { show: false } } - ], - { - yaxis: { show: true }, - xaxis: { mode: "time", timeformat: "%d/%m", minTickSize: [1, "day"], tickSize: [1, "day"] }, - legend: { position: "nw", noColumns: 5, backgroundOpacity: 0.3 }, - lines: { show: showlines, lineWidth: 1.0 }, - series: { - splines: { show: showsplines } - }, - grid: { - backgroundColor: { colors: ["#fff", "#ddd"] }, - hoverable: true - }, - colors: ["rgba(200, 30, 0, 1.0)"], - points: { show: true }, - zoom: { - interactive: true - }, - pan: { - interactive: true - } - }); - } catch (e) { } - $.mobile.loading('hide'); - }, - error: function(xhr, status, error) { - console.log('STATISTICS ERROR: '+xhr.status+':'+xhr.statusText); - $.mobile.loading('hide'); - } - }); - } - } - else - { - $.ajax({ - url: '/' + HG.WebApp.Data.ServiceKey + '/' + HG.WebApp.Data.ServiceDomain + '/Statistics/Parameter.StatsMultiple/' + HG.WebApp.Statistics._CurrentParameter + '/' + HG.WebApp.Statistics._CurrentModule + '/' + dfrom.getTime() + '/' + dto.getTime(), - type: 'GET', - success: function (data) { - var name = ''; - var tformat = ""; - var tickSize = ""; + if(showtype == true) + { + $.ajax({ + url: '/' + HG.WebApp.Data.ServiceKey + '/' + HG.WebApp.Data.ServiceDomain + '/Statistics/Parameter.StatsHour/' + HG.WebApp.Statistics._CurrentParameter + '/' + HG.WebApp.Statistics._CurrentModule + '/' + dfrom.getTime() + '/' + dto.getTime(), + type: 'GET', + success: function (data) { + var stats = eval(data); + try { + if (HG.WebApp.Statistics._CurrentParameter == 'Sensor.Temperature') { + // convert to farehnehit if needed + for (var sx = 0; sx < stats.length; sx++) + for (var tx = 0; tx < stats[sx].length; tx++) + stats[sx][tx][1] = HG.WebApp.Utility.GetLocaleTemperature(stats[sx][tx][1]); + } + $.plot($("#statshour"), [ + { label: 'Max', data: stats[1], bars: { show: showbars, barWidth: (30 * 60 * 1000), align: 'center', steps: true } }, + { label: 'Avg', data: stats[2], bars: { show: showbars, barWidth: (30 * 60 * 1000), align: 'center', steps: true } }, + { label: 'Min', data: stats[0], bars: { show: showbars, barWidth: (30 * 60 * 1000), align: 'center', steps: true } }, + { label: 'Today Avg', data: stats[3], bars: { show: showbars, barWidth: (10 * 60 * 1000), align: 'center', steps: false } }, + { label: 'Today Detail', data: stats[4], lines: { show: true, lineWidth: 2.0 }, bars: { show: false }, splines: { show: false }, points: { show: false } } + ], + { + yaxis: { show: true }, + xaxis: { mode: "time", timeformat: "%H:00", minTickSize: [1, "hour"], tickSize: [1, "hour"] }, + legend: { position: "nw", noColumns: 5, backgroundOpacity: 0.3 }, + lines: { show: showlines, lineWidth: 1.0 }, + series: { + splines: { show: showsplines } + }, + grid: { + backgroundColor: { colors: ["#fff", "#ddd"] }, + hoverable: true + }, + colors: ["rgba(200, 255, 0, 0.5)", "rgba(120, 160, 0, 0.5)", "rgba(40, 70, 0, 0.5)", "rgba(110, 80, 255, 0.5)", "rgba(200, 30, 0, 1.0)"], //"rgba(0, 30, 180, 1.0)" + points: { show: true }, + zoom: { + interactive: true + }, + pan: { + interactive: true + } + }); + } catch (e) { console.log(e); } + $.mobile.loading('hide'); + }, + error: function(xhr, status, error) { + console.log('STATISTICS ERROR: '+xhr.status+':'+xhr.statusText); + $.mobile.loading('hide'); + } + }); + } + else + { + $.ajax({ + url: '/' + HG.WebApp.Data.ServiceKey + '/' + HG.WebApp.Data.ServiceDomain + '/Statistics/Parameter.StatsDay/' + HG.WebApp.Statistics._CurrentParameter + '/' + HG.WebApp.Statistics._CurrentModule + '/' + dfrom.getTime() + '/' + dto.getTime(), + type: 'GET', + success: function (data) { + var stats = eval(data); + try { + if (HG.WebApp.Statistics._CurrentParameter == 'Sensor.Temperature') { + // convert to farehnehit if needed + for (var sx = 0; sx < stats.length; sx++) + for (var tx = 0; tx < stats[sx].length; tx++) + stats[sx][tx][1] = HG.WebApp.Utility.GetLocaleTemperature(stats[sx][tx][1]); + } + $.plot($("#statshour"), [ + { label: $('#page_analyze_title').text(), data: stats[0], lines: { show: true, lineWidth: 1.0 }, bars: { show: false }, splines: { show: false }, points: { show: false } } + ], + { + yaxis: { show: true }, + xaxis: { mode: "time", timeformat: "%d/%m", minTickSize: [1, "day"], tickSize: [1, "day"] }, + legend: { position: "nw", noColumns: 5, backgroundOpacity: 0.3 }, + lines: { show: showlines, lineWidth: 1.0 }, + series: { + splines: { show: showsplines } + }, + grid: { + backgroundColor: { colors: ["#fff", "#ddd"] }, + hoverable: true + }, + colors: ["rgba(200, 30, 0, 1.0)"], + points: { show: true }, + zoom: { + interactive: true + }, + pan: { + interactive: true + } + }); + } catch (e) { console.log(e); } + $.mobile.loading('hide'); + }, + error: function(xhr, status, error) { + console.log('STATISTICS ERROR: '+xhr.status+':'+xhr.statusText); + $.mobile.loading('hide'); + } + }); + } + } + else + { + $.ajax({ + url: '/' + HG.WebApp.Data.ServiceKey + '/' + HG.WebApp.Data.ServiceDomain + '/Statistics/Parameter.StatsMultiple/' + HG.WebApp.Statistics._CurrentParameter + '/' + HG.WebApp.Statistics._CurrentModule + '/' + dfrom.getTime() + '/' + dto.getTime(), + type: 'GET', + success: function (data) { + var name = ''; + var tformat = ""; + var tickSize = ""; var graph_data = []; - var stats = eval(data); + var stats = eval(data); + if (HG.WebApp.Statistics._CurrentParameter == 'Sensor.Temperature') { + // convert to farehnehit if needed + for (var sx = 1; sx < stats.length; sx+=2) + for (var tx = 0; tx < stats[sx].length; tx++) + stats[sx][tx][1] = HG.WebApp.Utility.GetLocaleTemperature(stats[sx][tx][1]); + } if(showtype == true) { tformat = "%H:00"; @@ -444,28 +462,28 @@ HG.WebApp.Statistics.Refresh = function () { xaxis: {mode: "time", timeformat: tformat, minTickSize: [1, tickSize], tickSize: [1, tickSize]}, legend: { backgroundOpacity: 0.3 }, grid: { - backgroundColor: { colors: ["#fff", "#ddd"] }, - hoverable: true - }, - points: { show: true }, - zoom: { + backgroundColor: { colors: ["#fff", "#ddd"] }, + hoverable: true + }, + points: { show: true }, + zoom: { interactive: true }, pan: { interactive: true - } + } }); - $.mobile.loading('hide'); - }, - error: function(xhr, status, error) { - console.log('STATISTICS ERROR: '+xhr.status+':'+xhr.statusText); - $.mobile.loading('hide'); - } - }); + $.mobile.loading('hide'); + }, + error: function(xhr, status, error) { + console.log('STATISTICS ERROR: '+xhr.status+':'+xhr.statusText); + $.mobile.loading('hide'); + } + }); } }); } - else + else { HG.Statistics.ServiceCall('Global.CounterTotal', HG.WebApp.Statistics._CurrentParameter, '', function (total) { $('#page_analyze_totalunits').val((total * 1).toFixed(2)); @@ -513,9 +531,9 @@ HG.WebApp.Statistics.Refresh = function () { }, pan: { interactive: true - } + } }); - } catch (e) { } + } catch (e) { console.log(e); } // $.mobile.loading('hide'); }, diff --git a/BaseFiles/Common/html/pages/analyze/main.html b/BaseFiles/Common/html/pages/analyze/main.html index 4e7ac013b..1bc31d8ad 100644 --- a/BaseFiles/Common/html/pages/analyze/main.html +++ b/BaseFiles/Common/html/pages/analyze/main.html @@ -109,12 +109,13 @@

    Options

    - +