From baaac31f1cafba4167f14983a5440586e9ee201c Mon Sep 17 00:00:00 2001 From: frankknoll Date: Sun, 12 Feb 2023 18:34:13 +0100 Subject: [PATCH] displaying histograms for each country and batchcode --- docs/HistoDescrsProvider.js | 4 +- docs/HistogramView.js | 8 +- docs/batchCodeTable.html | 258 ++++++++++++++++++++++++++---------- docs/batchCodeTable.js | 21 ++- 4 files changed, 205 insertions(+), 86 deletions(-) diff --git a/docs/HistoDescrsProvider.js b/docs/HistoDescrsProvider.js index 4c9032628e9..eda30dcd04d 100644 --- a/docs/HistoDescrsProvider.js +++ b/docs/HistoDescrsProvider.js @@ -1,7 +1,7 @@ class HistoDescrsProvider { - static getHistoDescrsForBatchcode(batchcode) { - return fetch(`data/histograms/global/${batchcode}.json`) + static getHistoDescrs(country, batchcode) { + return fetch(`data/histograms/${country}/${batchcode}.json`) .then(response => response.json()) .then(histoDescrs => { histoDescrs.histograms.sort((histoDescr1, histoDescr2) => histoDescr1.batchcodes.length - histoDescr2.batchcodes.length); diff --git a/docs/HistogramView.js b/docs/HistogramView.js index 21352a9527b..79863b44eb0 100644 --- a/docs/HistogramView.js +++ b/docs/HistogramView.js @@ -6,17 +6,17 @@ class HistogramView { this.#uiContainer = uiContainer } - displayHistogramViewForBatchcode(batchcode) { + displayHistogramView(country, batchcode) { this - .#loadHistoDescrsForBatchcode(batchcode) + .#loadHistoDescrs(country, batchcode) .then(histoDescrs => this.#displayHistogramViewForHistoDescrs(histoDescrs)); } - #loadHistoDescrsForBatchcode(batchcode) { + #loadHistoDescrs(country, batchcode) { const loadingText = document.createTextNode('Loading...'); this.#uiContainer.appendChild(loadingText); return HistoDescrsProvider - .getHistoDescrsForBatchcode(batchcode) + .getHistoDescrs(country, batchcode) .then(histoDescrs => { loadingText.remove(); return histoDescrs; diff --git a/docs/batchCodeTable.html b/docs/batchCodeTable.html index 21da7dc6328..94eafa5e55c 100644 --- a/docs/batchCodeTable.html +++ b/docs/batchCodeTable.html @@ -1,26 +1,33 @@ + - - -Batch Codes of Coronavirus 2019 Vaccines - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + -Fork me on GitHub -

Batch Codes of Coronavirus 2019 Vaccines

-

- -

-

-

-Check out your batch code (Last updated: February 10, 2023) + Fork me on GitHub +

Batch Codes of Coronavirus 2019 Vaccines

+

+

- - - - - - - - - - - - - - - -
BatchAdverse Reaction ReportsDeathsDisabilitiesLife Threatening IllnessesCompanyCountriesSevere reportsLethality
-

Data Source: -Vaccine Adverse Event Reporting System +

+

+ Check out your batch code (Last updated: February 10, 2023) +

+ + + + + + + + + + + + + + + +
BatchAdverse Reaction ReportsDeathsDisabilitiesLife Threatening IllnessesCompanyCountriesSevere reportsLethality
+

Data Source: + Vaccine Adverse Event Reporting System (VAERS) -

- - + + \ No newline at end of file diff --git a/docs/batchCodeTable.js b/docs/batchCodeTable.js index 037d0ca83dc..cdc99ab030a 100644 --- a/docs/batchCodeTable.js +++ b/docs/batchCodeTable.js @@ -15,11 +15,15 @@ class BatchCodeTableInitializer { initialize() { this.#batchCodeTable = this.#createEmptyBatchCodeTable(); this.#columnSearch = new ColumnSearch(this.#batchCodeTable.column(this.#getColumnIndex('Company'))); - this.#countrySelect.addEventListener('change', event => this.#displayCountry(event.target.value)); - this.#displayCountry('Global'); + this.#countrySelect.addEventListener('change', event => this.#displayCountry()); + this.#displayCountry(); this.#initializeHistogramView(); } + #getCountry() { + return UIUtils.getSelectedOption(this.#countrySelect).value; + } + #createEmptyBatchCodeTable() { return this.#batchCodeTableElement.DataTable( { @@ -95,10 +99,10 @@ class BatchCodeTableInitializer { } } - #displayCountry(country) { - this.#heading.textContent = country == 'Global' ? 'Global Batch Codes' : `Batch Codes for ${country}`; + #displayCountry() { + this.#heading.textContent = this.#getCountry() == 'Global' ? 'Global Batch Codes' : `Batch Codes for ${this.#getCountry()}`; // FK-TODO: show "Loading.." message or spinning wheel. - fetch(`data/batchCodeTables/${country}.json`) + fetch(`data/batchCodeTables/${this.#getCountry()}.json`) .then(response => response.json()) .then(json => { this.#_addEmptyControlColumn(json); @@ -108,7 +112,6 @@ class BatchCodeTableInitializer { this.#setTableRows(json.data); this.#columnSearch.columnContentUpdated(); this.#selectInput(); - this.#displayControlColumn(country == 'Global'); }); } @@ -130,10 +133,6 @@ class BatchCodeTableInitializer { input.select(); } - #displayControlColumn(isVisible) { - this.#batchCodeTable.column(this.#getColumnIndex('control')).visible(isVisible); - } - #initializeHistogramView() { const thisClassInstance = this; $(`#${this.#batchCodeTableElement[0].id} tbody`).on( @@ -150,7 +149,7 @@ class BatchCodeTableInitializer { row.child(uiContainer).show(); tr.addClass('shown'); const batchcode = row.data()[thisClassInstance.#getColumnIndex('Batch')]; - new HistogramView(uiContainer).displayHistogramViewForBatchcode(batchcode); + new HistogramView(uiContainer).displayHistogramView(thisClassInstance.#getCountry(), batchcode); } }); }