[Perl] DAQ system for the FAPG.
feat set page-specific default timeframes
Probes page defaults to daily view, insights page defaults to monthly view. The graph-control template emits an optional data-default-timeframe attribute read by the timeframe JS module.
Changed files
roles/dashboard/lib/FAPG/DAQ/Dashboard/Controller/Dashboard.pm
@@ -77,6 +77,7 @@
77
77
breadcrumbs =>
78
78
[ { label => 'Home', href => '/' }, { label => 'Insights' }, ],
79
79
graph_control_aria_label => 'Insights chart timeframe',
80
Added:
default_timeframe => 'month',
80
81
);
81
82
}
82
83
roles/dashboard/public/js/dashboard/timeframe.js
@@ -1,7 +1,9 @@
1
1
import { DEFAULT_TIMEFRAME, MAX_TIMEFRAME_RANGE, TIMEFRAMES } from "./constants.js";
2
2
3
3
export function createTimeframeState() {
4
Removed:
let active = DEFAULT_TIMEFRAME;
4
Added:
const pageDefault = document.querySelector("[data-default-timeframe]")?.dataset.defaultTimeframe;
5
Added:
const initial = TIMEFRAMES[pageDefault] ? pageDefault : DEFAULT_TIMEFRAME;
6
Added:
let active = initial;
5
7
const ranges = Object.fromEntries(Object.keys(TIMEFRAMES).map(timeframe => [timeframe, 1]));
6
8
7
9
function selected() {
roles/dashboard/templates/dashboard/graph-control.html.ep
@@ -1,7 +1,7 @@
1
1
<!-- -*- mode: web; -*- -->
2
2
3
Removed:
<div class="graph-control-scroll overflow-x-auto" tabindex="0" role="region" aria-label="<%= $aria_label %>">
4
Removed:
<div class="graph-control d-inline-flex gap-2 flex-nowrap">
3
Added:
% my $dt_attr = stash('default_timeframe') ? 'data-default-timeframe="' . stash('default_timeframe') . '"' : '';
4
Added:
<div class="graph-control-scroll overflow-x-auto" tabindex="0" role="region" aria-label="<%= $aria_label %>" <%== $dt_attr %>> <div class="graph-control d-inline-flex gap-2 flex-nowrap">
5
5
<div class="input-group input-group-sm range-control" aria-label="Adjust range">
6
6
<button
7
7
class="btn btn-outline-secondary"