Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ <h3 class="text-center">SSH Connection</h3>
</div>
<div id="results_row_menu">
<ul class="dropdown-menu" role="menu">
<li><a href="#" data-action="edit_value">Edit Value</a></li>
<li><a href="#" data-action="display_value">Display Value</a></li>
<li><a href="#" data-action="copy_value">Copy Value</a></li>
<li><a href="#" data-action="filter_by_value">Filter Rows By Value</a></li>
Expand Down
28 changes: 28 additions & 0 deletions static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,31 @@ function performRowAction(action, value) {
}
}

function editCellValue(context) {
var cell = $(context);
var originalValue = unescapeHtml(cell.find("div").html());
var newValue = prompt("Edit cell value:", originalValue);
if (newValue === null) {
return; // User cancelled the prompt
}

var rowIdx = cell.closest("tr").index();
var colIdx = cell.index();
var tableName = $("#results").data("table");
var colName = $("#results_header th").eq(colIdx).data("name");
var pkColumn = $("#results_header th").eq(0).data("name");
var pkValue = $("#results_body tr").eq(rowIdx).find("td").eq(0).text();
var updateQuery = `UPDATE ${tableName} SET "${colName}" = '${newValue}' WHERE "${pkColumn}" = '${pkValue}';`;

executeQuery(updateQuery, function(data) {
if (data.error) {
alert("Error updating value: " + data.error);
} else {
cell.find("div").html(escapeHtml(newValue));
}
});
}

function sortArrow(direction) {
switch (direction) {
case "ASC":
Expand Down Expand Up @@ -1257,6 +1282,9 @@ function bindTableHeaderMenu() {
var menuItem = $(e.target);

switch(menuItem.data("action")) {
case "edit_value":
editCellValue(context);
break;
case "display_value":
var value = $(context).text();
$("#content_modal .content").text(value);
Expand Down
17 changes: 6 additions & 11 deletions static/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ if (!Array.prototype.forEach) {
}
}

function copyToClipboard(text) {
const element = document.createElement("textarea");
element.style.display = "none;"
element.value = text;

document.body.appendChild(element);
element.focus();
element.setSelectionRange(0, element.value.length);

document.execCommand("copy");
document.body.removeChild(element);
async function copyToClipboard(text) {
try {
await navigator.clipboard.writeText(text);
} catch (err) {
console.error("Error copying to clipboard: ", err);
}
}

function guid() {
Expand Down