added in pagination for search result requests
This commit is contained in:
+172
-30
@@ -105,16 +105,6 @@ const crmHeadersReturn = {
|
||||
};
|
||||
|
||||
const azureHeaders = (SASToken) => {
|
||||
// console.log({
|
||||
// headers: {
|
||||
// "OData-MaxVersion": "4.0",
|
||||
// "OData-Version": "4.0",
|
||||
// "Accept": "application/json",
|
||||
// "Prefer": 'odata.include-annotations="*",return=representation',
|
||||
// "Content-Type": "application/json",
|
||||
// "ServiceBusAuthorization": SASToken,
|
||||
// },
|
||||
// });
|
||||
return {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
@@ -127,26 +117,60 @@ const azureHeaders = (SASToken) => {
|
||||
};
|
||||
};
|
||||
|
||||
// const azureHeaders = {
|
||||
// headers: {
|
||||
// "OData-MaxVersion": "4.0",
|
||||
// "OData-Version": "4.0",
|
||||
// "Accept": "application/json",
|
||||
// "Prefer": 'odata.include-annotations="*",return=representation',
|
||||
// "Content-Type": "application/json",
|
||||
// "Authorization": "Bearer " + accessToken,
|
||||
// },
|
||||
// };
|
||||
const azureHeadersPaged = (SASToken) => {
|
||||
return {
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
"Accept": "application/json",
|
||||
"Prefer":
|
||||
'odata.include-annotations="*",return=representation, odata.maxpagesize=10',
|
||||
"Content-Type": "application/json",
|
||||
"ServiceBusAuthorization": SASToken,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export const getBasicSearch = (token, searchString) => {
|
||||
//console.log("\n\n", token, searchString);
|
||||
|
||||
return axios
|
||||
.get(
|
||||
WEBAPI_URL +
|
||||
"incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=contains(title, '" +
|
||||
searchString +
|
||||
"') and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true&$top=201",
|
||||
azureHeaders(token)
|
||||
"') and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true",
|
||||
azureHeadersPaged(token)
|
||||
)
|
||||
.then((res) => {
|
||||
// console.log(" ");
|
||||
// console.log("/////////////////////");
|
||||
// console.log("data:" + res.data.value);
|
||||
// console.log("/////////////////////");
|
||||
// console.log(" ");
|
||||
return res.data;
|
||||
})
|
||||
.catch((error) => {
|
||||
//console.log("thiserror", error);
|
||||
return error.response;
|
||||
});
|
||||
};
|
||||
|
||||
export const getBasicSearchPaged = (searchString, pageNumber) => {
|
||||
//console.log("\n\n", token, searchString);
|
||||
var token = getSASToken();
|
||||
|
||||
console.log(typeof pageNumber != "undefined");
|
||||
return axios
|
||||
.get(
|
||||
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=contains(title, '" +
|
||||
searchString +
|
||||
"') and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
|
||||
(typeof pageNumber != "undefined"
|
||||
? "&$skiptoken=" +
|
||||
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
|
||||
: ""),
|
||||
azureHeadersPaged(token)
|
||||
)
|
||||
.then((res) => {
|
||||
// console.log(" ");
|
||||
@@ -167,7 +191,25 @@ export const getBasicDNSSearch = (token, searchString) => {
|
||||
.get(
|
||||
WEBAPI_URL +
|
||||
"incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true",
|
||||
azureHeaders(token)
|
||||
azureHeadersPaged(token)
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
return error.response;
|
||||
});
|
||||
};
|
||||
|
||||
export const getBasicDNSSearchPaged = (pageNumber) => {
|
||||
var token = getSASToken();
|
||||
|
||||
return axios
|
||||
.get(
|
||||
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
|
||||
(typeof pageNumber != "undefined"
|
||||
? "&$skiptoken=" +
|
||||
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
|
||||
: ""),
|
||||
azureHeadersPaged(token)
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
@@ -208,7 +250,7 @@ export const getAdvancedSearch = (token, searchString) => {
|
||||
queryString +
|
||||
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true&$top=201",
|
||||
|
||||
azureHeaders(token)
|
||||
azureHeadersPaged(token)
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
@@ -222,15 +264,99 @@ export const getAdvancedSearch = (token, searchString) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getBasicSearchDetails = (token, appealType, caseReference) => {
|
||||
export const getAdvancedSearchPaged = (searchString, pageNumber) => {
|
||||
console.log(searchString);
|
||||
var token = getSASToken();
|
||||
|
||||
var queryString = "";
|
||||
|
||||
queryString +=
|
||||
searchString.q != null
|
||||
? "contains(title, '" + searchString.q + "') "
|
||||
: "";
|
||||
|
||||
queryString +=
|
||||
searchString.lpa != null
|
||||
? (typeof searchString.q == "undefined" ? "" : " and ") +
|
||||
"_pinswg_associatedlpa_value eq " +
|
||||
searchString.lpa
|
||||
: "";
|
||||
queryString +=
|
||||
searchString.apt != null
|
||||
? (typeof searchString.q == "undefined" &&
|
||||
typeof searchString.lpa == "undefined"
|
||||
? ""
|
||||
: " and ") +
|
||||
"pinswg_appealcasetype eq " +
|
||||
searchString.apt
|
||||
: "";
|
||||
|
||||
return axios
|
||||
.get(
|
||||
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" +
|
||||
queryString +
|
||||
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
|
||||
(typeof pageNumber != "undefined"
|
||||
? "&$skiptoken=" +
|
||||
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
|
||||
: ""),
|
||||
|
||||
azureHeadersPaged(token)
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
let ErrResponse = {
|
||||
value: [],
|
||||
errorCode: error.response.status,
|
||||
errorMsg: error.response.statusText,
|
||||
};
|
||||
|
||||
return ErrResponse;
|
||||
});
|
||||
};
|
||||
export const getBasicSearchDetails = (
|
||||
token,
|
||||
appealTypeName,
|
||||
caseReference,
|
||||
primaryIdAttribute,
|
||||
incidentID
|
||||
) => {
|
||||
//console.log("check appealtype:", appealType, caseReference);
|
||||
return axios
|
||||
.get(
|
||||
WEBAPI_URL +
|
||||
appealType +
|
||||
"?$filter=pinswg_name eq '" +
|
||||
caseReference +
|
||||
"'&$count=true",
|
||||
appealTypeName +
|
||||
"?$filter=_" +
|
||||
primaryIdAttribute +
|
||||
"s_value eq " +
|
||||
incidentID +
|
||||
"&$count=true",
|
||||
azureHeadersPaged(token)
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("this error", error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getBasicSearchDetailsPaged = (
|
||||
appealTypeName,
|
||||
caseReference,
|
||||
primaryIdAttribute,
|
||||
incidentID
|
||||
) => {
|
||||
//console.log("check appealtype:", appealType, caseReference);
|
||||
var token = getSASToken();
|
||||
|
||||
return axios
|
||||
.get(
|
||||
"/api/proxy/" +
|
||||
appealTypeName +
|
||||
"?$filter=_" +
|
||||
primaryIdAttribute +
|
||||
"s_value eq " +
|
||||
incidentID +
|
||||
"&$count=true",
|
||||
azureHeaders(token)
|
||||
)
|
||||
.then((res) => res.data)
|
||||
@@ -307,7 +433,23 @@ export const getBasicDNSSearchDetails = (token, appealType, caseReference) => {
|
||||
"pinswg_dnses?$filter=pinswg_name eq '" +
|
||||
caseReference +
|
||||
"'&$count=true",
|
||||
azureHeaders(token)
|
||||
azureHeadersPaged(token)
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
console.log("thiserror", error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getBasicDNSSearchDetailsPaged = (caseReference) => {
|
||||
var token = getSASToken();
|
||||
|
||||
return axios
|
||||
.get(
|
||||
"/api/proxy/pinswg_dnses?$filter=pinswg_name eq '" +
|
||||
caseReference +
|
||||
"'&$count=true",
|
||||
azureHeadersPaged(token)
|
||||
)
|
||||
.then((res) => res.data)
|
||||
.catch((error) => {
|
||||
|
||||
Reference in New Issue
Block a user