Skip to content

Commit

Permalink
Improving the Test Connection button
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jan 7, 2016
1 parent 27ceb15 commit 9bc2f08
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
16 changes: 13 additions & 3 deletions panoramix/templates/panoramix/models/database/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@
$.ajax({
method: "POST",
url: url,
data: { uri: $("#sqlalchemy_uri").val() }
}).done(function() {
alert("success");
data: { uri: $("#sqlalchemy_uri").val() },
dataType: 'json'
}).done(function(data) {
alert("Seems OK!");
if ($('#tables').length == 0)
$('body div.container').append('<div id="tables"></div>');
div = $('#tables')
div.html('Tables:<br>');
$.each(data, function(i, d){
var id = 'tbl_' + d;
div.append('<span id="' + id + '" style="margin: 0px 10px 10px 0px;" class="btn btn-default">' + d + '</span>')
$('#' + id).click(function(){window.location = '/tableview/add';})
});
}).fail(function(error) {
alert("ERROR: " + error.responseText);
});
Expand Down
10 changes: 5 additions & 5 deletions panoramix/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,16 +471,16 @@ def save_dash(self, dashboard_id):
return "SUCCESS"

@has_access
@expose("/testconn", methods=["POST"])
@expose("/testconn", methods=["POST", "GET"])
def testconn(self):
try:
uri = request.form.get('uri')
db = create_engine(uri)
db.connect()
return "SUCCESS"
engine = create_engine(uri)
engine.connect()
return json.dumps(engine.table_names(), indent=4)
except Exception as e:
return Response(
str(e),
traceback.format_exc(),
status=500,
mimetype="application/json")

Expand Down

0 comments on commit 9bc2f08

Please sign in to comment.