Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,7 @@ const MonitoringApplications = () => {
<Tip text="System functions that are used for the monitoring application operation" />
</div>
{operatingFunctions.length === 0 && !loading ? (
<NoData
message={
error
? 'Failed to fetch monitoring applications'
: MONITORING_APPLICATIONS_NO_DATA_MESSAGE
}
/>
<NoData message={error ? error : MONITORING_APPLICATIONS_NO_DATA_MESSAGE} />
) : (
<SectionTable loading={loading} params={params} table={operatingFunctionsTable} />
)}
Expand All @@ -120,13 +114,7 @@ const MonitoringApplications = () => {
<span>All applications</span>
</div>
{applications.length === 0 && !loading ? (
<NoData
message={
error
? 'Failed to fetch monitoring applications'
: MONITORING_APPLICATIONS_NO_DATA_MESSAGE
}
/>
<NoData message={error ? error : MONITORING_APPLICATIONS_NO_DATA_MESSAGE} />
) : loading ? (
<Loader section secondary />
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ const MonitoringApplicationsPage = () => {
showErrorNotification(dispatch, error, '', 'Failed to fetch applications summary')
})
dispatch(fetchMonitoringApplications({ project: params.projectName, filters }))
.unwrap()
.catch(error => {
showErrorNotification(dispatch, error, '', 'Failed to fetch monitoring applications')
})
dispatch(
fetchMEPWithDetections({
project: params.projectName,
Expand Down
21 changes: 17 additions & 4 deletions src/reducers/monitoringApplicationsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ import { get } from 'lodash'

import { defaultPendingHandler, defaultRejectedHandler } from './redux.util'
import { splitApplicationsContent } from '../utils/applications.utils'
import { largeResponseCatchHandler } from '../utils/largeResponseCatchHandler'
import { getErrorMsg } from 'igz-controls/utils/common.util'

import { DATES_FILTER } from '../constants'

import monitoringApplicationsApi from '../api/monitoringApplications-api'
import nuclioApi from '../api/nuclio'
import { DATES_FILTER } from '../constants'

const initialState = {
applicationsSummary: {
Expand Down Expand Up @@ -95,7 +99,7 @@ export const fetchMonitoringApplication = createAsyncThunk(

export const fetchMonitoringApplications = createAsyncThunk(
'fetchMonitoringApplications',
async ({ project, filters }) => {
async ({ project, filters }, thunkAPI) => {
const params = {
start: filters[DATES_FILTER].value[0].getTime()
}
Expand All @@ -110,7 +114,13 @@ export const fetchMonitoringApplications = createAsyncThunk(
])

if (mlrunResult.status !== 'fulfilled') {
throw new Error(mlrunResult.reason)
largeResponseCatchHandler(
mlrunResult.reason,
'Failed to fetch monitoring applications',
thunkAPI.dispatch
)

return thunkAPI.rejectWithValue(getErrorMsg(mlrunResult.reason))
}

const mlrunApiApps = get(mlrunResult, 'value.data')
Expand Down Expand Up @@ -180,7 +190,10 @@ const monitoringApplicationsSlice = createSlice({
state.loading = false
state.error = null
})
builder.addCase(fetchMonitoringApplications.rejected, defaultRejectedHandler)
builder.addCase(fetchMonitoringApplications.rejected, (state, action) => {
state.loading = false
state.error = action.payload
})
builder.addCase(fetchMonitoringApplicationsSummary.pending, state => {
state.applicationsSummary.loading = true
})
Expand Down