Executed SQL commands: Add button for copy to clipboard

This commit is contained in:
Jakub Vrana
2025-08-09 14:08:30 +02:00
parent 6d0351ec7c
commit e551efb031
3 changed files with 9 additions and 1 deletions

View File

@@ -8,6 +8,7 @@
- Display data length and index length for materialized views
- Link routines from syntax highlighting
- Autofocus added field in alter table
- Executed SQL commands: Add button for copy to clipboard
- MySQL 5.0-: Do not load partitioning info in alter table (bug #1099)
- MariaDB: Parse COLLATE in routine definition (bug #1104)
- PostgreSQL: Show structure of inherited tables

View File

@@ -668,7 +668,7 @@ class Adminer {
}
$history[$_GET["db"]][] = array($query, time(), $time); // not DB - $_GET["db"] is changed in database.inc.php //! respect $_GET["ns"]
$sql_id = "sql-" . count($history[$_GET["db"]]);
$return = "<a href='#$sql_id' class='toggle'>" . lang('SQL command') . "</a>\n";
$return = "<a href='#$sql_id' class='toggle'>" . lang('SQL command') . "</a> <a href='' class='jsonly copy'>🗐</a>\n";
if (!$failed && ($warnings = driver()->warnings())) {
$id = "warnings-" . count($history[$_GET["db"]]);
$return = "<a href='#$id' class='toggle'>" . lang('Warnings') . "</a>, $return<div id='$id' class='hidden'>\n$warnings</div>\n";

View File

@@ -93,6 +93,13 @@ function messagesPrint(parent) {
for (const el of qsa('.toggle', parent)) {
el.onclick = partial(toggle, el.getAttribute('href').substr(1));
}
for (const el of qsa('.copy', parent)) {
el.onclick = () => {
navigator.clipboard.writeText(qs('code', el.parentElement).innerText).then(el.textContent = '✓');
setTimeout(() => el.textContent = '🗐', 1000);
return false;
};
}
}