Skip to content
Snippets Groups Projects
Commit 798402f4 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

remove code around connection testing from frontend database create/update now...

remove code around connection testing from frontend database create/update now that it is being handled in the api.
parent 7a57fae0
No related branches found
No related tags found
No related merge requests found
......@@ -102,42 +102,10 @@ DatabasesControllers.controller('DatabaseEdit', ['$scope', '$routeParams', '$loc
};
var save = function(database, details) {
// validate_connection needs engine so add it to request body
details.engine = database.engine;
function handleError(error) {
$scope.$broadcast("form:api-error", error);
throw error;
}
// for an existing DB check that connection is valid before save
if ($routeParams.databaseId) {
return Metabase.validate_connection(details).$promise.catch(handleError).then(function() {
return update(database, details);
});
// for a new DB we want to infer SSL support. First try to connect w/ SSL. If that fails, disable SSL
return update(database, details);
} else {
const engineSupportsSSL = _.contains(_.map($scope.engines[database.engine]['details-fields'], 'name'),
'ssl');
function createDB() {
console.log('Successfully connected to database with SSL = ' + details.ssl + '.');
return create(database, details);
}
// if the engine supports SSL, try connecting with SSL first, and then without
if (engineSupportsSSL) {
details.ssl = true;
return Metabase.validate_connection(details).$promise.catch(function() {
console.log('Unable to connect with SSL. Trying with SSL = false.');
details.ssl = false;
return Metabase.validate_connection(details).$promise;
}).then(createDB).catch(handleError);
} else {
delete details.ssl;
return Metabase.validate_connection(details).$promise.catch(handleError).then(createDB);
}
return create(database, details);
}
};
......
......@@ -21,15 +21,6 @@ MetabaseServices.factory('Metabase', ['$resource', '$cookies', 'MetabaseCore', f
}
}
},
validate_connection: {
url: '/api/database/validate/',
method: 'POST',
headers: {
'X-CSRFToken': function() {
return $cookies.csrftoken;
}
}
},
db_add_sample_dataset: {
url: '/api/database/sample_dataset',
method: 'POST'
......
......@@ -67,15 +67,13 @@
[org.clojure/tools.reader "0.10.0"] ; Need to explictly specify this dep otherwise expectations doesn't seem to work right :'(
[expectations "2.1.3"] ; unit tests
[ring/ring-mock "0.3.0"]]
:plugins [[cider/cider-nrepl "0.10.0-SNAPSHOT"] ; Interactive development w/ cider NREPL in Emacs
[jonase/eastwood "0.2.1"] ; Linting
:plugins [[jonase/eastwood "0.2.1"] ; Linting
[lein-ancient "0.6.7"] ; Check project for outdated dependencies + plugins w/ 'lein ancient'
[lein-bikeshed "0.2.0"] ; Linting
[lein-environ "1.0.0"] ; Specify env-vars in project.clj
[lein-expectations "0.0.8"] ; run unit tests with 'lein expectations'
[lein-instant-cheatsheet "2.1.4"] ; use awesome instant cheatsheet created by yours truly w/ 'lein instant-cheatsheet'
[michaelblume/lein-marginalia "0.9.0"] ; generate documentation with 'lein marg'
[refactor-nrepl "2.0.0-SNAPSHOT"]] ; support for advanced refactoring in Emacs/LightTable
[michaelblume/lein-marginalia "0.9.0"]] ; support for advanced refactoring in Emacs/LightTable
:global-vars {*warn-on-reflection* true} ; Emit warnings on all reflection calls
:env {:mb-run-mode "dev"}
:jvm-opts ["-Dlogfile.path=target/log"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment