mirror of
				https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
				synced 2025-10-31 02:07:45 +00:00 
			
		
		
		
	Dates are now handled as UNIX dates
This commit is contained in:
		| @@ -17,7 +17,7 @@ import { cilSync } from '@coreui/icons'; | |||||||
| import PropTypes from 'prop-types'; | import PropTypes from 'prop-types'; | ||||||
| import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||||||
| import { faClipboardCheck } from '@fortawesome/free-solid-svg-icons' | import { faClipboardCheck } from '@fortawesome/free-solid-svg-icons' | ||||||
| import { prettyDate, addDays } from '../../utils/helper'; | import { prettyDate, addDays, dateToUnix } from '../../utils/helper'; | ||||||
| import axiosInstance from '../../utils/axiosInstance'; | import axiosInstance from '../../utils/axiosInstance'; | ||||||
| import { getToken } from '../../utils/authHelper'; | import { getToken } from '../../utils/authHelper'; | ||||||
| import WifiScanResultModalWidget from './WifiScanResultModal'; | import WifiScanResultModalWidget from './WifiScanResultModal'; | ||||||
| @@ -78,8 +78,8 @@ const DeviceCommands = ({ selectedDeviceId }) => { | |||||||
|         Authorization: `Bearer ${getToken()}`, |         Authorization: `Bearer ${getToken()}`, | ||||||
|       }, |       }, | ||||||
|       params: { |       params: { | ||||||
|         startDate: utcStart, |         startDate: dateToUnix(utcStart), | ||||||
|         endDate: utcEnd, |         endDate: dateToUnix(utcEnd), | ||||||
|       }, |       }, | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ import { | |||||||
| } from '@coreui/react'; | } from '@coreui/react'; | ||||||
| import CIcon from '@coreui/icons-react'; | import CIcon from '@coreui/icons-react'; | ||||||
| import PropTypes from 'prop-types'; | import PropTypes from 'prop-types'; | ||||||
| import { cleanTimestamp } from '../../utils/helper'; | import { prettyDate } from '../../utils/helper'; | ||||||
| import axiosInstance from '../../utils/axiosInstance'; | import axiosInstance from '../../utils/axiosInstance'; | ||||||
| import { getToken } from '../../utils/authHelper'; | import { getToken } from '../../utils/authHelper'; | ||||||
|  |  | ||||||
| @@ -82,7 +82,7 @@ const DeviceConfiguration = ({ selectedDeviceId }) => { | |||||||
|                 <CLabel>Last Configuration Change : </CLabel> |                 <CLabel>Last Configuration Change : </CLabel> | ||||||
|               </CCol> |               </CCol> | ||||||
|               <CCol xs="12" md="9"> |               <CCol xs="12" md="9"> | ||||||
|                 {cleanTimestamp(device.lastConfigurationChange)} |                 {prettyDate(device.lastConfigurationChange)} | ||||||
|               </CCol> |               </CCol> | ||||||
|             </CFormGroup> |             </CFormGroup> | ||||||
|             <CFormGroup row> |             <CFormGroup row> | ||||||
| @@ -98,7 +98,7 @@ const DeviceConfiguration = ({ selectedDeviceId }) => { | |||||||
|                   <CLabel>Created : </CLabel> |                   <CLabel>Created : </CLabel> | ||||||
|                 </CCol> |                 </CCol> | ||||||
|                 <CCol xs="12" md="9"> |                 <CCol xs="12" md="9"> | ||||||
|                   {cleanTimestamp(device.createdTimestamp)} |                   {prettyDate(device.createdTimestamp)} | ||||||
|                 </CCol> |                 </CCol> | ||||||
|               </CFormGroup> |               </CFormGroup> | ||||||
|               <CFormGroup row> |               <CFormGroup row> | ||||||
| @@ -106,7 +106,7 @@ const DeviceConfiguration = ({ selectedDeviceId }) => { | |||||||
|                   <CLabel>Last Configuration Download : </CLabel> |                   <CLabel>Last Configuration Download : </CLabel> | ||||||
|                 </CCol> |                 </CCol> | ||||||
|                 <CCol xs="12" md="9"> |                 <CCol xs="12" md="9"> | ||||||
|                   {cleanTimestamp(device.lastConfigurationDownload)} |                   {prettyDate(device.lastConfigurationDownload)} | ||||||
|                 </CCol> |                 </CCol> | ||||||
|               </CFormGroup> |               </CFormGroup> | ||||||
|             <CCollapse show={collapse}> |             <CCollapse show={collapse}> | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ import { | |||||||
| import CIcon from '@coreui/icons-react'; | import CIcon from '@coreui/icons-react'; | ||||||
| import DatePicker from 'react-widgets/DatePicker'; | import DatePicker from 'react-widgets/DatePicker'; | ||||||
| import PropTypes from 'prop-types'; | import PropTypes from 'prop-types'; | ||||||
| import { prettyDate, addDays } from '../../utils/helper'; | import { prettyDate, addDays, dateToUnix } from '../../utils/helper'; | ||||||
| import axiosInstance from '../../utils/axiosInstance'; | import axiosInstance from '../../utils/axiosInstance'; | ||||||
| import { getToken } from '../../utils/authHelper'; | import { getToken } from '../../utils/authHelper'; | ||||||
|  |  | ||||||
| @@ -52,8 +52,8 @@ const DeviceHealth = ({ selectedDeviceId }) => { | |||||||
|         Authorization: `Bearer ${getToken()}`, |         Authorization: `Bearer ${getToken()}`, | ||||||
|       }, |       }, | ||||||
|       params: { |       params: { | ||||||
|         startDate: utcStart, |         startDate: dateToUnix(utcStart), | ||||||
|         endDate: utcEnd, |         endDate: dateToUnix(utcEnd), | ||||||
|       }, |       }, | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ import { | |||||||
| import CIcon from '@coreui/icons-react'; | import CIcon from '@coreui/icons-react'; | ||||||
| import DatePicker from 'react-widgets/DatePicker'; | import DatePicker from 'react-widgets/DatePicker'; | ||||||
| import PropTypes from 'prop-types'; | import PropTypes from 'prop-types'; | ||||||
| import { addDays, prettyDate } from '../../utils/helper'; | import { addDays, prettyDate, dateToUnix } from '../../utils/helper'; | ||||||
| import axiosInstance from '../../utils/axiosInstance'; | import axiosInstance from '../../utils/axiosInstance'; | ||||||
| import { getToken } from '../../utils/authHelper'; | import { getToken } from '../../utils/authHelper'; | ||||||
|  |  | ||||||
| @@ -49,8 +49,8 @@ const DeviceLogs = ({ selectedDeviceId }) => { | |||||||
|         Authorization: `Bearer ${getToken()}`, |         Authorization: `Bearer ${getToken()}`, | ||||||
|       }, |       }, | ||||||
|       params: { |       params: { | ||||||
|         startDate: utcStart, |         startDate: dateToUnix(utcStart), | ||||||
|         endDate: utcEnd, |         endDate: dateToUnix(utcEnd), | ||||||
|       }, |       }, | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -43,10 +43,16 @@ const prettyNumber = (number) => { | |||||||
|   return `0${number}`; |   return `0${number}`; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | const unixToDateString = (unixNumber) => unixNumber * 1000; | ||||||
|  |  | ||||||
|  |  | ||||||
| export const prettyDate = (dateString) => { | export const prettyDate = (dateString) => { | ||||||
|   const date = new Date(dateString); |   const convertedTimestamp = unixToDateString(dateString); | ||||||
|  |   const date = new Date(convertedTimestamp); | ||||||
|   return `${date.getFullYear()}-${prettyNumber(date.getMonth() + 1)}-${prettyNumber(date.getDate())} |   return `${date.getFullYear()}-${prettyNumber(date.getMonth() + 1)}-${prettyNumber(date.getDate())} | ||||||
|   ${prettyNumber(date.getHours())}:${prettyNumber(date.getMinutes())}:${prettyNumber( |   ${prettyNumber(date.getHours())}:${prettyNumber(date.getMinutes())}:${prettyNumber( | ||||||
|     date.getSeconds(), |     date.getSeconds(), | ||||||
|   )}`; |   )}`; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | export const dateToUnix = (date) => new Date(date).getTime()/1000; | ||||||
		Reference in New Issue
	
	Block a user
	 bourquecharles
					bourquecharles