diff --git a/dashboard/src/app/dashboard/dashboard-config.js b/dashboard/src/app/dashboard/dashboard-config.js index 44e34154ebd0..cabfc944bfbf 100644 --- a/dashboard/src/app/dashboard/dashboard-config.js +++ b/dashboard/src/app/dashboard/dashboard-config.js @@ -37,7 +37,17 @@ export class DashboardConfig { controller: 'DashboardController', controllerAs: 'dashboardController', resolve: { - check: ['$q', 'cheService', 'cheAdminService', ($q, cheService, cheAdminService) => { + check: ['$q', '$location', 'cheWorkspace', 'cheService', 'cheAdminService', ($q, $location, cheWorkspace, cheService, cheAdminService) => { + cheWorkspace.fetchWorkspaces().then(() => { + if (cheWorkspace.getWorkspaces().length === 0) { + $location.path('/create-project'); + } + }, (error) => { + if (error.status === 304 && cheWorkspace.getWorkspaces().length === 0) { + $location.path('/create-project'); + } + }); + var defer = $q.defer(); cheService.fetchServices().then(() => { cheAdminService.fetchServices().then(() => { diff --git a/dashboard/src/app/dashboard/dashboard.controller.js b/dashboard/src/app/dashboard/dashboard.controller.js index 2e81be27e10f..abe676c41947 100644 --- a/dashboard/src/app/dashboard/dashboard.controller.js +++ b/dashboard/src/app/dashboard/dashboard.controller.js @@ -23,27 +23,9 @@ export class DashboardController { * Default constructor * @ngInject for Dependency injection */ - constructor($rootScope, cheWorkspace, $location) { + constructor($rootScope) { 'ngInject'; $rootScope.showIDE = false; - this.cheWorkspace = cheWorkspace; - this.$location = $location; - cheWorkspace.fetchWorkspaces().then(() => { - this.checkWorkspaces(); - }, - (error) => { - if (error.status === 304) { - this.checkWorkspaces(); - return; - } - }); - } - - checkWorkspaces() { - //If there are any workspaces - redirect to create workspace with project page: - if (this.cheWorkspace.getWorkspaces() && this.cheWorkspace.getWorkspaces().length === 0) { - this.$location.path('/create-project'); - } } }