Skip to content
Snippets Groups Projects
Commit ea1a61b3 authored by Kyle Doherty's avatar Kyle Doherty
Browse files

Merge branch 'new_setup_flow' of github.com:metabase/metabase-init into new_setup_flow

parents f2156cd5 b4dd209e
Branches
Tags
No related merge requests found
......@@ -58,11 +58,12 @@ DatabasesControllers.controller('DatabaseEdit', ['$scope', '$routeParams', '$loc
var update = function(database, details) {
$scope.$broadcast("form:reset");
database.details = $scope.ENGINES[database.engine].buildDetails(details);
Metabase.db_update(database, function(updated_database) {
return Metabase.db_update(database).$promise.then(function(updated_database) {
$scope.database = updated_database;
$scope.$broadcast("form:api-success", "Successfully saved!");
}, function(error) {
$scope.$broadcast("form:api-error", error);
throw error;
});
};
......@@ -71,7 +72,7 @@ DatabasesControllers.controller('DatabaseEdit', ['$scope', '$routeParams', '$loc
$scope.$broadcast("form:reset");
database.org = $scope.currentOrg.id;
database.details = $scope.ENGINES[database.engine].buildDetails(details);
Metabase.db_create(database, function(new_database) {
return Metabase.db_create(database).$promise.then(function(new_database) {
if (redirectToDetail) {
$location.path('/' + $scope.currentOrg.slug + '/admin/databases/' + new_database.id);
}
......@@ -79,16 +80,16 @@ DatabasesControllers.controller('DatabaseEdit', ['$scope', '$routeParams', '$loc
$scope.$emit("database:created", new_database);
}, function(error) {
$scope.$broadcast("form:api-error", error);
throw error;
});
};
// TODO - Why do we *require* a valid connection in setup, but not care about it here? :sob:
$scope.save = function(database, details, redirectToDetail) {
if (arguments.length < 3) {
var save = function(database, details, redirectToDetail) {
if (redirectToDetail === undefined) {
redirectToDetail = true;
}
if ($routeParams.databaseId) {
update(database, details);
return update(database, details);
} else {
// for a new DB we want to infer SSL support. First try to connect w/ SSL. If that fails, disable SSL
details.ssl = true;
......@@ -96,17 +97,31 @@ DatabasesControllers.controller('DatabaseEdit', ['$scope', '$routeParams', '$loc
// add 'engine' to the request body
details.engine = database.engine;
Metabase.validate_connection(details, function() {
console.log('Successfully connected with SSL. Setting SSL = true.');
create(database, details, redirectToDetail);
}, function() {
console.log('Unable to connect with SSL. Setting SSL = false.');
return Metabase.validate_connection(details).$promise.catch(function() {
console.log('Unable to connect with SSL. Trying with SSL = false.');
details.ssl = false;
create(database, details, redirectToDetail);
return Metabase.validate_connection(details).$promise;
}).then(function() {
console.log("simulating timeout")
console.log('Successfully connected to database with SSL = ' + details.ssl + '.');
return create(database, details, redirectToDetail);
}).catch(function(error) {
$scope.$broadcast("form:api-error", error);
throw error;
});
}
};
$scope.save = save;
$scope.saveAndRedirect = function() {
return save($scope.database, $scope.details, true)
}
$scope.saveNoRedirect = function() {
return save($scope.database, $scope.details, false)
}
$scope.sync = function() {
var call = Metabase.db_sync_metadata({
'dbId': $scope.database.id
......
<!-- SETUP NAV -->
<nav class="SetupNav text-brand py4 flex layout-centered">
<cv-logo-icon class="mr2" width="41" height="51"></cv-logo-icon>
metabase
</nav>
<div class="SetupSteps flex flex-column layout-centered wrapper wrapper-max-sm">
<section class="SetupStep bordered rounded full relative" ng-class="{ 'SetupStep--active shadowed' : activeStep == 'user', 'SetupStep--completed shadowed' : completedSteps.user }">
<div class="flex align-center py4" ng-click="activeStep = 'user'">
......@@ -71,7 +77,7 @@
<!-- Bottom Actions -->
<div class="Form-actions">
<button class="Button" ng-class="{'Button--primary': form.$valid}" ng-click="save(database, details, false)" ng-disabled="!form.$valid || !database.engine">
<button class="Button" mb-action-button="saveNoRedirect" success-text="Saved!" failed-text="Failed!" active-text="Validating " ng-disabled="!form.$valid || !database.engine">
Save
</button>
<mb-form-message></mb-form-message>
......@@ -88,7 +94,7 @@
</div>
<p class="text-body">(This may take a little while depending on the size of your data, but you can start exploring any data we’ve finished importing right away.)</p>
<button class="Button Button--primary">Take me to my data</button>
<a class="Button Button--primary" href="/">Take me to my data</a>
</section>
</div>
......@@ -22,18 +22,13 @@ SetupControllers.controller('SetupInfo', ['$scope', '$routeParams', '$location',
database: false
};
if (AppState.model.currentUser) {
$location.path('/');
}
$scope.newUser = {};
$scope.setActiveStep = function(name) {
console.log(name);
if (name === "user") {
$scope.activeStep = "user";
} else if (name === "database" && $scope.completedSteps.user) {
$scope.activeStep = "database";
} else if (name === "finish" && $scope.completedSteps.user && $scope.completedSteps.database) {
$scope.activeStep = "finish";
}
}
$scope.$on("database:created", function(event, database) {
$timeout(function() {
......
......@@ -150,11 +150,6 @@
</div>
</nav>
<!-- SETUP NAV -->
<nav class="SetupNav text-brand py4 flex layout-centered" ng-show="nav === 'setup'">
<cv-logo-icon class="mr2" width="41" height="51"></cv-logo-icon>
metabase
</nav>
</div>
<div class="MainContent flex flex-column full-height" ng-view></div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment