Skip to content

Commit

Permalink
feat(ui): Set autorefresh of that dashboard to pause if absolute time…
Browse files Browse the repository at this point in the history
… range is selected
  • Loading branch information
ischolten committed Apr 16, 2019
1 parent 3c3d3c2 commit a14e64a
Show file tree
Hide file tree
Showing 26 changed files with 453 additions and 99 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## v2.0.0-alpha.9 [unreleased]

### Features
1. [13423](https://github.com/influxdata/influxdb/pull/13423): Set autorefresh of dashboard to pause if absolute time range is selected

### Bug Fixes

Expand Down
41 changes: 11 additions & 30 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions ui/src/dashboards/components/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {ErrorHandling} from 'src/shared/decorators/errors'
interface Props {
dashboard: Dashboard
timeRange: TimeRange
autoRefresh: number
manualRefresh: number
inPresentationMode: boolean
inView: (cell: Cell) => boolean
Expand All @@ -34,7 +33,6 @@ class DashboardComponent extends PureComponent<Props> {
onZoom,
dashboard,
timeRange,
autoRefresh,
manualRefresh,
onDeleteCell,
onCloneCell,
Expand All @@ -58,7 +56,6 @@ class DashboardComponent extends PureComponent<Props> {
<Cells
onZoom={onZoom}
timeRange={timeRange}
autoRefresh={autoRefresh}
manualRefresh={manualRefresh}
cells={dashboard.cells}
onCloneCell={onCloneCell}
Expand Down
42 changes: 36 additions & 6 deletions ui/src/dashboards/components/DashboardHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import React, {Component} from 'react'
// Components
import {Page} from 'src/pageLayout'
import AutoRefreshDropdown from 'src/shared/components/dropdown_auto_refresh/AutoRefreshDropdown'
import TimeRangeDropdown from 'src/shared/components/TimeRangeDropdown'
import TimeRangeDropdown, {
RangeType,
} from 'src/shared/components/TimeRangeDropdown'
import GraphTips from 'src/shared/components/graph_tips/GraphTips'
import RenamablePageTitle from 'src/pageLayout/components/RenamablePageTitle'
import {
Expand All @@ -24,14 +26,16 @@ import {
import * as AppActions from 'src/types/actions/app'
import * as QueriesModels from 'src/types/queries'
import {Dashboard} from '@influxdata/influx'
import {AutoRefresh, AutoRefreshStatus} from 'src/types'

interface Props {
activeDashboard: string
dashboard: Dashboard
timeRange: QueriesModels.TimeRange
autoRefresh: number
autoRefresh: AutoRefresh
handleChooseTimeRange: (timeRange: QueriesModels.TimeRange) => void
handleChooseAutoRefresh: AppActions.SetAutoRefreshActionCreator
handleChooseAutoRefresh: (autoRefreshInterval: number) => void
onSetAutoRefreshStatus: (status: AutoRefreshStatus) => void
onManualRefresh: () => void
handleClickPresentationButton: AppActions.DelayEnablePresentationModeDispatcher
onAddCell: () => void
Expand All @@ -55,8 +59,6 @@ export default class DashboardHeader extends Component<Props> {
const {
handleChooseAutoRefresh,
onManualRefresh,
autoRefresh,
handleChooseTimeRange,
timeRange: {upper, lower},
zoomedTimeRange: {upper: zoomedUpper, lower: zoomedLower},
isHidden,
Expand All @@ -65,6 +67,7 @@ export default class DashboardHeader extends Component<Props> {
onAddCell,
onRenameDashboard,
activeDashboard,
autoRefresh,
} = this.props

return (
Expand Down Expand Up @@ -97,7 +100,7 @@ export default class DashboardHeader extends Component<Props> {
selected={autoRefresh}
/>
<TimeRangeDropdown
onSetTimeRange={handleChooseTimeRange}
onSetTimeRange={this.handleChooseTimeRange}
timeRange={{
upper: zoomedUpper || upper,
lower: zoomedLower || lower,
Expand Down Expand Up @@ -130,4 +133,31 @@ export default class DashboardHeader extends Component<Props> {
private handleClickPresentationButton = (): void => {
this.props.handleClickPresentationButton()
}

private handleChooseTimeRange = (
timeRange: QueriesModels.TimeRange,
rangeType: RangeType = RangeType.Relative
) => {
const {
autoRefresh,
onSetAutoRefreshStatus,
handleChooseTimeRange,
} = this.props

handleChooseTimeRange(timeRange)

if (rangeType === RangeType.Absolute) {
onSetAutoRefreshStatus(AutoRefreshStatus.Disabled)
return
}

if (autoRefresh.status === AutoRefreshStatus.Disabled) {
if (autoRefresh.interval === 0) {
onSetAutoRefreshStatus(AutoRefreshStatus.Paused)
return
}

onSetAutoRefreshStatus(AutoRefreshStatus.Active)
}
}
}
Loading

0 comments on commit a14e64a

Please sign in to comment.