Merge: + client: show date in query logs
Close #1202 * commit 'af7b9523b5732e708bf29d1dc8102887eece93b5': rewrite using isToday helper + client: add jsdocs with returning format of date format functions + client: show date in query logs
This commit is contained in:
commit
3166607540
|
@ -9,6 +9,7 @@ import { HashLink as Link } from 'react-router-hash-link';
|
|||
import {
|
||||
formatTime,
|
||||
formatDateTime,
|
||||
isToday,
|
||||
} from '../../helpers/helpers';
|
||||
import { SERVICES, FILTERED_STATUS, TABLE_DEFAULT_PAGE_SIZE } from '../../helpers/constants';
|
||||
import { getTrackerData } from '../../helpers/trackers/trackers';
|
||||
|
@ -117,7 +118,7 @@ class Logs extends Component {
|
|||
getTimeCell = ({ value }) => (
|
||||
<div className="logs__row">
|
||||
<span className="logs__text" title={formatDateTime(value)}>
|
||||
{formatTime(value)}
|
||||
{isToday(value) ? formatTime(value) : formatDateTime(value)}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
|
@ -257,7 +258,7 @@ class Logs extends Component {
|
|||
{
|
||||
Header: t('time_table_header'),
|
||||
accessor: 'time',
|
||||
maxWidth: 100,
|
||||
minWidth: 105,
|
||||
Cell: this.getTimeCell,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@ import subHours from 'date-fns/sub_hours';
|
|||
import addHours from 'date-fns/add_hours';
|
||||
import addDays from 'date-fns/add_days';
|
||||
import subDays from 'date-fns/sub_days';
|
||||
import isSameDay from 'date-fns/is_same_day';
|
||||
import round from 'lodash/round';
|
||||
import axios from 'axios';
|
||||
import i18n from 'i18next';
|
||||
|
@ -19,11 +20,19 @@ import {
|
|||
DNS_RECORD_TYPES,
|
||||
} from './constants';
|
||||
|
||||
/**
|
||||
* @param string The time to format
|
||||
* @returns string Returns the time in the format HH:mm:ss
|
||||
*/
|
||||
export const formatTime = (time) => {
|
||||
const parsedTime = dateParse(time);
|
||||
return dateFormat(parsedTime, 'HH:mm:ss');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param string The date to format
|
||||
* @returns string Returns the date and time in the format DD/MM/YYYY, HH:mm
|
||||
*/
|
||||
export const formatDateTime = (dateTime) => {
|
||||
const currentLanguage = i18n.languages[0] || 'en';
|
||||
const parsedTime = dateParse(dateTime);
|
||||
|
@ -39,6 +48,12 @@ export const formatDateTime = (dateTime) => {
|
|||
return parsedTime.toLocaleString(currentLanguage, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param string
|
||||
* @returns boolean
|
||||
*/
|
||||
export const isToday = date => isSameDay(new Date(date), new Date());
|
||||
|
||||
export const normalizeLogs = logs => logs.map((log) => {
|
||||
const {
|
||||
time,
|
||||
|
|
Loading…
Reference in New Issue