added simple copy to clipboard from data-id prop

This commit is contained in:
ldinc
2017-10-14 01:23:53 +03:00
parent 72b9eb443c
commit 0e2926cc85
2 changed files with 12 additions and 5 deletions

View File

@@ -190,7 +190,7 @@
<div class="connection-ssh-group"> <div class="connection-ssh-group">
<hr/> <hr/>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">SSH Host</label> <label class="col-sm-3 control-label">SSH Host</label>
<div class="col-sm-7"> <div class="col-sm-7">
@@ -200,7 +200,7 @@
<input type="text" id="ssh_port" class="form-control" placeholder="22" /> <input type="text" id="ssh_port" class="form-control" placeholder="22" />
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">SSH User</label> <label class="col-sm-3 control-label">SSH User</label>
<div class="col-sm-9"> <div class="col-sm-9">
@@ -244,6 +244,8 @@
<li class="divider"></li> <li class="divider"></li>
<li><a href="#" data-action="truncate">Truncate Table</a></li> <li><a href="#" data-action="truncate">Truncate Table</a></li>
<li><a href="#" data-action="delete">Delete Table</a></li> <li><a href="#" data-action="delete">Delete Table</a></li>
<li class="divider"></li>
<li><a href="#" data-action="copy">Copy Table Name</a></li>
</ul> </ul>
</div> </div>
<div id="databases_context_menu"> <div id="databases_context_menu">

View File

@@ -191,6 +191,8 @@ function resetTable() {
removeClass("no-crop"); removeClass("no-crop");
} }
var tableNameRegExp = /(?:\.([^.]+))?$/;
function performTableAction(table, action, el) { function performTableAction(table, action, el) {
if (action == "truncate" || action == "delete") { if (action == "truncate" || action == "delete") {
var message = "Are you sure you want to " + action + " table " + table + " ?"; var message = "Are you sure you want to " + action + " table " + table + " ?";
@@ -224,6 +226,9 @@ function performTableAction(table, action, el) {
var win = window.open(url, "_blank"); var win = window.open(url, "_blank");
win.focus(); win.focus();
break; break;
case "copy":
copyToClipboard(tableNameRegExp.exec(table)[1]);
break;
} }
} }
@@ -313,7 +318,7 @@ function setCurrentTab(id) {
if (id != "table_content") { if (id != "table_content") {
$("#body").removeClass("with-pagination"); $("#body").removeClass("with-pagination");
} }
$("#nav ul li.selected").removeClass("selected"); $("#nav ul li.selected").removeClass("selected");
$("#" + id).addClass("selected"); $("#" + id).addClass("selected");
@@ -490,7 +495,7 @@ function showTableStructure() {
} }
setCurrentTab("table_structure"); setCurrentTab("table_structure");
$("#input").hide(); $("#input").hide();
$("#body").prop("class", "full"); $("#body").prop("class", "full");
@@ -1143,7 +1148,7 @@ $(document).ready(function() {
$("#pg_password").val(item.password); $("#pg_password").val(item.password);
$("#pg_db").val(item.database); $("#pg_db").val(item.database);
$("#connection_ssl").val(item.ssl); $("#connection_ssl").val(item.ssl);
if (item.ssh && Object.keys(item.ssh).length > 0) { if (item.ssh && Object.keys(item.ssh).length > 0) {
$("#ssh_host").val(item.ssh.host); $("#ssh_host").val(item.ssh.host);
$("#ssh_port").val(item.ssh.port); $("#ssh_port").val(item.ssh.port);