diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dc8e23c..9c7a4267 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project tries to adhere to [Semantic Versioning](https://semver.org/spe ### Changed - Remove locale EN +- Abort simulation run when switching to settings tab ### Fixed - various fixes in charts, texts and units diff --git a/digiplan/static/js/menu.js b/digiplan/static/js/menu.js index e96635fe..f52960aa 100644 --- a/digiplan/static/js/menu.js +++ b/digiplan/static/js/menu.js @@ -29,6 +29,7 @@ PubSub.subscribe(eventTopics.MENU_STATUS_QUO_SELECTED, hidePotentialLayers); PubSub.subscribe(eventTopics.MENU_SETTINGS_SELECTED, setMapChartViewVisibility); PubSub.subscribe(eventTopics.MENU_SETTINGS_SELECTED, showMapView); PubSub.subscribe(eventTopics.MENU_SETTINGS_SELECTED, deactivateChoropleth); +PubSub.subscribe(eventTopics.MENU_SETTINGS_SELECTED, terminateSimulation); PubSub.subscribe(eventTopics.MENU_RESULTS_SELECTED, setMapChartViewVisibility); PubSub.subscribe(eventTopics.MENU_RESULTS_SELECTED, hidePotentialLayers); PubSub.subscribe(eventTopics.MAP_VIEW_SELECTED, setResultsView); @@ -103,3 +104,18 @@ function setResultsView(msg) { } return logMessage(msg); } + +function terminateSimulation(msg) { + if (store.cold.task_id != null) { + $.ajax({ + url: "/oemof/terminate", + type: "POST", + data: {task_id: store.cold.task_id}, + success: function () { + store.cold.task_id = null; + } + }); + document.getElementById("simulation_spinner").hidden = true; + } + return logMessage(msg); +} diff --git a/digiplan/static/js/results.js b/digiplan/static/js/results.js index b916e423..9ca4a42c 100644 --- a/digiplan/static/js/results.js +++ b/digiplan/static/js/results.js @@ -44,8 +44,6 @@ futureDropdown.addEventListener("change", function() { PubSub.subscribe(eventTopics.MENU_RESULTS_SELECTED, simulate); PubSub.subscribe(eventTopics.MENU_RESULTS_SELECTED, showSimulationSpinner); PubSub.subscribe(eventTopics.SIMULATION_STARTED, checkResultsPeriodically); -// PubSub.subscribe(eventTopics.SIMULATION_STARTED, hideResultButtons); -// PubSub.subscribe(eventTopics.SIMULATION_FINISHED, showResultButtons); PubSub.subscribe(eventTopics.SIMULATION_FINISHED, showResults); PubSub.subscribe(eventTopics.SIMULATION_FINISHED, hideSimulationSpinner); PubSub.subscribe(eventTopics.SIMULATION_FINISHED, showResultCharts); @@ -63,6 +61,9 @@ function simulate(msg) { url : "/oemof/terminate", type : "POST", data : {task_id: store.cold.task_id}, + success: function() { + store.cold.task_id = null; + } }); } $.ajax({ @@ -97,6 +98,11 @@ function checkResults() { map_store.cold.state.simulation_id = json.simulation_id; PubSub.publish(eventTopics.SIMULATION_FINISHED); } + }, + error: function(json) { + store.cold.task_id = null; + map_store.cold.state.simulation_id = null; + PubSub.publish(eventTopics.SIMULATION_FINISHED); } }); } diff --git a/poetry.lock b/poetry.lock index b60db433..e0a3291c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1192,7 +1192,7 @@ resolved_reference = "14204e2ee3bc5e8146c17928b68130832be6e63b" [[package]] name = "django-oemof" -version = "0.14.0" +version = "0.15.0" description = "Django application to run oemof" optional = false python-versions = "^3.9" @@ -1210,7 +1210,7 @@ djangorestframework = "^3.14.0" type = "git" url = "https://github.com/rl-institut/django-oemof.git" reference = "HEAD" -resolved_reference = "05f595d95c2d2c83c770d52a12b9bd0222bb6925" +resolved_reference = "e982e4510fc855e0296544fa7a5370430ba89ff4" [[package]] name = "django-redis"