From c59f4193ed36ec5022d57186433ecc59e191ee22 Mon Sep 17 00:00:00 2001 From: Robert Carlson Date: Tue, 25 Jul 2023 14:17:18 -0700 Subject: [PATCH 01/96] Set conditionSet through UI (Draft) --- .../meters/CreateMeterModalComponent.tsx | 7 +- .../meters/EditMeterModalComponent.tsx | 69 ++++++++++++++++++- src/client/app/types/redux/meters.ts | 10 +++ src/server/models/Meter.js | 23 ++++++- src/server/routes/meters.js | 33 +++++++-- .../services/csvPipeline/uploadReadings.js | 18 ++++- src/server/sql/meter/create_meters_table.sql | 7 +- src/server/sql/meter/insert_new_meter.sql | 4 +- src/server/sql/meter/update_meter.sql | 7 +- src/server/util/insertData.js | 17 ++++- 10 files changed, 177 insertions(+), 18 deletions(-) diff --git a/src/client/app/components/meters/CreateMeterModalComponent.tsx b/src/client/app/components/meters/CreateMeterModalComponent.tsx index 800c2b19a..52656c18a 100644 --- a/src/client/app/components/meters/CreateMeterModalComponent.tsx +++ b/src/client/app/components/meters/CreateMeterModalComponent.tsx @@ -74,7 +74,12 @@ export default function CreateMeterModalComponent(props: CreateMeterModalCompone endTimestamp: '', previousEnd: '', areaUnit: AreaUnitType.none, - readingFrequency: adminState.defaultMeterReadingFrequency + readingFrequency: adminState.defaultMeterReadingFrequency, + minVal: 0, + maxVal: 0, + minDate: '', + maxDate: '', + maxError: 0 } const dropdownsStateDefaults = { diff --git a/src/client/app/components/meters/EditMeterModalComponent.tsx b/src/client/app/components/meters/EditMeterModalComponent.tsx index af4939d97..dcc12ae65 100644 --- a/src/client/app/components/meters/EditMeterModalComponent.tsx +++ b/src/client/app/components/meters/EditMeterModalComponent.tsx @@ -74,7 +74,12 @@ export default function EditMeterModalComponent(props: EditMeterModalComponentPr unitId: props.meter.unitId, defaultGraphicUnit: props.meter.defaultGraphicUnit, areaUnit: props.meter.areaUnit, - readingFrequency: props.meter.readingFrequency + readingFrequency: props.meter.readingFrequency, + minVal: props.meter.minVal, + maxVal: props.meter.maxVal, + minDate: props.meter.minDate, + maxDate: props.meter.maxDate, + maxError: props.meter.maxError } const dropdownsStateDefaults = { @@ -190,7 +195,12 @@ export default function EditMeterModalComponent(props: EditMeterModalComponentPr props.meter.endTimestamp != state.endTimestamp || props.meter.previousEnd != state.previousEnd || props.meter.areaUnit != state.areaUnit || - props.meter.readingFrequency != state.readingFrequency + props.meter.readingFrequency != state.readingFrequency || + props.meter.minVal != state.minVal || + props.meter.maxVal != state.maxVal || + props.meter.minDate != state.minDate || + props.meter.maxDate != state.maxDate || + props.meter.maxError != state.maxError ); // Only validate and store if any changes. @@ -749,6 +759,61 @@ export default function EditMeterModalComponent(props: EditMeterModalComponentPr onChange={e => handleStringChange(e)} placeholder='YYYY-MM-DD HH:MM:SS' value={state?.previousEnd} /> + + {/* minVal input */} + + + handleNumberChange(e)} + min="0" + defaultValue={state.minVal} + value={state.minVal} /> + + {/* maxVal input */} + + + handleNumberChange(e)} + min="0" + defaultValue={state.maxVal} + value={state.maxVal} /> + + {/* minDate input */} + + + handleNumberChange(e)} + min="0" + defaultValue={state.minDate} + value={state.minDate} /> + + {/* maxDate input */} + + + handleNumberChange(e)} + min="0" + defaultValue={state.maxDate} + value={state.maxDate} /> + + {/* maxError input */} + + + handleNumberChange(e)} + min="0" + defaultValue={state.maxError} + value={state.maxError} /> diff --git a/src/client/app/types/redux/meters.ts b/src/client/app/types/redux/meters.ts index 3d51ef0ca..3e5fee7ac 100644 --- a/src/client/app/types/redux/meters.ts +++ b/src/client/app/types/redux/meters.ts @@ -98,6 +98,11 @@ export interface MeterData { previousEnd: string; areaUnit: AreaUnitType; readingFrequency: string; + minVal: number; + maxVal: number; + minDate: string; + maxDate: string; + maxError: number; } export interface MeterEditData { @@ -129,6 +134,11 @@ export interface MeterEditData { previousEnd: string | undefined; areaUnit: AreaUnitType; readingFrequency: string; + minVal: number; + maxVal: number; + minDate: string; + maxDate: string; + maxError: number; } export interface MeterDataByID { diff --git a/src/server/models/Meter.js b/src/server/models/Meter.js index b5ae23f1a..a8bc9695e 100644 --- a/src/server/models/Meter.js +++ b/src/server/models/Meter.js @@ -39,6 +39,11 @@ class Meter { * @param defaultGraphicUnit The foreign key to the unit table represents the preferred unit to display this meter, default -99 * @param areaUnit The meter's area unit, default 'none' * @param readingFrequency The time between readings for this meter with default of '00:15:00' but should not depend on that. + * @param minVal + * @param maxVal + * @param minDate + * @param maxDate + * @param maxError */ // The start/end timestamps are the default start/end timestamps that are set to the first // day of time in moment. As always, we want to use UTC. @@ -52,7 +57,8 @@ class Meter { cumulative = false, cumulativeReset = false, cumulativeResetStart = '00:00:00', cumulativeResetEnd = '23:59:59.999999', readingGap = 0, readingVariation = 0, readingDuplication = 1, timeSort = 'increasing', endOnlyTime = false, reading = 0.0, startTimestamp = moment(0).utc().format('YYYY-MM-DD HH:mm:ssZ'), endTimestamp = moment(0).utc().format('YYYY-MM-DD HH:mm:ssZ'), - previousEnd = moment(0).utc(), unitId = -99, defaultGraphicUnit = -99, areaUnit = Unit.areaUnitType.NONE, readingFrequency = '00:15:00') { + previousEnd = moment(0).utc(), unitId = -99, defaultGraphicUnit = -99, areaUnit = Unit.areaUnitType.NONE, readingFrequency = '00:15:00', + minVal = null, maxVal = null, minDate = null, maxDate = null, maxError = null) { // In order for the CSV pipeline to work, the order of the parameters needs to match the order that the fields are declared. // In addition, each new parameter has to be added at the very end. this.id = id; @@ -83,6 +89,11 @@ class Meter { this.defaultGraphicUnit = defaultGraphicUnit; this.areaUnit = areaUnit; this.readingFrequency = readingFrequency; + this.minVal = minVal; + this.maxVal = maxVal; + this.minDate = minDate; + this.maxDate = maxDate; + this.maxError = maxError; } /** @@ -134,7 +145,8 @@ class Meter { var meter = new Meter(row.id, row.name, row.url, row.enabled, row.displayable, row.meter_type, row.default_timezone_meter, row.gps, row.identifier, row.note, row.area, row.cumulative, row.cumulative_reset, row.cumulative_reset_start, row.cumulative_reset_end, row.reading_gap, row.reading_variation, row.reading_duplication, row.time_sort, - row.end_only_time, row.reading, row.start_timestamp, row.end_timestamp, row.previous_end, row.unit_id, row.default_graphic_unit, row.area_unit, row.reading_frequency); + row.end_only_time, row.reading, row.start_timestamp, row.end_timestamp, row.previous_end, row.unit_id, row.default_graphic_unit, row.area_unit, row.reading_frequency, + row.min_val, row.max_val, row.min_date, row.max_date, row.max_error); meter.unitId = Meter.convertUnitValue(meter.unitId); meter.defaultGraphicUnit = Meter.convertUnitValue(meter.defaultGraphicUnit); return meter; @@ -236,7 +248,7 @@ class Meter { readingDuplication = this.readingDuplication, timeSort = this.timeSort, endOnlyTime = this.endOnlyTime, reading = this.reading, startTimestamp = this.startTimestamp, endTimestamp = this.endTimestamp, previousEnd = this.previousEnd, unitId = this.unitId, defaultGraphicUnit = this.defaultGraphicUnit, areaUnit = this.areaUnit, - readingFrequency = this.readingFrequency) { + readingFrequency = this.readingFrequency, minVal = this.minVal, maxVal = this.maxVal, minDate = this.minDate, maxDate = this.maxDate, maxError = this.maxError) { this.name = name; this.url = url; this.enabled = enabled; @@ -264,6 +276,11 @@ class Meter { this.defaultGraphicUnit = defaultGraphicUnit; this.areaUnit = areaUnit; this.readingFrequency = readingFrequency; + this.minVal = minVal; + this.maxVal = maxVal; + this.minDate = minDate; + this.maxDate = maxDate; + this.maxError = maxError; } /** diff --git a/src/server/routes/meters.js b/src/server/routes/meters.js index 89a9cde04..487c9ec07 100644 --- a/src/server/routes/meters.js +++ b/src/server/routes/meters.js @@ -56,7 +56,12 @@ function formatMeterForResponse(meter, loggedInAsAdmin) { unitId: meter.unitId, defaultGraphicUnit: meter.defaultGraphicUnit, areaUnit: meter.areaUnit, - readingFrequency: null + readingFrequency: null, + minVal: null, + maxVal: null, + minDate: null, + maxDate: null, + maxError: null }; // Only logged in Admins can see url, types, timezones, and internal names @@ -82,6 +87,11 @@ function formatMeterForResponse(meter, loggedInAsAdmin) { formattedMeter.endTimestamp = meter.endTimestamp; formattedMeter.previousEnd = meter.previousEnd; formattedMeter.readingFrequency = meter.readingFrequency; + formattedMeter.minVal = meter.minVal; + formattedMeter.maxVal = meter.maxVal; + formattedMeter.minDate = meter.minDate; + formattedMeter.maxDate = meter.maxDate; + formattedMeter.maxError = meter.maxError; } return formattedMeter; @@ -149,7 +159,7 @@ router.get('/:meter_id', async (req, res) => { function validateMeterParams(params) { const validParams = { type: 'object', - maxProperties: 28, + maxProperties: 33, // We can get rid of some of these if we defaulted more values in the meter model. required: ['name', 'url', 'enabled', 'displayable', 'meterType', 'timeZone', 'note', 'area'], properties: { @@ -228,6 +238,11 @@ function validateMeterParams(params) { enum: Object.values(Unit.areaUnitType) }, readingFrequency: { type: 'string' }, + minVal: { type: 'number' }, + maxVal: { type: 'number' }, + minDate: { type: 'string' }, + maxDate: { type: 'string' }, + minError: { type: 'number' }, } } const paramsValidationResult = validate(params, validParams); @@ -271,7 +286,12 @@ router.post('/edit', requiredAdmin('edit meters'), async (req, res) => { req.body.unitId, req.body.defaultGraphicUnit, req.body.areaUnit, - req.body.readingFrequency + req.body.readingFrequency, + req.body.minVal, + req.body.maxVal, + req.body.minDate, + req.body.maxDate, + req.body.maxError ); // Put any changed values from updatedMeter into meter. _.merge(meter, updatedMeter); @@ -328,7 +348,12 @@ router.post('/addMeter', async (req, res) => { req.body.unitId, req.body.defaultGraphicUnit, req.body.areaUnit, - req.body.readingFrequency + req.body.readingFrequency, + req.body.minVal, + req.body.maxVal, + req.body.minDate, + req.body.maxDate, + req.body.maxError ); // insert updates the newMeter values from DB. await newMeter.insert(conn); diff --git a/src/server/services/csvPipeline/uploadReadings.js b/src/server/services/csvPipeline/uploadReadings.js index 643ee7ac2..d8f8db261 100644 --- a/src/server/services/csvPipeline/uploadReadings.js +++ b/src/server/services/csvPipeline/uploadReadings.js @@ -66,7 +66,12 @@ async function uploadReadings(req, res, filepath, conn) { undefined, // unit undefined, // default graphic unit undefined, // area unit - undefined // reading frequency + undefined, // reading frequency + undefined, // minVal + undefined, // maxVal + undefined, // minDate + undefined, // maxDate + undefined // maxError ) await tempMeter.insert(conn); meterCreated = true; @@ -219,6 +224,15 @@ async function uploadReadings(req, res, filepath, conn) { const areReadingsEndOnly = (readingEndOnly === BooleanTypesJS.true); const mapRowToModel = row => { return row; }; // STUB function to satisfy the parameter of loadCsvInput. + + const conditionSetMap = new Map(); + conditionSetMap.set('minVal', meter.minVal); + conditionSetMap.set('maxVal', meter.maxVal); + conditionSetMap.set('minDate', meter.minDate); + conditionSetMap.set('maxDate', meter.maxDate); + conditionSetMap.set('threshold', meter.readingGap); + conditionSetMap.set('maxError', meter.maxError); + return await loadCsvInput( filepath, meter.id, @@ -234,7 +248,7 @@ async function uploadReadings(req, res, filepath, conn) { areReadingsEndOnly, hasHeaderRow, shouldUpdate, - undefined, + conditionSetMap, conn, shouldHonorDst, shouldRelaxedParsing diff --git a/src/server/sql/meter/create_meters_table.sql b/src/server/sql/meter/create_meters_table.sql index 332371f6e..bf0433a11 100644 --- a/src/server/sql/meter/create_meters_table.sql +++ b/src/server/sql/meter/create_meters_table.sql @@ -64,5 +64,10 @@ CREATE TABLE IF NOT EXISTS meters ( unit_id INTEGER REFERENCES units(id), default_graphic_unit INTEGER REFERENCES units(id), area_unit area_unit_type NOT NULL DEFAULT 'none', - reading_frequency INTERVAL NOT NULL DEFAULT '00:15:00' + reading_frequency INTERVAL NOT NULL DEFAULT '00:15:00', + min_val INTEGER NULL DEFAULT NULL, + max_val INTEGER NULL DEFAULT NULL, + min_date TIMESTAMP NULL DEFAULT NULL, + max_date TIMESTAMP NULL DEFAULT NULL, + max_error INTEGER NULL DEFAULT NULL ); diff --git a/src/server/sql/meter/insert_new_meter.sql b/src/server/sql/meter/insert_new_meter.sql index 91e50fcb3..ad42395ab 100644 --- a/src/server/sql/meter/insert_new_meter.sql +++ b/src/server/sql/meter/insert_new_meter.sql @@ -5,10 +5,10 @@ INSERT INTO meters(name, url, enabled, displayable, meter_type, default_timezone_meter, gps, identifier, note, area, cumulative, cumulative_reset, cumulative_reset_start, cumulative_reset_end, reading_gap, reading_variation, reading_duplication, time_sort, end_only_time, reading, start_timestamp, end_timestamp, previous_end, unit_id, - default_graphic_unit, area_unit, reading_frequency) + default_graphic_unit, area_unit, reading_frequency, min_val, max_val, min_date, max_date, max_error) VALUES (${name}, ${url}, ${enabled}, ${displayable}, ${type}, ${meterTimezone}, ${gps}, ${identifier}, ${note}, ${area}, ${cumulative}, ${cumulativeReset}, ${cumulativeResetStart}, ${cumulativeResetEnd}, ${readingGap}, ${readingVariation}, ${readingDuplication}, ${timeSort}, ${endOnlyTime}, ${reading}, ${startTimestamp}, ${endTimestamp}, ${previousEnd}, ${unitId}, ${defaultGraphicUnit}, ${areaUnit}, - ${readingFrequency}) + ${readingFrequency}, ${minVal}, ${maxVal}, ${minDate}, ${maxDate}, ${maxError}) RETURNING id, reading_frequency; diff --git a/src/server/sql/meter/update_meter.sql b/src/server/sql/meter/update_meter.sql index 639954fe4..8c4a76641 100644 --- a/src/server/sql/meter/update_meter.sql +++ b/src/server/sql/meter/update_meter.sql @@ -29,7 +29,12 @@ UPDATE meters unit_id = ${unitId}, default_graphic_unit = ${defaultGraphicUnit}, area_unit = ${areaUnit}, - reading_frequency = ${readingFrequency} + reading_frequency = ${readingFrequency}, + min_val = ${minVal}, + max_val = ${maxVal}, + min_date = ${minDate}, + max_date = ${maxDate}, + max_error = ${maxError} WHERE id = ${id} RETURNING reading_frequency; diff --git a/src/server/util/insertData.js b/src/server/util/insertData.js index 9e0c92177..5a7bf35bf 100644 --- a/src/server/util/insertData.js +++ b/src/server/util/insertData.js @@ -201,7 +201,12 @@ async function insertMeters(metersToInsert, conn) { meterData.unit, meterData.defaultGraphicUnit, meterData.areaUnit, - meterData.readingFrequency + meterData.readingFrequency, + meterData.minVal, + meterData.maxVal, + meterData.minDate, + meterData.maxDate, + meterData.maxError ); // This does not use Promise.all as units and conversions for two reasons. The primary one is that the current @@ -227,6 +232,14 @@ async function insertMeters(metersToInsert, conn) { const query = `update meters set id = ${meterData.id} where name = '${meter.name}'`; await conn.none(query); } + // setup conditionset variable + const conditionSetMap = new Map(); + conditionSetMap.set('minVal', meter.minVal); + conditionSetMap.set('maxVal', meter.maxVal); + conditionSetMap.set('minDate', meter.minDate); + conditionSetMap.set('maxDate', meter.maxDate); + conditionSetMap.set('threshold', meter.readingGap); + conditionSetMap.set('maxError', meter.maxError); await loadCsvInput( filename, // filePath meter.id, // meterID @@ -242,7 +255,7 @@ async function insertMeters(metersToInsert, conn) { meter.endOnlyTime, // isEndOnly true, // headerRow false, // shouldUpdate - undefined, // conditionSet + conditionSetMap, // conditionSet conn ); } From e85111aec27b1c3ad83ef88bda5792e9cd601307 Mon Sep 17 00:00:00 2001 From: Robert Carlson Date: Tue, 25 Jul 2023 14:40:18 -0700 Subject: [PATCH 02/96] Update --- .../meters/CreateMeterModalComponent.tsx | 57 ++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/src/client/app/components/meters/CreateMeterModalComponent.tsx b/src/client/app/components/meters/CreateMeterModalComponent.tsx index 52656c18a..66a2fecd4 100644 --- a/src/client/app/components/meters/CreateMeterModalComponent.tsx +++ b/src/client/app/components/meters/CreateMeterModalComponent.tsx @@ -737,7 +737,7 @@ export default function CreateMeterModalComponent(props: CreateMeterModalCompone placeholder='YYYY-MM-DD HH:MM:SS' value={state.endTimestamp} /> - {/* endTimestamp input */} + {/* previousEnd input */} handleStringChange(e)} placeholder='YYYY-MM-DD HH:MM:SS' value={state.previousEnd} /> + + {/* minVal input */} + + + handleNumberChange(e)} + min="0" + defaultValue={state.minVal} + value={state.minVal} /> + + {/* maxVal input */} + + + handleNumberChange(e)} + min="0" + defaultValue={state.maxVal} + value={state.maxVal} /> + + {/* minDate input */} + + + handleNumberChange(e)} + min="0" + defaultValue={state.minDate} + value={state.minDate} /> + + {/* maxDate input */} + + + handleNumberChange(e)} + min="0" + defaultValue={state.maxDate} + value={state.maxDate} /> + + {/* maxError input */} + + + handleNumberChange(e)} + min="0" + defaultValue={state.maxError} + value={state.maxError} /> From 35c355dcd896188f9d2b874f64f975d642a0a82b Mon Sep 17 00:00:00 2001 From: Robert Carlson Date: Tue, 25 Jul 2023 15:54:25 -0700 Subject: [PATCH 03/96] Update --- .../app/components/meters/CreateMeterModalComponent.tsx | 9 +++++++-- .../app/components/meters/EditMeterModalComponent.tsx | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/client/app/components/meters/CreateMeterModalComponent.tsx b/src/client/app/components/meters/CreateMeterModalComponent.tsx index 66a2fecd4..0a0b45058 100644 --- a/src/client/app/components/meters/CreateMeterModalComponent.tsx +++ b/src/client/app/components/meters/CreateMeterModalComponent.tsx @@ -754,6 +754,7 @@ export default function CreateMeterModalComponent(props: CreateMeterModalCompone handleNumberChange(e)} min="0" @@ -765,6 +766,7 @@ export default function CreateMeterModalComponent(props: CreateMeterModalCompone handleNumberChange(e)} min="0" @@ -776,8 +778,9 @@ export default function CreateMeterModalComponent(props: CreateMeterModalCompone handleNumberChange(e)} + onChange={e => handleStringChange(e)} min="0" defaultValue={state.minDate} value={state.minDate} /> @@ -787,8 +790,9 @@ export default function CreateMeterModalComponent(props: CreateMeterModalCompone handleNumberChange(e)} + onChange={e => handleStringChange(e)} min="0" defaultValue={state.maxDate} value={state.maxDate} /> @@ -798,6 +802,7 @@ export default function CreateMeterModalComponent(props: CreateMeterModalCompone handleNumberChange(e)} min="0" diff --git a/src/client/app/components/meters/EditMeterModalComponent.tsx b/src/client/app/components/meters/EditMeterModalComponent.tsx index dcc12ae65..dec9b2fb9 100644 --- a/src/client/app/components/meters/EditMeterModalComponent.tsx +++ b/src/client/app/components/meters/EditMeterModalComponent.tsx @@ -765,6 +765,7 @@ export default function EditMeterModalComponent(props: EditMeterModalComponentPr handleNumberChange(e)} min="0" @@ -776,6 +777,7 @@ export default function EditMeterModalComponent(props: EditMeterModalComponentPr handleNumberChange(e)} min="0" @@ -787,8 +789,9 @@ export default function EditMeterModalComponent(props: EditMeterModalComponentPr handleNumberChange(e)} + onChange={e => handleStringChange(e)} min="0" defaultValue={state.minDate} value={state.minDate} /> @@ -798,8 +801,9 @@ export default function EditMeterModalComponent(props: EditMeterModalComponentPr handleNumberChange(e)} + onChange={e => handleStringChange(e)} min="0" defaultValue={state.maxDate} value={state.maxDate} /> @@ -809,6 +813,7 @@ export default function EditMeterModalComponent(props: EditMeterModalComponentPr handleNumberChange(e)} min="0" From cfa6b71450af680f356a96d389a9ad5513f7ad41 Mon Sep 17 00:00:00 2001 From: mohammed m Date: Tue, 25 Jul 2023 16:24:43 -0700 Subject: [PATCH 04/96] added minVal condset val --- src/client/app/actions/admin.ts | 8 ++++++- .../components/admin/PreferencesComponent.tsx | 24 ++++++++++++++++++- .../containers/admin/PreferencesContainer.ts | 12 +++++++--- src/client/app/reducers/admin.ts | 13 ++++++++-- src/client/app/types/items.ts | 2 ++ src/client/app/types/redux/actions.ts | 2 ++ src/client/app/types/redux/admin.ts | 10 +++++++- 7 files changed, 63 insertions(+), 8 deletions(-) diff --git a/src/client/app/actions/admin.ts b/src/client/app/actions/admin.ts index f89b983e7..2634a7aa9 100644 --- a/src/client/app/actions/admin.ts +++ b/src/client/app/actions/admin.ts @@ -61,6 +61,11 @@ export function updateDefaultMeterReadingFrequency(defaultMeterReadingFrequency: return { type: ActionType.UpdateDefaultMeterReadingFrequency, defaultMeterReadingFrequency }; } +// TODO : ADD CONDSET VALUES (MINVAL, MAXVAL, READING GAP, MINDATE, MAXDATE, ) +export function updateDefaultMeterMinimumValue(defaultMeterMinimumValue: number): t.UpdateDefaultMeterMinimumValueAction { + return { type: ActionType.UpdateDefaultMeterMinimumValue, defaultMeterMinimumValue }; +} + function requestPreferences(): t.RequestPreferencesAction { return { type: ActionType.RequestPreferences }; } @@ -121,7 +126,8 @@ export function submitPreferences() { defaultFileSizeLimit: state.admin.defaultFileSizeLimit, defaultAreaNormalization: state.admin.defaultAreaNormalization, defaultAreaUnit: state.admin.defaultAreaUnit, - defaultMeterReadingFrequency: state.admin.defaultMeterReadingFrequency + defaultMeterReadingFrequency: state.admin.defaultMeterReadingFrequency, + defaultMeterMinimumValue: state.admin.defaultMeterMinimumValue }); // Only return the defaultMeterReadingFrequency because the value from the DB // generally differs from what the user input so update state with DB value. diff --git a/src/client/app/components/admin/PreferencesComponent.tsx b/src/client/app/components/admin/PreferencesComponent.tsx index e926707af..88291fe8c 100644 --- a/src/client/app/components/admin/PreferencesComponent.tsx +++ b/src/client/app/components/admin/PreferencesComponent.tsx @@ -15,7 +15,9 @@ import { UpdateDefaultFileSizeLimit, ToggleDefaultAreaNormalizationAction, UpdateDefaultAreaUnitAction, - UpdateDefaultMeterReadingFrequencyAction + UpdateDefaultMeterReadingFrequencyAction, + UpdateDefaultMeterMinimumValueAction + // TODO : ADD CONDSET VALUES (MINVAL, MAXVAL, READING GAP, MINDATE, MAXDATE, ) } from '../../types/redux/admin'; import { removeUnsavedChanges, updateUnsavedChanges } from '../../actions/unsavedWarning'; import { defineMessages, FormattedMessage, injectIntl, WrappedComponentProps } from 'react-intl'; @@ -37,6 +39,8 @@ interface PreferencesProps { defaultFileSizeLimit: number; defaultAreaUnit: AreaUnitType; defaultMeterReadingFrequency: string; + defaultMeterMinimumValue: number; + // TODO : ADD CONDSET VALUES (MINVAL, MAXVAL, READING GAP, MINDATE, MAXDATE, ) updateDisplayTitle(title: string): UpdateDisplayTitleAction; updateDefaultChartType(defaultChartToRender: ChartTypes): UpdateDefaultChartToRenderAction; toggleDefaultBarStacking(): ToggleDefaultBarStackingAction; @@ -48,6 +52,7 @@ interface PreferencesProps { updateDefaultFileSizeLimit(defaultFileSizeLimit: number): UpdateDefaultFileSizeLimit; updateDefaultAreaUnit(defaultAreaUnit: AreaUnitType): UpdateDefaultAreaUnitAction; updateDefaultMeterReadingFrequency(defaultMeterReadingFrequency: string): UpdateDefaultMeterReadingFrequencyAction; + updateDefaultMeterMinimumValue(defaultMeterMinimumValue : number): UpdateDefaultMeterMinimumValueAction; } type PreferencesPropsWithIntl = PreferencesProps & WrappedComponentProps; @@ -66,6 +71,7 @@ class PreferencesComponent extends React.Component { this.handleDefaultAreaNormalizationChange = this.handleDefaultAreaNormalizationChange.bind(this); this.handleDefaultAreaUnitChange = this.handleDefaultAreaUnitChange.bind(this); this.handleDefaultMeterReadingFrequencyChange = this.handleDefaultMeterReadingFrequencyChange.bind(this); + this.handleDefaultMeterMinumumValueChange = this.handleDefaultMeterMinumumValueChange.bind(this); } public render() { @@ -294,6 +300,17 @@ class PreferencesComponent extends React.Component { onChange={this.handleDefaultMeterReadingFrequencyChange} /> +
+

+ : +

+ +