Select default telegraf database

pull/10616/head
Brandon Farmer 2018-06-12 16:21:53 -07:00
parent fd52a65263
commit 5de1cc4cb7
1 changed files with 14 additions and 5 deletions

View File

@ -427,16 +427,25 @@ export const setTimeRangeAsync = (timeRange: TimeRange) => async (
dispatch(setTableQueryConfigAsync())
}
export const populateNamespacesAsync = (proxyLink: string) => async (
dispatch
): Promise<void> => {
export const populateNamespacesAsync = (
proxyLink: string,
source: Source = null
) => async (dispatch): Promise<void> => {
const namespaces = await getDatabasesWithRetentionPolicies(proxyLink)
if (namespaces && namespaces.length > 0) {
dispatch(setNamespaces(namespaces))
if (source) {
const defaultNamespace = namespaces.find(
namespace => namespace.database === source.telegraf
)
dispatch(setNamespaceAsync(defaultNamespace))
} else {
dispatch(setNamespaceAsync(namespaces[0]))
}
}
}
export const getSourceAndPopulateNamespacesAsync = (sourceID: string) => async (
dispatch
@ -448,7 +457,7 @@ export const getSourceAndPopulateNamespacesAsync = (sourceID: string) => async (
if (proxyLink) {
dispatch(setSource(source))
dispatch(populateNamespacesAsync(proxyLink))
dispatch(populateNamespacesAsync(proxyLink, source))
}
}