Batch select for plan overrides#4211
Open
kukumagi wants to merge 2 commits into
Open
Conversation
Make 'Manual Demand' and other overrides easier when needing multiple slots set. You start the batch select by clicking 'Batch select' in dropdown and next slots are selected, once desired slots are selected you can choose eg 'Manual demand' on last slot and it sets it to all selected slots.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds “batch select” support to the web plan override UI so users can select multiple plan slots and apply a single override action (e.g., Manual Demand) across all selected slots. It extends the /plan_override endpoint to accept comma-separated time values and updates the plan renderer to manage in-memory batch selection state and visuals.
Changes:
- Add server-side parsing of comma-separated override times and apply plan overrides across multiple slots (
web.py). - Add client-side batch selection state, UI controls (“Batch select” / “Cancel Batch”), and selection highlighting for plan slots (
web_helper.py). - Extend web interface tests to exercise multi-time
/plan_overriderequests and add JS snippet checks (test_web_if.py).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| apps/predbat/web.py | Accepts comma-separated time strings for plan overrides and applies overrides per selected time. |
| apps/predbat/web_helper.py | Implements batch selection UI/state, dropdown control injection, and visual highlighting for selected plan slots. |
| apps/predbat/tests/test_web_if.py | Adds coverage for multi-time plan override POSTs and validates batch-selection JS snippets are present. |
Comment on lines
+158
to
+173
| function toggleTimeSelection(time, dropdownId) { | ||
| // If batch mode is active, clicking toggles inclusion in the batch. | ||
| if (getBatchActive()) { | ||
| const selectedTimes = getSelectedTimeOverrides(); | ||
| const updated = selectedTimes.includes(time) | ||
| ? selectedTimes.filter(item => item !== time) | ||
| : selectedTimes.concat(time); | ||
| setSelectedTimeOverrides(updated); | ||
| openDropdown(dropdownId); | ||
| } else { | ||
| openDropdown(dropdownId); | ||
| } | ||
|
|
||
| // Not in batch mode: just open the dropdown. Do not select the slot yet. | ||
| openDropdown(dropdownId); | ||
| } |
Comment on lines
+6321
to
+6322
| const timesLabel = selectedTimes.length > 1 ? `${selectedTimes.length} slots` : time; | ||
| messageElement.textContent = `${action} override set for ${timesLabel}`; |
Comment on lines
+17
to
+33
| from web_helper import get_plan_renderer_js | ||
|
|
||
|
|
||
| def test_plan_renderer_renders_batch_controls(): | ||
| """ | ||
| Ensure the plan renderer exposes the batch selection controls and syncs | ||
| the runtime batch state. | ||
| """ | ||
| renderer_js = get_plan_renderer_js() | ||
| assert "predbatSelectedTimeOverrides" in renderer_js | ||
| assert "setSelectedTimeOverrides(getSelectedTimeOverrides())" in renderer_js | ||
| assert "openDropdown(dropdownId)" in renderer_js | ||
| assert "Batch select" in renderer_js | ||
| assert "Cancel Batch" in renderer_js | ||
| assert "batch-select-action" in renderer_js | ||
| assert "cancel-batch" in renderer_js | ||
| assert "querySelectorAll('a.batch-select-action, a.cancel-batch')" in renderer_js |
Comment on lines
+260
to
+269
| print("Test POST /plan_override with multiple times") | ||
| address = "http://127.0.0.1:5052/plan_override" | ||
| data = {"time": "00:00,01:00", "action": "Manual Demand"} | ||
| res = requests.post(address, data=data) | ||
| if res.status_code in [200]: | ||
| accessed_endpoints.add(("POST", "/plan_override")) | ||
| else: | ||
| print("ERROR: Unexpected response from /plan_override with multiple times: {} - {}".format(res.status_code, res.text)) | ||
| failed = 1 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make 'Manual Demand' and other overrides easier when needing multiple slots set. You start the batch select by clicking 'Batch select' in dropdown and next slots are selected, once desired slots are selected you can choose eg 'Manual demand' on last slot and it sets it to all selected slots.