diff options
-rw-r--r-- | modern/src/common/attributes/usePositionAttributes.js | 255 | ||||
-rw-r--r-- | modern/src/common/attributes/usePositionProperties.js | 56 | ||||
-rw-r--r-- | modern/src/common/components/PositionValue.js | 2 | ||||
-rw-r--r-- | modern/src/reports/RouteReportPage.js | 25 | ||||
-rw-r--r-- | modern/src/reports/components/ColumnSelect.js | 14 | ||||
-rw-r--r-- | web/l10n/en.json | 5 |
6 files changed, 336 insertions, 21 deletions
diff --git a/modern/src/common/attributes/usePositionAttributes.js b/modern/src/common/attributes/usePositionAttributes.js index 7b33720a..b6036945 100644 --- a/modern/src/common/attributes/usePositionAttributes.js +++ b/modern/src/common/attributes/usePositionAttributes.js @@ -9,13 +9,264 @@ export default (t) => useMemo(() => ({ name: t('positionIndex'), type: 'number', }, - ignition: { - name: t('positionIgnition'), + hdop: { + name: t('positionHdop'), + type: 'number', + }, + vdop: { + name: t('positionVdop'), + type: 'number', + }, + pdop: { + name: t('positionPdop'), + type: 'number', + }, + sat: { + name: t('positionSat'), + type: 'number', + }, + satVisible: { + name: t('positionSatVisible'), + type: 'number', + }, + rssi: { + name: t('positionRssi'), + type: 'number', + }, + gps: { + name: t('positionGps'), + type: 'number', + }, + roaming: { + name: t('positionRoaming'), type: 'boolean', }, + event: { + name: t('positionEvent'), + type: 'string', + }, + alarm: { + name: t('positionAlarm'), + type: 'string', + }, + status: { + name: t('positionStatus'), + type: 'string', + }, odometer: { name: t('positionOdometer'), type: 'number', dataType: 'distance', }, + serviceOdometer: { + name: t('positionServiceOdometer'), + type: 'number', + dataType: 'distance', + }, + tripOdometer: { + name: t('positionTripOdometer'), + type: 'number', + dataType: 'distance', + }, + hours: { + name: t('positionHours'), + type: 'number', + dataType: 'hours', + }, + steps: { + name: t('positionSteps'), + type: 'number', + }, + input: { + name: t('positionInput'), + type: 'number', + }, + in1: { + name: `${t('positionInput')} 1`, + type: 'boolean', + }, + in2: { + name: `${t('positionInput')} 2`, + type: 'boolean', + }, + in3: { + name: `${t('positionInput')} 3`, + type: 'boolean', + }, + in4: { + name: `${t('positionInput')} 4`, + type: 'boolean', + }, + output: { + name: t('positionOutput'), + type: 'number', + }, + out1: { + name: `${t('positionOutput')} 1`, + type: 'boolean', + }, + out2: { + name: `${t('positionOutput')} 2`, + type: 'boolean', + }, + out3: { + name: `${t('positionOutput')} 3`, + type: 'boolean', + }, + out4: { + name: `${t('positionOutput')} 4`, + type: 'boolean', + }, + power: { + name: t('positionPower'), + type: 'number', + dataType: 'voltage', + }, + battery: { + name: t('positionBattery'), + type: 'number', + dataType: 'voltage', + }, + batteryLevel: { + name: t('positionBatteryLevel'), + type: 'number', + dataType: 'percentage', + }, + fuel: { + name: t('positionFuel'), + type: 'number', + dataType: 'volume', + }, + fuelConsumption: { + name: t('positionFuelConsumption'), + type: 'number', + }, + versionFw: { + name: t('positionVersionFw'), + type: 'string', + }, + versionHw: { + name: t('positionVersionHw'), + type: 'string', + }, + type: { + name: t('sharedType'), + type: 'string', + }, + ignition: { + name: t('positionIgnition'), + type: 'boolean', + }, + flags: { + name: t('positionFlags'), + type: 'string', + }, + charge: { + name: t('positionCharge'), + type: 'boolean', + }, + ip: { + name: t('positionIp'), + type: 'string', + }, + archive: { + name: t('positionArchive'), + type: 'boolean', + }, + distance: { + name: t('positionDistance'), + type: 'number', + dataType: 'distance', + }, + totalDistance: { + name: t('deviceTotalDistance'), + type: 'number', + dataType: 'distance', + }, + rpm: { + name: t('positionRpm'), + type: 'number', + }, + vin: { + name: t('positionVin'), + type: 'string', + }, + approximate: { + name: t('positionApproximate'), + type: 'boolean', + }, + throttle: { + name: t('positionThrottle'), + type: 'number', + }, + motion: { + name: t('positionMotion'), + type: 'boolean', + }, + armed: { + name: t('positionArmed'), + type: 'number', + }, + geofence: { + name: t('sharedGeofence'), + type: 'string', + }, + acceleration: { + name: t('positionAcceleration'), + type: 'number', + }, + deviceTemp: { + name: t('positionDeviceTemp'), + type: 'number', + }, + temp1: { + name: `${t('positionTemp')} 1`, + type: 'number', + }, + temp2: { + name: `${t('positionTemp')} 2`, + type: 'number', + }, + temp3: { + name: `${t('positionTemp')} 3`, + type: 'number', + }, + temp4: { + name: `${t('positionTemp')} 4`, + type: 'number', + }, + operator: { + name: t('positionOperator'), + type: 'string', + }, + command: { + name: t('deviceCommand'), + type: 'string', + }, + blocked: { + name: t('positionBlocked'), + type: 'number', + }, + dtcs: { + name: t('positionDtcs'), + type: 'string', + }, + obdSpeed: { + name: t('positionObdSpeed'), + type: 'number', + dataType: 'speed', + }, + obdOdometer: { + name: t('positionObdOdometer'), + type: 'number', + dataType: 'distance', + }, + result: { + name: t('eventCommandResult'), + type: 'string', + }, + driverUniqueId: { + name: t('positionDriverUniqueId'), + type: 'string', + }, }), [t]); diff --git a/modern/src/common/attributes/usePositionProperties.js b/modern/src/common/attributes/usePositionProperties.js new file mode 100644 index 00000000..a31700d6 --- /dev/null +++ b/modern/src/common/attributes/usePositionProperties.js @@ -0,0 +1,56 @@ +import { useMemo } from 'react'; + +export default (t) => useMemo(() => ({ + id: { + name: t('deviceIdentifier'), + type: 'number', + }, + latitude: { + name: t('positionLatitude'), + type: 'number', + }, + longitude: { + name: t('positionLongitude'), + type: 'number', + }, + speed: { + name: t('positionSpeed'), + type: 'number', + }, + course: { + name: t('positionCourse'), + type: 'number', + }, + altitude: { + name: t('positionAltitude'), + type: 'number', + }, + accuracy: { + name: t('positionAccuracy'), + type: 'number', + }, + valid: { + name: t('positionValid'), + type: 'boolean', + }, + protocol: { + name: t('positionProtocol'), + type: 'string', + }, + address: { + name: t('positionAddress'), + type: 'string', + }, + deviceTime: { + name: t('positionDeviceTime'), + type: 'string', + }, + fixTime: { + name: t('positionFixTime'), + type: 'string', + }, + serverTime: { + name: t('positionServerTime'), + type: 'string', + }, +}), [t]); diff --git a/modern/src/common/components/PositionValue.js b/modern/src/common/components/PositionValue.js index 1d9d71f5..9f679605 100644 --- a/modern/src/common/components/PositionValue.js +++ b/modern/src/common/components/PositionValue.js @@ -65,7 +65,7 @@ const PositionValue = ({ position, property, attribute }) => { } if (typeof value === 'boolean') { return formatBoolean(value, t); } - return value; + return value || ''; } }; diff --git a/modern/src/reports/RouteReportPage.js b/modern/src/reports/RouteReportPage.js index 98f2cd5c..e1dd59a0 100644 --- a/modern/src/reports/RouteReportPage.js +++ b/modern/src/reports/RouteReportPage.js @@ -9,21 +9,16 @@ import ReportsMenu from './components/ReportsMenu'; import usePersistedState from '../common/util/usePersistedState'; import PositionValue from '../common/components/PositionValue'; import ColumnSelect from './components/ColumnSelect'; - -const columnsArray = [ - ['fixTime', 'positionFixTime'], - ['latitude', 'positionLatitude'], - ['longitude', 'positionLongitude'], - ['speed', 'positionSpeed'], - ['address', 'positionAddress'], - ['ignition', 'positionIgnition'], - ['totalDistance', 'deviceTotalDistance'], -]; -const columnsMap = new Map(columnsArray); +import usePositionProperties from '../common/attributes/usePositionProperties'; +import usePositionAttributes from '../common/attributes/usePositionAttributes'; const RouteReportPage = () => { const t = useTranslation(); + const positionProperties = usePositionProperties(t); + const positionAttributes = usePositionAttributes(t); + const columnsObject = { ...positionProperties, ...positionAttributes }; + const [columns, setColumns] = usePersistedState('routeColumns', ['fixTime', 'latitude', 'longitude', 'speed', 'address']); const [items, setItems] = useState([]); @@ -47,13 +42,17 @@ const RouteReportPage = () => { return ( <PageLayout menu={<ReportsMenu />} breadcrumbs={['reportTitle', 'reportRoute']}> <ReportFilter handleSubmit={handleSubmit}> - <ColumnSelect columns={columns} setColumns={setColumns} columnsArray={columnsArray} /> + <ColumnSelect + columns={columns} + setColumns={setColumns} + columnsObject={columnsObject} + /> </ReportFilter> <TableContainer> <Table> <TableHead> <TableRow> - {columns.map((key) => (<TableCell>{t(columnsMap.get(key))}</TableCell>))} + {columns.map((key) => (<TableCell>{columnsObject[key].name}</TableCell>))} </TableRow> </TableHead> <TableBody> diff --git a/modern/src/reports/components/ColumnSelect.js b/modern/src/reports/components/ColumnSelect.js index 991f21e7..d7306c58 100644 --- a/modern/src/reports/components/ColumnSelect.js +++ b/modern/src/reports/components/ColumnSelect.js @@ -5,7 +5,9 @@ import { import { useTranslation } from '../../common/components/LocalizationProvider'; import { useFilterStyles } from './ReportFilter'; -const ColumnSelect = ({ columns, setColumns, columnsArray }) => { +const ColumnSelect = ({ + columns, setColumns, columnsArray, columnsObject, +}) => { const classes = useFilterStyles(); const t = useTranslation(); @@ -19,9 +21,13 @@ const ColumnSelect = ({ columns, setColumns, columnsArray }) => { renderValue={(it) => it.length} multiple > - {columnsArray.map(([key, string]) => ( - <MenuItem value={key}>{t(string)}</MenuItem> - ))} + {columnsArray + ? columnsArray.map(([key, string]) => ( + <MenuItem key={key} value={key}>{t(string)}</MenuItem> + )) + : Object.keys(columnsObject).map((key) => ( + <MenuItem key={key} value={key}>{columnsObject[key].name}</MenuItem> + ))} </Select> </FormControl> </div> diff --git a/web/l10n/en.json b/web/l10n/en.json index 5e9a2619..0c8f433b 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -177,7 +177,9 @@ "reportTo": "To", "reportShow": "Show", "reportClear": "Clear", - "positionFixTime": "Time", + "positionFixTime": "Fix Time", + "positionDeviceTime": "Device Time", + "positionServerTime": "Server Time", "positionValid": "Valid", "positionAccuracy": "Accuracy", "positionLatitude": "Latitude", @@ -228,6 +230,7 @@ "positionMotion": "Motion", "positionArmed": "Armed", "positionAcceleration": "Acceleration", + "positionTemp": "Temperature", "positionDeviceTemp": "Device Temperature", "positionOperator": "Operator", "positionCommand": "Command", |