starting to make prrByVaccineTable downloadable
This commit is contained in:
@@ -5,8 +5,8 @@ class PageInitializer {
|
||||
PageInitializer.#configureVaccine(vaccine);
|
||||
}
|
||||
|
||||
static #configureSymptom({ symptomSelectElement, prrByVaccineTableElement }) {
|
||||
const prrByVaccineTableView = new PrrByVaccineTableView(prrByVaccineTableElement);
|
||||
static #configureSymptom({ symptomSelectElement, prrByVaccineTableElement, downloadPrrByVaccineTableButton }) {
|
||||
const prrByVaccineTableView = new PrrByVaccineTableView(prrByVaccineTableElement, downloadPrrByVaccineTableButton);
|
||||
PageInitializer.#initializeSelectElement(
|
||||
{
|
||||
selectElement: symptomSelectElement,
|
||||
|
||||
@@ -1,15 +1,34 @@
|
||||
class PrrByVaccineTableView {
|
||||
|
||||
#prrByVaccineTable;
|
||||
#prrByVaccine;
|
||||
#symptom;
|
||||
|
||||
constructor(prrByVaccineTableElement) {
|
||||
constructor(prrByVaccineTableElement, downloadPrrByVaccineTableButton) {
|
||||
this.#prrByVaccineTable = new PrrByVaccineTable(prrByVaccineTableElement);
|
||||
this.#prrByVaccineTable.initialize();
|
||||
downloadPrrByVaccineTableButton.addEventListener(
|
||||
'click',
|
||||
() => this.#downloadPrrByVaccine())
|
||||
}
|
||||
|
||||
displayPrrByVaccineTable4Symptom(symptom) {
|
||||
PrrByVaccineProvider
|
||||
.getPrrByVaccine(symptom)
|
||||
.then(prrByVaccine => this.#prrByVaccineTable.display(prrByVaccine));
|
||||
.then(prrByVaccine => {
|
||||
this.#prrByVaccine = prrByVaccine;
|
||||
this.#symptom = symptom;
|
||||
this.#prrByVaccineTable.display(prrByVaccine);
|
||||
});
|
||||
}
|
||||
|
||||
#downloadPrrByVaccine() {
|
||||
UIUtils.downloadUrlAsFilename(
|
||||
window.URL.createObjectURL(
|
||||
new Blob(
|
||||
[Utils.convertDict2CSV(this.#prrByVaccine)],
|
||||
{ type: 'text/csv' })),
|
||||
this.#symptom
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,4 +68,11 @@ class UIUtils {
|
||||
static isSearchParamYES(urlParams, searchParam) {
|
||||
return UIUtils.getSearchParam(urlParams, searchParam, 'NO').toUpperCase() == 'YES';
|
||||
}
|
||||
|
||||
static downloadUrlAsFilename(url, filename) {
|
||||
const a = document.createElement('a');
|
||||
a.setAttribute('href', url);
|
||||
a.setAttribute('download', filename);
|
||||
a.click();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user