added in pagination for search result requests
This commit is contained in:
@@ -40,7 +40,7 @@ const Home = (props) => {
|
||||
const { locale } = router;
|
||||
const { appealtypes } = router.query;
|
||||
|
||||
console.log(props, props.LPAData);
|
||||
//console.log(props, props.LPAData);
|
||||
var hasError =
|
||||
_.has(props.LPAData.LPAData, "errorCode") ||
|
||||
_.has(props.appealType.appealType, "errorCode")
|
||||
|
||||
@@ -20,15 +20,11 @@ import { setSearch, getSearchObj } from "../store/search/action";
|
||||
import {
|
||||
setSearchResults,
|
||||
setSearchDetails,
|
||||
setDocumentDetails,
|
||||
setDocumentHistory,
|
||||
getSearchResultsObj,
|
||||
} from "../store/searchOutput/action";
|
||||
import {
|
||||
getAdvancedSearch,
|
||||
getBasicSearchDetails,
|
||||
getSearchDocumentDetails,
|
||||
getSearchDocumentHistory,
|
||||
getSASToken,
|
||||
} from "../actions";
|
||||
|
||||
@@ -80,13 +76,14 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
store.dispatch(setSearchResults(searchResultsObj));
|
||||
store.dispatch(setSearchDetails(searchDetailsObj));
|
||||
store.dispatch(setSearch(Object.entries(query)));
|
||||
}
|
||||
);
|
||||
|
||||
const getFormCollection = (formtype) => {
|
||||
const collectionName = jsonpath.query(
|
||||
data,
|
||||
"$..[?(@.LogicalName=='" + formtype + "')].LogicalCollectionName"
|
||||
"$..[?(@.LogicalName=='" + formtype + "')]"
|
||||
);
|
||||
//console.log(collectionName[0]);
|
||||
return collectionName[0];
|
||||
@@ -102,19 +99,23 @@ const getSearchDetails = (token, searchResultsObj) => {
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
console.log(searchDetail.ticketnumber);
|
||||
} else {
|
||||
let formMeta = getFormCollection(
|
||||
"pinswg_" +
|
||||
searchDetail[
|
||||
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
|
||||
.toLowerCase()
|
||||
.slice(0, 39)
|
||||
);
|
||||
|
||||
detailsArr.push(
|
||||
getBasicSearchDetails(
|
||||
token,
|
||||
getFormCollection(
|
||||
"pinswg_" +
|
||||
searchDetail[
|
||||
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
|
||||
.toLowerCase()
|
||||
.slice(0, 39)
|
||||
),
|
||||
searchDetail.ticketnumber
|
||||
formMeta.LogicalCollectionName,
|
||||
searchDetail.title,
|
||||
formMeta.PrimaryIdAttribute,
|
||||
searchDetail.incidentid
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,8 @@ export default async function ApiProxy(req, res) {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||
"Prefer":
|
||||
'odata.include-annotations="*",return=representation,odata.maxpagesize=10',
|
||||
"Authorization": SASToken,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
@@ -99,13 +100,13 @@ export default async function ApiProxy(req, res) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let apiPath = req.url.split("/api/proxy/")[1];
|
||||
let hasDocument = apiPath.indexOf("/download") > 0 ? true : false;
|
||||
console.log(
|
||||
"//////////////",
|
||||
req.url.split("/api/proxy/")[1],
|
||||
PROXY_RELAY_URL + req.query.route[0],
|
||||
req.method,
|
||||
hasDocument
|
||||
);
|
||||
// console.log(
|
||||
// "//////////////",
|
||||
// req.url.split("/api/proxy/")[1],
|
||||
// PROXY_RELAY_URL + req.query.route[0],
|
||||
// req.method,
|
||||
// hasDocument
|
||||
// );
|
||||
axios(
|
||||
req.method == "GET"
|
||||
? hasDocument
|
||||
|
||||
+16
-12
@@ -90,7 +90,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
const getFormCollection = (formtype) => {
|
||||
const collectionName = jsonpath.query(
|
||||
data,
|
||||
"$..[?(@.LogicalName=='" + formtype + "')].LogicalCollectionName"
|
||||
"$..[?(@.LogicalName=='" + formtype + "')]"
|
||||
);
|
||||
//console.log(collectionName[0]);
|
||||
return collectionName[0];
|
||||
@@ -103,21 +103,25 @@ const getSearchDetails = (token, searchResultsObj) => {
|
||||
searchResultsObj = searchResultsObj.value;
|
||||
const detailsObj = searchResultsObj.map((searchDetail, index) => {
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
console.log(searchDetail.ticketnumber);
|
||||
console.log(searchDetail.title);
|
||||
} else {
|
||||
let formMeta = getFormCollection(
|
||||
"pinswg_" +
|
||||
searchDetail[
|
||||
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
|
||||
.toLowerCase()
|
||||
.slice(0, 39)
|
||||
);
|
||||
|
||||
detailsArr.push(
|
||||
getBasicSearchDetails(
|
||||
token,
|
||||
getFormCollection(
|
||||
"pinswg_" +
|
||||
searchDetail[
|
||||
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
|
||||
.toLowerCase()
|
||||
.slice(0, 39)
|
||||
),
|
||||
searchDetail.ticketnumber
|
||||
formMeta.LogicalCollectionName,
|
||||
searchDetail.title,
|
||||
formMeta.PrimaryIdAttribute,
|
||||
searchDetail.incidentid
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
+35
-80
@@ -19,17 +19,9 @@ import { setSearch, getSearchObj } from "../store/search/action";
|
||||
import {
|
||||
setSearchResults,
|
||||
setSearchDetails,
|
||||
setDocumentDetails,
|
||||
setDocumentHistory,
|
||||
getSearchResultsObj,
|
||||
} from "../store/searchOutput/action";
|
||||
import {
|
||||
getBasicSearch,
|
||||
getBasicSearchDetails,
|
||||
getSearchDocumentDetails,
|
||||
getSearchDocumentHistory,
|
||||
getSASToken,
|
||||
} from "../actions";
|
||||
import { getBasicSearch, getBasicSearchDetails, getSASToken } from "../actions";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, pages } = props;
|
||||
@@ -87,21 +79,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
searchResultsObj
|
||||
);
|
||||
|
||||
// const searchDocumentResultsObj = await getDocumentDetails(
|
||||
// token,
|
||||
// searchResultsObj
|
||||
// );
|
||||
|
||||
// const searchDocumentHistoryObj = await getDocumentHistory(
|
||||
// token,
|
||||
// searchDocumentResultsObj
|
||||
// );
|
||||
// console.log(searchDocumentHistoryObj);
|
||||
|
||||
store.dispatch(setSearchResults(searchResultsObj));
|
||||
store.dispatch(setSearchDetails(searchDetailsObj));
|
||||
//store.dispatch(setDocumentDetails(searchDocumentResultsObj));
|
||||
//store.dispatch(setDocumentHistory(searchDocumentHistoryObj));
|
||||
store.dispatch(setSearch(query.q));
|
||||
}
|
||||
);
|
||||
@@ -109,7 +88,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
const getFormCollection = (formtype) => {
|
||||
const collectionName = jsonpath.query(
|
||||
data,
|
||||
"$..[?(@.LogicalName=='" + formtype + "')].LogicalCollectionName"
|
||||
"$..[?(@.LogicalName=='" + formtype + "')]"
|
||||
);
|
||||
//console.log(collectionName[0]);
|
||||
return collectionName[0];
|
||||
@@ -123,8 +102,22 @@ const getSearchDetails = (token, searchResultsObj) => {
|
||||
searchResultsObj = searchResultsObj.value;
|
||||
const detailsObj = searchResultsObj.map((searchDetail, index) => {
|
||||
//console.log(searchDetail);
|
||||
|
||||
// console.log(
|
||||
// "the collect",
|
||||
// getFormCollection(
|
||||
// "pinswg_" +
|
||||
// searchDetail[
|
||||
// "pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
|
||||
// ]
|
||||
// .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
|
||||
// .toLowerCase()
|
||||
// .slice(0, 39)
|
||||
// )
|
||||
// );
|
||||
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
console.log(searchDetail.ticketnumber);
|
||||
console.log(searchDetail.title);
|
||||
} else {
|
||||
// console.log(
|
||||
// "appealtype collection name",
|
||||
@@ -138,21 +131,28 @@ const getSearchDetails = (token, searchResultsObj) => {
|
||||
// .replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
|
||||
// .toLowerCase()
|
||||
// .slice(0, 39),
|
||||
// searchDetail.ticketnumber
|
||||
// searchDetail.title,
|
||||
// searchDetail.ticketnumber,
|
||||
// searchDetail.incidentid
|
||||
// );
|
||||
|
||||
let formMeta = getFormCollection(
|
||||
"pinswg_" +
|
||||
searchDetail[
|
||||
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
|
||||
.toLowerCase()
|
||||
.slice(0, 39)
|
||||
);
|
||||
|
||||
detailsArr.push(
|
||||
getBasicSearchDetails(
|
||||
token,
|
||||
getFormCollection(
|
||||
"pinswg_" +
|
||||
searchDetail[
|
||||
"pinswg_appealcasetype@OData.Community.Display.V1.FormattedValue"
|
||||
]
|
||||
.replace(/(\band|[\s\-\+\(\)\,\&])/g, "")
|
||||
.toLowerCase()
|
||||
.slice(0, 39)
|
||||
),
|
||||
searchDetail.ticketnumber
|
||||
formMeta.LogicalCollectionName,
|
||||
searchDetail.title,
|
||||
formMeta.PrimaryIdAttribute,
|
||||
searchDetail.incidentid
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -161,51 +161,6 @@ const getSearchDetails = (token, searchResultsObj) => {
|
||||
return Promise.all(detailsArr);
|
||||
};
|
||||
|
||||
const getDocumentDetails = (token, searchResultsObj) => {
|
||||
//console.log(searchResultsObj);
|
||||
|
||||
let detailsArr = [];
|
||||
//console.log("search results", searchResultsObj);
|
||||
searchResultsObj = searchResultsObj.value;
|
||||
const detailsObj = searchResultsObj.map((searchDetail, index) => {
|
||||
if (searchDetail.pinswg_appealcasetype == null) {
|
||||
console.log(searchDetail.incidentid);
|
||||
} else {
|
||||
detailsArr.push(
|
||||
getSearchDocumentDetails(token, searchDetail.incidentid)
|
||||
);
|
||||
}
|
||||
});
|
||||
//console.log(detailsArr);
|
||||
return Promise.all(detailsArr);
|
||||
};
|
||||
|
||||
const getDocumentHistory = (token, searchDocumentDetailsObj) => {
|
||||
//console.log(searchResultsObj);
|
||||
|
||||
let historyArr = [];
|
||||
//console.log("search results", searchDocumentDetailsObj);
|
||||
searchDocumentDetailsObj = searchDocumentDetailsObj[0].value;
|
||||
|
||||
//console.log(searchDocumentDetailsObj);
|
||||
const detailsObj = searchDocumentDetailsObj.map((historyDetail, index) => {
|
||||
//console.log(historyDetail);
|
||||
if (historyDetail.pinswg_publishtoweb != true) {
|
||||
console.log(historyDetail.pinswg_documentid);
|
||||
} else {
|
||||
// console.log(
|
||||
// "history detail documentid:",
|
||||
// historyDetail.pinswg_documentid
|
||||
// );
|
||||
historyArr.push(
|
||||
getSearchDocumentHistory(token, historyDetail.pinswg_documentid)
|
||||
);
|
||||
}
|
||||
});
|
||||
console.log(historyArr);
|
||||
return Promise.all(historyArr);
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
currentView: state.currentView,
|
||||
|
||||
Reference in New Issue
Block a user