parent
2155217a60
commit
0e0ef31020
|
@ -1,17 +1,18 @@
|
|||
import {writeLineProtocol as writeLineProtocolAJAX} from 'src/data_explorer/apis'
|
||||
|
||||
import {errorThrown} from 'shared/actions/errors'
|
||||
import {notify} from 'shared/actions/notifications'
|
||||
|
||||
import {notifyDataWritten} from 'shared/copy/notifications'
|
||||
import {
|
||||
notifyDataWritten,
|
||||
notifyDataWriteFailed,
|
||||
} from 'shared/copy/notifications'
|
||||
|
||||
export const writeLineProtocolAsync = (source, db, data) => async dispatch => {
|
||||
try {
|
||||
await writeLineProtocolAJAX(source, db, data)
|
||||
dispatch(notify(notifyDataWritten()))
|
||||
} catch (response) {
|
||||
const errorMessage = `Write failed: ${response.data.error}`
|
||||
dispatch(errorThrown(response, errorMessage))
|
||||
dispatch(notify(notifyDataWriteFailed(response.data.error)))
|
||||
throw response
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,11 @@ export const notifyDataWritten = () => ({
|
|||
message: 'Data was written successfully.',
|
||||
})
|
||||
|
||||
export const notifyDataWriteFailed = errorMessage => ({
|
||||
...defaultErrorNotification,
|
||||
message: `Data write failed: ${errorMessage}`,
|
||||
})
|
||||
|
||||
export const notifySessionTimedOut = () => ({
|
||||
type: 'primary',
|
||||
icon: 'triangle',
|
||||
|
|
Loading…
Reference in New Issue