diff --git a/Lib/appconf/appconf.js b/Lib/appconf/appconf.js index 3a6ea94c..7347e3c6 100644 --- a/Lib/appconf/appconf.js +++ b/Lib/appconf/appconf.js @@ -576,25 +576,26 @@ var config = { } -var vue_config = new Vue({ - el: '#vue-config', - data: { - app_name: "App Name", - app_name_color: "#44b3e2", - app_description: "", - app_instructions: "", - config_name: "", - config_public: false, - config_items: [], - config_valid: false, - autogen_node: "", - autogen_feeds: [], - autogen_all_present: false, - autogen_status: "", - autogen_status_color: "#aaa", - - // Button only currently used by myheatpump app. - enable_process_daily: false +var vue_config_app = Vue.createApp({ + data: function() { + return { + app_name: "App Name", + app_name_color: "#44b3e2", + app_description: "", + app_instructions: "", + config_name: "", + config_public: false, + config_items: [], + config_valid: false, + autogen_node: "", + autogen_feeds: [], + autogen_all_present: false, + autogen_status: "", + autogen_status_color: "#aaa", + + // Button only currently used by myheatpump app. + enable_process_daily: false + }; }, methods: { @@ -833,4 +834,6 @@ var vue_config = new Vue({ config.reset_daily_data(); } } -}); \ No newline at end of file +}); + +var vue_config = vue_config_app.mount('#vue-config'); \ No newline at end of file diff --git a/Lib/appconf/appconf.php b/Lib/appconf/appconf.php index 146fb16d..ed5a3e02 100644 --- a/Lib/appconf/appconf.php +++ b/Lib/appconf/appconf.php @@ -5,9 +5,6 @@ $app_conf_version = time(); // Use timestamp for cache busting during development, replace with static version for production ?> - - -
@@ -149,4 +146,4 @@
- + \ No newline at end of file diff --git a/Views/app_list.php b/Views/app_list.php index cc0c9054..d3185313 100644 --- a/Views/app_list.php +++ b/Views/app_list.php @@ -2,8 +2,6 @@ defined('EMONCMS_EXEC') or die('Restricted access'); global $path; ?> - -

@@ -61,10 +59,11 @@
\ No newline at end of file diff --git a/Views/app_view.php b/Views/app_view.php index 18642b01..b4e2dd25 100644 --- a/Views/app_view.php +++ b/Views/app_view.php @@ -1,108 +1,133 @@ - -
+
-

Available Apps

-

Create a new instance of an app by clicking on one of the apps below.

+

Available Apps

+

Create a new instance of an app by clicking on one of the apps below.

-
+
-

Featured apps:

+

Featured apps:

-
-
-
{{ app.title }}
-
{{ app.description || "no description..." }}
-
-
-
- -

All apps:

+
+
+
{{ entry.app.title }}
+
{{ entry.app.description || "no description..." }}
+
+
+
-
-
-
{{ app.title }}
-
{{ app.description || "no description..." }}
-
-
+

All apps:

-
+
+
+
{{ entry.app.title }}
+
{{ entry.app.description || "no description..." }}
+
+
-
+
- diff --git a/apps/OpenEnergyMonitor/myheatpump/myheatpump.js b/apps/OpenEnergyMonitor/myheatpump/myheatpump.js index 74863c73..5eebe2bf 100644 --- a/apps/OpenEnergyMonitor/myheatpump/myheatpump.js +++ b/apps/OpenEnergyMonitor/myheatpump/myheatpump.js @@ -1,3 +1,5 @@ +var urlParams = Object.fromEntries(new URLSearchParams(window.location.search)); + feed.apikey = apikey; feed.public_userid = public_userid; feed.public_username = public_username; @@ -107,7 +109,7 @@ var realtime_cop_div_mode = "30min"; var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; // duration contants (milliseonds) -const MINUTE = 60 * 1000; +const MINUTE = 60; const HOUR = 60 * MINUTE; const DAY = 24 * HOUR; @@ -207,14 +209,14 @@ function show() { resize(); var date = new Date(); - var now = date.getTime(); + var now = date.getTime() * 0.001; - end = end_time * 1000; + end = end_time; if (now - end > HOUR) { $("#last_updated").show(); $("#live_table").hide(); - date.setTime(end); + date.setTime(end*1000); let h = date.getHours(); let m = date.getMinutes(); if (h < 10) h = "0" + h; @@ -248,13 +250,13 @@ function show() { // If this is a new dashboard there will be less than a days data // show power graph directly in this case - var timeWindow = (end - start_time * 1000); + var timeWindow = (end - start_time); if (timeWindow < 3 * DAY || viewmode == "powergraph") { if (timeWindow > 3 * DAY) timeWindow = DAY; var start = end - timeWindow; - if (urlParams.start != undefined) start = urlParams.start * 1000; - if (urlParams.end != undefined) end = urlParams.end * 1000; + if (urlParams.start != undefined) start = urlParams.start; + if (urlParams.end != undefined) end = urlParams.end; if (urlParams.hours != undefined) start = end - urlParams.hours * HOUR; view.start = start; @@ -267,10 +269,10 @@ function show() { } else { var timeWindow = 30 * DAY; var start = end - timeWindow; - if (start < (start_time * 1000)) start = start_time * 1000; + if (start < start_time) start = start_time; - if (urlParams.start != undefined) start = urlParams.start * 1000; - if (urlParams.end != undefined) end = urlParams.end * 1000; + if (urlParams.start != undefined) start = urlParams.start; + if (urlParams.end != undefined) end = urlParams.end; bargraph_load(start, end); bargraph_draw(); @@ -506,9 +508,9 @@ $(".viewhistory").click(function () { $(".powergraph-navigation").hide(); var timeWindow = 30 * DAY; // var end = (new Date()).getTime(); - var end = end_time * 1000; + var end = end_time; var start = end - timeWindow; - if (start < (start_time * 1000)) start = start_time * 1000; + if (start < start_time) start = start_time; if (last_bargraph_start && last_bargraph_end) { start = last_bargraph_start; @@ -523,13 +525,14 @@ $(".viewhistory").click(function () { $("#advanced-block").hide(); }); -$('#placeholder').bind("plothover", function (event, pos, item) { +document.getElementById('placeholder')?.addEventListener('plothover', function (event) { + const item = event.detail?.[1]; if (item) { if (previousPoint != item.datapoint) { previousPoint = item.datapoint; $("#tooltip").remove(); - if (viewmode == "bargraph") { + if (viewmode == "bargraph") { bargraph_tooltip(item); } else if (viewmode == "powergraph") { powergraph_tooltip(item); @@ -539,16 +542,18 @@ $('#placeholder').bind("plothover", function (event, pos, item) { }); // Auto click through to power graph -$('#placeholder').bind("plotclick", function (event, pos, item) { +document.getElementById('placeholder')?.addEventListener('plotclick', function (event) { + const item = event.detail?.[1]; if (item && !panning && viewmode == "bargraph") { last_bargraph_start = bargraph_start; last_bargraph_end = bargraph_end; var z = item.dataIndex; - view.start = data["heatpump_elec_kwhd"][z][0]; + view.start = data["heatpump_elec_kwhd"][z][0]*1; view.end = view.start + DAY; viewmode = "powergraph"; + powergraph_load(); $(".bargraph-navigation").hide(); @@ -562,7 +567,9 @@ $('#placeholder').bind("plotclick", function (event, pos, item) { } }); -$('#placeholder').bind("plotselected", function (event, ranges) { +document.getElementById('placeholder')?.addEventListener('plotselected', function (event) { + const ranges = event.detail?.[0]; + if (!ranges?.xaxis) return; var start = ranges.xaxis.from; var end = ranges.xaxis.to; panning = true; diff --git a/apps/OpenEnergyMonitor/myheatpump/myheatpump.php b/apps/OpenEnergyMonitor/myheatpump/myheatpump.php index 3d0a699e..25afe320 100644 --- a/apps/OpenEnergyMonitor/myheatpump/myheatpump.php +++ b/apps/OpenEnergyMonitor/myheatpump/myheatpump.php @@ -6,16 +6,13 @@ - - - - - - - - - - +
"); } } @@ -485,7 +488,7 @@ function bargraph_tooltip(item) var COP = null; if (heat_kwh !== null && elec_kwh !== null) COP = heat_kwh / elec_kwh; - var d = new Date(itemTime); + var d = new Date(itemTime*1000); var days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; var date = days[d.getDay()] + ", " + months[d.getMonth()] + " " + d.getDate(); @@ -607,16 +610,16 @@ $('.bargraph-day').click(function () { $('.bargraph-period').click(function () { var days = $(this).attr("days"); var timeWindow = days * DAY; - var end = (new Date()).getTime(); + var end = (new Date()).getTime() * 0.001; var start = end - timeWindow; - if (start < (start_time * 1000)) start = start_time * 1000; + if (start < start_time) start = start_time; bargraph_load(start, end); bargraph_draw(); }); $('.bargraph-alltime').click(function () { - var start = start_time * 1000; - var end = (new Date()).getTime(); + var start = start_time; + var end = (new Date()).getTime() * 0.001; bargraph_load(start, end); bargraph_draw(); }); diff --git a/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js b/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js index 656d97f5..01f35810 100644 --- a/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js +++ b/apps/OpenEnergyMonitor/myheatpump/myheatpump_powergraph.js @@ -32,15 +32,15 @@ function powergraph_load() { "heatpump_ch": { label: "CH", yaxis: 4, color: "#FB6", lines: { lineWidth: 0, show: true, fill: 0.15 } }, "heatpump_cooling": { label: "Cooling", yaxis: 4, color: "#66b0ff", lines: { lineWidth: 0, show: true, fill: 0.15 } }, "heatpump_error": { label: "Error", yaxis: 4, color: "#F00", lines: { lineWidth: 0, show: true, fill: 0.15 } }, - "heatpump_targetT": { label: "TargetT", yaxis: 2, color: "#ccc" }, - "heatpump_flowT": { label: "FlowT", yaxis: 2, color: 2 }, - "heatpump_returnT": { label: "ReturnT", yaxis: 2, color: 3 }, - "heatpump_outsideT": { label: "OutsideT", yaxis: 2, color: "#c880ff" }, - "heatpump_roomT": { label: "RoomT", yaxis: 2, color: "#000" }, - "heatpump_flowrate": { label: "Flow rate", yaxis: 3, color: 6 }, + "heatpump_targetT": { label: "TargetT", yaxis: 2, color: "#ccc", lines: { lineWidth: 1.8 } }, + "heatpump_flowT": { label: "FlowT", yaxis: 2, color: "#cb4b4b", lines: { lineWidth: 1.8 } }, + "heatpump_returnT": { label: "ReturnT", yaxis: 2, color: "#4da74d", lines: { lineWidth: 1.8 } }, + "heatpump_outsideT": { label: "OutsideT", yaxis: 2, color: "#c880ff", lines: { lineWidth: 1.8 } }, + "heatpump_roomT": { label: "RoomT", yaxis: 2, color: "#000", lines: { lineWidth: 1.8 } }, + "heatpump_flowrate": { label: "Flow rate", yaxis: 3, color: "#afd8f8", lines: { lineWidth: 1.8 } }, "boiler_heat": { label: "Boiler", yaxis: 1, color: "#FF5349", lines: { show: true, fill: 0.2, lineWidth: 0.5 } }, - "heatpump_heat": { label: "Heat", yaxis: 1, color: 0, lines: { show: true, fill: 0.2, lineWidth: 0.5 } }, - "heatpump_elec": { label: "Electric", yaxis: 1, color: 1, lines: { show: true, fill: 0.3, lineWidth: 0.5 } }, + "heatpump_heat": { label: "Heat", yaxis: 1, color: "#edc240", lines: { show: true, fill: 0.2, lineWidth: 0.5 } }, + "heatpump_elec": { label: "Electric", yaxis: 1, color: "#afd8f8", lines: { show: true, fill: 0.3, lineWidth: 0.5 } }, "immersion_elec": { label: "Immersion", yaxis: 1, color: 4, lines: { show: true, fill: 0.3, lineWidth: 0.5 } }, "heatpump_dhwT": { label: dhw_label, yaxis: dhw_axis, color: "#0080ff" }, "heatpump_dhwTargetT": { label: dhw_target_label, yaxis: dhw_axis, color:"#99cbfc" }, @@ -693,10 +693,10 @@ function powergraph_draw() { reserveSpace: false }, yaxes: [ - { min: 0, font: style, reserveSpace: false }, + { autoScale: "none", min: 0, font: style, reserveSpace: false }, { font: style, reserveSpace: false }, - { min: 0, font: { size: flot_font_size, color: "#44b3e2" }, reserveSpace: false }, - { min: 0, max: 1, show: false, reserveSpace: false } + { autoScale: "none", min: 0, font: { size: flot_font_size, color: "#44b3e2" }, reserveSpace: false }, + { autoScale: "none", min: 0, max: 1, show: false, reserveSpace: false } ], grid: { show: true, @@ -708,7 +708,7 @@ function powergraph_draw() { // axisMargin:0 margin: { top: 30 } }, - selection: { mode: "x" }, + selection: { mode: 'x', color: '#e8cfac', visualization: 'fill' }, legend: { position: "NW", noColumns: 13 } } @@ -717,6 +717,7 @@ function powergraph_draw() { } if ($('#placeholder').width()) { + if (!window.Flot || typeof window.Flot.plot !== 'function') return; // Remove keys var powergraph_series_without_key = []; for (var key in powergraph_series) { @@ -727,7 +728,7 @@ function powergraph_draw() { if (key == 'heatpump_dhwTargetT' && !show_dhw_temp) show = false; if (show) powergraph_series_without_key.push(powergraph_series[key]); } - $.plot($('#placeholder'), powergraph_series_without_key, options); + window.Flot.plot($('#placeholder')[0], powergraph_series_without_key, options); } // show symbol when live scrolling is active @@ -785,7 +786,8 @@ function draw_histogram(histogram) { legend: { position: "NW", noColumns: 6 } } if ($('#histogram').width() > 0) { - $.plot($('#histogram'), [{ data: sorted_histogram }], options); + if (!window.Flot || typeof window.Flot.plot !== 'function') return; + window.Flot.plot($('#histogram')[0], [{ data: sorted_histogram }], options); } } @@ -1071,7 +1073,8 @@ $("#configure_standby").click(function () { } }); -$('#histogram').bind("plothover", function (event, pos, item) { +document.getElementById('histogram')?.addEventListener('plothover', function (event) { + const item = event.detail?.[1]; if (item) { var z = item.dataIndex; if (previousPoint != item.datapoint) { diff --git a/apps/OpenEnergyMonitor/mysolarpvbattery/mysolarpvbattery.js b/apps/OpenEnergyMonitor/mysolarpvbattery/mysolarpvbattery.js index 2de06139..d577e373 100644 --- a/apps/OpenEnergyMonitor/mysolarpvbattery/mysolarpvbattery.js +++ b/apps/OpenEnergyMonitor/mysolarpvbattery/mysolarpvbattery.js @@ -260,6 +260,7 @@ function init() render_autogen_feed_list(); + view.timeBaseScale = 1000; view.end = power_end; view.start = power_start; diff --git a/apps/OpenEnergyMonitor/mysolarpvbattery/mysolarpvbattery.php b/apps/OpenEnergyMonitor/mysolarpvbattery/mysolarpvbattery.php index 7e6adf61..751fd413 100644 --- a/apps/OpenEnergyMonitor/mysolarpvbattery/mysolarpvbattery.php +++ b/apps/OpenEnergyMonitor/mysolarpvbattery/mysolarpvbattery.php @@ -1,21 +1,14 @@ - - +defined('EMONCMS_EXEC') or die('Restricted access'); +global $path, $session; - - - - - - - - - - +load_js("Modules/feed/feed.js"); +load_js("Lib/js/flot-5.1.0.js"); +load_js("Lib/js/vis.helper.js"); +load_js("Modules/app/Lib/timeseries.js"); +load_css("Modules/app/apps/OpenEnergyMonitor/mysolarpvbattery/mysolarpvbattery.css"); +?>