Skip to content

Commit 685b6aa

Browse files
authored
Merge pull request #112 from MVarshini/PANDA-445
Quay and Telco Tabs
2 parents 8187c4a + e2efcd2 commit 685b6aa

File tree

32 files changed

+1691
-347
lines changed

32 files changed

+1691
-347
lines changed

frontend/src/actions/commonActions.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import * as TYPES from "@/actions/types.js";
22

3-
import { setCatFilters, sliceTableRows } from "./homeActions";
3+
import { setCPTCatFilters, sliceCPTTableRows } from "./homeActions";
44
import { setOCPCatFilters, sliceOCPTableRows } from "./ocpActions";
5+
import { setQuayCatFilters, sliceQuayTableRows } from "./quayActions";
6+
import { setTelcoCatFilters, sliceTelcoTableRows } from "./telcoActions";
57

68
import { DEFAULT_PER_PAGE } from "@/assets/constants/paginationConstants";
79
import { cloneDeep } from "lodash";
@@ -45,7 +47,7 @@ const sortedTableRows = (currState, sortedResults) => (dispatch) => {
4547
type: TYPES.SET_FILTERED_DATA,
4648
payload: sortedResults,
4749
});
48-
dispatch(sliceTableRows(0, DEFAULT_PER_PAGE));
50+
dispatch(sliceCPTTableRows(0, DEFAULT_PER_PAGE));
4951
return;
5052
}
5153
if (currState === "ocp") {
@@ -54,6 +56,22 @@ const sortedTableRows = (currState, sortedResults) => (dispatch) => {
5456
payload: sortedResults,
5557
});
5658
dispatch(sliceOCPTableRows(0, DEFAULT_PER_PAGE));
59+
return;
60+
}
61+
if (currState === "quay") {
62+
dispatch({
63+
type: TYPES.SET_QUAY_FILTERED_DATA,
64+
payload: sortedResults,
65+
});
66+
dispatch(sliceQuayTableRows(0, DEFAULT_PER_PAGE));
67+
return;
68+
}
69+
if (currState === "telco") {
70+
dispatch({
71+
type: TYPES.SET_TELCO_FILTERED_DATA,
72+
payload: sortedResults,
73+
});
74+
dispatch(sliceTelcoTableRows(0, DEFAULT_PER_PAGE));
5775
}
5876
};
5977

