Skip to content
Snippets Groups Projects
Commit 6ae525d0 authored by Cam Saul's avatar Cam Saul
Browse files

Merge branch 'master' into use_annotations

parents 41c136fb ab754cd4
No related branches found
No related tags found
No related merge requests found
......@@ -14,9 +14,14 @@ Install clojure + npm/bower requirements with
lein deps
npm install
Compile application css file with
Build the application JS and CSS with
./node_modules/gulp/bin/gulp.js build
lein gulp
When developing the frontend client, you'll want to watch for changes,
so run the default gulp task.
./node_modules/gulp/bin/gulp.js
## Usage
......
......@@ -95,7 +95,7 @@ DashboardDirectives.directive('cvAddToDashboardModal', ['CorvusCore', 'Dashboard
}
});
};
element.click(openAddToDashModal);
element.bind('click', openAddToDashModal);
}
return {
......
......@@ -15,8 +15,8 @@
<div class="p4">
<div>
<ul class="Connection-enginePicker">
<li class="Connection-engine" ng-repeat="engine in engines" ng-click="setConnectionEngine(engine)" ng-class="{'Connection-engineSelected': connection.engine == engine }">
{{engine}}
<li class="Connection-engine" ng-repeat="engine in engines" ng-click="setConnectionEngine(engine.id)" ng-class="{'Connection-engineSelected': connection.engine == engine.id }">
{{engine.name}}
</li>
</ul>
<div ng-show="connection.engine != undefined">
......
......@@ -73,16 +73,14 @@ SetupControllers.controller('SetupIntro', ['$scope', '$location', '$timeout', 'i
SetupControllers.controller('SetupConnection', ['$scope', '$routeParams', '$location', 'Metabase', function($scope, $routeParams, $location, Metabase) {
var defaultPorts = {'MySql': 3306, 'Postgres': 5432, 'Mongo': 27017, "RedShift": 5439, 'Druid': 8083}
// TODO - we should be getting all this info from the api
var connectionEngines = {
'Postgres': "postgres",
};
var defaultPorts = {'MySql': 3306, 'Postgres': 5432, 'Mongo': 27017, "RedShift": 5439, 'Druid': 8083}
$scope.engines = [
'Postgres',
'MySQl',
'H2'
{'id': 'postgres', 'name':'Postgres'},
{'id': 'h2', 'name':'H2'},
{'id': 'mysql', 'name':'MySQL'}
];
$scope.connection = {};
......@@ -108,7 +106,7 @@ SetupControllers.controller('SetupConnection', ['$scope', '$routeParams', '$loca
$scope.connection = {
host: "localhost",
port: defaultPorts[connectionType],
engine: 'Postgres'
engine: 'postgres'
}
}
......
......@@ -15,6 +15,9 @@
[table :refer [Table]])
[metabase.util :as u]))
(defannotation DBEngine [symb value :nillable]
(checkp-contains? (set (map first driver/available-drivers)) symb value))
(defendpoint GET "/" [org]
{org Required}
(read-check Org org)
......@@ -24,18 +27,23 @@
(defendpoint POST "/" [:as {{:keys [org name engine details] :as body} :body}]
{org Required
name [Required NonEmptyString]
engine Required ; TODO - check that engine is a valid engine
engine [Required DBEngine]
details [Required IsDict]}
(write-check Org org)
(ins Database :organization_id org :name name :engine engine :details details))
(let-500 [new-db (ins Database :organization_id org :name name :engine engine :details details)]
;; kick off background job to gather schema metadata about our new db
(future (driver/sync-tables new-db))
;; make sure we return the newly created db object
new-db))
(defendpoint GET "/form_input" []
{:timezones metabase.models.common/timezones
:engines driver/available-drivers})
;Stub function that will eventually validate a connection string
;; Stub function that will eventually validate a connection string
(defendpoint POST "/validate" [:as {{:keys [host port]} :body}]
(require-params host port)
{host Required
port Required}
(let [response-invalid (fn [m] {:status 400 :body {:valid false :message m}})]
(cond
(not (u/host-up? host)) (response-invalid "Host not reachable")
......@@ -89,8 +97,8 @@
(simple-batched-hydrate Table :table_id :table))))
(defendpoint POST "/:id/sync" [id]
(let-404 [db (sel :one Database :id id)] ; TODO - run sync-tables asynchronously
(driver/sync-tables db))
(let-404 [db (sel :one Database :id id)]
(future (driver/sync-tables db))) ; run sync-tables asynchronously
{:status :ok})
......
......@@ -5,18 +5,22 @@
(metabase.models [session :refer [Session]]
[user :refer [User set-user-password]])
[metabase.setup :as setup]
[metabase.util :as util]
[metabase.util.password :as password]))
[metabase.util :as util]))
(defannotation SetupToken
"Check that param matches setup token or throw a 403."
[_ token]
(check (setup/token-match? token)
[403 "Token does not match the setup token."]))
;; special endpoint for creating the first user during setup
;; this endpoint both creates the user AND logs them in and returns a session id
(defendpoint POST "/user" [:as {{:keys [token first_name last_name email password] :as body} :body}]
;; check our input
(require-params token first_name last_name email password)
(check-400 (and (util/is-email? email) (password/is-complex? password)))
;; the submitted token must match our setup token
(check-403 (setup/token-match? token))
{token [Required SetupToken]
first_name [Required NonEmptyString]
last_name [Required NonEmptyString]
email [Required Email]
password [Required ComplexPassword]}
;; extra check. don't continue if there is already a user in the db.
(let [session-id (str (java.util.UUID/randomUUID))
new-user (ins User
......
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