mirror of https://github.com/apache/superset.git
Don't die on malformed json in the extras field. Give feedback to user (#338)
This commit is contained in:
parent
1e08b3e8c5
commit
8fe5790ec3
|
@ -2,12 +2,22 @@
|
|||
<script>
|
||||
$("#sqlalchemy_uri").parent()
|
||||
.append('<button id="testconn" class="btn">Test Connection</button>');
|
||||
$("#testconn").click(function() {
|
||||
$("#testconn").click(function(e) {
|
||||
e.preventDefault();
|
||||
var url = "/caravel/testconn";
|
||||
|
||||
var data = {};
|
||||
try{
|
||||
data = JSON.stringify({ uri: $("#sqlalchemy_uri").val(), extras: JSON.parse($("#extra").val()) })
|
||||
} catch(parse_error){
|
||||
alert("Malformed JSON in the extras field: " + parse_error);
|
||||
return false
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: url,
|
||||
data: JSON.stringify({ uri: $("#sqlalchemy_uri").val(), extras: JSON.parse($("#extra").val()) }),
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
contentType: "application/json; charset=utf-8"
|
||||
}).done(function(data) {
|
||||
|
|
|
@ -638,7 +638,7 @@ class Caravel(BaseView):
|
|||
"""Tests a sqla connection"""
|
||||
try:
|
||||
uri = request.json.get('uri')
|
||||
connect_args = request.json.get('extras', {}).get('engine_params', {}).get('connect_args')
|
||||
connect_args = request.json.get('extras', {}).get('engine_params', {}).get('connect_args', {})
|
||||
engine = create_engine(uri, connect_args=connect_args)
|
||||
engine.connect()
|
||||
return json.dumps(engine.table_names(), indent=4)
|
||||
|
|
Loading…
Reference in New Issue