From 798402f4a9df06ab28627e22f0675dd487b8e393 Mon Sep 17 00:00:00 2001 From: Allen Gilliland <agilliland@gmail.com> Date: Fri, 13 Nov 2015 23:33:05 -0800 Subject: [PATCH] remove code around connection testing from frontend database create/update now that it is being handled in the api. --- .../admin/databases/databases.controllers.js | 36 ++----------------- frontend/src/metabase/metabase.services.js | 9 ----- project.clj | 6 ++-- 3 files changed, 4 insertions(+), 47 deletions(-) diff --git a/frontend/src/admin/databases/databases.controllers.js b/frontend/src/admin/databases/databases.controllers.js index b9270607108..180f8bd7213 100644 --- a/frontend/src/admin/databases/databases.controllers.js +++ b/frontend/src/admin/databases/databases.controllers.js @@ -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); } }; diff --git a/frontend/src/metabase/metabase.services.js b/frontend/src/metabase/metabase.services.js index a63c4b14707..4bf55f2b0df 100644 --- a/frontend/src/metabase/metabase.services.js +++ b/frontend/src/metabase/metabase.services.js @@ -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' diff --git a/project.clj b/project.clj index 61cae437805..7c898f4a1e1 100644 --- a/project.clj +++ b/project.clj @@ -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" -- GitLab