aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings/MaintenancesPage.jsx
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-03-23 08:26:42 -0700
committerAnton Tananaev <anton@traccar.org>2024-03-23 08:26:42 -0700
commit399e0585d72bace51a0c81e9f889dda054e68519 (patch)
tree5e4b466b3d95f61ea07911bf64a4fd0f51cb3e48 /modern/src/settings/MaintenancesPage.jsx
parentf0614dc939051aab3544874b44510c59c683be10 (diff)
downloadtrackermap-web-399e0585d72bace51a0c81e9f889dda054e68519.tar.gz
trackermap-web-399e0585d72bace51a0c81e9f889dda054e68519.tar.bz2
trackermap-web-399e0585d72bace51a0c81e9f889dda054e68519.zip
Better time maintenance formatting
Diffstat (limited to 'modern/src/settings/MaintenancesPage.jsx')
-rw-r--r--modern/src/settings/MaintenancesPage.jsx15
1 files changed, 11 insertions, 4 deletions
diff --git a/modern/src/settings/MaintenancesPage.jsx b/modern/src/settings/MaintenancesPage.jsx
index 2a66590c..9170f9ee 100644
--- a/modern/src/settings/MaintenancesPage.jsx
+++ b/modern/src/settings/MaintenancesPage.jsx
@@ -1,4 +1,5 @@
import React, { useState } from 'react';
+import dayjs from 'dayjs';
import {
Table, TableRow, TableCell, TableHead, TableBody,
} from '@mui/material';
@@ -42,9 +43,15 @@ const MaintenacesPage = () => {
}
}, [timestamp]);
- const convertAttribute = (key, value) => {
+ const convertAttribute = (key, start, value) => {
const attribute = positionAttributes[key];
- if (attribute && attribute.dataType) {
+ if (key.endsWith('Time')) {
+ if (start) {
+ return dayjs(value).locale('en').format('YYYY-MM-DD');
+ } else {
+ return `${value / 86400000} ${t('sharedDays')}`;
+ }
+ } else if (attribute && attribute.dataType) {
switch (attribute.dataType) {
case 'speed':
return formatSpeed(value, speedUnit, t);
@@ -76,8 +83,8 @@ const MaintenacesPage = () => {
<TableRow key={item.id}>
<TableCell>{item.name}</TableCell>
<TableCell>{item.type}</TableCell>
- <TableCell>{convertAttribute(item.type, item.start)}</TableCell>
- <TableCell>{convertAttribute(item.type, item.period)}</TableCell>
+ <TableCell>{convertAttribute(item.type, true, item.start)}</TableCell>
+ <TableCell>{convertAttribute(item.type, false, item.period)}</TableCell>
<TableCell className={classes.columnAction} padding="none">
<CollectionActions itemId={item.id} editPath="/settings/maintenance" endpoint="maintenance" setTimestamp={setTimestamp} />
</TableCell>