fix(ui): adding times in script editor will default start and endtime for timerange queries (#16201)
fix(ui): adding times in script editor will default start and endtime for timerange queries, compute timeranges based on script and based on widest date range & fix dashboard so that cells that have been saved with timerange scripts are based on those timerangespull/15967/head
parent
48e854776e
commit
eefb8dd525
|
@ -25,6 +25,7 @@
|
||||||
1. [16175](https://github.com/influxdata/influxdb/pull/16175): Added delete functionality to note cells so that they can be deleted
|
1. [16175](https://github.com/influxdata/influxdb/pull/16175): Added delete functionality to note cells so that they can be deleted
|
||||||
1. [16204](https://github.com/influxdata/influxdb/pull/16204): Fix failure to create labels when creating telegraf configs
|
1. [16204](https://github.com/influxdata/influxdb/pull/16204): Fix failure to create labels when creating telegraf configs
|
||||||
1. [16207](https://github.com/influxdata/influxdb/pull/16207): Fix crash when editing a Telegraf config
|
1. [16207](https://github.com/influxdata/influxdb/pull/16207): Fix crash when editing a Telegraf config
|
||||||
|
1. [16201](https://github.com/influxdata/influxdb/pull/16201): Updated start/endtime functionality so that custom script timeranges overwrite dropdown selections
|
||||||
|
|
||||||
### UI Improvements
|
### UI Improvements
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,16 @@ import {DEFAULT_LINE_COLORS} from 'src/shared/constants/graphColorPalettes'
|
||||||
import {INVALID_DATA_COPY} from 'src/shared/copy/cell'
|
import {INVALID_DATA_COPY} from 'src/shared/copy/cell'
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import {RemoteDataState, HeatmapViewProperties, TimeZone} from 'src/types'
|
import {
|
||||||
|
RemoteDataState,
|
||||||
|
HeatmapViewProperties,
|
||||||
|
TimeZone,
|
||||||
|
TimeRange,
|
||||||
|
} from 'src/types'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
endTime: number
|
|
||||||
loading: RemoteDataState
|
loading: RemoteDataState
|
||||||
startTime: number
|
timeRange: TimeRange | null
|
||||||
table: Table
|
table: Table
|
||||||
timeZone: TimeZone
|
timeZone: TimeZone
|
||||||
viewProperties: HeatmapViewProperties
|
viewProperties: HeatmapViewProperties
|
||||||
|
@ -29,9 +33,8 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
const HeatmapPlot: FunctionComponent<Props> = ({
|
const HeatmapPlot: FunctionComponent<Props> = ({
|
||||||
endTime,
|
|
||||||
loading,
|
loading,
|
||||||
startTime,
|
timeRange,
|
||||||
table,
|
table,
|
||||||
timeZone,
|
timeZone,
|
||||||
viewProperties: {
|
viewProperties: {
|
||||||
|
@ -56,8 +59,7 @@ const HeatmapPlot: FunctionComponent<Props> = ({
|
||||||
const [xDomain, onSetXDomain, onResetXDomain] = useVisDomainSettings(
|
const [xDomain, onSetXDomain, onResetXDomain] = useVisDomainSettings(
|
||||||
storedXDomain,
|
storedXDomain,
|
||||||
table.getColumn(xColumn, 'number'),
|
table.getColumn(xColumn, 'number'),
|
||||||
startTime,
|
timeRange
|
||||||
endTime
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const [yDomain, onSetYDomain, onResetYDomain] = useVisDomainSettings(
|
const [yDomain, onSetYDomain, onResetYDomain] = useVisDomainSettings(
|
||||||
|
|
|
@ -10,13 +10,12 @@ import ViewSwitcher from 'src/shared/components/ViewSwitcher'
|
||||||
// Utils
|
// Utils
|
||||||
import {GlobalAutoRefresher} from 'src/utils/AutoRefresher'
|
import {GlobalAutoRefresher} from 'src/utils/AutoRefresher'
|
||||||
import {getTimeRangeVars} from 'src/variables/utils/getTimeRangeVars'
|
import {getTimeRangeVars} from 'src/variables/utils/getTimeRangeVars'
|
||||||
import {getVariableAssignments} from 'src/variables/selectors'
|
import {
|
||||||
import {getDashboardValuesStatus} from 'src/variables/selectors'
|
getVariableAssignments,
|
||||||
|
getDashboardValuesStatus,
|
||||||
|
} from 'src/variables/selectors'
|
||||||
import {checkResultsLength} from 'src/shared/utils/vis'
|
import {checkResultsLength} from 'src/shared/utils/vis'
|
||||||
|
import {getActiveTimeRange} from 'src/timeMachine/selectors/index'
|
||||||
// Selectors
|
|
||||||
import {getEndTime, getStartTime} from 'src/timeMachine/selectors/index'
|
|
||||||
import {getTimeRangeByDashboardID} from 'src/dashboards/selectors/index'
|
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import {
|
import {
|
||||||
|
@ -39,8 +38,7 @@ interface OwnProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface StateProps {
|
interface StateProps {
|
||||||
endTime: number
|
ranges: TimeRange | null
|
||||||
startTime: number
|
|
||||||
timeZone: TimeZone
|
timeZone: TimeZone
|
||||||
variableAssignments: VariableAssignment[]
|
variableAssignments: VariableAssignment[]
|
||||||
variablesStatus: RemoteDataState
|
variablesStatus: RemoteDataState
|
||||||
|
@ -73,14 +71,7 @@ class RefreshingView extends PureComponent<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const {
|
const {check, ranges, properties, manualRefresh, timeZone} = this.props
|
||||||
check,
|
|
||||||
endTime,
|
|
||||||
properties,
|
|
||||||
manualRefresh,
|
|
||||||
startTime,
|
|
||||||
timeZone,
|
|
||||||
} = this.props
|
|
||||||
const {submitToken} = this.state
|
const {submitToken} = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -111,12 +102,11 @@ class RefreshingView extends PureComponent<Props, State> {
|
||||||
>
|
>
|
||||||
<ViewSwitcher
|
<ViewSwitcher
|
||||||
check={check}
|
check={check}
|
||||||
endTime={endTime}
|
|
||||||
files={files}
|
files={files}
|
||||||
giraffeResult={giraffeResult}
|
giraffeResult={giraffeResult}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
properties={properties}
|
properties={properties}
|
||||||
startTime={startTime}
|
timeRange={ranges}
|
||||||
statuses={statuses}
|
statuses={statuses}
|
||||||
timeZone={timeZone}
|
timeZone={timeZone}
|
||||||
/>
|
/>
|
||||||
|
@ -168,15 +158,13 @@ const mstp = (state: AppState, ownProps: OwnProps): StateProps => {
|
||||||
state,
|
state,
|
||||||
ownProps.dashboardID
|
ownProps.dashboardID
|
||||||
)
|
)
|
||||||
const timeRange = getTimeRangeByDashboardID(state, ownProps.dashboardID)
|
|
||||||
|
|
||||||
const valuesStatus = getDashboardValuesStatus(state, ownProps.dashboardID)
|
const valuesStatus = getDashboardValuesStatus(state, ownProps.dashboardID)
|
||||||
|
const {properties} = ownProps
|
||||||
|
const timeRange = getActiveTimeRange(ownProps.timeRange, properties.queries)
|
||||||
const timeZone = state.app.persisted.timeZone
|
const timeZone = state.app.persisted.timeZone
|
||||||
|
|
||||||
return {
|
return {
|
||||||
endTime: getEndTime(timeRange),
|
ranges: timeRange,
|
||||||
startTime: getStartTime(timeRange),
|
|
||||||
timeZone,
|
timeZone,
|
||||||
variableAssignments,
|
variableAssignments,
|
||||||
variablesStatus: valuesStatus,
|
variablesStatus: valuesStatus,
|
||||||
|
|
|
@ -20,14 +20,18 @@ import {DEFAULT_LINE_COLORS} from 'src/shared/constants/graphColorPalettes'
|
||||||
import {INVALID_DATA_COPY} from 'src/shared/copy/cell'
|
import {INVALID_DATA_COPY} from 'src/shared/copy/cell'
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import {RemoteDataState, ScatterViewProperties, TimeZone} from 'src/types'
|
import {
|
||||||
|
RemoteDataState,
|
||||||
|
ScatterViewProperties,
|
||||||
|
TimeZone,
|
||||||
|
TimeRange,
|
||||||
|
} from 'src/types'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: (config: Config) => JSX.Element
|
children: (config: Config) => JSX.Element
|
||||||
endTime: number
|
|
||||||
fluxGroupKeyUnion?: string[]
|
fluxGroupKeyUnion?: string[]
|
||||||
loading: RemoteDataState
|
loading: RemoteDataState
|
||||||
startTime: number
|
timeRange: TimeRange | null
|
||||||
table: Table
|
table: Table
|
||||||
timeZone: TimeZone
|
timeZone: TimeZone
|
||||||
viewProperties: ScatterViewProperties
|
viewProperties: ScatterViewProperties
|
||||||
|
@ -35,9 +39,8 @@ interface Props {
|
||||||
|
|
||||||
const ScatterPlot: FunctionComponent<Props> = ({
|
const ScatterPlot: FunctionComponent<Props> = ({
|
||||||
children,
|
children,
|
||||||
endTime,
|
|
||||||
loading,
|
loading,
|
||||||
startTime,
|
timeRange,
|
||||||
timeZone,
|
timeZone,
|
||||||
table,
|
table,
|
||||||
viewProperties: {
|
viewProperties: {
|
||||||
|
@ -68,8 +71,7 @@ const ScatterPlot: FunctionComponent<Props> = ({
|
||||||
const [xDomain, onSetXDomain, onResetXDomain] = useVisDomainSettings(
|
const [xDomain, onSetXDomain, onResetXDomain] = useVisDomainSettings(
|
||||||
storedXDomain,
|
storedXDomain,
|
||||||
table.getColumn(xColumn, 'number'),
|
table.getColumn(xColumn, 'number'),
|
||||||
startTime,
|
timeRange
|
||||||
endTime
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const [yDomain, onSetYDomain, onResetYDomain] = useVisDomainSettings(
|
const [yDomain, onSetYDomain, onResetYDomain] = useVisDomainSettings(
|
||||||
|
|
|
@ -24,6 +24,7 @@ import {
|
||||||
StatusRow,
|
StatusRow,
|
||||||
TimeZone,
|
TimeZone,
|
||||||
XYViewProperties,
|
XYViewProperties,
|
||||||
|
TimeRange,
|
||||||
} from 'src/types'
|
} from 'src/types'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -34,18 +35,16 @@ interface Props {
|
||||||
properties: QueryViewProperties | CheckViewProperties
|
properties: QueryViewProperties | CheckViewProperties
|
||||||
timeZone: TimeZone
|
timeZone: TimeZone
|
||||||
statuses: StatusRow[][]
|
statuses: StatusRow[][]
|
||||||
endTime: number
|
timeRange: TimeRange | null
|
||||||
startTime: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ViewSwitcher: FunctionComponent<Props> = ({
|
const ViewSwitcher: FunctionComponent<Props> = ({
|
||||||
properties,
|
properties,
|
||||||
check,
|
check,
|
||||||
loading,
|
loading,
|
||||||
endTime,
|
timeRange,
|
||||||
files,
|
files,
|
||||||
giraffeResult: {table, fluxGroupKeyUnion},
|
giraffeResult: {table, fluxGroupKeyUnion},
|
||||||
startTime,
|
|
||||||
timeZone,
|
timeZone,
|
||||||
statuses,
|
statuses,
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -83,10 +82,9 @@ const ViewSwitcher: FunctionComponent<Props> = ({
|
||||||
case 'xy':
|
case 'xy':
|
||||||
return (
|
return (
|
||||||
<XYPlot
|
<XYPlot
|
||||||
endTime={endTime}
|
timeRange={timeRange}
|
||||||
fluxGroupKeyUnion={fluxGroupKeyUnion}
|
fluxGroupKeyUnion={fluxGroupKeyUnion}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
startTime={startTime}
|
|
||||||
table={table}
|
table={table}
|
||||||
timeZone={timeZone}
|
timeZone={timeZone}
|
||||||
viewProperties={properties}
|
viewProperties={properties}
|
||||||
|
@ -111,10 +109,9 @@ const ViewSwitcher: FunctionComponent<Props> = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<XYPlot
|
<XYPlot
|
||||||
endTime={endTime}
|
timeRange={timeRange}
|
||||||
fluxGroupKeyUnion={fluxGroupKeyUnion}
|
fluxGroupKeyUnion={fluxGroupKeyUnion}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
startTime={startTime}
|
|
||||||
table={table}
|
table={table}
|
||||||
timeZone={timeZone}
|
timeZone={timeZone}
|
||||||
viewProperties={xyProperties}
|
viewProperties={xyProperties}
|
||||||
|
@ -153,9 +150,8 @@ const ViewSwitcher: FunctionComponent<Props> = ({
|
||||||
case 'heatmap':
|
case 'heatmap':
|
||||||
return (
|
return (
|
||||||
<HeatmapPlot
|
<HeatmapPlot
|
||||||
endTime={endTime}
|
timeRange={timeRange}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
startTime={startTime}
|
|
||||||
table={table}
|
table={table}
|
||||||
timeZone={timeZone}
|
timeZone={timeZone}
|
||||||
viewProperties={properties}
|
viewProperties={properties}
|
||||||
|
@ -167,9 +163,8 @@ const ViewSwitcher: FunctionComponent<Props> = ({
|
||||||
case 'scatter':
|
case 'scatter':
|
||||||
return (
|
return (
|
||||||
<ScatterPlot
|
<ScatterPlot
|
||||||
endTime={endTime}
|
timeRange={timeRange}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
startTime={startTime}
|
|
||||||
table={table}
|
table={table}
|
||||||
viewProperties={properties}
|
viewProperties={properties}
|
||||||
timeZone={timeZone}
|
timeZone={timeZone}
|
||||||
|
|
|
@ -23,14 +23,13 @@ import {DEFAULT_LINE_COLORS} from 'src/shared/constants/graphColorPalettes'
|
||||||
import {INVALID_DATA_COPY} from 'src/shared/copy/cell'
|
import {INVALID_DATA_COPY} from 'src/shared/copy/cell'
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import {RemoteDataState, XYViewProperties, TimeZone} from 'src/types'
|
import {RemoteDataState, XYViewProperties, TimeZone, TimeRange} from 'src/types'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
children: (config: Config) => JSX.Element
|
children: (config: Config) => JSX.Element
|
||||||
endTime: number
|
|
||||||
fluxGroupKeyUnion: string[]
|
fluxGroupKeyUnion: string[]
|
||||||
loading: RemoteDataState
|
loading: RemoteDataState
|
||||||
startTime: number
|
timeRange: TimeRange | null
|
||||||
table: Table
|
table: Table
|
||||||
timeZone: TimeZone
|
timeZone: TimeZone
|
||||||
viewProperties: XYViewProperties
|
viewProperties: XYViewProperties
|
||||||
|
@ -38,10 +37,9 @@ interface Props {
|
||||||
|
|
||||||
const XYPlot: FunctionComponent<Props> = ({
|
const XYPlot: FunctionComponent<Props> = ({
|
||||||
children,
|
children,
|
||||||
endTime,
|
|
||||||
fluxGroupKeyUnion,
|
fluxGroupKeyUnion,
|
||||||
loading,
|
loading,
|
||||||
startTime,
|
timeRange,
|
||||||
table,
|
table,
|
||||||
timeZone,
|
timeZone,
|
||||||
viewProperties: {
|
viewProperties: {
|
||||||
|
@ -81,8 +79,7 @@ const XYPlot: FunctionComponent<Props> = ({
|
||||||
const [xDomain, onSetXDomain, onResetXDomain] = useVisDomainSettings(
|
const [xDomain, onSetXDomain, onResetXDomain] = useVisDomainSettings(
|
||||||
storedXDomain,
|
storedXDomain,
|
||||||
table.getColumn(xColumn, 'number'),
|
table.getColumn(xColumn, 'number'),
|
||||||
startTime,
|
timeRange
|
||||||
endTime
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const [yDomain, onSetYDomain, onResetYDomain] = useVisDomainSettings(
|
const [yDomain, onSetYDomain, onResetYDomain] = useVisDomainSettings(
|
||||||
|
|
|
@ -3,29 +3,50 @@ import {getValidRange} from 'src/shared/utils/useVisDomainSettings'
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import {numericColumnData as data} from 'mocks/dummyData'
|
import {numericColumnData as data} from 'mocks/dummyData'
|
||||||
|
import {CustomTimeRange} from 'src/types/queries'
|
||||||
|
|
||||||
describe('getValidRange', () => {
|
describe('getValidRange', () => {
|
||||||
const startTime: number = 1573123611000
|
const startTime: string = 'Nov 07 2019 02:46:51 GMT-0800'
|
||||||
const endTime: number = 1574981211000
|
const unixStart: number = 1573123611000
|
||||||
|
const endTime: string = 'Nov 28 2019 14:46:51 GMT-0800'
|
||||||
|
const unixEnd: number = 1574981211000
|
||||||
it('should return null when no parameters are input', () => {
|
it('should return null when no parameters are input', () => {
|
||||||
expect(getValidRange()).toEqual(null)
|
expect(getValidRange(undefined, undefined)).toEqual(null)
|
||||||
})
|
})
|
||||||
it('should return null when no data is passed', () => {
|
it('should return null when no data is passed', () => {
|
||||||
expect(getValidRange([], startTime, endTime)).toEqual(null)
|
const timeRange: CustomTimeRange = {
|
||||||
|
type: 'custom',
|
||||||
|
lower: startTime,
|
||||||
|
upper: endTime,
|
||||||
|
}
|
||||||
|
expect(getValidRange([], timeRange)).toEqual(null)
|
||||||
})
|
})
|
||||||
it("should return the startTime as startTime if it's before the first time in the data array", () => {
|
it("should return the startTime as startTime if it's before the first time in the data array", () => {
|
||||||
const [start] = getValidRange(data, startTime, endTime)
|
const timeRange: CustomTimeRange = {
|
||||||
expect(start).toEqual(startTime)
|
type: 'custom',
|
||||||
const [beginning] = getValidRange(data, endTime, endTime)
|
lower: startTime,
|
||||||
|
upper: endTime,
|
||||||
|
}
|
||||||
|
const [start] = getValidRange(data, timeRange)
|
||||||
|
expect(start).toEqual(unixStart)
|
||||||
|
timeRange.lower = endTime
|
||||||
|
const [beginning] = getValidRange(data, timeRange)
|
||||||
expect(beginning).toEqual(data[0])
|
expect(beginning).toEqual(data[0])
|
||||||
})
|
})
|
||||||
it("should return the endTime as endTime if it's before the last time in the data array", () => {
|
it("should return the endTime as endTime if it's before the last time in the data array", () => {
|
||||||
const range = getValidRange(data, startTime, endTime)
|
const timeRange: CustomTimeRange = {
|
||||||
expect(range[1]).toEqual(endTime)
|
type: 'custom',
|
||||||
const newRange = getValidRange(data, endTime, startTime)
|
lower: startTime,
|
||||||
|
upper: endTime,
|
||||||
|
}
|
||||||
|
const range = getValidRange(data, timeRange)
|
||||||
|
expect(range[1]).toEqual(unixEnd)
|
||||||
|
timeRange.lower = endTime
|
||||||
|
timeRange.upper = startTime
|
||||||
|
const newRange = getValidRange(data, timeRange)
|
||||||
expect(newRange[1]).toEqual(data[data.length - 1])
|
expect(newRange[1]).toEqual(data[data.length - 1])
|
||||||
})
|
})
|
||||||
it('should return the the start and end times based on the data array if no start / endTime are passed', () => {
|
it('should return the the start and end times based on the data array if no start / endTime are passed', () => {
|
||||||
expect(getValidRange(data)).toEqual([data[0], data[data.length - 1]])
|
expect(getValidRange(data, null)).toEqual([data[0], data[data.length - 1]])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,7 +5,10 @@ import {NumericColumnData} from '@influxdata/giraffe'
|
||||||
// Utils
|
// Utils
|
||||||
import {useOneWayState} from 'src/shared/utils/useOneWayState'
|
import {useOneWayState} from 'src/shared/utils/useOneWayState'
|
||||||
import {extent} from 'src/shared/utils/vis'
|
import {extent} from 'src/shared/utils/vis'
|
||||||
|
import {getStartTime, getEndTime} from 'src/timeMachine/selectors/index'
|
||||||
|
|
||||||
|
// Types
|
||||||
|
import {TimeRange} from 'src/types'
|
||||||
/*
|
/*
|
||||||
This hook helps map the domain setting stored for line graph to the
|
This hook helps map the domain setting stored for line graph to the
|
||||||
appropriate settings on a @influxdata/giraffe `Config` object.
|
appropriate settings on a @influxdata/giraffe `Config` object.
|
||||||
|
@ -16,11 +19,15 @@ import {extent} from 'src/shared/utils/vis'
|
||||||
*/
|
*/
|
||||||
export const getValidRange = (
|
export const getValidRange = (
|
||||||
data: NumericColumnData = [],
|
data: NumericColumnData = [],
|
||||||
startTime: number = Infinity,
|
timeRange: TimeRange | null
|
||||||
endTime: number = -Infinity
|
|
||||||
) => {
|
) => {
|
||||||
const range = extent((data as number[]) || [])
|
const range = extent((data as number[]) || [])
|
||||||
|
if (!timeRange) {
|
||||||
|
return range
|
||||||
|
}
|
||||||
if (range && range.length >= 2) {
|
if (range && range.length >= 2) {
|
||||||
|
const startTime = getStartTime(timeRange)
|
||||||
|
const endTime = getEndTime(timeRange)
|
||||||
const start = Math.min(startTime, range[0])
|
const start = Math.min(startTime, range[0])
|
||||||
const end = Math.max(endTime, range[1])
|
const end = Math.max(endTime, range[1])
|
||||||
return [start, end]
|
return [start, end]
|
||||||
|
@ -31,15 +38,14 @@ export const getValidRange = (
|
||||||
export const useVisDomainSettings = (
|
export const useVisDomainSettings = (
|
||||||
storedDomain: number[],
|
storedDomain: number[],
|
||||||
data: NumericColumnData,
|
data: NumericColumnData,
|
||||||
startTime: number = Infinity,
|
timeRange: TimeRange | null = null
|
||||||
endTime: number = -Infinity
|
|
||||||
) => {
|
) => {
|
||||||
const initialDomain = useMemo(() => {
|
const initialDomain = useMemo(() => {
|
||||||
if (storedDomain) {
|
if (storedDomain) {
|
||||||
return storedDomain
|
return storedDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
return getValidRange(data, startTime, endTime)
|
return getValidRange(data, timeRange)
|
||||||
}, [storedDomain, data])
|
}, [storedDomain, data])
|
||||||
|
|
||||||
const [domain, setDomain] = useOneWayState(initialDomain)
|
const [domain, setDomain] = useOneWayState(initialDomain)
|
||||||
|
|
|
@ -27,18 +27,18 @@ import {
|
||||||
AppState,
|
AppState,
|
||||||
QueryViewProperties,
|
QueryViewProperties,
|
||||||
TimeZone,
|
TimeZone,
|
||||||
|
TimeRange,
|
||||||
Check,
|
Check,
|
||||||
StatusRow,
|
StatusRow,
|
||||||
} from 'src/types'
|
} from 'src/types'
|
||||||
|
|
||||||
// Selectors
|
// Selectors
|
||||||
import {getEndTime, getStartTime} from 'src/timeMachine/selectors/index'
|
import {getActiveTimeRange} from 'src/timeMachine/selectors/index'
|
||||||
|
|
||||||
interface StateProps {
|
interface StateProps {
|
||||||
|
timeRange: TimeRange | null
|
||||||
loading: RemoteDataState
|
loading: RemoteDataState
|
||||||
errorMessage: string
|
errorMessage: string
|
||||||
endTime: number
|
|
||||||
startTime: number
|
|
||||||
files: string[]
|
files: string[]
|
||||||
viewProperties: QueryViewProperties
|
viewProperties: QueryViewProperties
|
||||||
isInitialFetch: boolean
|
isInitialFetch: boolean
|
||||||
|
@ -58,7 +58,7 @@ type Props = StateProps
|
||||||
const TimeMachineVis: SFC<Props> = ({
|
const TimeMachineVis: SFC<Props> = ({
|
||||||
loading,
|
loading,
|
||||||
errorMessage,
|
errorMessage,
|
||||||
endTime,
|
timeRange,
|
||||||
isInitialFetch,
|
isInitialFetch,
|
||||||
isViewingRawData,
|
isViewingRawData,
|
||||||
files,
|
files,
|
||||||
|
@ -69,7 +69,6 @@ const TimeMachineVis: SFC<Props> = ({
|
||||||
yColumn,
|
yColumn,
|
||||||
fillColumns,
|
fillColumns,
|
||||||
symbolColumns,
|
symbolColumns,
|
||||||
startTime,
|
|
||||||
timeZone,
|
timeZone,
|
||||||
statuses,
|
statuses,
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -113,12 +112,11 @@ const TimeMachineVis: SFC<Props> = ({
|
||||||
) : (
|
) : (
|
||||||
<ViewSwitcher
|
<ViewSwitcher
|
||||||
giraffeResult={giraffeResult}
|
giraffeResult={giraffeResult}
|
||||||
endTime={endTime}
|
timeRange={timeRange}
|
||||||
files={files}
|
files={files}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
properties={resolvedViewProperties}
|
properties={resolvedViewProperties}
|
||||||
check={check}
|
check={check}
|
||||||
startTime={startTime}
|
|
||||||
timeZone={timeZone}
|
timeZone={timeZone}
|
||||||
statuses={statuses}
|
statuses={statuses}
|
||||||
/>
|
/>
|
||||||
|
@ -166,8 +164,7 @@ const mstp = (state: AppState): StateProps => {
|
||||||
fillColumns,
|
fillColumns,
|
||||||
symbolColumns,
|
symbolColumns,
|
||||||
timeZone,
|
timeZone,
|
||||||
startTime: getStartTime(timeRange),
|
timeRange: getActiveTimeRange(timeRange, viewProperties.queries),
|
||||||
endTime: getEndTime(timeRange),
|
|
||||||
statuses,
|
statuses,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import {
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import {
|
import {
|
||||||
|
DashboardQuery,
|
||||||
FluxTable,
|
FluxTable,
|
||||||
QueryView,
|
QueryView,
|
||||||
AppState,
|
AppState,
|
||||||
|
@ -290,3 +291,21 @@ export const getEndTime = (timeRange: TimeRange): number => {
|
||||||
}
|
}
|
||||||
return moment().valueOf()
|
return moment().valueOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getActiveTimeRange = (
|
||||||
|
timeRange: TimeRange,
|
||||||
|
queries: DashboardQuery[]
|
||||||
|
) => {
|
||||||
|
if (!queries) {
|
||||||
|
return timeRange
|
||||||
|
}
|
||||||
|
const hasVariableTimes = queries.some(
|
||||||
|
query =>
|
||||||
|
query.text.includes('v.timeRangeStart') ||
|
||||||
|
query.text.includes('v.timeRangeStop')
|
||||||
|
)
|
||||||
|
if (hasVariableTimes) {
|
||||||
|
return timeRange
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue