-
Notifications
You must be signed in to change notification settings - Fork 17
feat: auto refresh with advanced control #804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b5b82ea
feat(tenants): use rtk query
ValeraS 37a5696
feat(api): add signal to params
ValeraS 563d969
feat(MetricChart): use rtk query
ValeraS 94470bc
feat(tablets): use rtk query
ValeraS 382abc2
feat(shards): use rtk query
ValeraS 2e9eb0a
feat(heatmap): use rtk query
ValeraS f8f1a93
feat(topics): use rtk query
ValeraS 99f872e
feat(pdisk/vdisk): use rtk query
ValeraS 7995030
feat(TopQueries): use rtk query
ValeraS 638de02
fix: endpoints should be uniq
ValeraS b42e8e8
feat(tablet): use rtk query
ValeraS ac98d50
feat(olapStats): use rtk query
ValeraS 0d9bab3
feat(preview): use rtk query
ValeraS b09fb96
feat(partitions): use rtk query
ValeraS 5cb37e1
feat(nodesList): use rtk query
ValeraS 7a8833e
feat(describe): use rtk query
ValeraS f2cc51e
feat(overview): use rtk query
ValeraS e52b3cf
feat(network): use rtk query
ValeraS 0a8b2fa
feat(node): use rtk query
ValeraS a9cc7cd
feat: remove autofetcher
ValeraS 9ac1ed1
feat(autofetch): use new controll
ValeraS 156db5c
fix: review
ValeraS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,86 +1,38 @@ | ||
| import {createRequestActionTypes} from '../../store/utils'; | ||
| import type {IResponseError} from '../../types/api/error'; | ||
|
|
||
| import type {PreparedMetricsData} from './types'; | ||
|
|
||
| const FETCH_CHART_DATA = createRequestActionTypes('chart', 'FETCH_CHART_DATA'); | ||
| const SET_CHART_DATA_WAS_NOT_LOADED = 'chart/SET_DATA_WAS_NOT_LOADED'; | ||
|
|
||
| export const setChartDataLoading = () => { | ||
| return { | ||
| type: FETCH_CHART_DATA.REQUEST, | ||
| } as const; | ||
| }; | ||
|
|
||
| export const setChartData = (data: PreparedMetricsData) => { | ||
| return { | ||
| data, | ||
| type: FETCH_CHART_DATA.SUCCESS, | ||
| } as const; | ||
| }; | ||
|
|
||
| export const setChartError = (error: IResponseError) => { | ||
| return { | ||
| error, | ||
| type: FETCH_CHART_DATA.FAILURE, | ||
| } as const; | ||
| }; | ||
|
|
||
| export const setChartDataWasNotLoaded = () => { | ||
| return { | ||
| type: SET_CHART_DATA_WAS_NOT_LOADED, | ||
| } as const; | ||
| }; | ||
|
|
||
| type ChartAction = | ||
| | ReturnType<typeof setChartDataLoading> | ||
| | ReturnType<typeof setChartData> | ||
| | ReturnType<typeof setChartError> | ||
| | ReturnType<typeof setChartDataWasNotLoaded>; | ||
|
|
||
| interface ChartState { | ||
| loading: boolean; | ||
| wasLoaded: boolean; | ||
| data: PreparedMetricsData; | ||
| error: IResponseError | undefined; | ||
| } | ||
|
|
||
| export const initialChartState: ChartState = { | ||
| // Set chart initial state as loading, in order not to mount and unmount component in between requests | ||
| // as it leads to memory leak errors in console (not proper useEffect cleanups in chart component itself) | ||
| // TODO: possible fix (check needed): chart component is always present, but display: none for chart while loading | ||
| loading: true, | ||
| wasLoaded: false, | ||
| data: {timeline: [], metrics: []}, | ||
| error: undefined, | ||
| }; | ||
|
|
||
| export const chartReducer = (state: ChartState, action: ChartAction) => { | ||
| switch (action.type) { | ||
| case FETCH_CHART_DATA.REQUEST: { | ||
| return {...state, loading: true}; | ||
| } | ||
| case FETCH_CHART_DATA.SUCCESS: { | ||
| return {...state, loading: false, wasLoaded: true, error: undefined, data: action.data}; | ||
| } | ||
| case FETCH_CHART_DATA.FAILURE: { | ||
| if (action.error?.isCancelled) { | ||
| return state; | ||
| } | ||
|
|
||
| return { | ||
| ...state, | ||
| error: action.error, | ||
| // Clear data, so error will be displayed with empty chart | ||
| data: {timeline: [], metrics: []}, | ||
| loading: false, | ||
| wasLoaded: true, | ||
| }; | ||
| } | ||
| case SET_CHART_DATA_WAS_NOT_LOADED: { | ||
| return {...state, wasLoaded: false}; | ||
| } | ||
| default: | ||
| return state; | ||
| } | ||
| }; | ||
| import {api} from '../../store/reducers/api'; | ||
|
|
||
| import {convertResponse} from './convertResponse'; | ||
| import type {GetChartDataParams} from './getChartData'; | ||
| import {getChartData} from './getChartData'; | ||
| import i18n from './i18n'; | ||
|
|
||
| export const chartApi = api.injectEndpoints({ | ||
| endpoints: (builder) => ({ | ||
| getChartData: builder.query({ | ||
| queryFn: async (params: GetChartDataParams, {signal}) => { | ||
| try { | ||
| const response = await getChartData(params, {signal}); | ||
|
|
||
| // Response could be a plain html for ydb versions without charts support | ||
| // Or there could be an error in response with 200 status code | ||
| // It happens when request is OK, but chart data cannot be returned due to some reason | ||
| // Example: charts are not enabled in the DB ('GraphShard is not enabled' error) | ||
| if (Array.isArray(response)) { | ||
| const preparedData = convertResponse(response, params.metrics); | ||
| return {data: preparedData}; | ||
| } | ||
|
|
||
| return { | ||
| error: new Error( | ||
| typeof response === 'string' ? i18n('not-supported') : response.error, | ||
| ), | ||
| }; | ||
| } catch (error) { | ||
| return {error}; | ||
| } | ||
| }, | ||
| providesTags: ['All'], | ||
| keepUnusedDataFor: 0, | ||
| }), | ||
| }), | ||
| overrideExisting: 'throw', | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.