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

New function: create error popup message

Use a third-party library 'SweetAlert' to create popup messages when
errors are thrown as a result of attempting to draw charts
parent fe44753a
......@@ -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>
......
......@@ -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();
......
......@@ -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,
};
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