39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
function getApplicationId() {
|
|
const match = window.location.hash.match(/^#\/job-procedures\/record\/([0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12})/)
|
|
if (match != null) {
|
|
return match[1]
|
|
}
|
|
throw "Unable to retrieve Application ID";
|
|
}
|
|
|
|
async function getApplicantFiles(applicant) {
|
|
fetch(`https://personal.uni-graz.at/api/erec/job-applications/${applicant.id}`)
|
|
.then((response) => {
|
|
console.log(response.body)
|
|
if (response.ok) {
|
|
return response.json()
|
|
}
|
|
throw "Failed to get application"
|
|
})
|
|
.then((jsonData) => {
|
|
return jsonData.application_files
|
|
})
|
|
}
|
|
|
|
function listAllFiles() {
|
|
const aid = getApplicationId()
|
|
console.log(`Application ID: ${aid}`)
|
|
fetch(`https://personal.uni-graz.at/api/erec/job-applications/procedure/${aid}`)
|
|
.then((response) => {
|
|
console.log(response.statusText)
|
|
if (response.ok) {
|
|
return response.json()
|
|
}
|
|
throw "Failed to get list of applications"
|
|
})
|
|
.then((jsonData) => {
|
|
return Promise.allSettled(jsonData.map(getApplicant))
|
|
})
|
|
}
|
|
|
|
console.log(listAllFiles())
|