starting to make prrByVaccineTable downloadable
This commit is contained in:
@@ -5,8 +5,8 @@ class PageInitializer {
|
|||||||
PageInitializer.#configureVaccine(vaccine);
|
PageInitializer.#configureVaccine(vaccine);
|
||||||
}
|
}
|
||||||
|
|
||||||
static #configureSymptom({ symptomSelectElement, prrByVaccineTableElement }) {
|
static #configureSymptom({ symptomSelectElement, prrByVaccineTableElement, downloadPrrByVaccineTableButton }) {
|
||||||
const prrByVaccineTableView = new PrrByVaccineTableView(prrByVaccineTableElement);
|
const prrByVaccineTableView = new PrrByVaccineTableView(prrByVaccineTableElement, downloadPrrByVaccineTableButton);
|
||||||
PageInitializer.#initializeSelectElement(
|
PageInitializer.#initializeSelectElement(
|
||||||
{
|
{
|
||||||
selectElement: symptomSelectElement,
|
selectElement: symptomSelectElement,
|
||||||
|
|||||||
@@ -1,15 +1,34 @@
|
|||||||
class PrrByVaccineTableView {
|
class PrrByVaccineTableView {
|
||||||
|
|
||||||
#prrByVaccineTable;
|
#prrByVaccineTable;
|
||||||
|
#prrByVaccine;
|
||||||
|
#symptom;
|
||||||
|
|
||||||
constructor(prrByVaccineTableElement) {
|
constructor(prrByVaccineTableElement, downloadPrrByVaccineTableButton) {
|
||||||
this.#prrByVaccineTable = new PrrByVaccineTable(prrByVaccineTableElement);
|
this.#prrByVaccineTable = new PrrByVaccineTable(prrByVaccineTableElement);
|
||||||
this.#prrByVaccineTable.initialize();
|
this.#prrByVaccineTable.initialize();
|
||||||
|
downloadPrrByVaccineTableButton.addEventListener(
|
||||||
|
'click',
|
||||||
|
() => this.#downloadPrrByVaccine())
|
||||||
}
|
}
|
||||||
|
|
||||||
displayPrrByVaccineTable4Symptom(symptom) {
|
displayPrrByVaccineTable4Symptom(symptom) {
|
||||||
PrrByVaccineProvider
|
PrrByVaccineProvider
|
||||||
.getPrrByVaccine(symptom)
|
.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) {
|
static isSearchParamYES(urlParams, searchParam) {
|
||||||
return UIUtils.getSearchParam(urlParams, searchParam, 'NO').toUpperCase() == 'YES';
|
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