diff --git a/package.json b/package.json index 3e2687856..4daac4237 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/client/app/containers/BarChartContainer.ts b/src/client/app/containers/BarChartContainer.ts index 19547f06f..0cc518d5d 100644 --- a/src/client/app/containers/BarChartContainer.ts +++ b/src/client/app/containers/BarChartContainer.ts @@ -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(` ${timeReading}
${label}: ${barReading.reading} kW`); + hoverText.push(` ${timeReading}
${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 @@ -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(` ${timeReading}
${label}: ${barReading.reading} kW`); + hoverText.push(` ${timeReading}
${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 @@ -103,7 +103,7 @@ function mapStateToProps(state: State) { orientation: 'h' }, yaxis: { - title: 'kW', + title: 'kWh', showgrid: true, gridcolor: '#ddd' }, diff --git a/src/client/app/containers/CompareChartContainer.ts b/src/client/app/containers/CompareChartContainer.ts index b8bf8e5c7..4bdda0a9e 100644 --- a/src/client/app/containers/CompareChartContainer.ts +++ b/src/client/app/containers/CompareChartContainer.ts @@ -43,13 +43,13 @@ function mapStateToProps(state: State, ownProps: CompareChartContainerProps): IP x: [periodLabels.prev, periodLabels.current], y: [previousPeriod, currentPeriod], hovertext: [ - `${previousPeriod} KW ${translate('used.this.time')}
${periodLabels.prev.toLowerCase()}`, - `${currentPeriod} KW ${translate('used.so.far')}
${periodLabels.current.toLowerCase()}` + `${previousPeriod} KWh ${translate('used.this.time')}
${periodLabels.prev.toLowerCase()}`, + `${currentPeriod} KWh ${translate('used.so.far')}
${periodLabels.current.toLowerCase()}` ], hoverinfo: 'text', type: 'bar', marker: {color: barColor}, - text: [ `${previousPeriod} kW`, `${currentPeriod} kW`], + text: [ `${previousPeriod} kWh`, `${currentPeriod} kWh`], textposition: 'auto', textfont: { color: 'rgba(0,0,0,1)' @@ -71,7 +71,7 @@ function mapStateToProps(state: State, ownProps: CompareChartContainerProps): IP legend: { }, yaxis: { - title: 'kW', + title: 'kWh', showgrid: true, gridcolor: '#ddd' }, diff --git a/src/client/app/containers/MapChartContainer.ts b/src/client/app/containers/MapChartContainer.ts index c681c63bd..84650b5ae 100644 --- a/src/client/app/containers/MapChartContainer.ts +++ b/src/client/app/containers/MapChartContainer.ts @@ -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(` ${timeReading}
${label}: ${averagedReading} kW/day`); + texts.push(` ${timeReading}
${label}: ${averagedReading} kWh/day`); } } } diff --git a/src/server/migrations/0.5.0-0.6.0/sql/meter/add_idenifier_column.sql b/src/server/migrations/0.5.0-0.6.0/sql/meter/add_idenifier_column.sql new file mode 100644 index 000000000..38c9aba6b --- /dev/null +++ b/src/server/migrations/0.5.0-0.6.0/sql/meter/add_idenifier_column.sql @@ -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=''; diff --git a/src/server/migrations/registerMigration.js b/src/server/migrations/registerMigration.js index ac53fad96..150867fa9 100644 --- a/src/server/migrations/registerMigration.js +++ b/src/server/migrations/registerMigration.js @@ -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 */ ]; diff --git a/src/server/routes/meters.js b/src/server/routes/meters.js index 78e6cfcc6..d22153cc0 100644 --- a/src/server/routes/meters.js +++ b/src/server/routes/meters.js @@ -109,7 +109,12 @@ 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: [ { @@ -117,10 +122,10 @@ router.post('/edit', async (req, res) => { 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' } ] } } @@ -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); diff --git a/src/server/routes/preferences.js b/src/server/routes/preferences.js index 25fdbefc6..30f3db98c 100644 --- a/src/server/routes/preferences.js +++ b/src/server/routes/preferences.js @@ -50,7 +50,10 @@ router.post('/', async (req, res) => { type: 'string' }, defaultTimezone: { - type: 'string' + oneOf: [ + { type: 'string' }, + { type: 'null' } + ] } } }