add download csv ranking
This commit is contained in:
@@ -6,6 +6,7 @@ import translationStrings from '../../../../translationStringsForComponents';
|
|||||||
|
|
||||||
// api
|
// api
|
||||||
import BandoService from '../../../../service/bando-service';
|
import BandoService from '../../../../service/bando-service';
|
||||||
|
import ApplicationService from '../../../../service/application-service';
|
||||||
|
|
||||||
// tools
|
// tools
|
||||||
import getTimeParsedFromString from '../../../../helpers/getTimeParsedFromString';
|
import getTimeParsedFromString from '../../../../helpers/getTimeParsedFromString';
|
||||||
@@ -23,6 +24,8 @@ import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
|||||||
import { Dropdown } from 'primereact/dropdown';
|
import { Dropdown } from 'primereact/dropdown';
|
||||||
import { Tag } from 'primereact/tag';
|
import { Tag } from 'primereact/tag';
|
||||||
import { Calendar } from 'primereact/calendar';
|
import { Calendar } from 'primereact/calendar';
|
||||||
|
import { storeSet } from '../../../../store';
|
||||||
|
|
||||||
|
|
||||||
const AllBandiPreInstructorTableAsync = () => {
|
const AllBandiPreInstructorTableAsync = () => {
|
||||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||||
@@ -86,10 +89,37 @@ const AllBandiPreInstructorTableAsync = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const actionsBodyTemplate = (rowData) => {
|
const actionsBodyTemplate = (rowData) => {
|
||||||
return <Link to={`/bandi/${rowData.id}`}>
|
return (
|
||||||
<Button severity="info" label={__('Mostra', 'gepafin')} icon="pi pi-eye" size="small" iconPos="right" />
|
<div className="p-d-flex p-flex-column">
|
||||||
<Button severity="info" label={__('Scarica graduatoria', 'gepafin')} icon="pi pi-download" size="small" iconPos="right" style={{marginTop:'10px'}}/>
|
<Link to={`/bandi/${rowData.id}`}>
|
||||||
</Link>
|
<Button severity="info" label={__('Mostra', 'gepafin')} icon="pi pi-eye" size="small" iconPos="right" />
|
||||||
|
</Link>
|
||||||
|
<Button severity="info" label={__('Scarica graduatoria', 'gepafin')} icon="pi pi-download" size="small" iconPos="right" style={{marginTop:'10px'}} onClick={() => handleDownloadRanking(rowData.id)}/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const downloadSuccessCallback = (resp, callId) => {
|
||||||
|
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-${callId}-applications-report.csv`);
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
link.remove();
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const downloadErrorCallback = (resp) => {
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDownloadRanking = (callId)=>{
|
||||||
|
setLocalAsyncRequest(true);
|
||||||
|
ApplicationService.downloadRanking(callId,
|
||||||
|
(resp)=>downloadSuccessCallback(resp,callId),
|
||||||
|
downloadErrorCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
const statusBodyTemplate = (rowData) => {
|
const statusBodyTemplate = (rowData) => {
|
||||||
|
|||||||
@@ -67,4 +67,8 @@ export default class ApplicationService {
|
|||||||
static reAdmitApplication = (id, callback, errCallback) => {
|
static reAdmitApplication = (id, callback, errCallback) => {
|
||||||
NetworkService.put(`${API_BASE_URL}/application/${id}/readmit`, {}, callback, errCallback);
|
NetworkService.put(`${API_BASE_URL}/application/${id}/readmit`, {}, callback, errCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static downloadRanking = (callId, callback, errCallback)=> {
|
||||||
|
NetworkService.getBlob(`${API_BASE_URL}/application/call/${callId}/ranking-csv`, callback, errCallback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user