Fine tune placement and text of time selection dropdowns

Co-authored-by: Alex Paxton <thealexpaxton@gmail.com>
Co-authored-by: Daniel Campbell <metalwhirlwind@gmail.com>
pull/10616/head
Alex P 2018-07-11 17:57:55 -07:00
parent ae5e30d479
commit dfdf29de06
4 changed files with 25 additions and 13 deletions

View File

@ -78,14 +78,14 @@ class LogViewerHeader extends PureComponent<Props> {
selected={this.selectedNamespace} selected={this.selectedNamespace}
onChoose={this.handleChooseNamespace} onChoose={this.handleChooseNamespace}
/> />
<TimeWindowDropdown
selectedTimeWindow={timeRange.windowOption}
onSetTimeWindow={onSetTimeWindow}
/>
<TimeMarkerDropdown <TimeMarkerDropdown
onSetTimeMarker={onSetTimeMarker} onSetTimeMarker={onSetTimeMarker}
selectedTimeMarker={timeRange.timeOption} selectedTimeMarker={timeRange.timeOption}
/> />
<TimeWindowDropdown
selectedTimeWindow={timeRange}
onSetTimeWindow={onSetTimeWindow}
/>
<Authorized requiredRole={EDITOR_ROLE}> <Authorized requiredRole={EDITOR_ROLE}>
<button <button
className="btn btn-sm btn-square btn-default" className="btn btn-sm btn-square btn-default"

View File

@ -1,21 +1,19 @@
import React, {Component} from 'react' import React, {Component} from 'react'
import Dropdown from 'src/shared/components/Dropdown' import Dropdown from 'src/shared/components/Dropdown'
import {TIME_RANGE_VALUES} from 'src/logs/constants' import {TIME_RANGE_VALUES} from 'src/logs/constants'
import {TimeWindow} from 'src/types/logs' import {TimeWindow, TimeRange} from 'src/types/logs'
interface Props { interface Props {
onSetTimeWindow: (timeWindow: TimeWindow) => void onSetTimeWindow: (timeWindow: TimeWindow) => void
selectedTimeWindow: string selectedTimeWindow: TimeRange
} }
class TimeWindowDropdown extends Component<Props> { class TimeWindowDropdown extends Component<Props> {
public render() { public render() {
const {selectedTimeWindow} = this.props
return ( return (
<Dropdown <Dropdown
className="dropdown-80" className="dropdown-90"
selected={selectedTimeWindow} selected={this.selected}
onChoose={this.handleChoose} onChoose={this.handleChoose}
buttonSize="btn-sm" buttonSize="btn-sm"
buttonColor="btn-default" buttonColor="btn-default"
@ -24,7 +22,19 @@ class TimeWindowDropdown extends Component<Props> {
) )
} }
public handleChoose = dropdownItem => { private get selected(): string {
const {
selectedTimeWindow: {timeOption, windowOption},
} = this.props
if (timeOption === 'now') {
return `- ${windowOption}`
}
return `+/- ${windowOption}`
}
private handleChoose = (dropdownItem): void => {
const {onSetTimeWindow} = this.props const {onSetTimeWindow} = this.props
const {text, seconds} = dropdownItem const {text, seconds} = dropdownItem

View File

@ -152,3 +152,5 @@ export const TIME_RANGE_VALUES = [
{text: '10m', seconds: 600}, {text: '10m', seconds: 600},
{text: '15m', seconds: 900}, {text: '15m', seconds: 900},
] ]
export const SECONDS_TO_MS = 1000

View File

@ -38,7 +38,7 @@ import {
filterTableColumns, filterTableColumns,
} from 'src/dashboards/utils/tableGraph' } from 'src/dashboards/utils/tableGraph'
import {SeverityFormatOptions} from 'src/logs/constants' import {SeverityFormatOptions, SECONDS_TO_MS} from 'src/logs/constants'
import {Source, Namespace} from 'src/types' import {Source, Namespace} from 'src/types'
import {HistogramData, TimePeriod} from 'src/types/histogram' import {HistogramData, TimePeriod} from 'src/types/histogram'
@ -326,7 +326,7 @@ class LogsPage extends PureComponent<Props, State> {
if (timeOption !== 'now') { if (timeOption !== 'now') {
const numberTimeOption = new Date(timeOption).valueOf() const numberTimeOption = new Date(timeOption).valueOf()
const milliseconds = seconds * 10 / 2 const milliseconds = seconds * SECONDS_TO_MS
lower = moment(numberTimeOption - milliseconds).toISOString() lower = moment(numberTimeOption - milliseconds).toISOString()
upper = moment(numberTimeOption + milliseconds).toISOString() upper = moment(numberTimeOption + milliseconds).toISOString()
} }