Applicant archive
+Select a file on the left to preview it here.
+diff --git a/content.js b/content.js index e22537f..42dfbf6 100644 --- a/content.js +++ b/content.js @@ -138,7 +138,8 @@ const CSV_FIELDS = [ "comment", "hearing_videos_link", "dir_name", - "details_url" + "details_url", + "files_json" ] function getApplicantDirectoryName(applicantDetails) { @@ -149,6 +150,29 @@ function getApplicantDetailsUrl(applicantId) { return `https://personal.uni-graz.at/#/applicants/record/${applicantId}` } +function getApplicantArchiveFileName(afile) { + const sourceName = String(afile.file_name ?? "") + const extension = sourceName.includes(".") + ? `.${sanitizeZipPathSegment(sourceName.split(".").slice(-1)[0], "file")}` + : "" + const baseName = sanitizeZipPathSegment(afile.field_name ?? afile.file_name, "file") + return `${baseName}${extension}` +} + +function getApplicantArchiveFiles(applicantDetails) { + const dirName = getApplicantDirectoryName(applicantDetails) + const files = applicantDetails.application_files ?? [] + + return files.map((afile) => { + const fileName = getApplicantArchiveFileName(afile) + + return { + fileName, + relativePath: `${dirName}/${fileName}` + } + }) +} + function getApplicantCsvValue(applicantDetails, fieldName) { if (fieldName === "dir_name") { return getApplicantDirectoryName(applicantDetails) @@ -158,6 +182,10 @@ function getApplicantCsvValue(applicantDetails, fieldName) { return getApplicantDetailsUrl(applicantDetails.id) } + if (fieldName === "files_json") { + return JSON.stringify(getApplicantArchiveFiles(applicantDetails)) + } + if (fieldName === "job_procedure") { return applicantDetails.job_procedure?.date_entered ?? "" } @@ -191,6 +219,381 @@ function createApplicantsCsv(applicantDetailsList) { return rows.join("\n") } +function createApplicantsIndexHtml() { + return ` + +
+ + +Select a file on the left to preview it here.
+