@@ -114,7 +132,19 @@ const setFilterData = (filterData, currState, activeFilter) => (dispatch) => {
114132
type: TYPES.SET_CPT_FILTER_DATA,
115133
payload: filterData,
116134
});
117-
dispatch(setCatFilters(activeFilter));
135+
dispatch(setCPTCatFilters(activeFilter));
136+
} else if (currState === "quay") {
137+
dispatch({
138+
type: TYPES.SET_QUAY_FILTER_DATA,
139+
payload: filterData,
140+
});
141+
dispatch(setQuayCatFilters(activeFilter));
142+
} else if (currState === "telco") {
143+
dispatch({
144+
type: TYPES.SET_TELCO_FILTER_DATA,
145+
payload: filterData,
146+
});
147+
dispatch(setTelcoCatFilters(activeFilter));
118148
}
119149
};
120150

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import {
2+
removeCPTAppliedFilters,
3+
setCPTAppliedFilters,
4+
setCPTCatFilters,
5+
setCPTDateFilter,
6+
setCPTOtherSummaryFilter,
7+
} from "./homeActions";
8+
import {
9+
removeOCPAppliedFilters,
10+
setOCPAppliedFilters,
11+
setOCPCatFilters,
12+
setOCPDateFilter,
13+
setOCPOtherSummaryFilter,
14+
} from "./ocpActions";
15+
import {
16+
removeQuayAppliedFilters,
17+
setQuayAppliedFilters,
18+
setQuayCatFilters,
19+
setQuayDateFilter,
20+
setQuayOtherSummaryFilter,
21+
} from "./quayActions";
22+
import {
23+
removeTelcoAppliedFilters,
24+
setTelcoAppliedFilters,
25+
setTelcoCatFilters,
26+
setTelcoDateFilter,
27+
setTelcoOtherSummaryFilter,
28+
} from "./telcoActions";
29+
30+
import store from "@/store/store";
31+
32+
const { dispatch } = store;
33+
34+
export const setCatFilters = (category, currType) => {
35+
if (currType === "cpt") {
36+
dispatch(setCPTCatFilters(category));
37+
} else if (currType === "ocp") {
38+
dispatch(setOCPCatFilters(category));
39+
} else if (currType === "quay") {
40+
dispatch(setQuayCatFilters(category));
41+
} else if (currType === "telco") {
42+
dispatch(setTelcoCatFilters(category));
43+
}
44+
};
45+
46+
export const setAppliedFilters = (navigation, currType) => {
47+
if (currType === "cpt") {
48+
dispatch(setCPTAppliedFilters(navigation));
49+
} else if (currType === "ocp") {
50+
dispatch(setOCPAppliedFilters(navigation));
51+
} else if (currType === "quay") {
52+
dispatch(setQuayAppliedFilters(navigation));
53+
} else if (currType === "telco") {
54+
dispatch(setTelcoAppliedFilters(navigation));
55+
}
56+
};
57+
58+
export const removeAppliedFilters = (key, value, navigation, currType) => {
59+
if (currType === "cpt") {
60+
dispatch(removeCPTAppliedFilters(key, value, navigation));
61+
} else if (currType === "ocp") {
62+
dispatch(removeOCPAppliedFilters(key, value, navigation));
63+
} else if (currType === "quay") {
64+
dispatch(removeQuayAppliedFilters(key, value, navigation));
65+
} else if (currType === "telco") {
66+
dispatch(removeTelcoAppliedFilters(key, value, navigation));
67+
}
68+
};
69+
70+
export const setDateFilter = (date, key, navigation, currType) => {
71+
if (currType === "cpt") {
72+
dispatch(setCPTDateFilter(date, key, navigation));
73+
} else if (currType === "ocp") {
74+
dispatch(setOCPDateFilter(date, key, navigation));
75+
} else if (currType === "quay") {
76+
dispatch(setQuayDateFilter(date, key, navigation));
77+
} else if (currType === "telco") {
78+
dispatch(setTelcoDateFilter(date, key, navigation));
79+
}
80+
};
81+
82+
export const setOtherSummaryFilter = (currType) => {
83+
if (currType === "cpt") {
84+
dispatch(setCPTOtherSummaryFilter());
85+
} else if (currType === "ocp") {
86+
dispatch(setOCPOtherSummaryFilter());
87+
} else if (currType === "quay") {
88+
dispatch(setQuayOtherSummaryFilter());
89+
} else if (currType === "telco") {
90+
dispatch(setTelcoOtherSummaryFilter());
91+
}
92+
};

