From 30a40e5500ecc488eacdad665da92fe13bcc4b27 Mon Sep 17 00:00:00 2001 From: Emrys Date: Fri, 13 Jul 2018 22:05:42 +0100 Subject: [PATCH 1/7] } // stops a part upgrade error - this change requires emoncms/emoncms repo to also be updated // keep button hidden if new version of clipboard.js is not available if (typeof copyToClipboardCustomMsg === 'function') { document.getElementById('copy-csv').classList.remove('hidden'); } else { --- group_view.php | 13 +++++++++++++ view.php | 18 +++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/group_view.php b/group_view.php index 9a39180..d26b612 100644 --- a/group_view.php +++ b/group_view.php @@ -35,6 +35,7 @@ --> + @@ -204,6 +205,10 @@ +
+ +
+ @@ -341,6 +346,14 @@ } }); + // stops a part upgrade error - this change requires emoncms/emoncms repo to also be updated + // keep button hidden if new version of clipboard.js is not available + if (typeof copyToClipboardCustomMsg === 'function') { + document.getElementById('copy-csv').classList.remove('hidden'); + } else { + copyToClipboardCustomMsg = function () {} + } + /****************************************** Functions ******************************************/ diff --git a/view.php b/view.php index 466e658..f3585ad 100644 --- a/view.php +++ b/view.php @@ -36,6 +36,7 @@ --> + @@ -204,8 +205,12 @@ - - + + +
+ +
+ @@ -235,8 +240,15 @@ }); } + // stops a part upgrade error - this change requires emoncms/emoncms repo to also be updated + // keep button hidden if new version of clipboard.js is not available + if (typeof copyToClipboardCustomMsg === 'function') { + document.getElementById('copy-csv').classList.remove('hidden'); + } else { + copyToClipboardCustomMsg = function () {} + } + // Assign active feedid from URL - console.log(window.location.pathname); var urlparts = window.location.pathname.split("graph/"); if (urlparts.length==2) { var feedids = urlparts[1].split(","); From 127861bafb08ecad08d23268e0e9333767a1a3e7 Mon Sep 17 00:00:00 2001 From: TrystanLea Date: Wed, 1 Aug 2018 08:16:28 +0100 Subject: [PATCH 2/7] check for group_model file rather than db entry --- graph_controller.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/graph_controller.php b/graph_controller.php index 4d52087..f20c342 100644 --- a/graph_controller.php +++ b/graph_controller.php @@ -9,8 +9,7 @@ function graph_controller() // Check if group module is installed $group = false; - $result = $mysqli->query("SHOW TABLES LIKE 'groups'"); - if ($result->num_rows > 0) { + if (file_exists("Modules/group/group_model.php")) { require_once "Modules/group/group_model.php"; $group = new Group($mysqli, $redis, null, null, null); } From 85f92197de920ecdbae93c0e0d0dba45ddc83fc0 Mon Sep 17 00:00:00 2001 From: Emrys Date: Mon, 24 Sep 2018 13:50:11 +0100 Subject: [PATCH 3/7] added feed unit to tooltip and legend --- graph.js | 28 ++++++++++++++++++---------- view.php | 1 + 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/graph.js b/graph.js index 82cd95f..5c8affc 100644 --- a/graph.js +++ b/graph.js @@ -55,13 +55,22 @@ $('#placeholder').bind("plotselected", function (event, ranges) graph_reloaddraw(); }); - +function getFeedUnit(id){ + let unit = '' + for(let key in feeds) { + if (feeds[key].id == id){ + unit = feeds[key].unit + } + } + return unit +} $('#placeholder').bind("plothover", function (event, pos, item) { var item_value; if (item) { var z = item.dataIndex; if (previousPoint != item.datapoint) { var dp=feedlist[item.seriesIndex].dp; + var feedid = feedlist[item.seriesIndex].id; previousPoint = item.datapoint; $("#tooltip").remove(); @@ -71,14 +80,12 @@ $('#placeholder').bind("plothover", function (event, pos, item) { } else { item_value=(item.datapoint[1]-item.datapoint[2]).toFixed(dp); } - - var d = new Date(item_time); - var days = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; - var months = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; - var minutes = d.getMinutes(); - if (minutes<10) minutes = "0"+minutes; - var date = d.getHours()+":"+minutes+" "+days[d.getDay()]+", "+months[d.getMonth()]+" "+d.getDate(); - tooltip(item.pageX, item.pageY, ""+item.series.label+"
"+item_value+"
"+date+"", "#fff"); + item_value+=' '+getFeedUnit(feedid); + var date = moment(item_time).format('llll') + tooltip(item.pageX, item.pageY, ""+item.series.label+""+ + "
"+item_value + + "
"+date+""+ + "
("+(item_time/1000)+")", "#fff"); } } else $("#tooltip").remove(); }); @@ -508,7 +515,7 @@ function graph_init_editor() $('body').on("click",".legendColorBox",function(d){ var country = $(this).html().toLowerCase(); - console.log(country); + // console.log(country); }); $(".feed-options-show-stats").click(function(){ @@ -674,6 +681,7 @@ function graph_draw() var label = ""; if (showtag) label += feedlist[z].tag+": "; label += feedlist[z].name; + label += ' '+getFeedUnit(feedlist[z].id); var stacked = (typeof(feedlist[z].stack) !== "undefined" && feedlist[z].stack); var plot = {label:label, data:data, yaxis:feedlist[z].yaxis, color: feedlist[z].color, stack: stacked}; diff --git a/view.php b/view.php index 466e658..c7cd465 100644 --- a/view.php +++ b/view.php @@ -213,6 +213,7 @@ +