Skip to content

Batch select for plan overrides#4211

Open
kukumagi wants to merge 2 commits into
springfall2008:mainfrom
kukumagi:feature/manual_override_batch_select
Open

Batch select for plan overrides#4211
kukumagi wants to merge 2 commits into
springfall2008:mainfrom
kukumagi:feature/manual_override_batch_select

Conversation

@kukumagi

@kukumagi kukumagi commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

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.

Screenshot 2026-07-08 at 16 33 51 Screenshot 2026-07-08 at 16 33 44

kukumagi and others added 2 commits July 8, 2026 16:25
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_override requests 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants