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

tidy up a couple small things with creating the first org and applying that to the frontend app.

parent 7067ad63
No related branches found
No related tags found
No related merge requests found
......@@ -93,6 +93,19 @@ CorvusServices.factory('AppState', ['$rootScope', '$routeParams', '$q', '$locati
return deferred.promise;
},
switchOrg: function (org_slug) {
console.log('changing org to ...', org_slug);
Organization.get_by_slug({
'slug': org_slug
}, function (org) {
service.model.currentOrgSlug = org.slug;
service.model.currentOrg = org;
$rootScope.$broadcast('appstate:organization', service.model.currentOrg);
}, function (error) {
console.log('error getting current org', error);
});
},
// This function performs whatever state cleanup and next steps are required when a user tries to access
// something they are not allowed to.
invalidAccess: function(user, url, message) {
......@@ -130,18 +143,6 @@ CorvusServices.factory('AppState', ['$rootScope', '$routeParams', '$q', '$locati
}
},
switchOrg: function (org_slug) {
console.log('swtiching to...', org_slug)
Organization.get_by_slug({
'slug': org_slug
}, function(org) {
service.model.currentOrg = org;
$rootScope.$broadcast('appstate:organization', service.model.currentOrg);
}, function(error) {
console.log('error getting current org', error);
});
},
routeChangedImpl: function(event) {
// whenever we have a route change (including initial page load) we need to establish some context
......
......@@ -44,9 +44,10 @@ SetupControllers.controller('SetupIntro', ['$scope', '$location', '$timeout', 'i
// now that we should be logged in and our session cookie is established, lets do the rest of the work
// create our first Organization
// TODO - we need some logic to slugify the name specified. can't have spaces, caps, etc.
Organization.create({
'name': name,
'slug': name
'name': $scope.userOrgName,
'slug': $scope.userOrgName
}, function (org) {
console.log('first org created', org);
......@@ -184,6 +185,8 @@ SetupControllers.controller('SetupConnection', ['$scope', '$routeParams', '$loca
SetupControllers.controller('SetupData', ['$scope', 'Metabase', function ($scope, Metabase) {
$scope.$watch('currentOrg', function (org) {
if(!org) return;
Metabase.db_list({
'orgId': org.id
},
......
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