Show list of databases and allow switching by clicking on current database name

This commit is contained in:
Dan Sosedoff
2016-11-05 22:49:17 -05:00
parent 7d08017c7f
commit a3c341b5b4
4 changed files with 40 additions and 5 deletions

View File

@@ -744,6 +744,20 @@ function bindContextMenus() {
}
});
});
$("#current_database").contextmenu({
target: "#databases_context_menu",
onItem: function(context, e) {
var name = $(e.target).text();
apiCall("post", "/switchdb", { db: name }, function(resp) {
if (resp.error) {
alert(resp.error);
return;
}
window.location.reload();
});
}
});
}
$(document).ready(function() {
@@ -929,6 +943,16 @@ $(document).ready(function() {
}
});
$("#current_database").on("click", function(e) {
apiCall("get", "/databases", {}, function(resp) {
$("#databases_context_menu > ul > li").remove();
resp.forEach(function(name) {
$("<li><a href='#'>" + name + "</a></li>").appendTo("#databases_context_menu > ul");
});
$("#current_database").triggerHandler("contextmenu");
});
});
$("#edit_connection").on("click", function() {
if (connected) {
$("#close_connection_window").show();