- re enabled CSV export for super user;
This commit is contained in:
@@ -94,17 +94,52 @@ const AllBandiTableAsync = () => {
|
|||||||
<Button severity="info" label={__('Mostra', 'gepafin')} icon="pi pi-eye" size="small" iconPos="right"/>
|
<Button severity="info" label={__('Mostra', 'gepafin')} icon="pi pi-eye" size="small" iconPos="right"/>
|
||||||
</Link>
|
</Link>
|
||||||
{['PUBLISH', 'EXPIRED'].includes(rowData.status)
|
{['PUBLISH', 'EXPIRED'].includes(rowData.status)
|
||||||
? <Button type="button"
|
? <>
|
||||||
|
<Button type="button"
|
||||||
size="small"
|
size="small"
|
||||||
severity='info'
|
severity="info"
|
||||||
icon="pi pi-download"
|
icon="pi pi-download"
|
||||||
iconPos="right"
|
iconPos="right"
|
||||||
label={__('Scarica graduatoria', 'gepafin')}
|
label={__('Scarica graduatoria', 'gepafin')}
|
||||||
onClick={() => handleDownloadRanking(rowData.id)}
|
onClick={() => handleDownloadRanking(rowData.id)}
|
||||||
/> : null}
|
/>
|
||||||
|
<Button type="button"
|
||||||
|
size="small"
|
||||||
|
icon="pi pi-receipt"
|
||||||
|
iconPos="right"
|
||||||
|
label={__('CSV', 'gepafin')}
|
||||||
|
onClick={() => exportToCSV(rowData.id)}/>
|
||||||
|
</>
|
||||||
|
: null}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const exportToCSV = (applicationId) => {
|
||||||
|
setLocalAsyncRequest(true);
|
||||||
|
ApplicationService.downloadCsvReport(
|
||||||
|
applicationId,
|
||||||
|
(resp) => getCsvReportback(resp, applicationId),
|
||||||
|
errCsvReportCallback
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const getCsvReportback = (resp, applicationId) => {
|
||||||
|
const file = new Blob([resp], { type: 'text/csv' });
|
||||||
|
const url = window.URL.createObjectURL(file);
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.setAttribute('download', `call-${applicationId}-applications-report.csv`);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
link.remove();
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const errCsvReportCallback = (resp) => {
|
||||||
|
set404FromErrorResponse(resp);
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
}
|
||||||
|
|
||||||
const handleDownloadRanking = (callId) => {
|
const handleDownloadRanking = (callId) => {
|
||||||
setLocalAsyncRequest(true);
|
setLocalAsyncRequest(true);
|
||||||
ApplicationService.downloadRanking(callId,
|
ApplicationService.downloadRanking(callId,
|
||||||
@@ -117,7 +152,7 @@ const AllBandiTableAsync = () => {
|
|||||||
const url = window.URL.createObjectURL(file);
|
const url = window.URL.createObjectURL(file);
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.setAttribute('download', `call-${applicationId}-applications-report.csv`);
|
link.setAttribute('download', `call-${applicationId}-graduatoria.csv`);
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
link.remove();
|
link.remove();
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
|||||||
|
|
||||||
const invalidFormula = (value) => {
|
const invalidFormula = (value) => {
|
||||||
try {
|
try {
|
||||||
const context = getTokens(value)
|
getTokens(value)
|
||||||
return false;
|
return false;
|
||||||
} catch {
|
} catch {
|
||||||
return __('Potrebbe essere un errore nella formula!')
|
return __('Potrebbe essere un errore nella formula!')
|
||||||
|
|||||||
@@ -100,9 +100,41 @@ const LatestBandiTableAsync = () => {
|
|||||||
iconPos="right"
|
iconPos="right"
|
||||||
label={__('Scarica graduatoria', 'gepafin')}
|
label={__('Scarica graduatoria', 'gepafin')}
|
||||||
onClick={() => handleDownloadRanking(rowData.id)}/>
|
onClick={() => handleDownloadRanking(rowData.id)}/>
|
||||||
|
<Button type="button"
|
||||||
|
size="small"
|
||||||
|
icon="pi pi-receipt"
|
||||||
|
iconPos="right"
|
||||||
|
label={__('CSV', 'gepafin')}
|
||||||
|
onClick={() => exportToCSV(rowData.id)}/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const exportToCSV = (applicationId) => {
|
||||||
|
setLocalAsyncRequest(true);
|
||||||
|
ApplicationService.downloadCsvReport(
|
||||||
|
applicationId,
|
||||||
|
(resp) => getCsvReportback(resp, applicationId),
|
||||||
|
errCsvReportCallback
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const getCsvReportback = (resp, applicationId) => {
|
||||||
|
const file = new Blob([resp], { type: 'text/csv' });
|
||||||
|
const url = window.URL.createObjectURL(file);
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.setAttribute('download', `call-${applicationId}-applications-report.csv`);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
link.remove();
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const errCsvReportCallback = (resp) => {
|
||||||
|
set404FromErrorResponse(resp);
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
}
|
||||||
|
|
||||||
const handleDownloadRanking = (callId) => {
|
const handleDownloadRanking = (callId) => {
|
||||||
setLocalAsyncRequest(true);
|
setLocalAsyncRequest(true);
|
||||||
ApplicationService.downloadRanking(callId,
|
ApplicationService.downloadRanking(callId,
|
||||||
@@ -115,7 +147,7 @@ const LatestBandiTableAsync = () => {
|
|||||||
const url = window.URL.createObjectURL(file);
|
const url = window.URL.createObjectURL(file);
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.setAttribute('download', `call-${applicationId}-applications-report.csv`);
|
link.setAttribute('download', `call-${applicationId}-graduatoria.csv`);
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
link.remove();
|
link.remove();
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
|||||||
const url = window.URL.createObjectURL(file);
|
const url = window.URL.createObjectURL(file);
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.setAttribute('download', `call-${applicationId}-applications-report.csv`);
|
link.setAttribute('download', `call-${applicationId}-graduatoria.csv`);
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
link.remove();
|
link.remove();
|
||||||
|
|||||||
Reference in New Issue
Block a user