Add & reorg types dirs and files for dashboard reducers, actions, & apis

Continue typing DashboardPage.
pull/3739/head
Jared Scheib 2018-06-20 17:42:43 -07:00
parent bd5ee7d9c1
commit 69e479fe22
15 changed files with 446 additions and 356 deletions

View File

@ -53,9 +53,11 @@ import idNormalizer, {TYPE_ID} from 'src/normalizers/id'
import {defaultTimeRange} from 'src/shared/data/timeRanges' import {defaultTimeRange} from 'src/shared/data/timeRanges'
import {Dispatch} from 'redux'
import {InjectedRouter} from 'react-router' import {InjectedRouter} from 'react-router'
import {Location} from 'history' import {Location} from 'history'
import {Dispatch} from 'redux' import {AxiosResponse} from 'axios'
// import * as AllData from 'src/types'
import { import {
Cell, Cell,
Dashboard, Dashboard,
@ -66,28 +68,18 @@ import {
TimeRange, TimeRange,
URLQueryParams, URLQueryParams,
} from 'src/types' } from 'src/types'
import {CellType, DashboardName} from 'src/types/dashboard' import * as DashboardData from 'src/types/dashboard'
import {TimeRangeOption} from 'src/shared/data/timeRanges' import * as DashboardActions from 'src/types/actions/dashboard'
import * as DashboardAPIs from 'src/types/apis/dashboard'
import * as DashboardReducers from 'src/types/reducers/dashboard'
import {PublishNotificationActionCreator} from 'src/shared/actions/notifications' import {PublishNotificationActionCreator} from 'src/shared/actions/notifications'
import * as ErrorActions from 'src/shared/actions/errors' import * as ErrorActions from 'src/shared/actions/errors'
import {LocationAction} from 'react-router-redux' import {LocationAction} from 'react-router-redux'
export type LoadDashboardsActionCreator = ( export const loadDashboards: DashboardActions.LoadDashboardsActionCreator = (
dashboards: Dashboard[], dashboards: Dashboard[],
dashboardID?: number dashboardID?: number
) => LoadDashboardsAction ): DashboardActions.LoadDashboardsAction => ({
interface LoadDashboardsAction {
type: 'LOAD_DASHBOARDS'
payload: {
dashboards: Dashboard[]
dashboardID: number
}
}
export const loadDashboards: LoadDashboardsActionCreator = (
dashboards: Dashboard[],
dashboardID?: number
): LoadDashboardsAction => ({
type: 'LOAD_DASHBOARDS', type: 'LOAD_DASHBOARDS',
payload: { payload: {
dashboards, dashboards,
@ -95,30 +87,19 @@ export const loadDashboards: LoadDashboardsActionCreator = (
}, },
}) })
interface LoadDashboardAction { export const loadDashboard = (
type: 'LOAD_DASHBOARD' dashboard: Dashboard
payload: { ): DashboardActions.LoadDashboardAction => ({
dashboard: Dashboard
}
}
export const loadDashboard = (dashboard: Dashboard): LoadDashboardAction => ({
type: 'LOAD_DASHBOARD', type: 'LOAD_DASHBOARD',
payload: { payload: {
dashboard, dashboard,
}, },
}) })
interface SetDashTimeV1Action {
type: 'SET_DASHBOARD_TIME_V1'
payload: {
dashboardID: number
timeRange: TimeRange
}
}
export const setDashTimeV1 = ( export const setDashTimeV1 = (
dashboardID: number, dashboardID: number,
timeRange: TimeRange timeRange: TimeRange
): SetDashTimeV1Action => ({ ): DashboardActions.SetDashTimeV1Action => ({
type: 'SET_DASHBOARD_TIME_V1', type: 'SET_DASHBOARD_TIME_V1',
payload: { payload: {
dashboardID, dashboardID,
@ -126,91 +107,52 @@ export const setDashTimeV1 = (
}, },
}) })
interface RetainRangesDashTimeV1Action {
type: 'RETAIN_RANGES_DASHBOARD_TIME_V1'
payload: {
dashboardIDs: string[]
}
}
export const retainRangesDashTimeV1 = ( export const retainRangesDashTimeV1 = (
dashboardIDs: string[] dashboardIDs: string[]
): RetainRangesDashTimeV1Action => ({ ): DashboardActions.RetainRangesDashTimeV1Action => ({
type: 'RETAIN_RANGES_DASHBOARD_TIME_V1', type: 'RETAIN_RANGES_DASHBOARD_TIME_V1',
payload: {dashboardIDs}, payload: {dashboardIDs},
}) })
export type SetTimeRangeActionCreator = ( export const setTimeRange = (
timeRange: TimeRange timeRange: TimeRange
) => SetTimeRangeAction ): DashboardActions.SetTimeRangeAction => ({
interface SetTimeRangeAction {
type: 'SET_DASHBOARD_TIME_RANGE'
payload: {
timeRange: TimeRange
}
}
export const setTimeRange = (timeRange: TimeRange): SetTimeRangeAction => ({
type: 'SET_DASHBOARD_TIME_RANGE', type: 'SET_DASHBOARD_TIME_RANGE',
payload: { payload: {
timeRange, timeRange,
}, },
}) })
interface SetZoomedTimeRangeAction {
type: 'SET_DASHBOARD_ZOOMED_TIME_RANGE'
payload: {
zoomedTimeRange: TimeRange
}
}
export const setZoomedTimeRange = ( export const setZoomedTimeRange = (
zoomedTimeRange: TimeRange zoomedTimeRange: TimeRange
): SetZoomedTimeRangeAction => ({ ): DashboardActions.SetZoomedTimeRangeAction => ({
type: 'SET_DASHBOARD_ZOOMED_TIME_RANGE', type: 'SET_DASHBOARD_ZOOMED_TIME_RANGE',
payload: { payload: {
zoomedTimeRange, zoomedTimeRange,
}, },
}) })
interface UpdateDashboardAction {
type: 'UPDATE_DASHBOARD'
payload: {
dashboard: Dashboard
}
}
export const updateDashboard = ( export const updateDashboard = (
dashboard: Dashboard dashboard: Dashboard
): UpdateDashboardAction => ({ ): DashboardActions.UpdateDashboardAction => ({
type: 'UPDATE_DASHBOARD', type: 'UPDATE_DASHBOARD',
payload: { payload: {
dashboard, dashboard,
}, },
}) })
interface CreateDashboardAction {
type: 'CREATE_DASHBOARD'
payload: {
dashboard: Dashboard
}
}
export const createDashboard = ( export const createDashboard = (
dashboard: Dashboard dashboard: Dashboard
): CreateDashboardAction => ({ ): DashboardActions.CreateDashboardAction => ({
type: 'CREATE_DASHBOARD', type: 'CREATE_DASHBOARD',
payload: { payload: {
dashboard, dashboard,
}, },
}) })
interface DeleteDashboardAction {
type: 'DELETE_DASHBOARD'
payload: {
dashboard: Dashboard
dashboardID: number
}
}
export const deleteDashboard = ( export const deleteDashboard = (
dashboard: Dashboard dashboard: Dashboard
): DeleteDashboardAction => ({ ): DashboardActions.DeleteDashboardAction => ({
type: 'DELETE_DASHBOARD', type: 'DELETE_DASHBOARD',
payload: { payload: {
dashboard, dashboard,
@ -218,32 +160,19 @@ export const deleteDashboard = (
}, },
}) })
interface DeleteDashboardFailedAction {
type: 'DELETE_DASHBOARD_FAILED'
payload: {
dashboard: Dashboard
}
}
export const deleteDashboardFailed = ( export const deleteDashboardFailed = (
dashboard: Dashboard dashboard: Dashboard
): DeleteDashboardFailedAction => ({ ): DashboardActions.DeleteDashboardFailedAction => ({
type: 'DELETE_DASHBOARD_FAILED', type: 'DELETE_DASHBOARD_FAILED',
payload: { payload: {
dashboard, dashboard,
}, },
}) })
interface SyncDashboardCellAction {
type: 'SYNC_DASHBOARD_CELL'
payload: {
dashboard: Dashboard
cell: Cell
}
}
export const syncDashboardCell = ( export const syncDashboardCell = (
dashboard: Dashboard, dashboard: Dashboard,
cell: Cell cell: Cell
): SyncDashboardCellAction => ({ ): DashboardActions.SyncDashboardCellAction => ({
type: 'SYNC_DASHBOARD_CELL', type: 'SYNC_DASHBOARD_CELL',
payload: { payload: {
dashboard, dashboard,
@ -251,17 +180,10 @@ export const syncDashboardCell = (
}, },
}) })
interface AddDashboardCellAction {
type: 'ADD_DASHBOARD_CELL'
payload: {
dashboard: Dashboard
cell: Cell
}
}
export const addDashboardCell = ( export const addDashboardCell = (
dashboard: Dashboard, dashboard: Dashboard,
cell: Cell cell: Cell
): AddDashboardCellAction => ({ ): DashboardActions.AddDashboardCellAction => ({
type: 'ADD_DASHBOARD_CELL', type: 'ADD_DASHBOARD_CELL',
payload: { payload: {
dashboard, dashboard,
@ -269,17 +191,10 @@ export const addDashboardCell = (
}, },
}) })
interface DeleteDashboardCellAction {
type: 'DELETE_DASHBOARD_CELL'
payload: {
dashboard: Dashboard
cell: Cell
}
}
export const deleteDashboardCell = ( export const deleteDashboardCell = (
dashboard: Dashboard, dashboard: Dashboard,
cell: Cell cell: Cell
): DeleteDashboardCellAction => ({ ): DashboardActions.DeleteDashboardCellAction => ({
type: 'DELETE_DASHBOARD_CELL', type: 'DELETE_DASHBOARD_CELL',
payload: { payload: {
dashboard, dashboard,
@ -287,17 +202,10 @@ export const deleteDashboardCell = (
}, },
}) })
interface EditCellQueryStatusAction {
type: 'EDIT_CELL_QUERY_STATUS'
payload: {
queryID: string
status: string
}
}
export const editCellQueryStatus = ( export const editCellQueryStatus = (
queryID: string, queryID: string,
status: string status: string
): EditCellQueryStatusAction => ({ ): DashboardActions.EditCellQueryStatusAction => ({
type: 'EDIT_CELL_QUERY_STATUS', type: 'EDIT_CELL_QUERY_STATUS',
payload: { payload: {
queryID, queryID,
@ -305,19 +213,11 @@ export const editCellQueryStatus = (
}, },
}) })
interface TemplateVariableSelectedAction {
type: 'TEMPLATE_VARIABLE_SELECTED'
payload: {
dashboardID: number
templateID: string
values: any[]
}
}
export const templateVariableSelected = ( export const templateVariableSelected = (
dashboardID: number, dashboardID: number,
templateID: string, templateID: string,
values values
): TemplateVariableSelectedAction => ({ ): DashboardActions.TemplateVariableSelectedAction => ({
type: 'TEMPLATE_VARIABLE_SELECTED', type: 'TEMPLATE_VARIABLE_SELECTED',
payload: { payload: {
dashboardID, dashboardID,
@ -326,17 +226,10 @@ export const templateVariableSelected = (
}, },
}) })
interface TemplateVariablesSelectedByNameAction {
type: 'TEMPLATE_VARIABLES_SELECTED_BY_NAME'
payload: {
dashboardID: number
queryParams: URLQueryParams
}
}
export const templateVariablesSelectedByName = ( export const templateVariablesSelectedByName = (
dashboardID: number, dashboardID: number,
queryParams: URLQueryParams queryParams: URLQueryParams
): TemplateVariablesSelectedByNameAction => ({ ): DashboardActions.TemplateVariablesSelectedByNameAction => ({
type: 'TEMPLATE_VARIABLES_SELECTED_BY_NAME', type: 'TEMPLATE_VARIABLES_SELECTED_BY_NAME',
payload: { payload: {
dashboardID, dashboardID,
@ -344,19 +237,11 @@ export const templateVariablesSelectedByName = (
}, },
}) })
interface EditTemplateVariableValuesAction {
type: 'EDIT_TEMPLATE_VARIABLE_VALUES'
payload: {
dashboardID: number
templateID: string
values: any[]
}
}
export const editTemplateVariableValues = ( export const editTemplateVariableValues = (
dashboardID: number, dashboardID: number,
templateID: string, templateID: string,
values values
): EditTemplateVariableValuesAction => ({ ): DashboardActions.EditTemplateVariableValuesAction => ({
type: 'EDIT_TEMPLATE_VARIABLE_VALUES', type: 'EDIT_TEMPLATE_VARIABLE_VALUES',
payload: { payload: {
dashboardID, dashboardID,
@ -365,26 +250,18 @@ export const editTemplateVariableValues = (
}, },
}) })
interface SetHoverTimeAction { export const setHoverTime = (
type: 'SET_HOVER_TIME' hoverTime: string
payload: { ): DashboardActions.SetHoverTimeAction => ({
hoverTime: string
}
}
export const setHoverTime = (hoverTime: string): SetHoverTimeAction => ({
type: 'SET_HOVER_TIME', type: 'SET_HOVER_TIME',
payload: { payload: {
hoverTime, hoverTime,
}, },
}) })
interface SetActiveCellAction { export const setActiveCell = (
type: 'SET_ACTIVE_CELL' activeCellID: string
payload: { ): DashboardActions.SetActiveCellAction => ({
activeCellID: string
}
}
export const setActiveCell = (activeCellID: string): SetActiveCellAction => ({
type: 'SET_ACTIVE_CELL', type: 'SET_ACTIVE_CELL',
payload: { payload: {
activeCellID, activeCellID,
@ -393,21 +270,18 @@ export const setActiveCell = (activeCellID: string): SetActiveCellAction => ({
// Async Action Creators // Async Action Creators
export type GetDashboardsDispatcher = () => GetDashboardsThunk export const getDashboardsAsync = (): DashboardActions.GetDashboardsThunk => async (
type GetDashboardsThunk = (
dispatch: Dispatch<ErrorActions.ErrorThrownActionCreator>
) => Promise<Dashboard[] | void>
export const getDashboardsAsync = (): GetDashboardsThunk => async (
dispatch: Dispatch< dispatch: Dispatch<
LoadDashboardsActionCreator | ErrorActions.ErrorThrownActionCreator | DashboardActions.LoadDashboardsActionCreator
| ErrorActions.ErrorThrownActionCreator
> >
): Promise<Dashboard[] | void> => { ): Promise<Dashboard[] | void> => {
try { try {
const { const {
data: {dashboards}, data: {dashboards},
} = await getDashboardsAJAX() } = (await getDashboardsAJAX()) as AxiosResponse<
DashboardAPIs.DashboardsResponse
>
dispatch(loadDashboards(dashboards)) dispatch(loadDashboards(dashboards))
return dashboards return dashboards
} catch (error) { } catch (error) {
@ -416,21 +290,13 @@ export const getDashboardsAsync = (): GetDashboardsThunk => async (
} }
} }
export type GetDashboardsNamesDispatcher = (
sourceID: string
) => GetDashboardsNamesThunk
type GetDashboardsNamesThunk = (
dispatch: Dispatch<ErrorActions.ErrorThrownActionCreator>
) => Promise<DashboardName[] | void>
// gets update-to-date names of dashboards, but does not dispatch action // gets update-to-date names of dashboards, but does not dispatch action
// in order to avoid duplicate and out-of-sync state problems in redux // in order to avoid duplicate and out-of-sync state problems in redux
export const getDashboardsNamesAsync = ( export const getDashboardsNamesAsync: DashboardActions.GetDashboardsNamesDispatcher = (
sourceID: string sourceID: string
): GetDashboardsNamesThunk => async ( ): DashboardActions.GetDashboardsNamesThunk => async (
dispatch: Dispatch<ErrorActions.ErrorThrownActionCreator> dispatch: Dispatch<ErrorActions.ErrorThrownActionCreator>
): Promise<DashboardName[] | void> => { ): Promise<DashboardData.DashboardName[] | void> => {
try { try {
// TODO: change this from getDashboardsAJAX to getDashboardsNamesAJAX // TODO: change this from getDashboardsAJAX to getDashboardsNamesAJAX
// to just get dashboard names (and links) as api view call when that // to just get dashboard names (and links) as api view call when that
@ -438,7 +304,9 @@ export const getDashboardsNamesAsync = (
// dashboard for each // dashboard for each
const { const {
data: {dashboards}, data: {dashboards},
} = await getDashboardsAJAX() } = (await getDashboardsAJAX()) as AxiosResponse<
DashboardAPIs.DashboardsResponse
>
const dashboardsNames = dashboards.map(({id, name}) => ({ const dashboardsNames = dashboards.map(({id, name}) => ({
id, id,
name, name,
@ -491,17 +359,12 @@ const removeUnselectedTemplateValues = (dashboard: Dashboard): Template[] => {
return templates return templates
} }
export type PutDashboardDispatcher = (dashboard: Dashboard) => PutDashboardThunk export const putDashboard = (
dashboard: Dashboard
type PutDashboardThunk = ( ): DashboardActions.PutDashboardThunk => async (
dispatch: Dispatch< dispatch: Dispatch<
UpdateDashboardAction | ErrorActions.ErrorThrownActionCreator | DashboardActions.UpdateDashboardAction
> | ErrorActions.ErrorThrownActionCreator
) => Promise<void>
export const putDashboard = (dashboard: Dashboard): PutDashboardThunk => async (
dispatch: Dispatch<
UpdateDashboardAction | ErrorActions.ErrorThrownActionCreator
> >
): Promise<void> => { ): Promise<void> => {
try { try {
@ -528,24 +391,11 @@ export const putDashboard = (dashboard: Dashboard): PutDashboardThunk => async (
} }
} }
interface DashboardsReducerState {
dashboardUI: {dashboards: Dashboard[]}
}
type PutDashboardByIDThunk = (
dispatch: Dispatch<ErrorActions.ErrorThrownActionCreator>,
getState: () => DashboardsReducerState
) => Promise<void>
export type PutDashboardByIDDispatcher = (
dashboardID: number
) => PutDashboardByIDThunk
export const putDashboardByID = ( export const putDashboardByID = (
dashboardID: number dashboardID: number
): PutDashboardByIDThunk => async ( ): DashboardActions.PutDashboardByIDThunk => async (
dispatch: Dispatch<ErrorActions.ErrorThrownActionCreator>, dispatch: Dispatch<ErrorActions.ErrorThrownActionCreator>,
getState: () => DashboardsReducerState getState: () => DashboardReducers.Dashboards
): Promise<void> => { ): Promise<void> => {
try { try {
const { const {
@ -560,8 +410,14 @@ export const putDashboardByID = (
} }
} }
export const updateDashboardCell = (dashboard: Dashboard, cell: Cell) => async ( export const updateDashboardCell: DashboardActions.UpdateDashboardCellDispatcher = (
dispatch dashboard: Dashboard,
cell: Cell
): DashboardActions.UpdateDashboardCellThunk => async (
dispatch: Dispatch<
| DashboardActions.SyncDashboardCellActionCreator
| ErrorActions.ErrorThrownActionCreator
>
): Promise<void> => { ): Promise<void> => {
try { try {
const {data} = await updateDashboardCellAJAX(cell) const {data} = await updateDashboardCellAJAX(cell)
@ -590,25 +446,12 @@ export const deleteDashboardAsync = (dashboard: Dashboard) => async (
} }
} }
export type AddDashboardCellDispatcher = (
dashboard: Dashboard,
cellType: CellType
) => AddDashboardCellThunk
type AddDashboardCellThunk = (
dispatch: Dispatch<
| AddDashboardCellAction
| PublishNotificationActionCreator
| ErrorActions.ErrorThrownActionCreator
>
) => Promise<void>
export const addDashboardCellAsync = ( export const addDashboardCellAsync = (
dashboard: Dashboard, dashboard: Dashboard,
cellType: CellType cellType: DashboardData.CellType
): AddDashboardCellThunk => async ( ): DashboardActions.AddDashboardCellThunk => async (
dispatch: Dispatch< dispatch: Dispatch<
| AddDashboardCellAction | DashboardActions.AddDashboardCellAction
| PublishNotificationActionCreator | PublishNotificationActionCreator
| ErrorActions.ErrorThrownActionCreator | ErrorActions.ErrorThrownActionCreator
> >
@ -681,7 +524,9 @@ export const importDashboardAsync = (dashboard: Dashboard) => async (
const { const {
data: {dashboards}, data: {dashboards},
} = await getDashboardsAJAX() } = (await getDashboardsAJAX()) as AxiosResponse<
DashboardAPIs.DashboardsResponse
>
dispatch(loadDashboards(dashboards)) dispatch(loadDashboards(dashboards))
dispatch(notify(notifyDashboardImported(name))) dispatch(notify(notifyDashboardImported(name)))
@ -730,21 +575,11 @@ export const hydrateTempVarValuesAsync = (
const removeNullValues = obj => _.pickBy(obj, o => o) const removeNullValues = obj => _.pickBy(obj, o => o)
type SyncURLQueryFromQueryParamsObjectDispatcher = (
location: Location,
updatedURLQueryParams: URLQueryParams,
deletedURLQueryParams: URLQueryParams
) => SyncURLQueryFromQueryParamsObjectActionCreator
type SyncURLQueryFromQueryParamsObjectActionCreator = (
dispatch: Dispatch<LocationAction>
) => void
export const syncURLQueryParamsFromQueryParamsObject = ( export const syncURLQueryParamsFromQueryParamsObject = (
location: Location, location: Location,
updatedURLQueryParams: URLQueryParams, updatedURLQueryParams: URLQueryParams,
deletedURLQueryParams: URLQueryParams = {} deletedURLQueryParams: URLQueryParams = {}
): SyncURLQueryFromQueryParamsObjectActionCreator => ( ): DashboardActions.SyncURLQueryFromQueryParamsObjectActionCreator => (
dispatch: Dispatch<LocationAction> dispatch: Dispatch<LocationAction>
): void => { ): void => {
const updatedLocationQuery = removeNullValues({ const updatedLocationQuery = removeNullValues({
@ -767,20 +602,15 @@ export const syncURLQueryParamsFromQueryParamsObject = (
dispatch(replace(updatedLocation)) dispatch(replace(updatedLocation))
} }
export type SyncURLQueryFromTempVarsDispatcher = (
location: Location,
tempVars: Template[],
deletedTempVars: Template[],
urlQueryParamsTimeRanges: URLQueryParams
) => SyncURLQueryFromQueryParamsObjectActionCreator
export const syncURLQueryFromTempVars = ( export const syncURLQueryFromTempVars = (
location: Location, location: Location,
tempVars: Template[], tempVars: Template[],
deletedTempVars: Template[] = [], deletedTempVars: Template[] = [],
urlQueryParamsTimeRanges: URLQueryParams = {} urlQueryParamsTimeRanges: URLQueryParams = {}
): SyncURLQueryFromQueryParamsObjectActionCreator => ( ): DashboardActions.SyncURLQueryFromQueryParamsObjectActionCreator => (
dispatch: Dispatch<SyncURLQueryFromQueryParamsObjectDispatcher> dispatch: Dispatch<
DashboardActions.SyncURLQueryFromQueryParamsObjectDispatcher
>
): void => { ): void => {
const updatedURLQueryParams = generateURLQueryParamsFromTempVars(tempVars) const updatedURLQueryParams = generateURLQueryParamsFromTempVars(tempVars)
const deletedURLQueryParams = generateURLQueryParamsFromTempVars( const deletedURLQueryParams = generateURLQueryParamsFromTempVars(
@ -799,23 +629,15 @@ export const syncURLQueryFromTempVars = (
)(dispatch) )(dispatch)
} }
interface AuthReducerState {
auth: {isUsingAuth: boolean; me: Me}
}
type SyncDashboardTempVarsFromURLQueryParamsDispatcher = (
dispatch: Dispatch<
PublishNotificationActionCreator | TemplateVariableSelectedAction
>,
getState: () => DashboardsReducerState & AuthReducerState
) => void
const syncDashboardTempVarsFromURLQueryParams = ( const syncDashboardTempVarsFromURLQueryParams = (
dashboardID: number, dashboardID: number,
urlQueryParams: URLQueryParams urlQueryParams: URLQueryParams
): SyncDashboardTempVarsFromURLQueryParamsDispatcher => ( ): DashboardActions.SyncDashboardTempVarsFromURLQueryParamsDispatcher => (
dispatch: Dispatch< dispatch: Dispatch<
PublishNotificationActionCreator | TemplateVariableSelectedAction | PublishNotificationActionCreator
| DashboardActions.TemplateVariableSelectedAction
>, >,
getState: () => DashboardsReducerState & AuthReducerState getState: () => DashboardReducers.Dashboards & AuthReducerState
): void => { ): void => {
const { const {
dashboardUI, dashboardUI,
@ -846,24 +668,13 @@ const syncDashboardTempVarsFromURLQueryParams = (
dispatch(templateVariablesSelectedByName(dashboardID, urlQueryParams)) dispatch(templateVariablesSelectedByName(dashboardID, urlQueryParams))
} }
type DashTimeV1Range = TimeRangeOption & {dashboardID: number}
interface DashTimeV1ReducerState {
dashTimeV1: {ranges: DashTimeV1Range[]}
}
type SyncDashboardTimeRangeFromURLQueryParamsDispatcher = (
dispatch: Dispatch<PublishNotificationActionCreator>,
getState: () => DashboardsReducerState & DashTimeV1ReducerState
) => void
const syncDashboardTimeRangeFromURLQueryParams = ( const syncDashboardTimeRangeFromURLQueryParams = (
dashboardID: number, dashboardID: number,
urlQueryParams: URLQueryParams, urlQueryParams: URLQueryParams,
location: Location location: Location
): SyncDashboardTimeRangeFromURLQueryParamsDispatcher => ( ): DashboardActions.SyncDashboardTimeRangeFromURLQueryParamsDispatcher => (
dispatch: Dispatch<PublishNotificationActionCreator>, dispatch: Dispatch<PublishNotificationActionCreator>,
getState: () => DashboardsReducerState & DashTimeV1ReducerState getState: () => DashboardReducers.Dashboards & DashboardReducers.DashTimeV1
): void => { ): void => {
const { const {
dashboardUI: {dashboards}, dashboardUI: {dashboards},
@ -919,19 +730,13 @@ const syncDashboardTimeRangeFromURLQueryParams = (
)(dispatch) )(dispatch)
} }
type SyncDashboardFromURLQueryParamsDispatcher = (
dispatch: Dispatch<
| SyncDashboardTempVarsFromURLQueryParamsDispatcher
| SyncDashboardTimeRangeFromURLQueryParamsDispatcher
>
) => void
const syncDashboardFromURLQueryParams = ( const syncDashboardFromURLQueryParams = (
dashboardID: number, dashboardID: number,
location: Location location: Location
): SyncDashboardFromURLQueryParamsDispatcher => ( ): DashboardActions.SyncDashboardFromURLQueryParamsDispatcher => (
dispatch: Dispatch< dispatch: Dispatch<
| SyncDashboardTempVarsFromURLQueryParamsDispatcher | DashboardActions.SyncDashboardTempVarsFromURLQueryParamsDispatcher
| SyncDashboardTimeRangeFromURLQueryParamsDispatcher | DashboardActions.SyncDashboardTimeRangeFromURLQueryParamsDispatcher
> >
): void => { ): void => {
const urlQueryParams = queryString.parse(window.location.search) const urlQueryParams = queryString.parse(window.location.search)
@ -947,23 +752,12 @@ const syncDashboardFromURLQueryParams = (
) )
} }
export type GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = ( export const getDashboardWithHydratedAndSyncedTempVarsAsync: DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = (
dashboardID: string,
source: Source,
router: InjectedRouter,
location: Location
) => GetDashboardWithHydratedAndSyncedTempVarsAsyncActionCreator
type GetDashboardWithHydratedAndSyncedTempVarsAsyncActionCreator = (
dispatch: Dispatch<PublishNotificationActionCreator>
) => Promise<void>
export const getDashboardWithHydratedAndSyncedTempVarsAsync = (
dashboardID: number, dashboardID: number,
source: Source, source: Source,
router: InjectedRouter, router: InjectedRouter,
location: Location location: Location
): GetDashboardWithHydratedAndSyncedTempVarsAsyncActionCreator => async ( ): DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk => async (
dispatch: Dispatch<PublishNotificationActionCreator> dispatch: Dispatch<PublishNotificationActionCreator>
): Promise<void> => { ): Promise<void> => {
const dashboard = await bindActionCreators(getDashboardAsync, dispatch)( const dashboard = await bindActionCreators(getDashboardAsync, dispatch)(

View File

@ -1,6 +1,11 @@
import AJAX from 'utils/ajax' import AJAX from 'src/utils/ajax'
export function getDashboards() { import {AxiosResponse} from 'axios'
import {DashboardsResponse} from 'src/types/apis/dashboard'
export const getDashboards = (): Promise<
AxiosResponse<DashboardsResponse> | DashboardsResponse
> => {
return AJAX({ return AJAX({
method: 'GET', method: 'GET',
resource: 'dashboards', resource: 'dashboards',
@ -19,7 +24,7 @@ export const getDashboard = async dashboardID => {
} }
} }
export function updateDashboard(dashboard) { export const updateDashboard = dashboard => {
return AJAX({ return AJAX({
method: 'PUT', method: 'PUT',
url: dashboard.links.self, url: dashboard.links.self,
@ -27,7 +32,7 @@ export function updateDashboard(dashboard) {
}) })
} }
export function updateDashboardCell(cell) { export const updateDashboardCell = cell => {
return AJAX({ return AJAX({
method: 'PUT', method: 'PUT',
url: cell.links.self, url: cell.links.self,

View File

@ -42,6 +42,7 @@ import {
Status, Status,
} from 'src/types' } from 'src/types'
import {ColorString, ColorNumber} from 'src/types/colors' import {ColorString, ColorNumber} from 'src/types/colors'
import * as DashboardActions from 'src/dashboards/actions'
import {SourceOption} from 'src/dashboards/components/OverlayControls' import {SourceOption} from 'src/dashboards/components/OverlayControls'
type QueryTransitions = typeof queryTransitions type QueryTransitions = typeof queryTransitions
@ -74,7 +75,7 @@ interface QueryStatus {
interface Props { interface Props {
sources: Source[] sources: Source[]
editQueryStatus: () => void editQueryStatus: DashboardActions.EditCellQueryStatusActionCreator
onCancel: () => void onCancel: () => void
onSave: (cell: Cell) => void onSave: (cell: Cell) => void
source: Source source: Source

View File

@ -10,11 +10,10 @@ import TimeRangeDropdown from 'src/shared/components/TimeRangeDropdown'
import GraphTips from 'src/shared/components/GraphTips' import GraphTips from 'src/shared/components/GraphTips'
import DashboardHeaderEdit from 'src/dashboards/components/DashboardHeaderEdit' import DashboardHeaderEdit from 'src/dashboards/components/DashboardHeaderEdit'
import DashboardSwitcher from 'src/dashboards/components/DashboardSwitcher' import DashboardSwitcher from 'src/dashboards/components/DashboardSwitcher'
import {Dashboard, TimeRange} from 'src/types'
interface DashboardName { import {Dashboard, TimeRange} from 'src/types'
text: string import {DashboardName} from 'src/types/dashboard'
} import * as AppActions from 'src/shared/actions/app'
interface Props { interface Props {
activeDashboard: string activeDashboard: string
@ -24,15 +23,15 @@ interface Props {
autoRefresh: number autoRefresh: number
isEditMode?: boolean isEditMode?: boolean
handleChooseTimeRange: (timeRange: TimeRange) => void handleChooseTimeRange: (timeRange: TimeRange) => void
handleChooseAutoRefresh: () => void handleChooseAutoRefresh: AppActions.SetAutoRefreshActionCreator
onManualRefresh: () => void onManualRefresh: () => void
handleClickPresentationButton: () => void handleClickPresentationButton: AppActions.DelayEnablePresentationModeThunk
onAddCell: () => void onAddCell: () => void
onToggleTempVarControls: () => void onToggleTempVarControls: () => void
showTemplateControlBar: boolean showTemplateControlBar: boolean
zoomedTimeRange: TimeRange zoomedTimeRange: TimeRange
onCancel: () => void onCancel: () => void
onSave: () => void onSave: (name: string) => Promise<void>
names: DashboardName[] names: DashboardName[]
isHidden: boolean isHidden: boolean
} }

View File

@ -10,7 +10,7 @@ import FancyScrollbar from 'src/shared/components/FancyScrollbar'
import {ErrorHandling} from 'src/shared/decorators/errors' import {ErrorHandling} from 'src/shared/decorators/errors'
import { import {
showOverlay as showOverlayAction, showOverlay as showOverlayAction,
ShowOverlay, ShowOverlayActionCreator,
} from 'src/shared/actions/overlayTechnology' } from 'src/shared/actions/overlayTechnology'
import {OverlayContext} from 'src/shared/components/OverlayTechnology' import {OverlayContext} from 'src/shared/components/OverlayTechnology'
@ -27,7 +27,7 @@ interface Props {
onExportDashboard: (dashboard: Dashboard) => () => void onExportDashboard: (dashboard: Dashboard) => () => void
onImportDashboard: (dashboard: Dashboard) => void onImportDashboard: (dashboard: Dashboard) => void
notify: (message: Notification) => void notify: (message: Notification) => void
showOverlay: ShowOverlay showOverlay: ShowOverlayActionCreator
dashboardLink: string dashboardLink: string
} }

View File

@ -49,14 +49,8 @@ import {ErrorHandling} from 'src/shared/decorators/errors'
import {getDeep} from 'src/utils/wrappers' import {getDeep} from 'src/utils/wrappers'
import {Location} from 'history' import {Location} from 'history'
import {Dispatch} from 'redux' import {InjectedRouter} from 'react-router'
import { import {Cell, Dashboard as IDashboard, Source, TimeRange} from 'src/types'
Cell,
CellType,
Dashboard as IDashboard,
Source,
TimeRange,
} from 'src/types'
import {DashboardName} from 'src/types/dashboard' import {DashboardName} from 'src/types/dashboard'
import {ColorNumber, ColorString} from 'src/types/colors' import {ColorNumber, ColorString} from 'src/types/colors'
import * as AnnotationActions from 'src/shared/actions/annotations' import * as AnnotationActions from 'src/shared/actions/annotations'
@ -74,9 +68,8 @@ interface DashboardActions {
getDashboardWithHydratedAndSyncedTempVarsAsync: DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher getDashboardWithHydratedAndSyncedTempVarsAsync: DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher
setTimeRange: DashboardActions.SetTimeRangeActionCreator setTimeRange: DashboardActions.SetTimeRangeActionCreator
addDashboardCellAsync: DashboardActions.AddDashboardCellDispatcher addDashboardCellAsync: DashboardActions.AddDashboardCellDispatcher
} editCellQueryStatus: DashboardActions.EditCellQueryStatusActionCreator
interface Router { updateDashboardCell: DashboardActions.UpdateDashboardCellDispatcher
push: (path: string) => void
} }
interface Props { interface Props {
@ -87,21 +80,18 @@ interface Props {
dashboardID: string dashboardID: string
} }
location: Location location: Location
dashboardID: number
dashboard: IDashboard dashboard: IDashboard
dashboardActions: DashboardActions dashboardActions: DashboardActions
dashboards: IDashboard[] dashboards: IDashboard[]
handleChooseAutoRefresh: ( handleChooseAutoRefresh: AppActions.SetAutoRefreshActionCreator
milliseconds: number
) => AppActions.SetAutoRefreshActionCreator
autoRefresh: number autoRefresh: number
templateControlBarVisibilityToggled: () => AppActions.TemplateControlBarVisibilityToggledActionCreator templateControlBarVisibilityToggled: () => AppActions.TemplateControlBarVisibilityToggledActionCreator
timeRange: TimeRange timeRange: TimeRange
zoomedTimeRange: TimeRange zoomedTimeRange: TimeRange
showTemplateControlBar: boolean showTemplateControlBar: boolean
inPresentationMode: boolean inPresentationMode: boolean
handleClickPresentationButton: ( handleClickPresentationButton: AppActions.DelayEnablePresentationModeThunk
dispatch: Dispatch<AppActions.EnablePresentationModeActionCreator>
) => Promise<void>
cellQueryStatus: { cellQueryStatus: {
queryID: string queryID: string
status: object status: object
@ -111,7 +101,7 @@ interface Props {
onManualRefresh: () => void onManualRefresh: () => void
meRole: string meRole: string
isUsingAuth: boolean isUsingAuth: boolean
router: Router router: InjectedRouter
notify: NotificationActions.PublishNotificationActionCreator notify: NotificationActions.PublishNotificationActionCreator
getAnnotationsAsync: AnnotationActions.GetAnnotationsDispatcher getAnnotationsAsync: AnnotationActions.GetAnnotationsDispatcher
handleShowCellEditorOverlay: CellEditorOverlayActions.ShowCellEditorOverlayActionCreator handleShowCellEditorOverlay: CellEditorOverlayActions.ShowCellEditorOverlayActionCreator
@ -135,7 +125,9 @@ interface State {
@ErrorHandling @ErrorHandling
class DashboardPage extends Component<Props, State> { class DashboardPage extends Component<Props, State> {
constructor(props) { private intervalID: number
public constructor(props: Props) {
super(props) super(props)
this.state = { this.state = {
@ -149,7 +141,7 @@ class DashboardPage extends Component<Props, State> {
public async componentDidMount() { public async componentDidMount() {
const { const {
params: {dashboardID}, dashboardID,
dashboardActions: {putDashboardByID}, dashboardActions: {putDashboardByID},
source, source,
meRole, meRole,
@ -163,7 +155,7 @@ class DashboardPage extends Component<Props, State> {
getAnnotationsAsync(source.links.annotations, annotationRange) getAnnotationsAsync(source.links.annotations, annotationRange)
if (autoRefresh) { if (autoRefresh) {
this.intervalID = setInterval(() => { this.intervalID = window.setInterval(() => {
getAnnotationsAsync(source.links.annotations, annotationRange) getAnnotationsAsync(source.links.annotations, annotationRange)
}, autoRefresh) }, autoRefresh)
} }
@ -188,7 +180,7 @@ class DashboardPage extends Component<Props, State> {
clearInterval(this.intervalID) clearInterval(this.intervalID)
const annotationRange = millisecondTimeRange(timeRange) const annotationRange = millisecondTimeRange(timeRange)
if (nextProps.autoRefresh) { if (nextProps.autoRefresh) {
this.intervalID = setInterval(() => { this.intervalID = window.setInterval(() => {
getAnnotationsAsync(source.links.annotations, annotationRange) getAnnotationsAsync(source.links.annotations, annotationRange)
}, nextProps.autoRefresh) }, nextProps.autoRefresh)
} }
@ -206,7 +198,6 @@ class DashboardPage extends Component<Props, State> {
public componentWillUnmount() { public componentWillUnmount() {
clearInterval(this.intervalID) clearInterval(this.intervalID)
this.intervalID = false
window.removeEventListener('resize', this.handleWindowResize, true) window.removeEventListener('resize', this.handleWindowResize, true)
this.props.handleDismissEditingAnnotation() this.props.handleDismissEditingAnnotation()
} }
@ -224,6 +215,7 @@ class DashboardPage extends Component<Props, State> {
showTemplateControlBar, showTemplateControlBar,
dashboard, dashboard,
dashboards, dashboards,
dashboardID,
lineColors, lineColors,
gaugeColors, gaugeColors,
autoRefresh, autoRefresh,
@ -239,7 +231,7 @@ class DashboardPage extends Component<Props, State> {
handleShowCellEditorOverlay, handleShowCellEditorOverlay,
handleHideCellEditorOverlay, handleHideCellEditorOverlay,
handleClickPresentationButton, handleClickPresentationButton,
params: {sourceID, dashboardID}, params: {sourceID},
} = this.props } = this.props
const {dashboardsNames} = this.state const {dashboardsNames} = this.state
@ -311,9 +303,7 @@ class DashboardPage extends Component<Props, State> {
) : null} ) : null}
<DashboardHeader <DashboardHeader
names={dashboardsNames} names={dashboardsNames}
sourceID={sourceID}
dashboard={dashboard} dashboard={dashboard}
dashboards={dashboards}
timeRange={timeRange} timeRange={timeRange}
isEditMode={isEditMode} isEditMode={isEditMode}
autoRefresh={autoRefresh} autoRefresh={autoRefresh}
@ -353,13 +343,10 @@ class DashboardPage extends Component<Props, State> {
autoRefresh={autoRefresh} autoRefresh={autoRefresh}
manualRefresh={manualRefresh} manualRefresh={manualRefresh}
onZoom={this.handleZoomedTimeRange} onZoom={this.handleZoomedTimeRange}
onAddCell={this.handleAddCell}
inPresentationMode={inPresentationMode} inPresentationMode={inPresentationMode}
onPositionChange={this.handleUpdatePosition} onPositionChange={this.handleUpdatePosition}
onSelectTemplate={this.handleSelectTemplate}
onDeleteCell={this.handleDeleteDashboardCell} onDeleteCell={this.handleDeleteDashboardCell}
onCloneCell={this.handleCloneCell} onCloneCell={this.handleCloneCell}
showTemplateControlBar={showTemplateControlBar}
templatesIncludingDashTime={templatesIncludingDashTime} templatesIncludingDashTime={templatesIncludingDashTime}
onSummonOverlayTechnologies={handleShowCellEditorOverlay} onSummonOverlayTechnologies={handleShowCellEditorOverlay}
/> />
@ -368,13 +355,15 @@ class DashboardPage extends Component<Props, State> {
) )
} }
private handleWindowResize = () => { private handleWindowResize = (): void => {
this.setState({windowHeight: window.innerHeight}) this.setState({windowHeight: window.innerHeight})
} }
private async getDashboard() { private async getDashboard(): Promise<
DashboardActions.GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk
> {
const { const {
params: {dashboardID}, dashboardID,
dashboardActions: {getDashboardWithHydratedAndSyncedTempVarsAsync}, dashboardActions: {getDashboardWithHydratedAndSyncedTempVarsAsync},
source, source,
router, router,
@ -389,7 +378,7 @@ class DashboardPage extends Component<Props, State> {
) )
} }
private async getDashboardsNames() { private async getDashboardsNames(): Promise<void> {
const { const {
params: {sourceID}, params: {sourceID},
dashboardActions: {getDashboardsNamesAsync}, dashboardActions: {getDashboardsNamesAsync},
@ -477,7 +466,7 @@ class DashboardPage extends Component<Props, State> {
this.setState({isEditMode: false}) this.setState({isEditMode: false})
} }
private handleRenameDashboard = async name => { private handleRenameDashboard = async (name: string): Promise<void> => {
const {dashboardActions, dashboard} = this.props const {dashboardActions, dashboard} = this.props
this.setState({isEditMode: false}) this.setState({isEditMode: false})
const newDashboard = {...dashboard, name} const newDashboard = {...dashboard, name}
@ -498,12 +487,7 @@ class DashboardPage extends Component<Props, State> {
} }
private handleSelectTemplate = templateID => value => { private handleSelectTemplate = templateID => value => {
const { const {dashboardActions, dashboard, dashboardID, location} = this.props
dashboardActions,
dashboard,
params: {dashboardID},
location,
} = this.props
const currentTempVar = dashboard.templates.find( const currentTempVar = dashboard.templates.find(
tempVar => tempVar.id === templateID tempVar => tempVar.id === templateID
@ -602,6 +586,7 @@ const mstp = (state, {params: {dashboardID}}) => {
sources, sources,
meRole, meRole,
dashboard, dashboard,
dashboardID: Number(dashboardID),
timeRange, timeRange,
zoomedTimeRange, zoomedTimeRange,
dashboards, dashboards,

View File

@ -22,7 +22,11 @@ export const disablePresentationMode = (): DisablePresentationModeAction => ({
type: 'DISABLE_PRESENTATION_MODE', type: 'DISABLE_PRESENTATION_MODE',
}) })
export const delayEnablePresentationMode = async ( export type DelayEnablePresentationModeThunk = (
dispatch: Dispatch<EnablePresentationModeAction>
) => Promise<NodeJS.Timer>
export const delayEnablePresentationMode: DelayEnablePresentationModeThunk = async (
dispatch: Dispatch<EnablePresentationModeAction> dispatch: Dispatch<EnablePresentationModeAction>
): Promise<NodeJS.Timer> => ): Promise<NodeJS.Timer> =>
setTimeout(() => { setTimeout(() => {
@ -41,7 +45,9 @@ interface SetAutoRefreshAction {
milliseconds: number milliseconds: number
} }
} }
export const setAutoRefresh = (milliseconds: number): SetAutoRefreshAction => ({ export const setAutoRefresh: SetAutoRefreshActionCreator = (
milliseconds: number
): SetAutoRefreshAction => ({
type: 'SET_AUTOREFRESH', type: 'SET_AUTOREFRESH',
payload: { payload: {
milliseconds, milliseconds,

View File

@ -56,7 +56,7 @@ const AutoRefresh = (
inView: true, inView: true,
} }
private intervalID: NodeJS.Timer | null private intervalID: number
constructor(props: Props) { constructor(props: Props) {
super(props) super(props)
@ -199,7 +199,7 @@ const AutoRefresh = (
this.executeQueries() this.executeQueries()
if (autoRefresh) { if (autoRefresh) {
this.intervalID = setInterval(this.executeQueries, autoRefresh) this.intervalID = window.setInterval(this.executeQueries, autoRefresh)
} }
} }

View File

@ -1,10 +1,4 @@
import {TimeRange} from 'src/types/query' import {TimeRangeOption} from 'src/types/dashboard'
export interface TimeRangeOption extends TimeRange {
defaultGroupBy: string
seconds: number
inputValue: string
menuOption: string
}
const nowMinus30d = 'now() - 30d' const nowMinus30d = 'now() - 30d'

View File

@ -16,7 +16,6 @@ interface Props {
source: Source source: Source
onSelectTemplate: (id: string) => void onSelectTemplate: (id: string) => void
onSaveTemplates: (templates: Template[]) => void onSaveTemplates: (templates: Template[]) => void
onCreateTemplateVariable: () => void
} }
interface State { interface State {

View File

@ -0,0 +1,278 @@
import {Dispatch} from 'redux'
import {InjectedRouter} from 'react-router'
import {LocationAction} from 'react-router-redux'
import {Source} from 'src/types'
import * as DashboardData from 'src/types/dashboard'
import * as QueryData from 'src/types/query'
import * as TempVarData from 'src/types/tempVars'
import * as ErrorActions from 'src/shared/actions/errors'
import * as NotificationActions from 'src/shared/actions/notifications'
import * as DashboardReducers from 'src/types/reducers/dashboard'
export type LoadDashboardsActionCreator = (
dashboards: DashboardData.Dashboard[],
dashboardID?: number
) => LoadDashboardsAction
export interface LoadDashboardsAction {
type: 'LOAD_DASHBOARDS'
payload: {
dashboards: DashboardData.Dashboard[]
dashboardID: number
}
}
export interface LoadDashboardAction {
type: 'LOAD_DASHBOARD'
payload: {
dashboard: DashboardData.Dashboard
}
}
export interface SetDashTimeV1Action {
type: 'SET_DASHBOARD_TIME_V1'
payload: {
dashboardID: number
timeRange: QueryData.TimeRange
}
}
export interface RetainRangesDashTimeV1Action {
type: 'RETAIN_RANGES_DASHBOARD_TIME_V1'
payload: {
dashboardIDs: string[]
}
}
export type SetTimeRangeActionCreator = (
timeRange: QueryData.TimeRange
) => SetTimeRangeAction
export interface SetTimeRangeAction {
type: 'SET_DASHBOARD_TIME_RANGE'
payload: {
timeRange: QueryData.TimeRange
}
}
export interface SetZoomedTimeRangeAction {
type: 'SET_DASHBOARD_ZOOMED_TIME_RANGE'
payload: {
zoomedTimeRange: QueryData.TimeRange
}
}
export interface UpdateDashboardAction {
type: 'UPDATE_DASHBOARD'
payload: {
dashboard: DashboardData.Dashboard
}
}
export interface CreateDashboardAction {
type: 'CREATE_DASHBOARD'
payload: {
dashboard: DashboardData.Dashboard
}
}
export interface DeleteDashboardAction {
type: 'DELETE_DASHBOARD'
payload: {
dashboard: DashboardData.Dashboard
dashboardID: number
}
}
export interface DeleteDashboardFailedAction {
type: 'DELETE_DASHBOARD_FAILED'
payload: {
dashboard: DashboardData.Dashboard
}
}
export type SyncDashboardCellActionCreator = (
dashboard: DashboardData.Dashboard,
cell: DashboardData.Cell
) => SyncDashboardCellAction
export interface SyncDashboardCellAction {
type: 'SYNC_DASHBOARD_CELL'
payload: {
dashboard: DashboardData.Dashboard
cell: DashboardData.Cell
}
}
export interface AddDashboardCellAction {
type: 'ADD_DASHBOARD_CELL'
payload: {
dashboard: DashboardData.Dashboard
cell: DashboardData.Cell
}
}
export interface DeleteDashboardCellAction {
type: 'DELETE_DASHBOARD_CELL'
payload: {
dashboard: DashboardData.Dashboard
cell: DashboardData.Cell
}
}
export type EditCellQueryStatusActionCreator = (
queryID: string,
status: string
) => EditCellQueryStatusAction
export interface EditCellQueryStatusAction {
type: 'EDIT_CELL_QUERY_STATUS'
payload: {
queryID: string
status: string
}
}
export interface TemplateVariableSelectedAction {
type: 'TEMPLATE_VARIABLE_SELECTED'
payload: {
dashboardID: number
templateID: string
values: any[]
}
}
export interface TemplateVariablesSelectedByNameAction {
type: 'TEMPLATE_VARIABLES_SELECTED_BY_NAME'
payload: {
dashboardID: number
queryParams: TempVarData.URLQueryParams
}
}
export interface EditTemplateVariableValuesAction {
type: 'EDIT_TEMPLATE_VARIABLE_VALUES'
payload: {
dashboardID: number
templateID: string
values: any[]
}
}
export interface SetHoverTimeAction {
type: 'SET_HOVER_TIME'
payload: {
hoverTime: string
}
}
export interface SetActiveCellAction {
type: 'SET_ACTIVE_CELL'
payload: {
activeCellID: string
}
}
export type GetDashboardsDispatcher = () => GetDashboardsThunk
export type GetDashboardsThunk = (
dispatch: Dispatch<ErrorActions.ErrorThrownActionCreator>
) => Promise<DashboardData.Dashboard[] | void>
export type GetDashboardsNamesDispatcher = (
sourceID: string
) => GetDashboardsNamesThunk
export type GetDashboardsNamesThunk = (
dispatch: Dispatch<ErrorActions.ErrorThrownActionCreator>
) => Promise<DashboardData.DashboardName[] | void>
export type PutDashboardDispatcher = (
dashboard: DashboardData.Dashboard
) => PutDashboardThunk
export type PutDashboardThunk = (
dispatch: Dispatch<
UpdateDashboardAction | ErrorActions.ErrorThrownActionCreator
>
) => Promise<void>
export type PutDashboardByIDThunk = (
dispatch: Dispatch<ErrorActions.ErrorThrownActionCreator>,
getState: () => DashboardReducers.Dashboards
) => Promise<void>
export type PutDashboardByIDDispatcher = (
dashboardID: number
) => PutDashboardByIDThunk
export type UpdateDashboardCellDispatcher = (
dashboard: DashboardData.Dashboard,
cell: DashboardData.Cell
) => UpdateDashboardCellThunk
export type UpdateDashboardCellThunk = (
dispatch: Dispatch<
SyncDashboardCellActionCreator | ErrorActions.ErrorThrownActionCreator
>
) => Promise<void>
export type AddDashboardCellDispatcher = (
dashboard: DashboardData.Dashboard,
cellType: DashboardData.CellType
) => AddDashboardCellThunk
export type AddDashboardCellThunk = (
dispatch: Dispatch<
| AddDashboardCellAction
| NotificationActions.PublishNotificationActionCreator
| ErrorActions.ErrorThrownActionCreator
>
) => Promise<void>
export type SyncURLQueryFromQueryParamsObjectDispatcher = (
location: Location,
updatedURLQueryParams: TempVarData.URLQueryParams,
deletedURLQueryParams: TempVarData.URLQueryParams
) => SyncURLQueryFromQueryParamsObjectActionCreator
export type SyncURLQueryFromQueryParamsObjectActionCreator = (
dispatch: Dispatch<LocationAction>
) => void
export type SyncURLQueryFromTempVarsDispatcher = (
location: Location,
tempVars: TempVarData.Template[],
deletedTempVars: TempVarData.Template[],
urlQueryParamsTimeRanges: TempVarData.URLQueryParams
) => SyncURLQueryFromQueryParamsObjectActionCreator
export type SyncDashboardTempVarsFromURLQueryParamsDispatcher = (
dispatch: Dispatch<
| NotificationActions.PublishNotificationActionCreator
| TemplateVariableSelectedAction
>,
getState: () => DashboardReducers.Dashboards & DashboardReducers.Auth
) => void
export type SyncDashboardTimeRangeFromURLQueryParamsDispatcher = (
dispatch: Dispatch<NotificationActions.PublishNotificationActionCreator>,
getState: () => DashboardReducers.Dashboards & DashboardReducers.DashTimeV1
) => void
export type SyncDashboardFromURLQueryParamsDispatcher = (
dispatch: Dispatch<
| SyncDashboardTempVarsFromURLQueryParamsDispatcher
| SyncDashboardTimeRangeFromURLQueryParamsDispatcher
>
) => void
export type GetDashboardWithHydratedAndSyncedTempVarsAsyncDispatcher = (
dashboardID: number,
source: Source,
router: InjectedRouter,
location: Location
) => GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk
export type GetDashboardWithHydratedAndSyncedTempVarsAsyncThunk = (
dispatch: Dispatch<NotificationActions.PublishNotificationActionCreator>
) => Promise<void>

View File

@ -0,0 +1,5 @@
import {Dashboard} from 'src/types/dashboard'
export interface DashboardsResponse {
dashboards: Dashboard[]
}

View File

@ -99,3 +99,12 @@ export interface TimeShift {
unit: string unit: string
quantity: string quantity: string
} }
export interface TimeRangeOption extends TimeRange {
defaultGroupBy: string
seconds: number
inputValue: string
menuOption: string
}
export type DashTimeV1Range = TimeRangeOption & {dashboardID: number}

View File

@ -0,0 +1,15 @@
import {Dashboard} from 'src/types'
import {Me} from 'src/types/auth'
import {DashTimeV1Range} from 'src/types/query'
export interface Dashboards {
dashboardUI: {dashboards: Dashboard[]}
}
export interface Auth {
auth: {isUsingAuth: boolean; me: Me}
}
export interface DashTimeV1 {
dashTimeV1: {ranges: DashTimeV1Range[]}
}

View File

@ -72,7 +72,7 @@ function generateResponseWithLinks<T extends object>(
} }
interface RequestParams { interface RequestParams {
url: string | string[] url?: string | string[]
resource?: string | null resource?: string | null
id?: string | null id?: string | null
method?: string method?: string