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

@@ -116,6 +116,7 @@
<div class="btn-group btn-group-sm connection-group-switch">
<button type="button" data="scheme" class="btn btn-default" id="connection_scheme">Scheme</button>
<button type="button" data="standard" class="btn btn-default active" id="connection_standard">Standard</button>
<button type="button" data="ssh" class="btn btn-default" id="connection_ssh">SSH</button>
</div>
</div>
@@ -204,14 +205,14 @@
<div class="form-group">
<label class="col-sm-3 control-label">SSH Password</label>
<div class="col-sm-9">
<input type="text" id="ssh_password" class="form-control" placeholder="optional" />
<input type="password" id="ssh_password" class="form-control" placeholder="optional" />
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">SSH Port</label>
<div class="col-sm-9">
<input type="text" id="pg_host" class="form-control" placeholder="optional" />
<input type="text" id="ssh_port" class="form-control" placeholder="optional" />
</div>
</div>
</div>

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) {