diff --git a/public/index.html b/public/index.html index 10807a7ec4c88601a834bdc2bec8257520aeead7..789d4ecba0c66ed2c656b75c7ce0c902c420fecf 100644 --- a/public/index.html +++ b/public/index.html @@ -65,6 +65,9 @@ <!-- vanillaSelectBox --> <link href="./css/thirdparty/vanillaSelectBox.css" rel="stylesheet" /> + <!-- SweetAlert --> + <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script> + <!-- Custom JS --> <script defer type="module" src="./js/appCesium.js"></script> diff --git a/public/js/appChart.js b/public/js/appChart.js index de1a5cf09344c929bda931cc28306ef5e7b6bd41..c3a7f6a73d656f3f49671b115c25654e5dee848b 100644 --- a/public/js/appChart.js +++ b/public/js/appChart.js @@ -40,6 +40,7 @@ import { checkIfSelectedBuildingDataPointsOptionsAreValid, checkIfSelectedAggregationOptionsAreValid, getAbbreviationsForSelectedOptionsFromAllDropDownLists, + createErrorPopupMessage, } from "./src_modules/dropDownListHelpers.mjs"; import { drawColumnChartBasedOnSelectedOptions } from "./src_modules/dropDownListChartColumn.mjs"; @@ -256,8 +257,8 @@ const drawChartUsingSelectedOptions = async function () { } catch (err) { console.error(err); - // Display a dialog window with the error message - alert(err); + // Display a popup that displays the error message + createErrorPopupMessage(err); } finally { // Enable the 'draw chart' button enableDrawChartButton(); diff --git a/public/js/src_modules/dropDownListHelpers.mjs b/public/js/src_modules/dropDownListHelpers.mjs index bb37a61cfd798d97a079b2723cf287b03189a1e4..1231b4ed419fef34f30f1267042ad3cdb1e8002e 100644 --- a/public/js/src_modules/dropDownListHelpers.mjs +++ b/public/js/src_modules/dropDownListHelpers.mjs @@ -471,6 +471,20 @@ const getAbbreviationsForSelectedOptionsFromAllDropDownLists = function ( } }; +/** + * Create a pop up message (when an error is thrown) using the SweetAlert library + * + * @param {Object} errorObj An error object + * @returns {undefined} undefined + */ +const createErrorPopupMessage = function (errorObj) { + swal({ + title: "Something went wrong!", + text: `${errorObj.message}`, + icon: "error", + }); +}; + export { splitMultipleOptionsTextDelimitedBySlash, getSelectedOptionsFromAllDropDownLists, @@ -481,4 +495,5 @@ export { checkIfSelectedBuildingDataPointsOptionsAreValid, checkIfSelectedAggregationOptionsAreValid, getAbbreviationsForSelectedOptionsFromAllDropDownLists, + createErrorPopupMessage, };