frontend/src/actions/homeActions.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,26 @@ export const fetchOCPJobsData = () => async (dispatch, getState) => {
3030
...(end_date && { end_date }),
3131
},
3232
});
33-
if (response?.data?.results?.length > 0) {
33+
if (response.status === 200) {
3434
const startDate = response.data.startDate,
3535
endDate = response.data.endDate;
3636
//on initial load startDate and endDate are empty, so from response append to url
3737
appendDateFilter(startDate, endDate);
38-
39-
dispatch({
40-
type: TYPES.SET_CPT_JOBS_DATA,
41-
payload: response.data.results,
42-
});
4338
dispatch({
4439
type: TYPES.SET_CPT_DATE_FILTER,
4540
payload: {
4641
start_date: startDate,
4742
end_date: endDate,
4843
},
4944
});
45+
}
46+
47+
if (response?.data?.results?.length > 0) {
48+
dispatch({
49+
type: TYPES.SET_CPT_JOBS_DATA,
50+
payload: response.data.results,
51+
});
52+
5053
dispatch(applyFilters());
5154
dispatch(sortTable("cpt"));
5255
dispatch(tableReCalcValues());
@@ -67,7 +70,7 @@ export const setCPTSortDir = (direction) => ({
6770
payload: direction,
6871
});
6972

70-
export const sliceTableRows = (startIdx, endIdx) => (dispatch, getState) => {
73+
export const sliceCPTTableRows = (startIdx, endIdx) => (dispatch, getState) => {
7174
const results = [...getState().cpt.filteredResults];
7275

7376
dispatch({
@@ -76,7 +79,7 @@ export const sliceTableRows = (startIdx, endIdx) => (dispatch, getState) => {
7679
});
7780
};
7881

79-
export const setCatFilters = (category) => (dispatch, getState) => {
82+
export const setCPTCatFilters = (category) => (dispatch, getState) => {
8083
const filterData = [...getState().cpt.filterData];
8184
const options = filterData.filter((item) => item.name === category)[0].value;
8285
const list = options.map((item) => ({ name: item, value: item }));
@@ -112,7 +115,7 @@ export const setSelectedFilter =
112115
});
113116
};
114117

115-
export const setAppliedFilters = (navigate) => (dispatch, getState) => {
118+
export const setCPTAppliedFilters = (navigate) => (dispatch, getState) => {
116119
const { selectedFilters, start_date, end_date } = getState().cpt;
117120

118121
const appliedFilterArr = selectedFilters.filter((i) => i.value.length > 0);
@@ -130,7 +133,7 @@ export const setAppliedFilters = (navigate) => (dispatch, getState) => {
130133
dispatch(applyFilters());
131134
};
132135

133-
export const setOtherSummaryFilter = () => (dispatch, getState) => {
136+
export const setCPTOtherSummaryFilter = () => (dispatch, getState) => {
134137
const filteredResults = [...getState().cpt.filteredResults];
135138
const keyWordArr = ["success", "failure"];
136139
const data = filteredResults.filter(
@@ -142,7 +145,7 @@ export const setOtherSummaryFilter = () => (dispatch, getState) => {
142145
});
143146
dispatch(tableReCalcValues());
144147
};
145-
export const removeAppliedFilters =
148+
export const removeCPTAppliedFilters =
146149
(filterKey, filterValue, navigate) => (dispatch, getState) => {
147150
const { start_date, end_date } = getState().cpt;
148151

@@ -184,7 +187,7 @@ export const setFilterFromURL = (searchParams) => ({
184187
payload: searchParams,
185188
});
186189

187-
export const setDateFilter =
190+
export const setCPTDateFilter =
188191
(start_date, end_date, navigate) => (dispatch, getState) => {
189192
const appliedFilters = getState().cpt.appliedFilters;
190193

@@ -201,12 +204,12 @@ export const setDateFilter =
201204
dispatch(fetchOCPJobsData());
202205
};
203206

204-
export const setPage = (pageNo) => ({
207+
export const setCPTPage = (pageNo) => ({
205208
type: TYPES.SET_PAGE,
206209
payload: pageNo,
207210
});
208211

209-
export const setPageOptions = (page, perPage) => ({
212+
export const setCPTPageOptions = (page, perPage) => ({
210213
type: TYPES.SET_PAGE_OPTIONS,
211214
payload: { page, perPage },
212215
});
@@ -223,6 +226,6 @@ export const getCPTSummary = () => (dispatch, getState) => {
223226

224227
export const tableReCalcValues = () => (dispatch) => {
225228
dispatch(getCPTSummary());
226-
dispatch(setPageOptions(START_PAGE, DEFAULT_PER_PAGE));
227-
dispatch(sliceTableRows(0, DEFAULT_PER_PAGE));
229+
dispatch(setCPTPageOptions(START_PAGE, DEFAULT_PER_PAGE));
230+
dispatch(sliceCPTTableRows(0, DEFAULT_PER_PAGE));
228231
};

0 commit comments

Comments
 (0)