Merged PR 785: select number records returned
select number records returned Related work items: #7407
This commit is contained in:
+5
-5
@@ -28,11 +28,11 @@ RELAYPATH = "test-pedw-hc"
|
|||||||
|
|
||||||
|
|
||||||
//Preprod Oauth WGO
|
//Preprod Oauth WGO
|
||||||
CLIENT_ID = ab6c4678-b31a-4eb3-b429-e039120e488a
|
//CLIENT_ID = ab6c4678-b31a-4eb3-b429-e039120e488a
|
||||||
CLIENT_SECRET = Ioo7Q~RJfhWsE45wPsuHm1CzRk1SppnNN3lZF
|
//CLIENT_SECRET = Ioo7Q~RJfhWsE45wPsuHm1CzRk1SppnNN3lZF
|
||||||
RELAY_ROOT = https://pp-pedw-ns.servicebus.windows.net/pp-pedw-hc/
|
//RELAY_ROOT = https://pp-pedw-ns.servicebus.windows.net/pp-pedw-hc/
|
||||||
RELAYURI = "pp-pedw-ns.servicebus.windows.net"
|
//RELAYURI = "pp-pedw-ns.servicebus.windows.net"
|
||||||
RELAYPATH = "pp-pedw-hc"
|
//RELAYPATH = "pp-pedw-hc"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+29
-6
@@ -90,6 +90,20 @@ export const azureHeadersPaged = (access_token) => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
export const azureHeadersPagedCustom = (access_token, showNumberOfRecords) => {
|
||||||
|
return {
|
||||||
|
headers: {
|
||||||
|
"OData-MaxVersion": "4.0",
|
||||||
|
"OData-Version": "4.0",
|
||||||
|
"Accept": "application/json;odata.metadata=none",
|
||||||
|
"Prefer":
|
||||||
|
'odata.include-annotations="*",return=representation, odata.maxpagesize=' +
|
||||||
|
showNumberOfRecords,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": "Bearer " + access_token,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export const hashAPIPath = (queryPath) => {
|
export const hashAPIPath = (queryPath) => {
|
||||||
var hashlink = CryptoJS.HmacSHA256(
|
var hashlink = CryptoJS.HmacSHA256(
|
||||||
@@ -135,7 +149,8 @@ export const getBasicSearchPaged = (
|
|||||||
searchString,
|
searchString,
|
||||||
pageNumber,
|
pageNumber,
|
||||||
orderBy,
|
orderBy,
|
||||||
fieldSort
|
fieldSort,
|
||||||
|
showNumberOfRecords
|
||||||
) => {
|
) => {
|
||||||
//console.log(queryUrl);
|
//console.log(queryUrl);
|
||||||
return axios
|
return axios
|
||||||
@@ -147,7 +162,9 @@ export const getBasicSearchPaged = (
|
|||||||
"&orderby=" +
|
"&orderby=" +
|
||||||
orderBy +
|
orderBy +
|
||||||
"&fieldSort=" +
|
"&fieldSort=" +
|
||||||
fieldSort
|
fieldSort +
|
||||||
|
"&showNumberOfRecords=" +
|
||||||
|
showNumberOfRecords
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
return res.data;
|
return res.data;
|
||||||
@@ -205,7 +222,8 @@ export const getAdvancedSearchPaged = (
|
|||||||
searchString,
|
searchString,
|
||||||
pageNumber,
|
pageNumber,
|
||||||
orderBy,
|
orderBy,
|
||||||
fieldSort
|
fieldSort,
|
||||||
|
showNumberOfRecords
|
||||||
) => {
|
) => {
|
||||||
return axios
|
return axios
|
||||||
.get(
|
.get(
|
||||||
@@ -216,7 +234,9 @@ export const getAdvancedSearchPaged = (
|
|||||||
"&orderby=" +
|
"&orderby=" +
|
||||||
orderBy +
|
orderBy +
|
||||||
"&fieldSort=" +
|
"&fieldSort=" +
|
||||||
fieldSort
|
fieldSort +
|
||||||
|
"&showNumberOfRecords=" +
|
||||||
|
showNumberOfRecords
|
||||||
)
|
)
|
||||||
.then((res) => res.data)
|
.then((res) => res.data)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
@@ -291,7 +311,8 @@ export const getSearchDocumentDetailsPaged = (
|
|||||||
incidentID,
|
incidentID,
|
||||||
pageNumber,
|
pageNumber,
|
||||||
orderBy,
|
orderBy,
|
||||||
fieldSort
|
fieldSort,
|
||||||
|
showNumberOfRecords
|
||||||
) => {
|
) => {
|
||||||
return axios
|
return axios
|
||||||
.get(
|
.get(
|
||||||
@@ -302,7 +323,9 @@ export const getSearchDocumentDetailsPaged = (
|
|||||||
"&orderby=" +
|
"&orderby=" +
|
||||||
orderBy +
|
orderBy +
|
||||||
"&fieldSort=" +
|
"&fieldSort=" +
|
||||||
fieldSort
|
fieldSort +
|
||||||
|
"&showNumberOfRecords=" +
|
||||||
|
showNumberOfRecords
|
||||||
)
|
)
|
||||||
.then((res) => res.data)
|
.then((res) => res.data)
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|||||||
@@ -45,10 +45,11 @@ const DocumentDetails = (props) => {
|
|||||||
|
|
||||||
var documentDetailsArr = documentDetailsObj || [];
|
var documentDetailsArr = documentDetailsObj || [];
|
||||||
|
|
||||||
const DocumentView = (documentDetailsArr) => {
|
const [selectedOption, setSelectedOption] = useState(10);
|
||||||
//console.log(documentDetailsArr);
|
|
||||||
|
|
||||||
|
const DocumentView = (documentDetailsArr) => {
|
||||||
documentDetailsArr = documentDetailsArr.value;
|
documentDetailsArr = documentDetailsArr.value;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<p>
|
<p>
|
||||||
@@ -60,13 +61,36 @@ const DocumentDetails = (props) => {
|
|||||||
? t("case:documents-count-label-2")
|
? t("case:documents-count-label-2")
|
||||||
: t("case:documents-count-label-2a")}
|
: t("case:documents-count-label-2a")}
|
||||||
</p>
|
</p>
|
||||||
|
<div id="recordCountSelect" className="govuk-grid-row">
|
||||||
|
<div className="govuk-form-group">
|
||||||
|
<label className="govuk-label-s " htmlFor="sort">
|
||||||
|
Show
|
||||||
|
<select
|
||||||
|
onChange={(e) => {
|
||||||
|
setSelectedOption(e.target.value);
|
||||||
|
}}
|
||||||
|
value={selectedOption}
|
||||||
|
className="govuk-select"
|
||||||
|
id="showNumberOfRecords"
|
||||||
|
name="showNumberOfRecords"
|
||||||
|
>
|
||||||
|
<option value="5">5</option>
|
||||||
|
<option value="10">10</option>
|
||||||
|
<option value="20">20</option>
|
||||||
|
<option value="30">30</option>
|
||||||
|
<option value="50">50</option>
|
||||||
|
</select>{" "}
|
||||||
|
records
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<dl className="documentList govuk-summary-list govuk-!-margin-bottom-9 results">
|
<dl className="documentList govuk-summary-list govuk-!-margin-bottom-9 results">
|
||||||
<div className="govuk-summary-list__row results-headings">
|
<div className="govuk-summary-list__row results-headings">
|
||||||
<dd className="govuk-summary-list__key govuk-!-font-size-16 ">
|
<dd className="govuk-summary-list__key govuk-!-font-size-16 ">
|
||||||
{t("case:documents-name-label")}
|
{t("case:documents-name-label")}
|
||||||
</dd>
|
</dd>
|
||||||
<dd className="govuk-summary-list__key govuk-!-font-size-16">
|
<dd className="govuk-summary-list__key govuk-!-font-size-16">
|
||||||
{t("case:documents-doc-type-label")}
|
{/* {t("case:documents-doc-type-label")} */}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
@@ -85,7 +109,7 @@ const DocumentDetails = (props) => {
|
|||||||
</button>
|
</button>
|
||||||
</dd>
|
</dd>
|
||||||
<dd className="govuk-summary-list__key govuk-!-font-size-16">
|
<dd className="govuk-summary-list__key govuk-!-font-size-16">
|
||||||
{t("case:documents-date-published-label")}
|
{/* {t("case:documents-date-published-label")} */}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => sortDataBy("createdon")}
|
onClick={() => sortDataBy("createdon")}
|
||||||
@@ -225,6 +249,7 @@ const DocumentDetails = (props) => {
|
|||||||
)}
|
)}
|
||||||
</dl>
|
</dl>
|
||||||
<PaginationControl
|
<PaginationControl
|
||||||
|
showNoOfRecords={selectedOption}
|
||||||
currentPage={currentPage}
|
currentPage={currentPage}
|
||||||
searchResultsObj={documentDetailsObj}
|
searchResultsObj={documentDetailsObj}
|
||||||
spinnerState={spinnerState}
|
spinnerState={spinnerState}
|
||||||
@@ -237,6 +262,11 @@ const DocumentDetails = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (selectedOption) {
|
||||||
|
setShowSpinnerState(true);
|
||||||
|
getDocumentResults(1, orderByState, fieldSortState);
|
||||||
|
}
|
||||||
|
|
||||||
const docDetailsObj = async () => {
|
const docDetailsObj = async () => {
|
||||||
let docObj = await getSearchDocumentDetails(incidentid)
|
let docObj = await getSearchDocumentDetails(incidentid)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
@@ -279,14 +309,15 @@ const DocumentDetails = (props) => {
|
|||||||
return Promise.all(historyArr);
|
return Promise.all(historyArr);
|
||||||
};
|
};
|
||||||
const searchDocumentResultsObj = docDetailsObj();
|
const searchDocumentResultsObj = docDetailsObj();
|
||||||
}, [incidentid, setDocumentHistory, setDocumentDetails]);
|
}, [incidentid, setDocumentHistory, setDocumentDetails, selectedOption]);
|
||||||
|
|
||||||
const getDocumentResults = (incidentid, pageNumber, orderBy, fieldSort) => {
|
const getDocumentResults = (pageNumber, orderBy, fieldSort) => {
|
||||||
getSearchDocumentDetailsPaged(
|
getSearchDocumentDetailsPaged(
|
||||||
incidentid,
|
props.incidentid,
|
||||||
pageNumber,
|
pageNumber,
|
||||||
orderBy,
|
orderBy,
|
||||||
fieldSort
|
fieldSort,
|
||||||
|
selectedOption
|
||||||
)
|
)
|
||||||
.then((data) => data)
|
.then((data) => data)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
@@ -395,18 +426,18 @@ const DocumentDetails = (props) => {
|
|||||||
: setDocumentSearchState(true);
|
: setDocumentSearchState(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
// const sortDataBy = (whichField) => {
|
const sortDataBy = (whichField) => {
|
||||||
// setOrderbyState(whichField);
|
setOrderbyState(whichField);
|
||||||
// setfieldSortState("asc");
|
setfieldSortState("asc");
|
||||||
|
|
||||||
// getSearchPageResults(1, whichField, fieldSortState);
|
getDocumentResults(1, whichField, fieldSortState);
|
||||||
// whichField == orderByState
|
whichField == orderByState
|
||||||
// ? fieldSortState == "desc"
|
? fieldSortState == "desc"
|
||||||
// ? setfieldSortState("asc")
|
? setfieldSortState("asc")
|
||||||
// : setfieldSortState("desc")
|
: setfieldSortState("desc")
|
||||||
// : setfieldSortState("asc");
|
: setfieldSortState("asc");
|
||||||
// setShowSpinnerState(true);
|
setShowSpinnerState(true);
|
||||||
// };
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import useTranslation from "next-translate/useTranslation";
|
|||||||
|
|
||||||
const PaginationControl = (props) => {
|
const PaginationControl = (props) => {
|
||||||
const {
|
const {
|
||||||
|
showNoOfRecords,
|
||||||
orderBy,
|
orderBy,
|
||||||
fieldSort,
|
fieldSort,
|
||||||
searchString,
|
searchString,
|
||||||
@@ -17,7 +18,9 @@ const PaginationControl = (props) => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { locale } = router;
|
const { locale } = router;
|
||||||
|
|
||||||
const pagesCount = Math.ceil(searchResultsObj["@odata.count"] / 10);
|
const pagesCount = Math.ceil(
|
||||||
|
searchResultsObj["@odata.count"] / showNoOfRecords
|
||||||
|
);
|
||||||
|
|
||||||
const getRange = (start, end) => {
|
const getRange = (start, end) => {
|
||||||
//console.log(start, end);
|
//console.log(start, end);
|
||||||
@@ -29,9 +32,9 @@ const PaginationControl = (props) => {
|
|||||||
const paginationNumbers = (currentPage, pageCount) => {
|
const paginationNumbers = (currentPage, pageCount) => {
|
||||||
//console.log(currentPage);
|
//console.log(currentPage);
|
||||||
let delta;
|
let delta;
|
||||||
if (pageCount <= 10) {
|
if (pageCount <= showNoOfRecords) {
|
||||||
// delta === 7: [1 2 3 4 5 6 7]
|
// delta === 7: [1 2 3 4 5 6 7]
|
||||||
delta = 10;
|
delta = showNoOfRecords;
|
||||||
} else {
|
} else {
|
||||||
// delta === 2: [1 ... 4 5 6 ... 10]
|
// delta === 2: [1 ... 4 5 6 ... 10]
|
||||||
// delta === 4: [1 2 3 4 5 ... 10]
|
// delta === 4: [1 2 3 4 5 ... 10]
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ export default function Footer(props) {
|
|||||||
"common:footer-contact-us-link"
|
"common:footer-contact-us-link"
|
||||||
)}
|
)}
|
||||||
className="govuk-footer__link"
|
className="govuk-footer__link"
|
||||||
id="aAccess"
|
id="aContactUs"
|
||||||
>
|
>
|
||||||
{t(
|
{t(
|
||||||
"common:footer-contact-us-link-label"
|
"common:footer-contact-us-link-label"
|
||||||
@@ -176,7 +176,7 @@ export default function Footer(props) {
|
|||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
className="govuk-footer__link"
|
className="govuk-footer__link"
|
||||||
id="aAccess"
|
id="aAccessibility"
|
||||||
>
|
>
|
||||||
{t(
|
{t(
|
||||||
"common:footer-accessibility-link-label"
|
"common:footer-accessibility-link-label"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import jsonpath from "jsonpath";
|
|||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import transLookup from "../../data/lookuptranslations.json";
|
import transLookup from "../../data/lookuptranslations.json";
|
||||||
import PaginationControl from "./pagination";
|
import PaginationControl from "./pagination";
|
||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import LoadingOverlay from "react-loading-overlay";
|
import LoadingOverlay from "react-loading-overlay";
|
||||||
import {
|
import {
|
||||||
getBasicDNSSearchPaged,
|
getBasicDNSSearchPaged,
|
||||||
@@ -48,6 +48,7 @@ const DNSSearchResults = (props) => {
|
|||||||
|
|
||||||
const [orderByState, setOrderbyState] = useState("createdon");
|
const [orderByState, setOrderbyState] = useState("createdon");
|
||||||
const [fieldSortState, setfieldSortState] = useState("asc");
|
const [fieldSortState, setfieldSortState] = useState("asc");
|
||||||
|
const [selectedOption, setSelectedOption] = useState(10);
|
||||||
|
|
||||||
const ResultsView = (resultsArr) => {
|
const ResultsView = (resultsArr) => {
|
||||||
return (
|
return (
|
||||||
@@ -273,6 +274,7 @@ const DNSSearchResults = (props) => {
|
|||||||
)}
|
)}
|
||||||
</dl>
|
</dl>
|
||||||
<PaginationControl
|
<PaginationControl
|
||||||
|
showNoOfRecords={selectedOption}
|
||||||
currentPage={currentPage}
|
currentPage={currentPage}
|
||||||
searchResultsObj={searchResultsObj}
|
searchResultsObj={searchResultsObj}
|
||||||
orderBy={orderByState}
|
orderBy={orderByState}
|
||||||
@@ -335,6 +337,12 @@ const DNSSearchResults = (props) => {
|
|||||||
setShowSpinnerState(true);
|
setShowSpinnerState(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (selectedOption) {
|
||||||
|
setShowSpinnerState(true);
|
||||||
|
getSearchPageResults(1, orderByState, fieldSortState);
|
||||||
|
}
|
||||||
|
}, [selectedOption]);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="govuk-grid-row">
|
<div className="govuk-grid-row">
|
||||||
@@ -354,6 +362,29 @@ const DNSSearchResults = (props) => {
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="recordCountSelect" className="govuk-grid-row">
|
||||||
|
<div className="govuk-form-group">
|
||||||
|
<label className="govuk-label-s " htmlFor="sort">
|
||||||
|
{t("search:searchresults-show-records-label-a")}
|
||||||
|
<select
|
||||||
|
onChange={(e) => {
|
||||||
|
setSelectedOption(e.target.value);
|
||||||
|
}}
|
||||||
|
value={selectedOption}
|
||||||
|
className="govuk-select"
|
||||||
|
id="showNumberOfRecords"
|
||||||
|
name="showNumberOfRecords"
|
||||||
|
>
|
||||||
|
<option value="5">5</option>
|
||||||
|
<option value="10">10</option>
|
||||||
|
<option value="20">20</option>
|
||||||
|
<option value="30">30</option>
|
||||||
|
<option value="50">50</option>
|
||||||
|
</select>{" "}
|
||||||
|
{t("search:searchresults-show-records-label-b")}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{resultsArr.length > 0 ? (
|
{resultsArr.length > 0 ? (
|
||||||
ResultsView(resultsArr)
|
ResultsView(resultsArr)
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import useTranslation from "next-translate/useTranslation";
|
|||||||
|
|
||||||
const PaginationControl = (props) => {
|
const PaginationControl = (props) => {
|
||||||
const {
|
const {
|
||||||
|
showNoOfRecords,
|
||||||
orderBy,
|
orderBy,
|
||||||
fieldSort,
|
fieldSort,
|
||||||
searchString,
|
searchString,
|
||||||
@@ -17,7 +18,9 @@ const PaginationControl = (props) => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { locale } = router;
|
const { locale } = router;
|
||||||
|
|
||||||
const pagesCount = Math.ceil(searchResultsObj["@odata.count"] / 10);
|
const pagesCount = Math.ceil(
|
||||||
|
searchResultsObj["@odata.count"] / showNoOfRecords
|
||||||
|
);
|
||||||
|
|
||||||
const getRange = (start, end) => {
|
const getRange = (start, end) => {
|
||||||
//console.log(start, end);
|
//console.log(start, end);
|
||||||
@@ -29,9 +32,9 @@ const PaginationControl = (props) => {
|
|||||||
const paginationNumbers = (currentPage, pageCount) => {
|
const paginationNumbers = (currentPage, pageCount) => {
|
||||||
//console.log(currentPage);
|
//console.log(currentPage);
|
||||||
let delta;
|
let delta;
|
||||||
if (pageCount <= 10) {
|
if (pageCount <= showNoOfRecords) {
|
||||||
// delta === 7: [1 2 3 4 5 6 7]
|
// delta === 7: [1 2 3 4 5 6 7]
|
||||||
delta = 10;
|
delta = showNoOfRecords;
|
||||||
} else {
|
} else {
|
||||||
// delta === 2: [1 ... 4 5 6 ... 10]
|
// delta === 2: [1 ... 4 5 6 ... 10]
|
||||||
// delta === 4: [1 2 3 4 5 ... 10]
|
// delta === 4: [1 2 3 4 5 ... 10]
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ const SearchResults = (props) => {
|
|||||||
var resultsArr = searchResultsObj.value || [];
|
var resultsArr = searchResultsObj.value || [];
|
||||||
|
|
||||||
const [showSpinnerState, setShowSpinnerState] = useState(false);
|
const [showSpinnerState, setShowSpinnerState] = useState(false);
|
||||||
|
const [selectedOption, setSelectedOption] = useState(10);
|
||||||
|
|
||||||
let spinnerState = () => {
|
let spinnerState = () => {
|
||||||
showSpinnerState == true
|
showSpinnerState == true
|
||||||
@@ -494,6 +495,7 @@ const SearchResults = (props) => {
|
|||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<PaginationControl
|
<PaginationControl
|
||||||
|
showNoOfRecords={selectedOption}
|
||||||
currentPage={currentPage}
|
currentPage={currentPage}
|
||||||
searchResultsObj={searchResultsObj}
|
searchResultsObj={searchResultsObj}
|
||||||
orderBy={orderByState}
|
orderBy={orderByState}
|
||||||
@@ -534,7 +536,13 @@ const SearchResults = (props) => {
|
|||||||
...searchString.map(([key, val]) => ({ [key]: val }))
|
...searchString.map(([key, val]) => ({ [key]: val }))
|
||||||
);
|
);
|
||||||
|
|
||||||
getAdvancedSearchPaged(searchoObj, pageNumber, orderBy, fieldSort)
|
getAdvancedSearchPaged(
|
||||||
|
searchoObj,
|
||||||
|
pageNumber,
|
||||||
|
orderBy,
|
||||||
|
fieldSort,
|
||||||
|
selectedOption
|
||||||
|
)
|
||||||
.then((data) => data)
|
.then((data) => data)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
//console.log("getting details", data);
|
//console.log("getting details", data);
|
||||||
@@ -545,7 +553,13 @@ const SearchResults = (props) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
getBasicSearchPaged(searchString, pageNumber, orderBy, fieldSort)
|
getBasicSearchPaged(
|
||||||
|
searchString,
|
||||||
|
pageNumber,
|
||||||
|
orderBy,
|
||||||
|
fieldSort,
|
||||||
|
selectedOption
|
||||||
|
)
|
||||||
.then((data) => data)
|
.then((data) => data)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
//console.log("getting details", data);
|
//console.log("getting details", data);
|
||||||
@@ -571,6 +585,12 @@ const SearchResults = (props) => {
|
|||||||
setShowSpinnerState(true);
|
setShowSpinnerState(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (selectedOption) {
|
||||||
|
setShowSpinnerState(true);
|
||||||
|
getSearchPageResults(1, orderByState, fieldSortState);
|
||||||
|
}
|
||||||
|
}, [selectedOption]);
|
||||||
// console.log(
|
// console.log(
|
||||||
// "page is here ",
|
// "page is here ",
|
||||||
// currentPage,
|
// currentPage,
|
||||||
@@ -610,6 +630,29 @@ const SearchResults = (props) => {
|
|||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
<div id="recordCountSelect" className="govuk-grid-row">
|
||||||
|
<div className="govuk-form-group">
|
||||||
|
<label className="govuk-label-s " htmlFor="sort">
|
||||||
|
{t("search:searchresults-show-records-label-a")}
|
||||||
|
<select
|
||||||
|
onChange={(e) => {
|
||||||
|
setSelectedOption(e.target.value);
|
||||||
|
}}
|
||||||
|
value={selectedOption}
|
||||||
|
className="govuk-select"
|
||||||
|
id="showNumberOfRecords"
|
||||||
|
name="showNumberOfRecords"
|
||||||
|
>
|
||||||
|
<option value="5">5</option>
|
||||||
|
<option value="10">10</option>
|
||||||
|
<option value="20">20</option>
|
||||||
|
<option value="30">30</option>
|
||||||
|
<option value="50">50</option>
|
||||||
|
</select>{" "}
|
||||||
|
{t("search:searchresults-show-records-label-b")}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{resultsArr.length > 0 ? (
|
{resultsArr.length > 0 ? (
|
||||||
ResultsView(resultsArr)
|
ResultsView(resultsArr)
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -60,5 +60,7 @@
|
|||||||
"searchresults-watch-label": "Gwylio",
|
"searchresults-watch-label": "Gwylio",
|
||||||
"searchresults-search-button-label": "Chwilio uwch",
|
"searchresults-search-button-label": "Chwilio uwch",
|
||||||
"searchresults-new-search-button-label": "Chwiliad newydd",
|
"searchresults-new-search-button-label": "Chwiliad newydd",
|
||||||
"searchresults-no-records-label": "Nid oes unrhyw gofnodion"
|
"searchresults-no-records-label": "Nid oes unrhyw gofnodion",
|
||||||
|
"searchresults-show-records-label-a": "Dangoswch",
|
||||||
|
"searchresults-show-records-label-b": "cofnod"
|
||||||
}
|
}
|
||||||
@@ -60,5 +60,7 @@
|
|||||||
"searchresults-watch-label": "Watch",
|
"searchresults-watch-label": "Watch",
|
||||||
"searchresults-search-button-label": "Advanced Search",
|
"searchresults-search-button-label": "Advanced Search",
|
||||||
"searchresults-new-search-button-label": "New Search",
|
"searchresults-new-search-button-label": "New Search",
|
||||||
"searchresults-no-records-label": "There are no records"
|
"searchresults-no-records-label": "There are no records",
|
||||||
|
"searchresults-show-records-label-a": "Show",
|
||||||
|
"searchresults-show-records-label-b": "records"
|
||||||
}
|
}
|
||||||
+1
-1
@@ -46,7 +46,7 @@ class MyDocument extends Document {
|
|||||||
csp += `base-uri 'self';`;
|
csp += `base-uri 'self';`;
|
||||||
csp += `form-action 'self';`;
|
csp += `form-action 'self';`;
|
||||||
csp += `object-src 'self' data:;`;
|
csp += `object-src 'self' data:;`;
|
||||||
csp += `script-src 'self' https://www.googletagmanager.com 'nonce-${generatedNonce}' ${
|
csp += `script-src 'self' unsafe-inline https://www.googletagmanager.com 'nonce-${generatedNonce}' ${
|
||||||
process.env.NODE_ENV != "production" ? " 'unsafe-eval';" : " ;"
|
process.env.NODE_ENV != "production" ? " 'unsafe-eval';" : " ;"
|
||||||
}`;
|
}`;
|
||||||
csp += `img-src 'self' https://www.googletagmanager.com https://gov.wales https://www.google-analytics.com 'nonce-${generatedNonce}' data:;`;
|
csp += `img-src 'self' https://www.googletagmanager.com https://gov.wales https://www.google-analytics.com 'nonce-${generatedNonce}' data:;`;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import axios from "axios";
|
|||||||
import CryptoJS from "crypto-js";
|
import CryptoJS from "crypto-js";
|
||||||
import { query } from "jsonpath";
|
import { query } from "jsonpath";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { getToken, azureHeadersPaged } from "../../../actions";
|
import { getToken, azureHeadersPagedCustom } from "../../../actions";
|
||||||
|
|
||||||
const WORDKEY = process.env.HASHKEY;
|
const WORDKEY = process.env.HASHKEY;
|
||||||
|
|
||||||
@@ -29,6 +29,7 @@ export default async function ApiProxy(req, res) {
|
|||||||
|
|
||||||
var orderby = req.query.orderby;
|
var orderby = req.query.orderby;
|
||||||
var fieldSort = req.query.fieldSort;
|
var fieldSort = req.query.fieldSort;
|
||||||
|
var showNumberOfRecords = req.query.showNumberOfRecords;
|
||||||
|
|
||||||
searchString = _.isEmpty(searchString)
|
searchString = _.isEmpty(searchString)
|
||||||
? searchString
|
? searchString
|
||||||
@@ -80,7 +81,10 @@ export default async function ApiProxy(req, res) {
|
|||||||
: axios
|
: axios
|
||||||
.get(
|
.get(
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||||
azureHeadersPaged(token.access_token)
|
azureHeadersPagedCustom(
|
||||||
|
token.access_token,
|
||||||
|
showNumberOfRecords
|
||||||
|
)
|
||||||
)
|
)
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
var dataStr;
|
var dataStr;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import CryptoJS from "crypto-js";
|
import CryptoJS from "crypto-js";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { getToken, azureHeadersPaged } from "../../../actions";
|
import { getToken, azureHeadersPagedCustom } from "../../../actions";
|
||||||
|
|
||||||
const WORDKEY = process.env.HASHKEY;
|
const WORDKEY = process.env.HASHKEY;
|
||||||
|
|
||||||
@@ -26,6 +26,7 @@ export default async function ApiProxy(req, res) {
|
|||||||
|
|
||||||
var orderby = req.query.orderby;
|
var orderby = req.query.orderby;
|
||||||
var fieldSort = req.query.fieldSort;
|
var fieldSort = req.query.fieldSort;
|
||||||
|
var showNumberOfRecords = req.query.showNumberOfRecords;
|
||||||
|
|
||||||
var queryUrl =
|
var queryUrl =
|
||||||
"incidents?$select=description,numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" +
|
"incidents?$select=description,numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" +
|
||||||
@@ -48,7 +49,10 @@ export default async function ApiProxy(req, res) {
|
|||||||
? axios
|
? axios
|
||||||
.get(
|
.get(
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||||
azureHeadersPaged(token.access_token)
|
azureHeadersPagedCustom(
|
||||||
|
token.access_token,
|
||||||
|
showNumberOfRecords
|
||||||
|
)
|
||||||
)
|
)
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
var dataStr;
|
var dataStr;
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export default async function ApiProxy(req, res) {
|
|||||||
incidentID +
|
incidentID +
|
||||||
"&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference";
|
"&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference";
|
||||||
|
|
||||||
console.log("docu: ", queryUrl);
|
console.log("docu: ", WEBAPI_URL + queryUrl + hashAPIPath(queryUrl));
|
||||||
|
|
||||||
return axios
|
return axios
|
||||||
.get(
|
.get(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import CryptoJS from "crypto-js";
|
import CryptoJS from "crypto-js";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { getToken, azureHeadersPaged } from "../../../actions";
|
import { getToken, azureHeadersPagedCustom } from "../../../actions";
|
||||||
|
|
||||||
const WORDKEY = process.env.HASHKEY;
|
const WORDKEY = process.env.HASHKEY;
|
||||||
|
|
||||||
@@ -41,9 +41,10 @@ export default async function ApiProxy(req, res) {
|
|||||||
|
|
||||||
var orderby = req.query.orderby;
|
var orderby = req.query.orderby;
|
||||||
var fieldSort = req.query.fieldSort;
|
var fieldSort = req.query.fieldSort;
|
||||||
|
var showNumberOfRecords = req.query.showNumberOfRecords;
|
||||||
|
|
||||||
var queryUrl =
|
var queryUrl =
|
||||||
"pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
|
"pinswg_documents?$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
|
||||||
incidentID +
|
incidentID +
|
||||||
"&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference&$orderby=" +
|
"&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference&$orderby=" +
|
||||||
orderby +
|
orderby +
|
||||||
@@ -54,12 +55,12 @@ export default async function ApiProxy(req, res) {
|
|||||||
? "&$skiptoken=" + ('<cookie pagenumber="' + pageNumber + '" />')
|
? "&$skiptoken=" + ('<cookie pagenumber="' + pageNumber + '" />')
|
||||||
: "");
|
: "");
|
||||||
|
|
||||||
console.log("docu: ", queryUrl);
|
console.log("docu paged: ", queryUrl);
|
||||||
|
|
||||||
return axios
|
return axios
|
||||||
.get(
|
.get(
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||||
azureHeadersPaged(token.access_token)
|
azureHeadersPagedCustom(token.access_token, showNumberOfRecords)
|
||||||
)
|
)
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
data.value.forEach(function (element) {
|
data.value.forEach(function (element) {
|
||||||
|
|||||||
@@ -1865,3 +1865,15 @@ fade {
|
|||||||
top: 10px;
|
top: 10px;
|
||||||
left: 10px;
|
left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// record selection
|
||||||
|
|
||||||
|
#recordCountSelect {
|
||||||
|
text-align: right;
|
||||||
|
select {
|
||||||
|
margin-right: 10px;
|
||||||
|
margin-left: 10px;
|
||||||
|
width: 70px;
|
||||||
|
background-position: 90% 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user