Skip to content

Commit d0bca0a

Browse files
Disable "Daily" aggregation when grouping by asset type (#115)
* Initial plan * Grey out/disable Daily aggregation when grouping by asset type Agent-Logs-Url: https://github.com/dandi/access-page/sessions/cc6ead0c-9b34-432f-a45f-d60a55b0be70 Co-authored-by: CodyCBakerPhD <51133164+CodyCBakerPhD@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: CodyCBakerPhD <51133164+CodyCBakerPhD@users.noreply.github.com>
1 parent 687705a commit d0bca0a

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

src/plots.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,31 @@ function apply_over_time_group_by_visibility() {
136136
}
137137
}
138138

139+
/**
140+
* Disables the 'Daily' aggregation radio button when grouping by 'asset type',
141+
* because the underlying data is only available at weekly granularity.
142+
* If 'Daily' is currently selected, it is automatically switched to 'Weekly'.
143+
*/
144+
function apply_daily_aggregation_restriction() {
145+
const daily_radio = document.getElementById("aggregation_daily");
146+
const daily_label = document.querySelector('label[for="aggregation_daily"]');
147+
if (!daily_radio) return;
148+
149+
const restrict = OVER_TIME_GROUP_BY === "asset_type";
150+
daily_radio.disabled = restrict;
151+
if (daily_label) {
152+
daily_label.title = restrict
153+
? "Daily data is not available when grouping by asset type"
154+
: "";
155+
}
156+
157+
if (restrict && TIME_AGGREGATION === "daily") {
158+
TIME_AGGREGATION = "weekly";
159+
const weekly_radio = document.getElementById("aggregation_weekly");
160+
if (weekly_radio) weekly_radio.checked = true;
161+
}
162+
}
163+
139164
/**
140165
* Toggles visibility between a Plotly plot element and its paired table element.
141166
* Before switching, the enclosing `.view-section` wrapper's current rendered
@@ -447,6 +472,7 @@ function syncFromUrl() {
447472
OVER_TIME_GROUP_BY = ["none", "dandisets", "asset_type"].includes(urlGroupBy) ? urlGroupBy : "none";
448473
groupBySelector.value = OVER_TIME_GROUP_BY;
449474
}
475+
apply_daily_aggregation_restriction();
450476

451477
// Top N dandisets
452478
const topNInput = document.getElementById("top_n_dandisets");
@@ -654,9 +680,11 @@ window.addEventListener("load", () => {
654680
if (groupBySelector) {
655681
groupBySelector.addEventListener("change", function () {
656682
OVER_TIME_GROUP_BY = this.value;
683+
apply_daily_aggregation_restriction();
657684

658685
const params = new URLSearchParams(window.location.search);
659686
setUrlParam(params, "group_by", OVER_TIME_GROUP_BY, "none");
687+
setUrlParam(params, "aggregation", TIME_AGGREGATION, "daily");
660688
const query = params.toString();
661689
window.history.pushState({}, "", window.location.pathname + (query ? "?" + query : ""));
662690

src/styles.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,13 @@ input[type="number"]:focus {
448448
outline-offset: 2px;
449449
}
450450

451+
/* Disabled state */
452+
.radio-toggle input[type="radio"]:disabled + label {
453+
opacity: 0.4;
454+
cursor: not-allowed;
455+
pointer-events: none;
456+
}
457+
451458
.separator {
452459
width: 1px;
453460
height: 20px;

0 commit comments

Comments
 (0)