Make log time formats consistent (#4447)
* Fix inconsistent log time formats * Remove unused query results logicpull/4454/head
parent
01f480b730
commit
702400c995
|
@ -0,0 +1,36 @@
|
||||||
|
import React, {PureComponent} from 'react'
|
||||||
|
import {SearchStatus} from 'src/types/logs'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
count: number
|
||||||
|
queryCount: number
|
||||||
|
searchStatus: SearchStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
class HistogramResults extends PureComponent<Props> {
|
||||||
|
public render() {
|
||||||
|
return (
|
||||||
|
<label className="logs-viewer--results-text">
|
||||||
|
{this.isPending ? this.pendingContents : this.completedContents}
|
||||||
|
</label>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private get isPending(): boolean {
|
||||||
|
return this.props.searchStatus !== SearchStatus.Loaded
|
||||||
|
}
|
||||||
|
|
||||||
|
private get pendingContents(): JSX.Element {
|
||||||
|
return <>Updating Histogram...</>
|
||||||
|
}
|
||||||
|
|
||||||
|
private get completedContents(): JSX.Element {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
Displaying <strong> {this.props.count} Events</strong> in Histogram
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default HistogramResults
|
|
@ -46,6 +46,7 @@ import {
|
||||||
RowHeightHandler,
|
RowHeightHandler,
|
||||||
SearchStatus,
|
SearchStatus,
|
||||||
Filter,
|
Filter,
|
||||||
|
TimeFormatOption,
|
||||||
} from 'src/types/logs'
|
} from 'src/types/logs'
|
||||||
import {INITIAL_LIMIT} from 'src/logs/actions'
|
import {INITIAL_LIMIT} from 'src/logs/actions'
|
||||||
|
|
||||||
|
@ -541,6 +542,11 @@ class LogsTable extends Component<Props, State> {
|
||||||
const highlightRow = rowIndex === this.state.currentRow
|
const highlightRow = rowIndex === this.state.currentRow
|
||||||
|
|
||||||
if (column === 'timestamp') {
|
if (column === 'timestamp') {
|
||||||
|
const formattedTime = moment(
|
||||||
|
formattedValue as string,
|
||||||
|
TimeFormatOption.SLASH_YMD_TIME
|
||||||
|
).format(TimeFormatOption.DEFAULT)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classnames('logs-viewer--cell', {
|
className={classnames('logs-viewer--cell', {
|
||||||
|
@ -555,12 +561,12 @@ class LogsTable extends Component<Props, State> {
|
||||||
<div
|
<div
|
||||||
data-tag-key={column}
|
data-tag-key={column}
|
||||||
data-tag-value={value}
|
data-tag-value={value}
|
||||||
onClick={this.handleTimestampClick(`${formattedValue}`)}
|
onClick={this.handleTimestampClick(`${formattedTime}`)}
|
||||||
data-index={rowIndex}
|
data-index={rowIndex}
|
||||||
onMouseOver={this.handleMouseOver}
|
onMouseOver={this.handleMouseOver}
|
||||||
className="logs-viewer--clickable"
|
className="logs-viewer--clickable"
|
||||||
>
|
>
|
||||||
{formattedValue}
|
{formattedTime}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -656,7 +662,7 @@ class LogsTable extends Component<Props, State> {
|
||||||
|
|
||||||
private handleTimestampClick = (time: string) => () => {
|
private handleTimestampClick = (time: string) => () => {
|
||||||
const {onChooseCustomTime} = this.props
|
const {onChooseCustomTime} = this.props
|
||||||
const formattedTime = moment(time, 'YYYY/MM/DD HH:mm:ss').toISOString()
|
const formattedTime = moment(time, TimeFormatOption.DEFAULT).toISOString()
|
||||||
onChooseCustomTime(formattedTime)
|
onChooseCustomTime(formattedTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
import React, {PureComponent} from 'react'
|
|
||||||
import moment from 'moment'
|
|
||||||
import {SearchStatus} from 'src/types/logs'
|
|
||||||
|
|
||||||
const QUERY_RESULTS_TIME_FORMAT = 'MMM D, YYYY @HH:mm:ss'
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
count: number
|
|
||||||
queryCount: number
|
|
||||||
isInsideHistogram?: boolean
|
|
||||||
searchStatus: SearchStatus
|
|
||||||
upper?: number | undefined
|
|
||||||
lower?: number | undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
class QueryResults extends PureComponent<Props> {
|
|
||||||
public static defaultProps: Partial<Props> = {
|
|
||||||
isInsideHistogram: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
public render() {
|
|
||||||
return (
|
|
||||||
<label className="logs-viewer--results-text">
|
|
||||||
{this.isPending ? this.pendingContents : this.completedContents}
|
|
||||||
</label>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private get isPending(): boolean {
|
|
||||||
return this.props.searchStatus !== SearchStatus.Loaded
|
|
||||||
}
|
|
||||||
|
|
||||||
private get pendingContents(): JSX.Element {
|
|
||||||
if (this.props.isInsideHistogram) {
|
|
||||||
return <>Updating Histogram...</>
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
Querying back to
|
|
||||||
<br />
|
|
||||||
{this.formattedUpperTime}...
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private get completedContents(): JSX.Element {
|
|
||||||
if (this.props.isInsideHistogram) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
Displaying <strong> {this.props.count} Events</strong> in Histogram
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{this.eventContents}
|
|
||||||
{this.rangeContents}
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private get eventContents(): JSX.Element {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
Query returned <strong>{this.props.count} Events</strong> <br />
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private get rangeContents(): JSX.Element {
|
|
||||||
if (this.props.upper === undefined || this.props.lower === undefined) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<span>
|
|
||||||
Newest: <strong>{this.formattedUpperTime}</strong>
|
|
||||||
</span>
|
|
||||||
<br />
|
|
||||||
<span>
|
|
||||||
Oldest: <strong>{this.formattedLowerTime}</strong>
|
|
||||||
</span>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private get formattedLowerTime(): string {
|
|
||||||
return moment(this.props.lower).format(QUERY_RESULTS_TIME_FORMAT)
|
|
||||||
}
|
|
||||||
|
|
||||||
private get formattedUpperTime(): string {
|
|
||||||
return moment(this.props.upper).format(QUERY_RESULTS_TIME_FORMAT)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default QueryResults
|
|
|
@ -11,7 +11,7 @@ import {fetchChunk} from 'src/logs/utils/fetchChunk'
|
||||||
import {notify as notifyAction} from 'src/shared/actions/notifications'
|
import {notify as notifyAction} from 'src/shared/actions/notifications'
|
||||||
|
|
||||||
import {Greys} from 'src/reusable_ui/types'
|
import {Greys} from 'src/reusable_ui/types'
|
||||||
import QueryResults from 'src/logs/components/QueryResults'
|
import HistogramResults from 'src/logs/components/HistogramResults'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
NOW,
|
NOW,
|
||||||
|
@ -81,6 +81,7 @@ import {
|
||||||
TimeBounds,
|
TimeBounds,
|
||||||
SearchStatus,
|
SearchStatus,
|
||||||
FetchLoop,
|
FetchLoop,
|
||||||
|
TimeFormatOption,
|
||||||
} from 'src/types/logs'
|
} from 'src/types/logs'
|
||||||
import {
|
import {
|
||||||
applyChangesToTableData,
|
applyChangesToTableData,
|
||||||
|
@ -692,9 +693,7 @@ class LogsPage extends Component<Props, State> {
|
||||||
height={textSize}
|
height={textSize}
|
||||||
fill={Greys.Sidewalk}
|
fill={Greys.Sidewalk}
|
||||||
>
|
>
|
||||||
{moment(timeOption).format(
|
{moment(timeOption).format(TimeFormatOption.DEFAULT)}
|
||||||
'YYYY-MM-DD | HH:mm:ss.SSS'
|
|
||||||
)}
|
|
||||||
</text>
|
</text>
|
||||||
</svg>
|
</svg>
|
||||||
</>
|
</>
|
||||||
|
@ -751,10 +750,9 @@ class LogsPage extends Component<Props, State> {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="logs-viewer--graph-controls">
|
<div className="logs-viewer--graph-controls">
|
||||||
<QueryResults
|
<HistogramResults
|
||||||
count={this.histogramTotal}
|
count={this.histogramTotal}
|
||||||
queryCount={queryCount}
|
queryCount={queryCount}
|
||||||
isInsideHistogram={true}
|
|
||||||
searchStatus={searchStatus}
|
searchStatus={searchStatus}
|
||||||
/>
|
/>
|
||||||
<TimeWindowDropdown
|
<TimeWindowDropdown
|
||||||
|
|
|
@ -10,6 +10,11 @@ import {FieldOption} from 'src/types/dashboards'
|
||||||
import {TimeSeriesValue} from 'src/types/series'
|
import {TimeSeriesValue} from 'src/types/series'
|
||||||
import {TimeRange} from 'src/types/logs'
|
import {TimeRange} from 'src/types/logs'
|
||||||
|
|
||||||
|
export enum TimeFormatOption {
|
||||||
|
DEFAULT = 'YYYY-MM-DD HH:mm:ss',
|
||||||
|
SLASH_YMD_TIME = 'YYYY/MM/DD HH:mm:ss',
|
||||||
|
}
|
||||||
|
|
||||||
export enum SearchStatus {
|
export enum SearchStatus {
|
||||||
None = 'None',
|
None = 'None',
|
||||||
Loading = 'Loading',
|
Loading = 'Loading',
|
||||||
|
|
Loading…
Reference in New Issue