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 @@ ...@@ -65,6 +65,9 @@
<!-- vanillaSelectBox --> <!-- vanillaSelectBox -->
<link href="./css/thirdparty/vanillaSelectBox.css" rel="stylesheet" /> <link href="./css/thirdparty/vanillaSelectBox.css" rel="stylesheet" />
<!-- SweetAlert -->
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<!-- <!--
Custom JS --> Custom JS -->
<script defer type="module" src="./js/appCesium.js"></script> <script defer type="module" src="./js/appCesium.js"></script>
......
...@@ -40,6 +40,7 @@ import { ...@@ -40,6 +40,7 @@ import {
checkIfSelectedBuildingDataPointsOptionsAreValid, checkIfSelectedBuildingDataPointsOptionsAreValid,
checkIfSelectedAggregationOptionsAreValid, checkIfSelectedAggregationOptionsAreValid,
getAbbreviationsForSelectedOptionsFromAllDropDownLists, getAbbreviationsForSelectedOptionsFromAllDropDownLists,
createErrorPopupMessage,
} from "./src_modules/dropDownListHelpers.mjs"; } from "./src_modules/dropDownListHelpers.mjs";
import { drawColumnChartBasedOnSelectedOptions } from "./src_modules/dropDownListChartColumn.mjs"; import { drawColumnChartBasedOnSelectedOptions } from "./src_modules/dropDownListChartColumn.mjs";
...@@ -256,8 +257,8 @@ const drawChartUsingSelectedOptions = async function () { ...@@ -256,8 +257,8 @@ const drawChartUsingSelectedOptions = async function () {
} catch (err) { } catch (err) {
console.error(err); console.error(err);
// Display a dialog window with the error message // Display a popup that displays the error message
alert(err); createErrorPopupMessage(err);
} finally { } finally {
// Enable the 'draw chart' button // Enable the 'draw chart' button
enableDrawChartButton(); enableDrawChartButton();
......
...@@ -471,6 +471,20 @@ const getAbbreviationsForSelectedOptionsFromAllDropDownLists = function ( ...@@ -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 { export {
splitMultipleOptionsTextDelimitedBySlash, splitMultipleOptionsTextDelimitedBySlash,
getSelectedOptionsFromAllDropDownLists, getSelectedOptionsFromAllDropDownLists,
...@@ -481,4 +495,5 @@ export { ...@@ -481,4 +495,5 @@ export {
checkIfSelectedBuildingDataPointsOptionsAreValid, checkIfSelectedBuildingDataPointsOptionsAreValid,
checkIfSelectedAggregationOptionsAreValid, checkIfSelectedAggregationOptionsAreValid,
getAbbreviationsForSelectedOptionsFromAllDropDownLists, 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