Skip to content

Commit 39de03e

Browse files
committed
copy cell content on click
1 parent 995014d commit 39de03e

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

web/static/css/admin.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ body {
1212
}
1313

1414
.container {
15-
max-width: 1600px;
15+
max-width: 1650px;
1616
margin: 0 auto;
1717
padding: 0;
1818
}

web/templates/admin.html.tmpl

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,75 @@
168168
{{end}}
169169
{{end}}
170170
</div>
171+
<style>
172+
.copy-icon {
173+
display: none;
174+
position: absolute;
175+
right: 4px;
176+
top: 50%;
177+
transform: translateY(-50%) scaleX(-1);
178+
width: 14px;
179+
height: 14px;
180+
opacity: 0.5;
181+
pointer-events: none;
182+
}
183+
184+
.providers-table tbody td {
185+
position: relative;
186+
padding-right: 24px;
187+
transition: background-color 0.5s ease-out;
188+
}
189+
190+
.providers-table tbody td:hover .copy-icon {
191+
display: block;
192+
}
193+
</style>
194+
<script>
195+
// Make all table cells copyable on click with visual copy icon
196+
document.addEventListener('DOMContentLoaded', function() {
197+
const tables = document.querySelectorAll('.providers-table');
198+
199+
// SVG copy icon
200+
const copyIconSVG = `
201+
<svg class="copy-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
202+
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
203+
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
204+
</svg>
205+
`;
206+
207+
tables.forEach(table => {
208+
const cells = table.querySelectorAll('tbody td');
209+
210+
cells.forEach(cell => {
211+
cell.style.cursor = 'pointer';
212+
213+
// Add copy icon to cell
214+
cell.insertAdjacentHTML('beforeend', copyIconSVG);
215+
216+
cell.addEventListener('click', function() {
217+
// Get the text content
218+
const textToCopy = this.textContent.trim();
219+
220+
if (!textToCopy || textToCopy === 'No stats available') {
221+
return;
222+
}
223+
224+
// Copy to clipboard
225+
navigator.clipboard.writeText(textToCopy).then(() => {
226+
// Visual feedback with smooth fade
227+
const originalBg = this.style.backgroundColor;
228+
this.style.backgroundColor = '#d4edda';
229+
230+
setTimeout(() => {
231+
this.style.backgroundColor = originalBg;
232+
}, 300);
233+
}).catch(err => {
234+
console.error('Failed to copy:', err);
235+
});
236+
});
237+
});
238+
});
239+
});
240+
</script>
171241
</body>
172242
</html>

0 commit comments

Comments
 (0)