batchCodes.html?showCountriesColumn=yes or batchCodes.html?showCountriesColumn=no

This commit is contained in:
frankknoll
2023-06-09 22:47:21 +02:00
parent 39d4e47314
commit 79156123d7
4 changed files with 15 additions and 10 deletions

View File

@@ -1,11 +1,11 @@
class BatchCodeTableInitializer { class BatchCodeTableInitializer {
initialize({ batchCodeTableElement, showCountries }) { initialize({ batchCodeTableElement, showCountriesColumn }) {
// FK-TODO: show "Loading.." message or spinning wheel. // FK-TODO: show "Loading.." message or spinning wheel.
this.#loadBarChartDescriptions(showCountries) this.#loadBarChartDescriptions(showCountriesColumn)
.then(barChartDescriptions => { .then(barChartDescriptions => {
const batchCodeTable = this.#createEmptyBatchCodeTable(batchCodeTableElement, showCountries, barChartDescriptions); const batchCodeTable = this.#createEmptyBatchCodeTable(batchCodeTableElement, showCountriesColumn, barChartDescriptions);
this.#setVisibilityOfCountriesColumn(batchCodeTable, showCountries); this.#setVisibilityOfCountriesColumn(batchCodeTable, showCountriesColumn);
fetch('data/batchCodeTables/Global.json') fetch('data/batchCodeTables/Global.json')
.then(response => response.json()) .then(response => response.json())
.then(json => { .then(json => {
@@ -25,7 +25,7 @@ class BatchCodeTableInitializer {
Promise.resolve({}); Promise.resolve({});
} }
#createEmptyBatchCodeTable(batchCodeTableElement, showCountries, barChartDescriptions) { #createEmptyBatchCodeTable(batchCodeTableElement, showCountriesColumn, barChartDescriptions) {
return batchCodeTableElement.DataTable( return batchCodeTableElement.DataTable(
{ {
language: language:
@@ -78,7 +78,7 @@ class BatchCodeTableInitializer {
return null; return null;
}, },
createdCell: (cell, cellData, row, rowIndex, colIndex) => { createdCell: (cell, cellData, row, rowIndex, colIndex) => {
if (showCountries) { if (showCountriesColumn) {
this.#displayBatchcodeByCountryBarChart( this.#displayBatchcodeByCountryBarChart(
row[this.#getColumnIndex('Batch')], row[this.#getColumnIndex('Batch')],
barChartDescriptions, barChartDescriptions,
@@ -124,10 +124,10 @@ class BatchCodeTableInitializer {
} }
} }
#setVisibilityOfCountriesColumn(batchCodeTable, showCountries) { #setVisibilityOfCountriesColumn(batchCodeTable, showCountriesColumn) {
batchCodeTable batchCodeTable
.column(this.#getColumnIndex('Countries')) .column(this.#getColumnIndex('Countries'))
.visible(showCountries); .visible(showCountriesColumn);
} }
#addCountriesColumn(json) { #addCountriesColumn(json) {

View File

@@ -58,4 +58,10 @@ class UIUtils {
} }
} }
} }
static getSearchParam(urlParams, searchParam, defaultValue) {
return urlParams.has(searchParam) ?
urlParams.get(searchParam) :
defaultValue;
}
} }

View File

@@ -40,7 +40,7 @@
new BatchCodeTableInitializer().initialize( new BatchCodeTableInitializer().initialize(
{ {
batchCodeTableElement: $('#batchCodeTable'), batchCodeTableElement: $('#batchCodeTable'),
showCountries: false showCountriesColumn: UIUtils.getSearchParam(new URLSearchParams(window.location.search), 'showCountriesColumn', '').toUpperCase() == 'YES'
}); });
}); });
</script> </script>

View File

@@ -5,7 +5,6 @@ FK-FIXME:
FK-TODO: FK-TODO:
- add google captcha to batchCodeTable.html - add google captcha to batchCodeTable.html
- Symptomhistogramm - Symptomhistogramm
- batchCodes.html?showCountries=yes oder batchCodes.html?showCountries=no als Default dazufügen.
anacron job: anacron job:
sudo cp src/intensivstationen_howbadismybatch.sh /etc/cron.daily/intensivstationen_howbadismybatch sudo cp src/intensivstationen_howbadismybatch.sh /etc/cron.daily/intensivstationen_howbadismybatch