diff --git a/src/client/app/components/meters/CreateMeterModalComponent.tsx b/src/client/app/components/meters/CreateMeterModalComponent.tsx index d8a49cc1c..d9063ea1a 100644 --- a/src/client/app/components/meters/CreateMeterModalComponent.tsx +++ b/src/client/app/components/meters/CreateMeterModalComponent.tsx @@ -559,61 +559,59 @@ export default function CreateMeterModalComponent(props: CreateMeterModalCompone {/* cumulative input */} - - - - handleBooleanChange(e)}> - {Object.keys(TrueFalseType).map(key => { - return () - })} - - - {/* cumulativeReset input */} - - - handleBooleanChange(e)}> - {Object.keys(TrueFalseType).map(key => { - return () - })} - - - + + + handleBooleanChange(e)}> + {Object.keys(TrueFalseType).map(key => { + return () + })} + + + {/* cumulativeReset input */} + + + handleBooleanChange(e)}> + {Object.keys(TrueFalseType).map(key => { + return () + })} + + + + {/* cumulativeResetStart input */} - - - - handleStringChange(e)} - value={state.cumulativeResetStart} - placeholder='HH:MM:SS' /> - - {/* cumulativeResetEnd input */} - - - handleStringChange(e)} - value={state.cumulativeResetEnd} - placeholder='HH:MM:SS' /> - - + + + handleStringChange(e)} + value={state.cumulativeResetStart} + placeholder='HH:MM:SS' /> + + {/* cumulativeResetEnd input */} + + + handleStringChange(e)} + value={state.cumulativeResetEnd} + placeholder='HH:MM:SS' /> + {/* endOnlyTime input */} @@ -682,76 +680,76 @@ export default function CreateMeterModalComponent(props: CreateMeterModalCompone {/* timeSort input */} - - - - handleStringChange(e)}> - {Object.keys(MeterTimeSortType).map(key => { - // This is a bit of a hack but it should work fine. The TypeSortTypes and MeterTimeSortType should be in sync. - // The translation is on the former so we use that enum name there but loop on the other to get the value desired. - return () - })} - - - {/* Timezone input */} - - - handleTimeZoneChange(timeZone)} /> - - {/* reading input */} - - - handleNumberChange(e)} - defaultValue={state.reading} /> - - + + + handleStringChange(e)}> + {Object.keys(MeterTimeSortType).map(key => { + // This is a bit of a hack but it should work fine. The TypeSortTypes and MeterTimeSortType should be in sync. + // The translation is on the former so we use that enum name there but loop on the other to get the value desired. + return () + })} + + + {/* Timezone input */} + + + handleTimeZoneChange(timeZone)} /> + + + + {/* reading input */} + + + handleNumberChange(e)} + defaultValue={state.reading} /> + {/* startTimestamp input */} - - - - handleStringChange(e)} - placeholder='YYYY-MM-DD HH:MM:SS' - value={state.startTimestamp} /> - - {/* endTimestamp input */} - - - handleStringChange(e)} - placeholder='YYYY-MM-DD HH:MM:SS' - value={state.endTimestamp} /> - - {/* endTimestamp input */} - - - handleStringChange(e)} - placeholder='YYYY-MM-DD HH:MM:SS' - value={state.previousEnd} /> - - + + + handleStringChange(e)} + placeholder='YYYY-MM-DD HH:MM:SS' + value={state.startTimestamp} /> + + + + {/* endTimestamp input */} + + + handleStringChange(e)} + placeholder='YYYY-MM-DD HH:MM:SS' + value={state.endTimestamp} /> + + {/* endTimestamp input */} + + + handleStringChange(e)} + placeholder='YYYY-MM-DD HH:MM:SS' + value={state.previousEnd} /> + @@ -764,7 +762,7 @@ export default function CreateMeterModalComponent(props: CreateMeterModalCompone - + ); } diff --git a/src/client/app/components/meters/EditMeterModalComponent.tsx b/src/client/app/components/meters/EditMeterModalComponent.tsx index 60fe15df8..9fee8034f 100644 --- a/src/client/app/components/meters/EditMeterModalComponent.tsx +++ b/src/client/app/components/meters/EditMeterModalComponent.tsx @@ -565,59 +565,59 @@ export default function EditMeterModalComponent(props: EditMeterModalComponentPr {/* cumulative input */} - - - - handleBooleanChange(e)}> - {Object.keys(TrueFalseType).map(key => { - return () - })} - - - {/* cumulativeReset input */} - - - handleBooleanChange(e)}> - {Object.keys(TrueFalseType).map(key => { - return () - })} - - + + + handleBooleanChange(e)}> + {Object.keys(TrueFalseType).map(key => { + return () + })} + + + {/* cumulativeReset input */} + + + handleBooleanChange(e)}> + {Object.keys(TrueFalseType).map(key => { + return () + })} + + + + {/* cumulativeResetStart input */} - - - - handleStringChange(e)} - value={state.cumulativeResetStart} - placeholder='HH:MM:SS' /> - - {/* cumulativeResetEnd input */} - - - handleStringChange(e)} - value={state?.cumulativeResetEnd} - placeholder='HH:MM:SS' /> - + + + handleStringChange(e)} + value={state.cumulativeResetStart} + placeholder='HH:MM:SS' /> + + {/* cumulativeResetEnd input */} + + + handleStringChange(e)} + value={state?.cumulativeResetEnd} + placeholder='HH:MM:SS' /> + {/* endOnlyTime input */} @@ -686,76 +686,76 @@ export default function EditMeterModalComponent(props: EditMeterModalComponentPr {/* timeSort input */} - - - - handleStringChange(e)}> - {Object.keys(MeterTimeSortType).map(key => { - // This is a bit of a hack but it should work fine. The TypeSortTypes and MeterTimeSortType should be in sync. - // The translation is on the former so we use that enum name there but loop on the other to get the value desired. - return () - })} - - - {/* Timezone input */} - - - handleTimeZoneChange(timeZone)} /> - - {/* reading input */} - - - handleNumberChange(e)} - defaultValue={state?.reading} /> - - + + + handleStringChange(e)}> + {Object.keys(MeterTimeSortType).map(key => { + // This is a bit of a hack but it should work fine. The TypeSortTypes and MeterTimeSortType should be in sync. + // The translation is on the former so we use that enum name there but loop on the other to get the value desired. + return () + })} + + + {/* Timezone input */} + + + handleTimeZoneChange(timeZone)} /> + + + + {/* reading input */} + + + handleNumberChange(e)} + defaultValue={state?.reading} /> + {/* startTimestamp input */} - - - - handleStringChange(e)} - placeholder='YYYY-MM-DD HH:MM:SS' - value={state?.startTimestamp} /> - - {/* endTimestamp input */} - - - handleStringChange(e)} - placeholder='YYYY-MM-DD HH:MM:SS' - value={state?.endTimestamp} /> - - {/* previousEnd input */} - - - handleStringChange(e)} - placeholder='YYYY-MM-DD HH:MM:SS' - value={state?.previousEnd} /> - - + + + handleStringChange(e)} + placeholder='YYYY-MM-DD HH:MM:SS' + value={state?.startTimestamp} /> + + + + {/* endTimestamp input */} + + + handleStringChange(e)} + placeholder='YYYY-MM-DD HH:MM:SS' + value={state?.endTimestamp} /> + + {/* previousEnd input */} + + + handleStringChange(e)} + placeholder='YYYY-MM-DD HH:MM:SS' + value={state?.previousEnd} /> + diff --git a/src/client/app/utils/exportData.ts b/src/client/app/utils/exportData.ts index a99226ad5..2594aaba3 100644 --- a/src/client/app/utils/exportData.ts +++ b/src/client/app/utils/exportData.ts @@ -8,14 +8,14 @@ import { ChartTypes, MeterOrGroup } from '../types/redux/graph'; /** * Function to converts the meter readings into a CSV formatted string. - * @param readings The meter readings. - * @param meter the meter identifier for data being exported + * @param readings The readings from the meter/group to export the graphic points. + * @param name the meter identifier or group name for data being exported * @param unitLabel the full y-axis label on the graphic * @param scaling factor to scale readings by, normally the rate factor for line or 1 * @param meterGroup tells if this is a meter or group export * @returns A string containing the CSV formatted meter readings. */ -function convertToCSV(readings: LineReading[], meter: string, unitLabel: string, scaling: number, meterGroup: MeterOrGroup) { +function convertToCSV(readings: LineReading[], name: string, unitLabel: string, scaling: number, meterGroup: MeterOrGroup) { // TODO should be internationalized let meterOrGroupString = ''; if (meterGroup === MeterOrGroup.meter) { @@ -23,7 +23,7 @@ function convertToCSV(readings: LineReading[], meter: string, unitLabel: string, } else { meterOrGroupString = 'Group' } - let csvOutput = `Readings, Start Timestamp, End Timestamp, ${meterOrGroupString} name, ${meter}, Unit, ${unitLabel}\n`; + let csvOutput = `Readings, Start Timestamp, End Timestamp, ${meterOrGroupString} name, ${name}, Unit, ${unitLabel}\n`; readings.forEach(reading => { const value = reading.reading * scaling; // As usual, maintain UTC. @@ -57,19 +57,19 @@ function downloadCSV(inputCSV: string, fileName: string) { /** * Function to export readings from the graph currently displaying. May be used for routing if more export options are added - * @param readings The readings from the meter to export the graphic points. - * @param meter the meter identifier for data being exported + * @param readings The readings from the meter/group to export the graphic points. + * @param name the meter identifier or group name for data being exported * @param unitLabel the full y-axis label on the graphic * @param unitIdentifier the unit identifier for data being exported * @param chartName the name of the chart/graphic being exported * @param scaling factor to scale readings by, normally the rate factor for line or 1 * @param meterGroup tells if this is a meter or group export */ -export default function graphExport(readings: LineReading[], meter: string, unitLabel: string, unitIdentifier: string, +export default function graphExport(readings: LineReading[], name: string, unitLabel: string, unitIdentifier: string, chartName: ChartTypes, scaling: number, meterGroup: MeterOrGroup) { // It is possible that some meters have not readings so skip if do. This can happen if resize the range of dates (or no data). if (readings.length !== 0) { - const dataToExport = convertToCSV(readings, meter, unitLabel, scaling, meterGroup); + const dataToExport = convertToCSV(readings, name, unitLabel, scaling, meterGroup); // Determine and format the first time in the dataset which is first one in array since just sorted and the start time. // As usual, maintain UTC. @@ -82,7 +82,7 @@ export default function graphExport(readings: LineReading[], meter: string, unit // This is the file name with all the above info so unique. // Note it only uses the unit identifier not with the rate because that has funny characters. - const filename = `oedExport_${chartName}_${startTimeString}_to_${endTimeString}_${meter}_${unitIdentifier}.csv`; + const filename = `oedExport_${chartName}_${startTimeString}_to_${endTimeString}_${name}_${unitIdentifier}.csv`; downloadCSV(dataToExport, filename); } }