Tie together both time dropdowns
parent
0eaaf6b2ca
commit
a2ca106a6b
|
@ -8,10 +8,9 @@ import Dropdown from 'src/shared/components/Dropdown'
|
|||
import PointInTimeDropDown from 'src/logs/components/PointInTimeDropDown'
|
||||
import PageHeader from 'src/reusable_ui/components/page_layout/PageHeader'
|
||||
import PageHeaderTitle from 'src/reusable_ui/components/page_layout/PageHeaderTitle'
|
||||
import TimeMarkerDropdown from 'src/logs/components/TimeMarkerDropdown'
|
||||
import TimeWindowDropdown from 'src/logs/components/TimeWindowDropdown'
|
||||
import Authorized, {EDITOR_ROLE} from 'src/auth/Authorized'
|
||||
import {TimeRange, TimeWindow, TimeMarker, LiveUpdating} from 'src/types/logs'
|
||||
import {TimeRange, TimeWindow, LiveUpdating} from 'src/types/logs'
|
||||
|
||||
interface SourceItem {
|
||||
id: string
|
||||
|
@ -29,7 +28,6 @@ interface Props {
|
|||
onChangeLiveUpdatingStatus: () => void
|
||||
onShowOptionsOverlay: () => void
|
||||
timeRange: TimeRange
|
||||
onSetTimeMarker: (timeMarker: TimeMarker) => void
|
||||
onSetTimeWindow: (timeWindow: TimeWindow) => void
|
||||
customTime?: string
|
||||
relativeTime?: number
|
||||
|
@ -61,7 +59,6 @@ class LogViewerHeader extends PureComponent<Props> {
|
|||
const {
|
||||
onShowOptionsOverlay,
|
||||
onSetTimeWindow,
|
||||
onSetTimeMarker,
|
||||
customTime,
|
||||
relativeTime,
|
||||
onChooseCustomTime,
|
||||
|
@ -98,10 +95,6 @@ class LogViewerHeader extends PureComponent<Props> {
|
|||
onChooseCustomTime={onChooseCustomTime}
|
||||
onChooseRelativeTime={onChooseRelativeTime}
|
||||
/>
|
||||
<TimeMarkerDropdown
|
||||
onSetTimeMarker={onSetTimeMarker}
|
||||
selectedTimeMarker={timeRange.timeOption}
|
||||
/>
|
||||
<TimeWindowDropdown
|
||||
selectedTimeWindow={timeRange}
|
||||
onSetTimeWindow={onSetTimeWindow}
|
||||
|
|
|
@ -133,7 +133,7 @@ class TimeRangeDropdown extends Component<Props, State> {
|
|||
return point.text
|
||||
}
|
||||
|
||||
return 'None'
|
||||
return 'now'
|
||||
}
|
||||
|
||||
return format(this.props.customTime)
|
||||
|
|
|
@ -228,14 +228,33 @@ class LogsPage extends Component<Props, State> {
|
|||
)
|
||||
}
|
||||
|
||||
private handleChooseCustomTime = (time: string) => {
|
||||
private handleChooseCustomTime = async (time: string) => {
|
||||
this.props.setTableCustomTime(time)
|
||||
this.setState({hasScrolled: false})
|
||||
|
||||
await this.props.setTimeMarker({
|
||||
timeOption: time,
|
||||
})
|
||||
|
||||
this.handleSetTimeBounds()
|
||||
}
|
||||
|
||||
private handleChooseRelativeTime = (time: number) => {
|
||||
private handleChooseRelativeTime = async (time: number) => {
|
||||
this.props.setTableRelativeTime(time)
|
||||
this.setState({hasScrolled: false})
|
||||
|
||||
let timeOption = {
|
||||
timeOption: moment()
|
||||
.subtract(time, 'seconds')
|
||||
.toISOString(),
|
||||
}
|
||||
|
||||
if (time === 0) {
|
||||
timeOption = {timeOption: 'now'}
|
||||
}
|
||||
|
||||
await this.props.setTimeMarker(timeOption)
|
||||
this.handleSetTimeBounds()
|
||||
}
|
||||
|
||||
private get tableData(): TableData {
|
||||
|
@ -353,7 +372,6 @@ class LogsPage extends Component<Props, State> {
|
|||
return (
|
||||
<LogViewerHeader
|
||||
timeRange={timeRange}
|
||||
onSetTimeMarker={this.handleSetTimeMarker}
|
||||
onSetTimeWindow={this.handleSetTimeWindow}
|
||||
liveUpdating={this.liveUpdatingStatus}
|
||||
availableSources={sources}
|
||||
|
@ -418,9 +436,9 @@ class LogsPage extends Component<Props, State> {
|
|||
}
|
||||
|
||||
private handleBarClick = (time: string): void => {
|
||||
const timeOption = moment(time).toISOString()
|
||||
const formattedTime = moment(time).toISOString()
|
||||
|
||||
this.handleSetTimeMarker({timeOption})
|
||||
this.handleChooseCustomTime(formattedTime)
|
||||
}
|
||||
|
||||
private handleSetTimeBounds = async () => {
|
||||
|
@ -451,11 +469,6 @@ class LogsPage extends Component<Props, State> {
|
|||
this.handleSetTimeBounds()
|
||||
}
|
||||
|
||||
private handleSetTimeMarker = async (timeMarker: TimeMarker) => {
|
||||
await this.props.setTimeMarker(timeMarker)
|
||||
this.handleSetTimeBounds()
|
||||
}
|
||||
|
||||
private handleChooseSource = (sourceID: string) => {
|
||||
this.props.getSource(sourceID)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
export default [
|
||||
{
|
||||
text: 'now',
|
||||
value: 0,
|
||||
},
|
||||
{
|
||||
text: '1m ago',
|
||||
value: 60,
|
||||
|
|
Loading…
Reference in New Issue