diff --git a/resources/frontend_client/app/services.js b/resources/frontend_client/app/services.js index 5165ad4c51cd07cb866749226e2d93bfa62c6568..5fc631aca77f44e5ce6c2bfa4c2e9e952c09ac8b 100644 --- a/resources/frontend_client/app/services.js +++ b/resources/frontend_client/app/services.js @@ -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 diff --git a/resources/frontend_client/app/setup/setup.controllers.js b/resources/frontend_client/app/setup/setup.controllers.js index 154179a7971d0c4db74cb840b32632877c3e7a68..d2e7fd15efbea90b843e200a8179ee6b242f1548 100644 --- a/resources/frontend_client/app/setup/setup.controllers.js +++ b/resources/frontend_client/app/setup/setup.controllers.js @@ -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 },