jason.lam 1 jaar geleden
bovenliggende
commit
bd7878d879
4 gewijzigde bestanden met toevoegingen van 35 en 29 verwijderingen
  1. +1
    -1
      src/pages/Organization/SearchPage/OrganizationSearchForm.js
  2. +2
    -3
      src/pages/Proof/Reply_GLD/ApplicationDetails.js
  3. +1
    -2
      src/pages/PublicNotice/Details_GLD/tabTableDetail/ProofTab.js
  4. +31
    -23
      src/utils/HttpUtils.js

+ 1
- 1
src/pages/Organization/SearchPage/OrganizationSearchForm.js Bestand weergeven

@@ -45,7 +45,7 @@ const OrganizationSearchForm = ({ applySearch }) => {
}

const doExport=()=>{
HttpUtils.get({
HttpUtils.fileDownload({
url: UrlUtils.GET_ORG_EXPORT
});
}


+ 2
- 3
src/pages/Proof/Reply_GLD/ApplicationDetails.js Bestand weergeven

@@ -85,9 +85,8 @@ const ApplicationDetailCard = ({

const genProof = () =>{
// window.open(UrlUtils.GEN_GAZETTE_PROOF);
HttpUtils.reportDownload({
url: UrlUtils.GEN_GAZETTE_PROOF+"/"+params.id,
filename: "proof.pdf"
HttpUtils.fileDownload({
url: UrlUtils.GEN_GAZETTE_PROOF+"/"+params.id
});
}



+ 1
- 2
src/pages/PublicNotice/Details_GLD/tabTableDetail/ProofTab.js Bestand weergeven

@@ -25,9 +25,8 @@ export default function ProofTab({rows}) {
};

const onDownloadClick = (params) => () => {
HttpUtils.reportDownload({
HttpUtils.fileDownload({
url: UrlUtils.GEN_GAZETTE_PROOF+"/"+params.row.id,
filename: "proofSlip.pdf"
});
};



+ 31
- 23
src/utils/HttpUtils.js Bestand weergeven

@@ -58,17 +58,21 @@ export const postWithFiles = ({url, params, files, onSuccess, onFail, onError})
});
};

export const fileDownload = ({fileId, skey, filename, onResponse, onError}) =>{
axios.get( FILE_DOWN_GET+"/"+fileId+"/"+skey+"/"+filename,
export const fileDownload = ({url, fileId, skey, filename, onResponse, onError}) =>{
if(!url){
url = FILE_DOWN_GET+"/"+fileId+"/"+skey+"/"+filename
}
axios.get( url,
{
responseType: 'blob',
}
).then(
(response)=>{
const fn = response.headers.get("content-disposition")?.split("filename=")[1]?.split('"')[1]?.trim()??filename;
const url = URL.createObjectURL(response.data);
const a = document.createElement('a');
a.href = url;
a.setAttribute("download", filename);
a.setAttribute("download", fn);
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
@@ -82,26 +86,30 @@ export const fileDownload = ({fileId, skey, filename, onResponse, onError}) =>{
});
};

export const reportDownload = ({url, filename, onError}) =>{
axios.get( url,
{
responseType: 'blob',
}
).then(
(response)=>{
const url = URL.createObjectURL(response.data);
const a = document.createElement('a');
a.href = url;
a.setAttribute("download", filename);
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}
).catch(error => {
return handleError(error,onError);
});
};
// export const reportDownload = ({url, onError}) =>{
// axios.get( url,
// {
// responseType: 'blob',
// }
// ).then(
// (response)=>{
// const filename = response.headers
// .get("content-disposition")
// .split("filename=")[1]
// .split('"')[1].trim();
// const url = URL.createObjectURL(response.data);
// const a = document.createElement('a');
// a.href = url;
// a.setAttribute("download", filename);
// document.body.appendChild(a);
// a.click();
// document.body.removeChild(a);
// URL.revokeObjectURL(url);
// }
// ).catch(error => {
// return handleError(error,onError);
// });
// };

export const fileUpload = ({ refType, refId, files, refCode, onSuccess, onFail, onError}) =>{
// console.log(files);


Laden…
Annuleren
Opslaan