Commit e02c4e2a authored by Pithon Kabiro's avatar Pithon Kabiro
Browse files

Merge branch 'wip_select-sensors-dropdown-list-7' into 'master'

Update logic for drop-down list

Deactivate 'draw chart' button during async task. In addition, improve 
legibilty by replacing multiple if's with 'case' statement

See merge request !18
parents 04eb3a11 559e7982
...@@ -24,6 +24,8 @@ import { drawColumnChartHighcharts } from "./src_modules/chartColumn.mjs"; ...@@ -24,6 +24,8 @@ import { drawColumnChartHighcharts } from "./src_modules/chartColumn.mjs";
import { import {
showLoadingSpinner, showLoadingSpinner,
hideLoadingSpinner, hideLoadingSpinner,
disableDrawChartButton,
enableDrawChartButton,
} from "./src_modules/loadingIndicator.mjs"; } from "./src_modules/loadingIndicator.mjs";
import { vanillaSelectBox } from "./thirdparty/vanillaSelectBox.mjs"; import { vanillaSelectBox } from "./thirdparty/vanillaSelectBox.mjs";
...@@ -138,7 +140,7 @@ const drawChartUsingSelectedOptions = async function () { ...@@ -138,7 +140,7 @@ const drawChartUsingSelectedOptions = async function () {
const selectedOptionsAllDropDownLists = const selectedOptionsAllDropDownLists =
getSelectedOptionsFromAllDropDownLists(); getSelectedOptionsFromAllDropDownLists();
// Note: The aggregation type + duration and chart type are the first and // Note: The chart type amd aggregation type + duration are the first and
// third elements respectively, we have ignored the second and fourth elements // third elements respectively, we have ignored the second and fourth elements
const [selectedChartTypeArr, , selectedAggregationTypeDurationArr] = const [selectedChartTypeArr, , selectedAggregationTypeDurationArr] =
selectedOptionsAllDropDownLists; selectedOptionsAllDropDownLists;
...@@ -178,71 +180,74 @@ const drawChartUsingSelectedOptions = async function () { ...@@ -178,71 +180,74 @@ const drawChartUsingSelectedOptions = async function () {
); );
// Create copies of the arrays of building(s) + data point(s) + sampling rate // Create copies of the arrays of building(s) + data point(s) + sampling rate
const selectedBuildingsDataPointsSamplingRateAbbrevNonComputedCopyArr = [ const selectedBuildingsDataPointsSamplingRateAbbrevRawObsCopyArr = [
...selectedBuildingsDataPointsSamplingRateAbbrevNestedArr, ...selectedBuildingsDataPointsSamplingRateAbbrevNestedArr,
]; ];
const selectedBuildingsDataPointsSamplingRateAbbrevComputedCopyArr = [ const selectedBuildingsDataPointsSamplingRateAbbrevTempDiffCopyArr = [
...selectedBuildingsDataPointsSamplingRateAbbrevNestedArr, ...selectedBuildingsDataPointsSamplingRateAbbrevNestedArr,
]; ];
// Check if we have non-computed // Check if we have raw observations
const selectedBuildingsDataPointsSamplingRateAbbrevNonComputedArr = const selectedBuildingsDataPointsSamplingRateAbbrevRawObsArr =
checkIfSelectedOptionsContainTemperatureDifference( checkIfSelectedOptionsContainTemperatureDifference(
selectedBuildingsDataPointsSamplingRateAbbrevNonComputedCopyArr selectedBuildingsDataPointsSamplingRateAbbrevRawObsCopyArr
) )
? deleteTemperatureDifferenceOptions( ? deleteTemperatureDifferenceOptions(
selectedBuildingsDataPointsSamplingRateAbbrevNonComputedCopyArr selectedBuildingsDataPointsSamplingRateAbbrevRawObsCopyArr
) )
: selectedBuildingsDataPointsSamplingRateAbbrevNonComputedCopyArr; : selectedBuildingsDataPointsSamplingRateAbbrevRawObsCopyArr;
// Check if we have computed / dT // Check if we have dT (temperature difference)
const selectedBuildingsDataPointsSamplingRateAbbrevComputedArr = const selectedBuildingsDataPointsSamplingRateAbbrevTempDiffArr =
checkIfSelectedOptionsContainTemperatureDifference( checkIfSelectedOptionsContainTemperatureDifference(
selectedBuildingsDataPointsSamplingRateAbbrevComputedCopyArr selectedBuildingsDataPointsSamplingRateAbbrevTempDiffCopyArr
) )
? extractTemperatureDifferenceOptions( ? extractTemperatureDifferenceOptions(
selectedBuildingsDataPointsSamplingRateAbbrevComputedCopyArr selectedBuildingsDataPointsSamplingRateAbbrevTempDiffCopyArr
) )
: []; : [];
// Display the loading indicator // Display the loading indicator
showLoadingSpinner(); showLoadingSpinner();
// Fetch the observations + metadata / non-computed // Disable the 'draw chart' button
const observationsPlusMetadataNonComputedArr = disableDrawChartButton();
selectedBuildingsDataPointsSamplingRateAbbrevNonComputedArr.length === 0
// Fetch the observations + metadata / raw observations
const observationsRawPlusMetadataArr =
selectedBuildingsDataPointsSamplingRateAbbrevRawObsArr.length === 0
? [[], []] ? [[], []]
: await getMetadataPlusObservationsFromSingleOrMultipleDatastreams( : await getMetadataPlusObservationsFromSingleOrMultipleDatastreams(
BASE_URL, BASE_URL,
QUERY_PARAMS_COMBINED, QUERY_PARAMS_COMBINED,
selectedBuildingsDataPointsSamplingRateAbbrevNonComputedArr selectedBuildingsDataPointsSamplingRateAbbrevRawObsArr
); );
// Fetch the observations + metadata / computed (dT) // Fetch the observations + metadata / temperature difference (dT)
const observationsPlusMetadataComputedArr = const observationsTempDiffPlusMetadataArr =
selectedBuildingsDataPointsSamplingRateAbbrevComputedArr.length === 0 selectedBuildingsDataPointsSamplingRateAbbrevTempDiffArr.length === 0
? [[], []] ? [[], []]
: await calculateVorlaufMinusRuecklaufTemperature( : await calculateVorlaufMinusRuecklaufTemperature(
BASE_URL, BASE_URL,
QUERY_PARAMS_COMBINED, QUERY_PARAMS_COMBINED,
extractBuildingPlusSamplingRate( extractBuildingPlusSamplingRate(
selectedBuildingsDataPointsSamplingRateAbbrevComputedArr selectedBuildingsDataPointsSamplingRateAbbrevTempDiffArr
) )
); );
// Extract the combined arrays for observations and metadata / non-computed // Extract the combined arrays for observations and metadata / raw observations
const [observationsNestedNonComputedArr, metadataNestedNonComputedArr] = const [observationsRawNestedArr, metadataTempDiffNestedArr] =
observationsPlusMetadataNonComputedArr; observationsRawPlusMetadataArr;
// Extract the combined arrays for observations and metadata / computed (dT) // Extract the combined arrays for observations and metadata / temperature difference (dT)
const [observationsNestedComputedArr, metadataNestedComputedArr] = const [observationsNestedComputedArr, metadataNestedComputedArr] =
observationsPlusMetadataComputedArr; observationsTempDiffPlusMetadataArr;
// Create a combined array of observations and metadata // Create a combined array of observations and metadata
const observationsPlusMetadataCombined = [ const observationsPlusMetadataCombined = [
[...observationsNestedNonComputedArr, ...observationsNestedComputedArr], [...observationsRawNestedArr, ...observationsNestedComputedArr],
[...metadataNestedNonComputedArr, ...metadataNestedComputedArr], [...metadataTempDiffNestedArr, ...metadataNestedComputedArr],
]; ];
const [observationsComboNestedArr, metadataComboNestedArr] = const [observationsComboNestedArr, metadataComboNestedArr] =
...@@ -253,8 +258,8 @@ const drawChartUsingSelectedOptions = async function () { ...@@ -253,8 +258,8 @@ const drawChartUsingSelectedOptions = async function () {
(metadataObj) => formatDatastreamMetadataForChart(metadataObj) (metadataObj) => formatDatastreamMetadataForChart(metadataObj)
); );
// Extract the formatted metadata properties - used by ALL chart types // Extract the formatted metadata properties for the raw observations - used by ALL chart types
const extractedFormattedDatastreamProperties = const rawObservationsExtractedFormattedDatastreamProperties =
extractPropertiesFromFormattedDatastreamMetadata( extractPropertiesFromFormattedDatastreamMetadata(
formattedMetadataNestedArr, formattedMetadataNestedArr,
false false
...@@ -272,111 +277,125 @@ const drawChartUsingSelectedOptions = async function () { ...@@ -272,111 +277,125 @@ const drawChartUsingSelectedOptions = async function () {
const aggregationStartDate = "2020-01-01"; const aggregationStartDate = "2020-01-01";
const aggregationEndDate = "2020-12-31"; const aggregationEndDate = "2020-12-31";
// Extract observations within the user-specified start and end date - used by MULTIPLE chart types // Create final array of observations- used by MULTIPLE chart types
const observationsAggregationNestedArr = observationsComboNestedArr.map( // If we are performing aggregation, it was envisioned that the user would
(obsArr) => // select observations that fall within a start and end date
extractObservationsWithinDatesInterval( const observationsComboNestedFinalArr =
obsArr, selectedAggregationType === "None (raw data)"
"60min", ? observationsComboNestedArr
aggregationStartDate, : observationsComboNestedArr.map((observationsArr) =>
aggregationEndDate extractObservationsWithinDatesInterval(
) observationsArr,
); selectedSamplingRateAbbrev,
aggregationStartDate,
aggregationEndDate
)
);
// Unique calendar dates - used by MULTIPLE chart types // Unique calendar dates - used by MULTIPLE chart types
const uniqueCalendarDatesNestedArr = observationsAggregationNestedArr.map( const uniqueCalendarDatesNestedArr = observationsComboNestedFinalArr.map(
(observationsArr) => (observationsArr) =>
extractUniqueCalendarDatesFromTimestamp(observationsArr) extractUniqueCalendarDatesFromTimestamp(observationsArr)
); );
for (const selectedChartType of selectedChartTypeArr) { for (const selectedChartType of selectedChartTypeArr) {
if (selectedChartType === "Heatmap") { switch (selectedChartType) {
// We are interested in raw observations // We are interested in raw observations ONLY
if ( case "Heatmap":
selectedAggregationOptionsAreValid && if (
selectedBuildingDataPointsOptionsAreValid selectedAggregationOptionsAreValid &&
) { selectedBuildingDataPointsOptionsAreValid
drawHeatmapBasedOnSelectedOptions( ) {
observationsComboNestedArr, drawHeatmapBasedOnSelectedOptions(
extractedFormattedDatastreamProperties observationsComboNestedFinalArr,
); rawObservationsExtractedFormattedDatastreamProperties
}
}
if (selectedChartType === "Scatter Plot") {
// We are interested in raw observations
if (
selectedAggregationOptionsAreValid &&
selectedBuildingDataPointsOptionsAreValid
) {
drawScatterPlotFromChartSelection(
observationsComboNestedArr,
extractedFormattedDatastreamProperties
);
}
}
if (selectedChartType === "Line") {
// We are interested in raw observations or aggregated observations
// Raw observations
if (selectedAggregationType === "None (raw data)") {
// Create formatted array(s) for observations
const formattedRawObservationsLineChartNestedArr =
observationsComboNestedArr.map((observationsArr) =>
formatSensorThingsApiResponseForLineOrColumnChart(observationsArr)
); );
}
drawLineChartHighcharts( break;
formattedRawObservationsLineChartNestedArr,
extractedFormattedDatastreamProperties // We are interested in raw observations ONLY
); case "Scatter Plot":
} if (
// Aggregated observations selectedAggregationOptionsAreValid &&
else { selectedBuildingDataPointsOptionsAreValid
drawLineChartBasedOnSelectedAggregationOptions( ) {
selectedAggregationType, drawScatterPlotFromChartSelection(
selectedAggregationDuration, observationsComboNestedFinalArr,
observationsAggregationNestedArr, rawObservationsExtractedFormattedDatastreamProperties
selectedSamplingRateAbbrev, );
uniqueCalendarDatesNestedArr, }
formattedMetadataNestedArr break;
);
} // We are interested in BOTH raw observations and aggregated observations
} case "Line":
// Raw observations
if (selectedChartType === "Column") { if (selectedAggregationType === "None (raw data)") {
// We are interested in raw observations or aggregated observations // Create formatted array(s) for observations
const formattedRawObservationsLineChartNestedArr =
// Raw observations observationsComboNestedFinalArr.map((observationsArr) =>
if (selectedAggregationType === "None (raw data)") { formatSensorThingsApiResponseForLineOrColumnChart(
// Create formatted array(s) for observations observationsArr
const formattedRawObservationsColumnChartNestedArr = )
observationsComboNestedArr.map((observationsArr) => );
formatSensorThingsApiResponseForLineOrColumnChart(observationsArr)
drawLineChartHighcharts(
formattedRawObservationsLineChartNestedArr,
rawObservationsExtractedFormattedDatastreamProperties
); );
}
// Aggregated observations
else {
drawLineChartBasedOnSelectedAggregationOptions(
selectedAggregationType,
selectedAggregationDuration,
observationsComboNestedFinalArr,
selectedSamplingRateAbbrev,
uniqueCalendarDatesNestedArr,
formattedMetadataNestedArr
);
}
break;
// We are interested in BOTH raw observations and aggregated observations
case "Column":
// Raw observations
if (selectedAggregationType === "None (raw data)") {
// Create formatted array(s) for observations
const formattedRawObservationsColumnChartNestedArr =
observationsComboNestedFinalArr.map((observationsArr) =>
formatSensorThingsApiResponseForLineOrColumnChart(
observationsArr
)
);
drawColumnChartHighcharts(
formattedRawObservationsColumnChartNestedArr,
rawObservationsExtractedFormattedDatastreamProperties
);
}
// Aggregated observations
else {
drawColumnChartBasedOnSelectedAggregationOptions(
selectedAggregationType,
selectedAggregationDuration,
observationsComboNestedFinalArr,
selectedSamplingRateAbbrev,
uniqueCalendarDatesNestedArr,
formattedMetadataNestedArr
);
}
break;
drawColumnChartHighcharts( default:
formattedRawObservationsColumnChartNestedArr, throw new Error("None of the chart type options were selected");
extractedFormattedDatastreamProperties
);
}
// Aggregated observations
else {
drawColumnChartBasedOnSelectedAggregationOptions(
selectedAggregationType,
selectedAggregationDuration,
observationsAggregationNestedArr,
selectedSamplingRateAbbrev,
uniqueCalendarDatesNestedArr,
formattedMetadataNestedArr
);
}
} }
} }
} catch (err) { } catch (err) {
console.error(err); console.error(err);
} finally { } finally {
// Enable the 'draw chart' button
enableDrawChartButton();
// Hide the loading indicator // Hide the loading indicator
hideLoadingSpinner(); hideLoadingSpinner();
} }
......
...@@ -5,6 +5,16 @@ import { ...@@ -5,6 +5,16 @@ import {
extractObservationValuesWithinMonthInterval, extractObservationValuesWithinMonthInterval,
} from "./aggregateHelpers.mjs"; } from "./aggregateHelpers.mjs";
/**
* Remove `null` observation values from an array of observation values
*
* @param {Array} obsValuesArr An array of observation values
* @returns {Array} An array with `null` observation values removed
*/
const filterOutNullObservationValues = function (obsValuesArr) {
return obsValuesArr.filter((obs) => obs !== null);
};
/** /**
* Calculate the minimum observation values that fall within a time interval delimited by a start date and end date * Calculate the minimum observation values that fall within a time interval delimited by a start date and end date
* @param {Array} obsValuesForDaysIntervalArr An array of observation values that fall within our time interval * @param {Array} obsValuesForDaysIntervalArr An array of observation values that fall within our time interval
...@@ -13,7 +23,10 @@ import { ...@@ -13,7 +23,10 @@ import {
const calculateMinimumObservationValuesWithinDatesInterval = function ( const calculateMinimumObservationValuesWithinDatesInterval = function (
obsValuesForDaysIntervalArr obsValuesForDaysIntervalArr
) { ) {
return Math.min(...obsValuesForDaysIntervalArr); // If the observation value is `null`, skip the calculation
return obsValuesForDaysIntervalArr.reduce((previousValue, obsValue) =>
obsValue === null ? null : Math.min(previousValue, obsValue)
);
}; };
/** /**
...@@ -24,7 +37,10 @@ const calculateMinimumObservationValuesWithinDatesInterval = function ( ...@@ -24,7 +37,10 @@ const calculateMinimumObservationValuesWithinDatesInterval = function (
const calculateMaximumObservationValuesWithinDatesInterval = function ( const calculateMaximumObservationValuesWithinDatesInterval = function (
obsValuesForDaysIntervalArr obsValuesForDaysIntervalArr
) { ) {
return Math.max(...obsValuesForDaysIntervalArr); // If the observation value is `null`, skip the calculation
return obsValuesForDaysIntervalArr.reduce((previousValue, obsValue) =>
obsValue === null ? null : Math.max(previousValue, obsValue)
);
}; };
/** /**
...@@ -35,8 +51,10 @@ const calculateMaximumObservationValuesWithinDatesInterval = function ( ...@@ -35,8 +51,10 @@ const calculateMaximumObservationValuesWithinDatesInterval = function (
const calculateSumOfObservationValuesWithinDatesInterval = function ( const calculateSumOfObservationValuesWithinDatesInterval = function (
obsValuesForDaysIntervalArr obsValuesForDaysIntervalArr
) { ) {
return obsValuesForDaysIntervalArr.reduce( // Remove the `null` observation values before calculating the sum
(accumulator, obsValue) => accumulator + obsValue return filterOutNullObservationValues(obsValuesForDaysIntervalArr).reduce(
(previousValue, obsValue) => previousValue + obsValue,
0
); );
}; };
...@@ -48,10 +66,11 @@ const calculateSumOfObservationValuesWithinDatesInterval = function ( ...@@ -48,10 +66,11 @@ const calculateSumOfObservationValuesWithinDatesInterval = function (
const calculateAverageOfObservationValuesWithinDatesInterval = function ( const calculateAverageOfObservationValuesWithinDatesInterval = function (
obsValuesForDaysIntervalArr obsValuesForDaysIntervalArr
) { ) {
// The observation values array should only include non-`null` values
return ( return (
calculateSumOfObservationValuesWithinDatesInterval( calculateSumOfObservationValuesWithinDatesInterval(
obsValuesForDaysIntervalArr obsValuesForDaysIntervalArr
) / obsValuesForDaysIntervalArr.length ) / filterOutNullObservationValues(obsValuesForDaysIntervalArr).length
); );
}; };
...@@ -63,7 +82,10 @@ const calculateAverageOfObservationValuesWithinDatesInterval = function ( ...@@ -63,7 +82,10 @@ const calculateAverageOfObservationValuesWithinDatesInterval = function (
const calculateMinimumObservationValuesWithinMonthInterval = function ( const calculateMinimumObservationValuesWithinMonthInterval = function (
obsValuesForMonthIntervalArr obsValuesForMonthIntervalArr
) { ) {
return Math.min(...obsValuesForMonthIntervalArr); // If the observation value is `null`, skip the calculation
return obsValuesForMonthIntervalArr.reduce((previousValue, obsValue) =>
obsValue === null ? null : Math.min(previousValue, obsValue)
);
}; };
/** /**
...@@ -74,7 +96,10 @@ const calculateMinimumObservationValuesWithinMonthInterval = function ( ...@@ -74,7 +96,10 @@ const calculateMinimumObservationValuesWithinMonthInterval = function (
const calculateMaximumObservationValuesWithinMonthInterval = function ( const calculateMaximumObservationValuesWithinMonthInterval = function (
obsValuesForMonthIntervalArr obsValuesForMonthIntervalArr
) { ) {
return Math.max(...obsValuesForMonthIntervalArr); // If the observation value is `null`, skip the calculation
return obsValuesForMonthIntervalArr.reduce((previousValue, obsValue) =>
obsValue === null ? null : Math.max(previousValue, obsValue)
);
}; };
/** /**
...@@ -85,8 +110,10 @@ const calculateMaximumObservationValuesWithinMonthInterval = function ( ...@@ -85,8 +110,10 @@ const calculateMaximumObservationValuesWithinMonthInterval = function (
const calculateSumOfObservationValuesWithinMonthInterval = function ( const calculateSumOfObservationValuesWithinMonthInterval = function (
obsValuesForMonthIntervalArr obsValuesForMonthIntervalArr
) { ) {
return obsValuesForMonthIntervalArr.reduce( // Remove the `null` observation values before calculating the sum
(accumulator, obsValue) => accumulator + obsValue return filterOutNullObservationValues(obsValuesForMonthIntervalArr).reduce(
(previousValue, obsValue) => previousValue + obsValue,
0
); );
}; };
...@@ -98,10 +125,11 @@ const calculateSumOfObservationValuesWithinMonthInterval = function ( ...@@ -98,10 +125,11 @@ const calculateSumOfObservationValuesWithinMonthInterval = function (
const calculateAverageOfObservationValuesWithinMonthInterval = function ( const calculateAverageOfObservationValuesWithinMonthInterval = function (
obsValuesForMonthIntervalArr obsValuesForMonthIntervalArr
) { ) {
// The observation values array should only include non-`null` values
return ( return (
calculateSumOfObservationValuesWithinMonthInterval( calculateSumOfObservationValuesWithinMonthInterval(
obsValuesForMonthIntervalArr obsValuesForMonthIntervalArr
) / obsValuesForMonthIntervalArr.length ) / filterOutNullObservationValues(obsValuesForMonthIntervalArr).length
); );
}; };
......
...@@ -131,10 +131,12 @@ const drawColumnChartHighcharts = function ( ...@@ -131,10 +131,12 @@ const drawColumnChartHighcharts = function (
title: { title: {
text: textChartTitle, text: textChartTitle,
"align": "center",
}, },
subtitle: { subtitle: {
text: textChartSubtitle, text: textChartSubtitle,
"align": "center",
}, },
xAxis: { xAxis: {
...@@ -143,7 +145,6 @@ const drawColumnChartHighcharts = function ( ...@@ -143,7 +145,6 @@ const drawColumnChartHighcharts = function (
}, },
yAxis: { yAxis: {
min: 0,
title: { title: {
text: `${phenomenonName} [${unitOfMeasurementSymbol}]`, text: `${phenomenonName} [${unitOfMeasurementSymbol}]`,
}, },
...@@ -155,10 +156,10 @@ const drawColumnChartHighcharts = function ( ...@@ -155,10 +156,10 @@ const drawColumnChartHighcharts = function (
// this.x -- common for all points // this.x -- common for all points
// this.points -- an array containing properties for each series // this.points -- an array containing properties for each series
// Note that our `reduce` method is in this format: // Note that our `reduce` method is in this format:
// ((accumulator, currentValue, currentIndex) => {...}, initialValue) // ((previousValue, currentValue, currentIndex) => {...}, initialValue)
return this.points.reduce( return this.points.reduce(
(accumulator, point, i) => (previousValue, point, i) =>
`${accumulator} <br/> <span style="color:${point.color}">${ `${previousValue} <br/> <span style="color:${point.color}">${
point.series.name point.series.name
}</span>: <b>${point.y.toFixed(2)} ${ }</span>: <b>${point.y.toFixed(2)} ${
unitOfMeasurementSymbolsArr[i] unitOfMeasurementSymbolsArr[i]
......
...@@ -48,7 +48,8 @@ const calculateMinMaxValuesForHeatmapColorAxis = function ( ...@@ -48,7 +48,8 @@ const calculateMinMaxValuesForHeatmapColorAxis = function (
const maxValue = Math.trunc(Math.max(...obsValueArr)); const maxValue = Math.trunc(Math.max(...obsValueArr));
// Calculate the closest multiple of 5 // Calculate the closest multiple of 5
const minObsValue = minValue - (minValue % 5); const minObsValue =
minValue > 0 ? minValue - (minValue % 5) : minValue + (minValue % 5);
const maxObsValue = maxValue + (5 - (maxValue % 5)); const maxObsValue = maxValue + (5 - (maxValue % 5));
return { minObsValue, maxObsValue }; return { minObsValue, maxObsValue };
...@@ -98,13 +99,13 @@ const drawHeatMapHighcharts = function ( ...@@ -98,13 +99,13 @@ const drawHeatMapHighcharts = function (
title: { title: {
text: TEXT_CHART_TITLE, text: TEXT_CHART_TITLE,
align: "left", align: "center",
x: 40, x: 40,
}, },
subtitle: { subtitle: {
text: TEXT_CHART_SUBTITLE, text: TEXT_CHART_SUBTITLE,
align: "left", align: "center",
x: 40, x: 40,
}, },
......
...@@ -134,12 +134,12 @@ const drawLineChartHighcharts = function ( ...@@ -134,12 +134,12 @@ const drawLineChartHighcharts = function (
title: { title: {
text: textChartTitle, text: textChartTitle,
"align": "left", "align": "center",
}, },
subtitle: { subtitle: {
text: textChartSubtitle, text: textChartSubtitle,
align: "left", align: "center",
}, },
tooltip: { tooltip: {
......
...@@ -231,12 +231,12 @@ const drawScatterPlotHighcharts = function ( ...@@ -231,12 +231,12 @@ const drawScatterPlotHighcharts = function (
title: { title: {
text: CHART_TITLE, text: CHART_TITLE,
"align": "left", "align": "center",
}, },
subtitle: { subtitle: {
text: CHART_SUBTITLE, text: CHART_SUBTITLE,
"align": "left", "align": "center",
}, },
xAxis: { xAxis: {
......
"use strict";
/** /**
* Get the selected option(s) from a dropdown list * Get the selected option(s) from a dropdown list
* *
......
"use strict";
import { drawLineChartHighcharts } from "./chartLine.mjs"; import { drawLineChartHighcharts } from "./chartLine.mjs";
import { import {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* Show a loading indicator at the start of an async task. The indicator consists of a spinner and a transluscent mask placed on top of page elements * Show a loading indicator at the start of an async task. The indicator consists of a spinner and a transluscent mask placed on top of page elements
* @returns {undefined} * @returns {undefined} undefined
*/ */
const showLoadingSpinner = function () { const showLoadingSpinner = function () {
const loadingIndicatorMask = document.querySelector("#loadingIndicator"); const loadingIndicatorMask = document.querySelector("#loadingIndicator");
...@@ -14,7 +14,7 @@ const showLoadingSpinner = function () { ...@@ -14,7 +14,7 @@ const showLoadingSpinner = function () {
/** /**
* Hide the loading indicator after completion of the async tasks * Hide the loading indicator after completion of the async tasks
* @returns {undefined} * @returns {undefined} undefined
*/ */
const hideLoadingSpinner = function () { const hideLoadingSpinner = function () {
const loadingIndicatorMask = document.querySelector("#loadingIndicator"); const loadingIndicatorMask = document.querySelector("#loadingIndicator");
...@@ -24,4 +24,27 @@ const hideLoadingSpinner = function () { ...@@ -24,4 +24,27 @@ const hideLoadingSpinner = function () {
loadingIconSpinner.style.display = "none"; loadingIconSpinner.style.display = "none";
}; };
export { showLoadingSpinner, hideLoadingSpinner }; /**
* Disable the button used to trigger the drawing of charts
*
* @returns {undefined} undefined
*/
const disableDrawChartButton = function () {
document.querySelector("#btn-draw-chart").disabled = true;
};
/**
* Enable the button used to trigger the drawing of charts
*
* @returns {undefined} undefined
*/
const enableDrawChartButton = function () {
document.querySelector("#btn-draw-chart").disabled = false;
};
export {
showLoadingSpinner,
hideLoadingSpinner,
disableDrawChartButton,
enableDrawChartButton,
};
/*! /*!
* Start Bootstrap - SB Admin v6.0.2 (https://startbootstrap.com/template/sb-admin) * Start Bootstrap - SB Admin v7.0.3 (https://startbootstrap.com/template/sb-admin)
* Copyright 2013-2020 Start Bootstrap * Copyright 2013-2021 Start Bootstrap
* Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-sb-admin/blob/master/LICENSE) * Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-sb-admin/blob/master/LICENSE)
*/ */
(function($) { //
"use strict"; // Scripts
//
// Add active state to sidbar nav links window.addEventListener("DOMContentLoaded", (event) => {
var path = window.location.href; // because the 'href' property of the DOM element is the absolute path // Toggle the side navigation
$("#layoutSidenav_nav .sb-sidenav a.nav-link").each(function() { const sidebarToggle = document.body.querySelector("#sidebarToggle");
if (this.href === path) { if (sidebarToggle) {
$(this).addClass("active"); // Uncomment Below to persist sidebar toggle between refreshes
} // if (localStorage.getItem('sb|sidebar-toggle') === 'true') {
}); // document.body.classList.toggle('sb-sidenav-toggled');
// }
// Toggle the side navigation sidebarToggle.addEventListener("click", (event) => {
$("#sidebarToggle").on("click", function(e) { event.preventDefault();
e.preventDefault(); document.body.classList.toggle("sb-sidenav-toggled");
$("body").toggleClass("sb-sidenav-toggled"); localStorage.setItem(
"sb|sidebar-toggle",
document.body.classList.contains("sb-sidenav-toggled")
);
}); });
})(jQuery); }
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment