Skip to content

Commit

Permalink
Merge pull request #568 from OpenEnergyDashboard/huss
Browse files Browse the repository at this point in the history
Changes to move OED to version 0.6.0
  • Loading branch information
huss authored Feb 26, 2021
2 parents 02e0b7c + 75e865b commit 4a8bcc4
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Open-Energy-Dashboard",
"version": "0.5.0",
"version": "0.6.0",
"private": false,
"license": "MPL-2.0",
"repository": "https://github.com/OpenEnergyDashboard/OED",
Expand Down
6 changes: 3 additions & 3 deletions src/client/app/containers/BarChartContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function mapStateToProps(state: State) {
`${moment(barReading.startTimestamp).utc().format('MMM DD, YYYY')} - ${moment(barReading.endTimestamp).utc().format('MMM DD, YYYY')}`;
xData.push(timeReading);
yData.push(barReading.reading);
hoverText.push(`<b> ${timeReading} </b> <br> ${label}: ${barReading.reading} kW`);
hoverText.push(`<b> ${timeReading} </b> <br> ${label}: ${barReading.reading} kWh`);
});

// This variable contains all the elements (x and y values, bar type, etc.) assigned to the data parameter of the Plotly object
Expand Down Expand Up @@ -72,7 +72,7 @@ function mapStateToProps(state: State) {
`${moment(barReading.startTimestamp).utc().format('MMM DD, YYYY')} - ${moment(barReading.endTimestamp).utc().format('MMM DD, YYYY')}`;
xData.push(timeReading);
yData.push(barReading.reading);
hoverText.push(`<b> ${timeReading} </b> <br> ${label}: ${barReading.reading} kW`);
hoverText.push(`<b> ${timeReading} </b> <br> ${label}: ${barReading.reading} kWh`);
});

// This variable contains all the elements (x and y values, bar chart, etc.) assigned to the data parameter of the Plotly object
Expand Down Expand Up @@ -103,7 +103,7 @@ function mapStateToProps(state: State) {
orientation: 'h'
},
yaxis: {
title: 'kW',
title: 'kWh',
showgrid: true,
gridcolor: '#ddd'
},
Expand Down
8 changes: 4 additions & 4 deletions src/client/app/containers/CompareChartContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ function mapStateToProps(state: State, ownProps: CompareChartContainerProps): IP
x: [periodLabels.prev, periodLabels.current],
y: [previousPeriod, currentPeriod],
hovertext: [
`<b>${previousPeriod} KW</b> ${translate('used.this.time')}<br>${periodLabels.prev.toLowerCase()}`,
`<b>${currentPeriod} KW</b> ${translate('used.so.far')}<br>${periodLabels.current.toLowerCase()}`
`<b>${previousPeriod} KWh</b> ${translate('used.this.time')}<br>${periodLabels.prev.toLowerCase()}`,
`<b>${currentPeriod} KWh</b> ${translate('used.so.far')}<br>${periodLabels.current.toLowerCase()}`
],
hoverinfo: 'text',
type: 'bar',
marker: {color: barColor},
text: [ `<b>${previousPeriod} kW</b>`, `<b>${currentPeriod} kW</b>`],
text: [ `<b>${previousPeriod} kWh</b>`, `<b>${currentPeriod} kWh</b>`],
textposition: 'auto',
textfont: {
color: 'rgba(0,0,0,1)'
Expand All @@ -71,7 +71,7 @@ function mapStateToProps(state: State, ownProps: CompareChartContainerProps): IP
legend: {
},
yaxis: {
title: 'kW',
title: 'kWh',
showgrid: true,
gridcolor: '#ddd'
},
Expand Down
2 changes: 1 addition & 1 deletion src/client/app/containers/MapChartContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function mapStateToProps(state: State) {
`${moment(mapReading.startTimestamp).utc().format('MMM DD, YYYY')} - ${moment(mapReading.endTimestamp).utc().format('MMM DD, YYYY')}`;
const averagedReading = mapReading.reading / barDuration.asDays(); // average total reading by days of duration
size.push(averagedReading);
texts.push(`<b> ${timeReading} </b> <br> ${label}: ${averagedReading} kW/day`);
texts.push(`<b> ${timeReading} </b> <br> ${label}: ${averagedReading} kWh/day`);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

ALTER TABLE meters
ADD COLUMN IF NOT EXISTS identifier TEXT;

UPDATE meters SET identifier=name WHERE identifier IS NULL or identifier='';
3 changes: 2 additions & 1 deletion src/server/migrations/registerMigration.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
const migrations = [
/* eslint-disable global-require */
//require('./0.2.0-0.3.0-Template/indexTemplate'),
require('./0.3.0-0.5.0')
require('./0.3.0-0.5.0'),
require('./0.5.0-0.6.0')
/* eslint-disable global-require */
];

Expand Down
13 changes: 9 additions & 4 deletions src/server/routes/meters.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,23 @@ router.post('/edit', async (req, res) => {
id: { type: 'integer' },
enabled: { type: 'bool' },
displayable: { type: 'bool' },
timeZone: { type: 'string' },
timeZone: {
oneOf: [
{ type: 'string' },
{ type: 'null' }
]
},
gps: {
oneOf: [
{
type: 'object',
required: ['latitude', 'longitude'],
properties: {
latitude: { type: 'number', minimum: '-90', maximum: '90' },
longitude: { type: 'number', minimum: '-180', maximum: '180'}
longitude: { type: 'number', minimum: '-180', maximum: '180' }
}
},
{type: 'null'}
{ type: 'null' }
]
}
}
Expand All @@ -137,7 +142,7 @@ router.post('/edit', async (req, res) => {
meter.enabled = req.body.enabled;
meter.displayable = req.body.displayable;
meter.meterTimezone = req.body.timeZone;
meter.gps = (req.body.gps)? new Point(req.body.gps.longitude, req.body.gps.latitude): null;
meter.gps = (req.body.gps) ? new Point(req.body.gps.longitude, req.body.gps.latitude) : null;
await meter.update(conn);
} catch (err) {
log.error('Failed to edit meter', err);
Expand Down
5 changes: 4 additions & 1 deletion src/server/routes/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ router.post('/', async (req, res) => {
type: 'string'
},
defaultTimezone: {
type: 'string'
oneOf: [
{ type: 'string' },
{ type: 'null' }
]
}
}
}
Expand Down

0 comments on commit 4a8bcc4

Please sign in to comment.