update download url

This commit is contained in:
2022-02-17 18:28:18 +05:30
parent 82be6d24f0
commit 47a1bb5939
14 changed files with 47 additions and 43 deletions

View File

@ -78,15 +78,19 @@ function Index() {
function setingReport(e){
setReport(e.target.value);
setStartDate(null);
setDownloadUrl('');
}
function setingSelectedCons(e) {
setSelectedCons(e.target.value);
setStartDate(null);
setDownloadUrl('');
}
function setingGraph(e){
console.log("setting report" + downloadUrl);
setGraph(e.target.checked);
setDownloadUrl('');
}
function doGetReport(){
@ -102,36 +106,36 @@ function Index() {
else{
url = baseUrl + "/generate" + report + "?construction_id=" +selectedcons+ "&construction_date="+getDateWithFormat(startDate);
}
setDownloadUrl(url)
setDownloadUrl(url);
//downloadReport(url);
}
else {
if(graph){
url = baseUrl + "/generate" + report + "?construction_id=" +selectedcons+"&graph=true";
}
else{
url = baseUrl + "/generate" + report + "?construction_id=" +selectedcons;
}
setDownloadUrl(url)
// if(graph){
// url = baseUrl + "/generate" + report + "?construction_id=" +selectedcons+"&graph=true";
// }
// else{
// url = baseUrl + "/generate" + report + "?construction_id=" +selectedcons;
// }
setDownloadUrl('');
//downloadReport(url);
}
}
function downloadReport(url) {
console.log(url);
fetch(url)
.then(response => {
console.log(response)
const filename = response.headers.get('Content-Disposition').split('filename=')[1];
response.blob().then(blob => {
let url = window.URL.createObjectURL(blob);
let a = document.createElement('a');
a.href = url;
a.download = filename;
a.click();
});
});
}
// function downloadReport(url) {
// console.log(url);
// fetch(url)
// .then(response => {
// console.log(response)
// const filename = response.headers.get('Content-Disposition').split('filename=')[1];
// response.blob().then(blob => {
// let url = window.URL.createObjectURL(blob);
// let a = document.createElement('a');
// a.href = url;
// a.download = filename;
// a.click();
// });
// });
// }
// function downloadReport(url) {
// axios({