fix: ResizeObserver leak, CSS class lowercase, active sessions live update
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
let dashboardState = null;
|
let dashboardState = null;
|
||||||
let dashboardUnsubscribe = null;
|
let dashboardUnsubscribe = null;
|
||||||
let dashboardChart = null;
|
let dashboardChart = null;
|
||||||
|
let dashboardResizeObserver = null;
|
||||||
|
|
||||||
function getWsURL() {
|
function getWsURL() {
|
||||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||||
@@ -81,6 +82,10 @@
|
|||||||
dashboardChart.destroy();
|
dashboardChart.destroy();
|
||||||
dashboardChart = null;
|
dashboardChart = null;
|
||||||
}
|
}
|
||||||
|
if (dashboardResizeObserver) {
|
||||||
|
dashboardResizeObserver.disconnect();
|
||||||
|
dashboardResizeObserver = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function route() {
|
function route() {
|
||||||
@@ -1068,6 +1073,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dashboardState.summary) {
|
if (dashboardState.summary) {
|
||||||
|
if (eventType === 'session.start') dashboardState.summary.active_sessions++;
|
||||||
|
if (eventType === 'session.end') dashboardState.summary.active_sessions = Math.max(0, dashboardState.summary.active_sessions - 1);
|
||||||
if (eventType === 'run.start') dashboardState.summary.runs_today++;
|
if (eventType === 'run.start') dashboardState.summary.runs_today++;
|
||||||
if (eventType === 'error') dashboardState.summary.errors_today++;
|
if (eventType === 'error') dashboardState.summary.errors_today++;
|
||||||
if (eventType === 'span.end') {
|
if (eventType === 'span.end') {
|
||||||
@@ -1212,14 +1219,17 @@
|
|||||||
|
|
||||||
dashboardChart = new uPlot(opts, [timestamps, runs, tools, errors], container);
|
dashboardChart = new uPlot(opts, [timestamps, runs, tools, errors], container);
|
||||||
|
|
||||||
const ro = new ResizeObserver(entries => {
|
if (dashboardResizeObserver) {
|
||||||
|
dashboardResizeObserver.disconnect();
|
||||||
|
}
|
||||||
|
dashboardResizeObserver = new ResizeObserver(entries => {
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
if (dashboardChart) {
|
if (dashboardChart) {
|
||||||
dashboardChart.setSize({ width: entry.contentRect.width, height: 200 });
|
dashboardChart.setSize({ width: entry.contentRect.width, height: 200 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ro.observe(container);
|
dashboardResizeObserver.observe(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendToCurrentBucket(evt) {
|
function appendToCurrentBucket(evt) {
|
||||||
@@ -1270,7 +1280,7 @@
|
|||||||
container.innerHTML = entries.map(([name, stats]) => {
|
container.innerHTML = entries.map(([name, stats]) => {
|
||||||
const total = stats.runs + stats.tools + stats.errors;
|
const total = stats.runs + stats.tools + stats.errors;
|
||||||
const pct = maxTotal > 0 ? (total / maxTotal * 100) : 0;
|
const pct = maxTotal > 0 ? (total / maxTotal * 100) : 0;
|
||||||
const cssClass = name.replace(/[^a-z0-9-]/g, '-');
|
const cssClass = name.toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
||||||
return `
|
return `
|
||||||
<div class="fw-bar-row">
|
<div class="fw-bar-row">
|
||||||
<div class="fw-bar-label">
|
<div class="fw-bar-label">
|
||||||
|
|||||||
Reference in New Issue
Block a user