2017-08-14 18:58:01 +00:00
|
|
|
var app = angular.module('launchpad', ['oauth3.org', 'ui.router', 'LocalStorageModule']);
|
2017-08-15 15:37:37 +00:00
|
|
|
|
|
|
|
app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider',
|
|
|
|
function($stateProvider, $urlRouterProvider, localStorageServiceProvider){
|
|
|
|
|
2017-08-09 18:41:43 +00:00
|
|
|
localStorageServiceProvider.setPrefix('launchpad').setStorageType('sessionStorage');
|
2017-08-09 04:23:19 +00:00
|
|
|
|
2017-08-09 18:41:43 +00:00
|
|
|
$urlRouterProvider.otherwise('/splash-page');
|
|
|
|
$stateProvider
|
2017-08-12 03:49:18 +00:00
|
|
|
.state('splash-page', {
|
2017-08-14 18:41:55 +00:00
|
|
|
data: { requiresLogin: false },
|
2017-08-12 03:49:18 +00:00
|
|
|
url: '/splash-page',
|
|
|
|
templateUrl: '/templates/splash-page.html',
|
|
|
|
})
|
2017-08-09 18:41:43 +00:00
|
|
|
.state('app',{
|
2017-08-14 18:41:55 +00:00
|
|
|
data: { requiresLogin: true },
|
2017-08-11 21:37:06 +00:00
|
|
|
url: '/',
|
2017-08-09 18:41:43 +00:00
|
|
|
views: {
|
|
|
|
'header': {
|
|
|
|
templateUrl: '/templates/partials/header.html',
|
2017-08-15 15:37:37 +00:00
|
|
|
controller: 'loginCtrl',
|
2017-08-09 18:41:43 +00:00
|
|
|
controllerAs: 'vm'
|
|
|
|
},
|
|
|
|
'menu': {
|
|
|
|
templateUrl: '/templates/partials/menu.html'
|
|
|
|
},
|
|
|
|
'content': {
|
|
|
|
templateUrl: '/templates/home.html'
|
|
|
|
}
|
2017-08-11 19:21:35 +00:00
|
|
|
}
|
2017-08-09 18:41:43 +00:00
|
|
|
})
|
|
|
|
.state('app.home', {
|
|
|
|
url: 'home',
|
|
|
|
views: {
|
|
|
|
'content@': {
|
|
|
|
templateUrl: 'templates/home.html',
|
2017-08-15 15:37:37 +00:00
|
|
|
controller: 'loginCtrl',
|
2017-08-09 18:41:43 +00:00
|
|
|
controllerAs: 'vm'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('app.bolt', {
|
|
|
|
url: 'bolt',
|
|
|
|
views: {
|
|
|
|
'content@': {
|
|
|
|
templateUrl: 'templates/bolt.html',
|
2017-08-15 15:37:37 +00:00
|
|
|
controller: 'boltCtrl',
|
2017-08-11 19:21:35 +00:00
|
|
|
controllerAs: 'vm'
|
2017-08-09 18:41:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('app.files', {
|
|
|
|
url: 'files',
|
|
|
|
views: {
|
|
|
|
'content@': {
|
|
|
|
templateUrl: 'templates/files.html',
|
2017-08-15 15:37:37 +00:00
|
|
|
controller: 'fileCtrl',
|
|
|
|
controllerAs: 'vm'
|
2017-08-09 18:41:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('app.contacts', {
|
|
|
|
url: 'contacts',
|
|
|
|
views: {
|
|
|
|
'content@': {
|
|
|
|
templateUrl: 'templates/contacts.html',
|
2017-08-15 15:37:37 +00:00
|
|
|
controller: 'contactCtrl',
|
|
|
|
controllerAs: 'vm'
|
2017-08-09 18:41:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('app.music', {
|
|
|
|
url: 'music',
|
|
|
|
views: {
|
|
|
|
'content@': {
|
|
|
|
templateUrl: 'templates/music.html',
|
2017-08-15 15:37:37 +00:00
|
|
|
controller: 'musicCtrl',
|
|
|
|
controllerAs: 'vm'
|
2017-08-09 18:41:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('app.email', {
|
|
|
|
url: 'email',
|
|
|
|
views: {
|
|
|
|
'content@': {
|
|
|
|
templateUrl: 'templates/email.html',
|
2017-08-15 15:37:37 +00:00
|
|
|
controller: 'emailCtrl',
|
|
|
|
controllerAs: 'vm'
|
2017-08-09 18:41:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('app.website', {
|
|
|
|
url: 'website',
|
|
|
|
views: {
|
|
|
|
'content@': {
|
|
|
|
templateUrl: 'templates/website.html',
|
2017-08-15 15:37:37 +00:00
|
|
|
controller: 'websiteCtrl',
|
|
|
|
controllerAs: 'vm'
|
2017-08-09 18:41:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('app.dns', {
|
|
|
|
url: 'dns',
|
|
|
|
views: {
|
|
|
|
'content@': {
|
|
|
|
templateUrl: 'templates/dns.html',
|
2017-08-15 15:37:37 +00:00
|
|
|
controller: 'dnsCtrl',
|
|
|
|
controllerAs: 'vm'
|
2017-08-09 18:41:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2017-08-10 17:36:59 +00:00
|
|
|
}]);
|
|
|
|
|
|
|
|
app.run(['$rootScope', '$state', 'Auth', function($rootScope, $state, Auth) {
|
2017-08-15 15:37:37 +00:00
|
|
|
$rootScope.urlArray = [];
|
2017-08-09 18:41:43 +00:00
|
|
|
|
|
|
|
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
|
2017-08-10 17:36:59 +00:00
|
|
|
var requiresLogin = toState.data.requiresLogin;
|
2017-08-15 15:37:37 +00:00
|
|
|
$rootScope.redirectedURL = toState.url;
|
|
|
|
$rootScope.urlArray.push($rootScope.redirectedURL);
|
|
|
|
if ($rootScope.urlArray.length > 1) {
|
|
|
|
$rootScope.redirectedURL = $rootScope.urlArray[0];
|
|
|
|
$rootScope.urlArray = [];
|
2017-08-10 17:36:59 +00:00
|
|
|
}
|
|
|
|
|
2017-08-10 22:33:54 +00:00
|
|
|
if (requiresLogin && !Auth.isLoggedIn()) {
|
|
|
|
event.preventDefault();
|
2017-08-14 18:41:55 +00:00
|
|
|
$state.go('splash-page', { 'toState': toState.name });
|
2017-08-10 22:33:54 +00:00
|
|
|
}
|
2017-08-10 17:36:59 +00:00
|
|
|
});
|
2017-08-09 04:23:19 +00:00
|
|
|
}]);
|