Add button to edit connection settings
This commit is contained in:
parent
7cbf8a0a84
commit
306dc2e4d8
@ -349,6 +349,16 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#edit_connection {
|
||||||
|
position: fixed;
|
||||||
|
right: 8px;
|
||||||
|
top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#close_connection_window {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
#connection_error {
|
#connection_error {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
<li id="table_history">History</li>
|
<li id="table_history">History</li>
|
||||||
<li id="table_connection">Connection</li>
|
<li id="table_connection">Connection</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<a href="#" id="edit_connection" class="btn btn-primary btn-sm">Edit Connection</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
<div class="tables-list">
|
<div class="tables-list">
|
||||||
@ -71,7 +73,7 @@
|
|||||||
<form role="form" id="connection_form">
|
<form role="form" id="connection_form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label>Enter server URL scheme</label>
|
<label>Enter server URL scheme</label>
|
||||||
<input type="text" class="form-control" id="connection_url">
|
<input type="text" class="form-control" id="connection_url" name="url">
|
||||||
<p class="help-block">URL format: postgres://user:password@host:port/db</p>
|
<p class="help-block">URL format: postgres://user:password@host:port/db</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -86,6 +88,7 @@
|
|||||||
|
|
||||||
<div id="connection_error" class="alert alert-danger"></div>
|
<div id="connection_error" class="alert alert-danger"></div>
|
||||||
<button type="submit" class="btn btn-primary">Connect</button>
|
<button type="submit" class="btn btn-primary">Connect</button>
|
||||||
|
<a href="#" id="close_connection_window" class="btn btn-default">Cancel</a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
var editor;
|
var editor;
|
||||||
|
var connected = false;
|
||||||
|
|
||||||
function apiCall(method, path, params, cb) {
|
function apiCall(method, path, params, cb) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -307,6 +308,10 @@ function addShortcutTooltips() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showConnectionSettings() {
|
||||||
|
$("#connection_window").show();
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#table_content").on("click", function() { showTableContent(); });
|
$("#table_content").on("click", function() { showTableContent(); });
|
||||||
$("#table_structure").on("click", function() { showTableStructure(); });
|
$("#table_structure").on("click", function() { showTableStructure(); });
|
||||||
@ -339,6 +344,18 @@ $(document).ready(function() {
|
|||||||
showTableInfo();
|
showTableInfo();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#edit_connection").on("click", function() {
|
||||||
|
if (connected) {
|
||||||
|
$("#close_connection_window").show();
|
||||||
|
}
|
||||||
|
|
||||||
|
showConnectionSettings();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#close_connection_window").on("click", function() {
|
||||||
|
$("#connection_window").hide();
|
||||||
|
})
|
||||||
|
|
||||||
$("#connection_form").on("submit", function(e) {
|
$("#connection_form").on("submit", function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@ -361,9 +378,11 @@ $(document).ready(function() {
|
|||||||
button.prop("disabled", false).text("Connect");
|
button.prop("disabled", false).text("Connect");
|
||||||
|
|
||||||
if (resp.error) {
|
if (resp.error) {
|
||||||
|
connected = false;
|
||||||
$("#connection_error").text(resp.error).show();
|
$("#connection_error").text(resp.error).show();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
connected = true;
|
||||||
$("#connection_window").hide();
|
$("#connection_window").hide();
|
||||||
loadTables();
|
loadTables();
|
||||||
$("#main").show();
|
$("#main").show();
|
||||||
@ -376,9 +395,11 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
apiCall("get", "/info", {}, function(resp) {
|
apiCall("get", "/info", {}, function(resp) {
|
||||||
if (resp.error) {
|
if (resp.error) {
|
||||||
$("#connection_window").show();
|
connected = false;
|
||||||
|
showConnectionSettings();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
connected = true;
|
||||||
loadTables();
|
loadTables();
|
||||||
$("#main").show();
|
$("#main").show();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user