Skip to content

Commit

Permalink
Abort simulation run when switching to settings tab
Browse files Browse the repository at this point in the history
  • Loading branch information
henhuy committed Oct 5, 2023
1 parent 30ddeb9 commit be47cfb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions digiplan/static/js/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
5 changes: 3 additions & 2 deletions digiplan/static/js/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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({
Expand Down

0 comments on commit be47cfb

Please sign in to comment.