Skip to content

Commit

Permalink
Check statuses (#18171)
Browse files Browse the repository at this point in the history
* Fix: Loading status checks

The first pass at fixing the loading screen

* Fix: Loading status checks

* Fix: Loading status checks

Fix non used variables

* Fix: Loading status checks

fix copy

* Fix: Loading status checks

prettier
  • Loading branch information
zoesteinkamp authored May 21, 2020
1 parent 7f4ddab commit f1b3e97
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ui/src/alerting/utils/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const loadStatuses = (
orgID: string,
{offset, limit, since, until, filter}: LoadRowsOptions
): CancelBox<StatusRow[]> => {
const start = since ? Math.round(since / 1000) : '-60d'
const start = since ? Math.round(since / 1000) : '-1d'
const fluxFilter = filter ? searchExprToFlux(renameTagKeys(filter)) : null

const query = `
Expand Down
2 changes: 1 addition & 1 deletion ui/src/eventViewer/components/EventTable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ $event-table--field-margin: $ix-marg-b;
}

to {
opacity: 0.8;
opacity: 0.5;
}
}

Expand Down
44 changes: 40 additions & 4 deletions ui/src/eventViewer/components/EventTable.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Libraries
import React, {useLayoutEffect, FC} from 'react'
import React, {useLayoutEffect, FC, useEffect, useState} from 'react'
import {connect} from 'react-redux'
import {AutoSizer, InfiniteLoader, List} from 'react-virtualized'

// Components
Expand All @@ -9,6 +10,9 @@ import LoadingRow from 'src/eventViewer/components/LoadingRow'
import FooterRow from 'src/eventViewer/components/FooterRow'
import ErrorRow from 'src/eventViewer/components/ErrorRow'

// Actions
import {notify as notifyAction} from 'src/shared/actions/notifications'

// Utils
import {
loadNextRows,
Expand All @@ -19,17 +23,42 @@ import {
import {EventViewerChildProps, Fields} from 'src/eventViewer/types'
import {RemoteDataState} from 'src/types'

type Props = EventViewerChildProps & {
// Constants
import {checkStatusLoading} from 'src/shared/copy/notifications'

type DispatchProps = {
notify: typeof notifyAction
}

type OwnProps = {
fields: Fields
}

const EventTable: FC<Props> = ({state, dispatch, loadRows, fields}) => {
type Props = EventViewerChildProps & DispatchProps & OwnProps

const EventTable: FC<Props> = ({state, dispatch, loadRows, fields, notify}) => {
const rowCount = getRowCount(state)

const isRowLoaded = ({index}) => !!state.rows[index]

const isRowLoadedBoolean = !!state.rows[0]

const loadMoreRows = () => loadNextRows(state, dispatch, loadRows)

const [isLongRunningQuery, setIsLongRunningQuery] = useState(false)

useEffect(() => {
setTimeout(() => {
setIsLongRunningQuery(true)
}, 5000)
})

useEffect(() => {
if (isLongRunningQuery && !isRowLoadedBoolean) {
notify(checkStatusLoading)
}
}, [isLongRunningQuery, isRowLoaded])

const rowRenderer = ({key, index, style}) => {
const isLastRow = index === state.rows.length

Expand Down Expand Up @@ -103,4 +132,11 @@ const EventTable: FC<Props> = ({state, dispatch, loadRows, fields}) => {
)
}

export default EventTable
const mdtp: DispatchProps = {
notify: notifyAction,
}

export default connect<{}, DispatchProps, OwnProps>(
null,
mdtp
)(EventTable)
2 changes: 1 addition & 1 deletion ui/src/eventViewer/components/LoadingRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const LoadingRow: FC<Props> = ({index, style}) => {
style={{
width: `${width}px`,
height: `${PLACEHOLDER_HEIGHT}px`,
animationDelay: `${(index % 5) / 2}s`,
animationDelay: `${((index % 5) / 2) * 100}ms`,
}}
/>
</div>
Expand Down
5 changes: 5 additions & 0 deletions ui/src/shared/copy/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ export const SigninError: Notification = {
message: `Could not sign in`,
}

export const checkStatusLoading: Notification = {
...defaultSuccessNotification,
message: `Currently loading checks`,
}

export const QuickstartScraperCreationSuccess: Notification = {
...defaultSuccessNotification,
message: `The InfluxDB Scraper has been configured for ${QUICKSTART_SCRAPER_TARGET_URL}`,
Expand Down

0 comments on commit f1b3e97

Please sign in to comment.