Skip to content

Commit 21c99db

Browse files
committed
make sim id copyable
1 parent cc15c04 commit 21c99db

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

src/PerfProblemSimulator/wwwroot/css/dashboard.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,8 +995,18 @@ body.page-secondary {
995995
}
996996

997997
.sim-msg {
998-
cursor: help;
998+
cursor: pointer;
999999
border-bottom: 1px dotted currentColor;
1000+
transition: background-color 0.15s ease;
1001+
}
1002+
1003+
.sim-msg:hover {
1004+
background-color: rgba(0, 120, 212, 0.1);
1005+
border-radius: 2px;
1006+
}
1007+
1008+
.sim-msg.copied {
1009+
background-color: rgba(16, 124, 16, 0.2);
10001010
}
10011011

10021012
/* --------------------------------------------------------------------------

src/PerfProblemSimulator/wwwroot/js/dashboard.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1601,13 +1601,44 @@ const LOG_ICONS = {
16011601

16021602
/**
16031603
* Wraps a message with a simulation ID tooltip for correlation.
1604+
* Clicking the message copies the simulation ID to clipboard.
16041605
* @param {string} message - The message to display
16051606
* @param {string} simulationId - The full GUID simulation ID (shown in tooltip)
16061607
* @returns {string} HTML string with message and tooltip
16071608
*/
16081609
function withSimulationId(message, simulationId) {
16091610
if (!simulationId) return message;
1610-
return `<span class="sim-msg" title="Simulation ID: ${simulationId}">${message}</span>`;
1611+
return `<span class="sim-msg" data-simid="${simulationId}" title="Click to copy Simulation ID: ${simulationId}">${message}</span>`;
1612+
}
1613+
1614+
/**
1615+
* Copies the simulation ID to clipboard when a sim-msg element is clicked.
1616+
* Shows a brief visual feedback to indicate successful copy.
1617+
*/
1618+
function initSimulationIdCopyHandlers() {
1619+
document.getElementById('eventLog').addEventListener('click', async (e) => {
1620+
const simMsg = e.target.closest('.sim-msg');
1621+
if (!simMsg) return;
1622+
1623+
const simId = simMsg.dataset.simid;
1624+
if (!simId) return;
1625+
1626+
try {
1627+
await navigator.clipboard.writeText(simId);
1628+
1629+
// Visual feedback
1630+
simMsg.classList.add('copied');
1631+
const originalTitle = simMsg.title;
1632+
simMsg.title = 'Copied!';
1633+
1634+
setTimeout(() => {
1635+
simMsg.classList.remove('copied');
1636+
simMsg.title = originalTitle;
1637+
}, 1500);
1638+
} catch (err) {
1639+
console.error('Failed to copy simulation ID:', err);
1640+
}
1641+
});
16111642
}
16121643

16131644
/**
@@ -1780,6 +1811,9 @@ document.addEventListener('DOMContentLoaded', async () => {
17801811
// Wire up side panel toggle
17811812
initializeSidePanel();
17821813

1814+
// Enable click-to-copy for simulation IDs in event log
1815+
initSimulationIdCopyHandlers();
1816+
17831817
logEvent('system', `Dashboard initialized (probe rate: ${CONFIG.latencyProbeIntervalMs}ms, idle timeout: ${CONFIG.idleTimeoutMinutes}m)`);
17841818
});
17851819

0 commit comments

Comments
 (0)