mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-01-20 01:55:03 +00:00
Use device timezone in gui
This commit is contained in:
parent
959664f61d
commit
104617afd2
22
lib/SvelteUi/app/dist/index.js
vendored
22
lib/SvelteUi/app/dist/index.js
vendored
File diff suppressed because one or more lines are too long
@ -1,12 +1,20 @@
|
||||
<script>
|
||||
import { zeropad, monthnames } from './Helpers.js';
|
||||
import { zeropad, monthnames, addHours } from './Helpers.js';
|
||||
|
||||
export let timestamp;
|
||||
export let fullTimeColor;
|
||||
export let offset;
|
||||
|
||||
let showFull;
|
||||
let adjusteTimestamp;
|
||||
$:{
|
||||
showFull = Math.abs(new Date().getTime()-timestamp.getTime()) < 300000;
|
||||
addHours(timestamp, offset);
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if Math.abs(new Date().getTime()-timestamp.getTime()) < 300000 }
|
||||
{`${zeropad(timestamp.getDate())}. ${monthnames[timestamp.getMonth()]} ${zeropad(timestamp.getHours())}:${zeropad(timestamp.getMinutes())}`}
|
||||
{#if showFull }
|
||||
{`${zeropad(timestamp.getDate())}. ${monthnames[timestamp.getMonth()]} ${zeropad(timestamp.getUTCHours())}:${zeropad(timestamp.getMinutes())}`}
|
||||
{:else}
|
||||
<span class="{fullTimeColor}">{`${zeropad(timestamp.getDate())}.${zeropad(timestamp.getMonth()+1)}.${timestamp.getFullYear()} ${zeropad(timestamp.getHours())}:${zeropad(timestamp.getMinutes())}`}</span>
|
||||
<span class="{fullTimeColor}">{`${zeropad(timestamp.getDate())}.${zeropad(timestamp.getMonth()+1)}.${timestamp.getFullYear()} ${zeropad(timestamp.getUTCHours())}:${zeropad(timestamp.getMinutes())}`}</span>
|
||||
{/if}
|
||||
|
||||
@ -82,17 +82,17 @@
|
||||
{/if}
|
||||
{#if uiVisibility(sysinfo.ui.p, data.pe && !Number.isNaN(data.p))}
|
||||
<div class="cnt gwf">
|
||||
<PricePlot json={prices}/>
|
||||
<PricePlot json={prices} sysinfo={sysinfo}/>
|
||||
</div>
|
||||
{/if}
|
||||
{#if uiVisibility(sysinfo.ui.d, dayPlot)}
|
||||
<div class="cnt gwf">
|
||||
<DayPlot json={dayPlot} />
|
||||
<DayPlot json={dayPlot} sysinfo={sysinfo}/>
|
||||
</div>
|
||||
{/if}
|
||||
{#if uiVisibility(sysinfo.ui.m, monthPlot)}
|
||||
<div class="cnt gwf">
|
||||
<MonthPlot json={monthPlot} />
|
||||
<MonthPlot json={monthPlot} sysinfo={sysinfo}/>
|
||||
</div>
|
||||
{/if}
|
||||
{#if uiVisibility(sysinfo.ui.s, data.t && data.t != -127 && temperatures.c > 1)}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
import BarChart from './BarChart.svelte';
|
||||
|
||||
export let json;
|
||||
export let sysinfo;
|
||||
|
||||
let config = {};
|
||||
let max = 0;
|
||||
@ -15,6 +16,7 @@
|
||||
let points = [];
|
||||
let cur = addHours(new Date(), -24);
|
||||
let currentHour = new Date().getUTCHours();
|
||||
addHours(cur, sysinfo.clock_offset);
|
||||
for(i = currentHour; i<24; i++) {
|
||||
let imp = json["i"+zeropad(i)];
|
||||
let exp = json["e"+zeropad(i)];
|
||||
@ -22,7 +24,7 @@
|
||||
if(exp === undefined) exp = 0;
|
||||
|
||||
xTicks.push({
|
||||
label: zeropad(cur.getHours())
|
||||
label: zeropad(cur.getUTCHours())
|
||||
});
|
||||
points.push({
|
||||
label: imp.toFixed(1),
|
||||
@ -44,7 +46,7 @@
|
||||
if(exp === undefined) exp = 0;
|
||||
|
||||
xTicks.push({
|
||||
label: zeropad(cur.getHours())
|
||||
label: zeropad(cur.getUTCHours())
|
||||
});
|
||||
points.push({
|
||||
label: imp.toFixed(1),
|
||||
|
||||
@ -73,7 +73,7 @@
|
||||
<a class="float-right" href='https://github.com/UtilitechAS/amsreader-firmware' target='_blank' rel="noreferrer" aria-label="GitHub"><img class="gh-logo" src={GitHubLogo} alt="GitHub repo"/></a>
|
||||
</div>
|
||||
<div class="flex-none my-auto px-2">
|
||||
<Clock timestamp={ data.c ? new Date(data.c * 1000) : new Date(0) } fullTimeColor="text-red-500" />
|
||||
<Clock timestamp={ data.c ? new Date(data.c * 1000) : new Date(0) } offset={sysinfo.clock_offset} fullTimeColor="text-red-500" />
|
||||
</div>
|
||||
{#if sysinfo.vndcfg && sysinfo.usrcfg}
|
||||
<div class="flex-none px-1 mt-1" title="Configuration">
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
<script>
|
||||
import { zeropad } from './Helpers.js';
|
||||
import { zeropad, addHours } from './Helpers.js';
|
||||
import BarChart from './BarChart.svelte';
|
||||
|
||||
export let json;
|
||||
export let sysinfo;
|
||||
|
||||
let config = {};
|
||||
let max = 0;
|
||||
@ -15,6 +16,8 @@
|
||||
let points = [];
|
||||
let cur = new Date();
|
||||
let lm = new Date();
|
||||
addHours(cur, sysinfo.clock_offset);
|
||||
addHours(lm, sysinfo.clock_offset);
|
||||
lm.setDate(0);
|
||||
|
||||
for(i = cur.getDate(); i<=lm.getDate(); i++) {
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
import BarChart from './BarChart.svelte';
|
||||
|
||||
export let json;
|
||||
export let sysinfo;
|
||||
|
||||
let config = {};
|
||||
let max = 0;
|
||||
@ -18,11 +19,12 @@
|
||||
let xTicks = [];
|
||||
let points = [];
|
||||
let cur = new Date();
|
||||
addHours(cur, sysinfo.clock_offset);
|
||||
for(i = hour; i<24; i++) {
|
||||
val = json[zeropad(h++)];
|
||||
if(val == null) break;
|
||||
xTicks.push({
|
||||
label: zeropad(cur.getHours())
|
||||
label: zeropad(cur.getUTCHours())
|
||||
});
|
||||
points.push({
|
||||
label: val >= 0 ? val.toFixed(d) : '',
|
||||
@ -41,7 +43,7 @@
|
||||
val = json[zeropad(h++)];
|
||||
if(val == null) break;
|
||||
xTicks.push({
|
||||
label: zeropad(cur.getHours())
|
||||
label: zeropad(cur.getUTCHours())
|
||||
});
|
||||
points.push({
|
||||
label: val >= 0 ? val.toFixed(d) : '',
|
||||
|
||||
@ -17,18 +17,18 @@ export default defineConfig({
|
||||
plugins: [svelte()],
|
||||
server: {
|
||||
proxy: {
|
||||
"/data.json": "http://192.168.233.235",
|
||||
"/energyprice.json": "http://192.168.233.235",
|
||||
"/dayplot.json": "http://192.168.233.235",
|
||||
"/monthplot.json": "http://192.168.233.235",
|
||||
"/temperature.json": "http://192.168.233.235",
|
||||
"/sysinfo.json": "http://192.168.233.235",
|
||||
"/configuration.json": "http://192.168.233.235",
|
||||
"/tariff.json": "http://192.168.233.235",
|
||||
"/save": "http://192.168.233.235",
|
||||
"/reboot": "http://192.168.233.235",
|
||||
"/configfile": "http://192.168.233.235",
|
||||
"/upgrade": "http://192.168.233.235"
|
||||
"/data.json": "http://192.168.28.100",
|
||||
"/energyprice.json": "http://192.168.28.100",
|
||||
"/dayplot.json": "http://192.168.28.100",
|
||||
"/monthplot.json": "http://192.168.28.100",
|
||||
"/temperature.json": "http://192.168.28.100",
|
||||
"/sysinfo.json": "http://192.168.28.100",
|
||||
"/configuration.json": "http://192.168.28.100",
|
||||
"/tariff.json": "http://192.168.28.100",
|
||||
"/save": "http://192.168.28.100",
|
||||
"/reboot": "http://192.168.28.100",
|
||||
"/configfile": "http://192.168.28.100",
|
||||
"/upgrade": "http://192.168.28.100"
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -50,5 +50,6 @@
|
||||
"c" : %.2f,
|
||||
"p" : %.2f,
|
||||
"i" : %.2f
|
||||
}
|
||||
},
|
||||
"clock_offset": %d
|
||||
}
|
||||
@ -261,6 +261,8 @@ void AmsWebServer::sysinfoJson() {
|
||||
if(!meterId.isEmpty())
|
||||
meterId.replace(F("\\"), F("\\\\"));
|
||||
|
||||
time_t now = time(nullptr);
|
||||
|
||||
int size = snprintf_P(buf, BufferSize, SYSINFO_JSON,
|
||||
FirmwareVersion::VersionString,
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||
@ -326,7 +328,8 @@ void AmsWebServer::sysinfoJson() {
|
||||
ea->getUseLastMonth(),
|
||||
ea->getCostLastMonth(),
|
||||
ea->getProducedLastMonth(),
|
||||
ea->getIncomeLastMonth()
|
||||
ea->getIncomeLastMonth(),
|
||||
(tz->toLocal(now)-now)/3600
|
||||
);
|
||||
|
||||
stripNonAscii((uint8_t*) buf, size+1);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user