Skip to content

Commit

Permalink
added list update every 6 seconds for applications and helm releases (#…
Browse files Browse the repository at this point in the history
…224)

* added list update every 10 seconds for applications and helm releases

* Update refresh to 6 seconds

Co-authored-by: Arthur Berezin <[email protected]>
  • Loading branch information
ATomkivEX and rtpro committed Dec 21, 2022
1 parent 1252e43 commit 7a89678
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 19 deletions.
19 changes: 15 additions & 4 deletions frontend/src/app/main/applications/ApplicationsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ import { useDispatch, useSelector } from 'react-redux';
import FuseLoading from '@fuse/core/FuseLoading';
import FuseScrollbars from '@fuse/core/FuseScrollbars/FuseScrollbars';
import FuseSvgIcon from '@fuse/core/FuseSvgIcon';
import { getApplicationsList, selectApplications, selectIsApplicationsLoading } from 'app/store/applicationsSlice';
import {
getApplicationsList,
selectApplications,
selectIsApplicationsLoading,
setIsFirstApplicationsRequest,
} from 'app/store/applicationsSlice';
import { getContextList, selectContexts } from 'app/store/clustersSlice';
import { getTemplatesList } from 'app/store/templatesSlice';
import { selectUser } from 'app/store/userSlice';
Expand All @@ -43,11 +48,17 @@ const ApplicationsTable = () => {
const user = useSelector(selectUser);

useEffect(() => {
dispatch(getApplicationsList());
dispatch(getTemplatesList());
}, [dispatch]);
const getApplicationsTimer = setInterval(() => {
dispatch(getApplicationsList());
}, 6000);

return () => clearInterval(getApplicationsTimer);
}, []);

useEffect(() => {
dispatch(getApplicationsList());
dispatch(setIsFirstApplicationsRequest());
dispatch(getTemplatesList());
dispatch(getContextList());
}, [dispatch]);

Expand Down
22 changes: 17 additions & 5 deletions frontend/src/app/main/releases/ReleasesTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import FuseLoading from '@fuse/core/FuseLoading';
import FuseScrollbars from '@fuse/core/FuseScrollbars';
import FuseSvgIcon from '@fuse/core/FuseSvgIcon';
import withRouter from '@fuse/core/withRouter';
import { getReleases, selectIsReleasesLoading, selectReleases } from 'app/store/releasesSlice';
import {
getReleases,
selectIsReleasesLoading,
selectReleases,
setIsFirstReleasesRequest,
} from 'app/store/releasesSlice';

import { getReleaseHealth, getReleaseTtl } from '../../api';
import { selectUser } from '../../store/userSlice';
Expand Down Expand Up @@ -59,13 +64,16 @@ const ReleasesTable = () => {
const isLoading = useSelector(selectIsReleasesLoading);

useEffect(() => {
setReleases(releasesData);
getHealthRows(releasesData);
getTtlRows(releasesData);
}, [releasesData]);
const getReleasesTimer = setInterval(() => {
dispatch(getReleases());
}, 6000);

return () => clearInterval(getReleasesTimer);
}, []);

useEffect(() => {
dispatch(getReleases());
dispatch(setIsFirstReleasesRequest());
}, [dispatch]);

useEffect(() => {
Expand All @@ -80,6 +88,10 @@ const ReleasesTable = () => {
const clustersSelectOptions = getSelectItemsFromArray(uniqueClusters);
setNamespaces(namespacesSelectOptions);
setClusters(clustersSelectOptions);

setReleases(releasesData);
getHealthRows(releasesData);
getTtlRows(releasesData);
}
}, [releasesData]);

Expand Down
10 changes: 8 additions & 2 deletions frontend/src/app/store/applicationsSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,21 @@ const applicationsSlice = createSlice({
initialState: {
isLoading: false,
applications: [],
isFirstRequest: true,
},
reducers: {
setIsFirstApplicationsRequest(state) {
state.isFirstRequest = false;
},
},
reducers: {},
extraReducers: {
[getApplicationsList.fulfilled]: (state, { payload }) => ({
applications: payload,
isLoading: false,
}),
[getApplicationsList.pending]: (state) => ({
...state,
isLoading: true,
isLoading: state.isFirstRequest,
}),
[getApplicationsList.rejected]: (state) => ({
...state,
Expand All @@ -89,4 +94,5 @@ const applicationsSlice = createSlice({
export const selectApplications = ({ applications }) => applications.applications;
export const selectIsApplicationsLoading = ({ applications }) => applications.isLoading;

export const { setIsFirstApplicationsRequest } = applicationsSlice.actions;
export default applicationsSlice.reducer;
13 changes: 10 additions & 3 deletions frontend/src/app/store/releasesSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
deleteReleaseTtl as deleteReleaseTtlAPI,
} from '../api';

export const getReleases = createAsyncThunk('releases/getReleasesList', async () => {
export const getReleases = createAsyncThunk('releases/getReleasesList', async (status) => {
try {
const response = await getReleasesList();
const { data } = response;
Expand Down Expand Up @@ -66,17 +66,23 @@ const releasesSlice = createSlice({
initialState: {
isLoading: false,
releases: [],
isFirstRequest: true,
},
reducers: {
setIsFirstReleasesRequest(state) {
state.isFirstRequest = false;
},
},
reducers: {},
extraReducers: {
[getReleases.fulfilled]: (state, { payload }) => ({
releases: payload,
isLoading: false,
}),
[getReleases.pending]: (state) => ({
...state,
isLoading: true,
isLoading: state.isFirstRequest,
}),

[getReleases.rejected]: (state) => ({
...state,
isLoading: false,
Expand All @@ -87,4 +93,5 @@ const releasesSlice = createSlice({
export const selectReleases = ({ releases }) => releases.releases;
export const selectIsReleasesLoading = ({ releases }) => releases.isLoading;

export const { setIsFirstReleasesRequest } = releasesSlice.actions;
export default releasesSlice.reducer;
5 changes: 0 additions & 5 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5804,11 +5804,6 @@
"resolved" "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
"version" "1.0.0"

"fsevents@^2.3.2", "fsevents@~2.3.2":
"integrity" "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="
"resolved" "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
"version" "2.3.2"

"function-bind@^1.1.1":
"integrity" "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
"resolved" "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz"
Expand Down

0 comments on commit 7a89678

Please sign in to comment.