fix naming to introduce applicantDetails
This commit is contained in:
parent
e6efcf6dfd
commit
b626c8a818
1 changed files with 10 additions and 13 deletions
23
content.js
23
content.js
|
|
@ -20,10 +20,10 @@ async function getXSRFToken() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getApplicant(applicant, token) {
|
async function getApplicant(applicant, token) {
|
||||||
return getApplicantWithProgress(applicant, token)
|
return getApplicantDetailsWithProgress(applicant, token)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getApplicantWithProgress(applicant, token, onProgress = () => { }) {
|
async function getApplicantDetailsWithProgress(applicant, token, onProgress = () => { }) {
|
||||||
return fetch(`https://personal.uni-graz.at/api/erec/job-applications/${applicant.id}`,
|
return fetch(`https://personal.uni-graz.at/api/erec/job-applications/${applicant.id}`,
|
||||||
{
|
{
|
||||||
credentials: "same-origin",
|
credentials: "same-origin",
|
||||||
|
|
@ -279,12 +279,12 @@ function rip(event) {
|
||||||
progressDialog.initializeApplicant(applicant)
|
progressDialog.initializeApplicant(applicant)
|
||||||
})
|
})
|
||||||
|
|
||||||
const applicantResults = await Promise.allSettled(applicants.map(async (applicant) => {
|
const applicantDetailsResults = await Promise.allSettled(applicants.map(async (applicant) => {
|
||||||
try {
|
try {
|
||||||
const applicantData = await getApplicantWithProgress(applicant, token, ({ downloaded, total, bytes }) => {
|
const applicantDetails = await getApplicantDetailsWithProgress(applicant, token, ({ downloaded, total, bytes }) => {
|
||||||
progressDialog.updateApplicant(applicant, downloaded, total, bytes)
|
progressDialog.updateApplicant(applicant, downloaded, total, bytes)
|
||||||
})
|
})
|
||||||
return applicantData
|
return applicantDetails
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
progressDialog.markApplicantFailed(applicant)
|
progressDialog.markApplicantFailed(applicant)
|
||||||
throw error
|
throw error
|
||||||
|
|
@ -294,23 +294,20 @@ function rip(event) {
|
||||||
progressDialog.setStatus("Creating zip archive...")
|
progressDialog.setStatus("Creating zip archive...")
|
||||||
const zip = new JSZip()
|
const zip = new JSZip()
|
||||||
|
|
||||||
applicantResults.forEach((result) => {
|
applicantDetailsResults.forEach((result) => {
|
||||||
if (result.status !== "fulfilled") {
|
if (result.status !== "fulfilled") {
|
||||||
throw result.reason
|
throw result.reason
|
||||||
}
|
}
|
||||||
|
|
||||||
const applicant = result.value
|
const applicantDetails = result.value
|
||||||
const dirName = `${applicant.last_name}_${applicant.first_name}`
|
// const dirName = `${applicantDetails.last_name}_${applicantDetails.first_name}`
|
||||||
// const dirName = `${sanitizeZipPathSegment(applicant.last_name)}_${sanitizeZipPathSegment(applicant.first_name)}`
|
const dirName = `${sanitizeZipPathSegment(applicantDetails.last_name)}_${sanitizeZipPathSegment(applicantDetails.first_name)}`
|
||||||
const applicantDir = zip.folder(dirName)
|
const applicantDir = zip.folder(dirName)
|
||||||
const files = applicant.application_files ?? []
|
const files = applicantDetails.application_files ?? []
|
||||||
|
|
||||||
files.forEach((afile) => {
|
files.forEach((afile) => {
|
||||||
const ext = afile.file_name.split(".").slice(-1)
|
const ext = afile.file_name.split(".").slice(-1)
|
||||||
const filename = `${afile.field_name}.${ext}`
|
const filename = `${afile.field_name}.${ext}`
|
||||||
// const filename = sanitizeZipPathSegment(afile.file_name)
|
|
||||||
console.log(filename)
|
|
||||||
console.log(afile.blob)
|
|
||||||
applicantDir.file(filename, afile.blob)
|
applicantDir.file(filename, afile.blob)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue