Tunnel implementation, allow using ssh on connection screen

This commit is contained in:
Dan Sosedoff
2016-01-14 19:50:01 -06:00
parent fb66acebc3
commit f0f447857f
11 changed files with 229 additions and 93 deletions

View File

@@ -648,7 +648,7 @@ function getConnectionString() {
var mode = $(".connection-group-switch button.active").attr("data");
var ssl = $("#connection_ssl").val();
if (mode == "standard") {
if (mode == "standard" || mode == "ssh") {
var host = $("#pg_host").val();
var port = $("#pg_port").val();
var user = $("#pg_user").val();
@@ -929,22 +929,39 @@ $(document).ready(function() {
$("#pg_password").val(item.password);
$("#pg_db").val(item.database);
$("#connection_ssl").val(item.ssl);
if (item.ssh) {
$("#ssh_host").val(item.ssh.host);
$("#ssh_port").val(item.ssh.port);
$("#ssh_user").val(item.ssh.user);
$("#ssh_password").val(item.ssh.password);
}
});
$("#connection_form").on("submit", function(e) {
e.preventDefault();
var button = $(this).children("button");
var url = getConnectionString();
var params = {
url: getConnectionString()
};
if (url.length == 0) {
if (params.url.length == 0) {
return;
}
if ($(".connection-group-switch button.active").attr("data") == "ssh") {
params["ssh"] = 1
params["ssh_host"] = $("#ssh_host").val();
params["ssh_port"] = $("#ssh_port").val();
params["ssh_user"] = $("#ssh_user").val();
params["ssh_password"] = $("#ssh_password").val();
}
$("#connection_error").hide();
button.prop("disabled", true).text("Please wait...");
apiCall("post", "/connect", { url: url }, function(resp) {
apiCall("post", "/connect", params, function(resp) {
button.prop("disabled", false).text("Connect");
if (resp.error) {