diff --git a/index.html b/index.html index f841a57..7af5072 100644 --- a/index.html +++ b/index.html @@ -1,49 +1,49 @@ - - - Launch-pad - - - - - + + + Launch-pad + + + + + - -
- -
- -
-
-
+ +
+ +
+ +
+
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/js/app.js b/js/app.js index cd3b272..e589ae9 100644 --- a/js/app.js +++ b/js/app.js @@ -1,142 +1,148 @@ var app = angular.module('launchpad', ['ui.router', 'LocalStorageModule']); app.config(['$stateProvider', '$urlRouterProvider', 'localStorageServiceProvider', function($stateProvider, $urlRouterProvider, localStorageServiceProvider){ - localStorageServiceProvider.setPrefix('launchpad').setStorageType('sessionStorage'); + localStorageServiceProvider.setPrefix('launchpad').setStorageType('sessionStorage'); - $urlRouterProvider.otherwise('/splash-page'); + $urlRouterProvider.otherwise('/splash-page'); + + $stateProvider + .state('splash-page', { + url: '/splash-page', + data: { + 'requiresLogin': false + }, + params: { + 'toState': 'launchpad-home', // default state to proceed to after login + 'toParams': {} + }, + templateUrl: '/templates/splash-page.html', + }) + .state('app',{ + url: '/launchpad-', + data: { + 'requiresLogin': true + }, + views: { + 'header': { + templateUrl: '/templates/partials/header.html', + controller: 'HomeController', + controllerAs: 'vm' + }, + 'menu': { + templateUrl: '/templates/partials/menu.html' + }, + 'content': { + templateUrl: '/templates/home.html' + }, + 'notifications': { + templateUrl: '/templates/partials/notifications.html' + } + } + }) + .state('app.home', { + url: 'home', + data: { + 'requiresLogin': true + }, + views: { + 'content@': { + templateUrl: 'templates/home.html', + controller: 'HomeController', + controllerAs: 'vm' + } + } + }) + .state('app.bolt', { + url: 'bolt', + data: { + 'requiresLogin': true + }, + views: { + 'content@': { + templateUrl: 'templates/bolt.html', + controller: 'BoltController' + } + } + }) + .state('app.files', { + url: 'files', + views: { + 'content@': { + templateUrl: 'templates/files.html', + controller: 'FilesController' + } + } + }) + .state('app.contacts', { + url: 'contacts', + views: { + 'content@': { + templateUrl: 'templates/contacts.html', + controller: 'ContactController' + } + } + }) + .state('app.contacts.detail', { + url: '/:id', + /* + templateUrl: 'templates/partials/subscriber-detail.html', + controller: 'SubscriberDetailController' + */ + views: { + 'detail@app.contacts': { + templateUrl: 'templates/partials/contact-detail.html', + controller: 'ContactDetailController' + } + } + }) + .state('app.music', { + url: 'music', + views: { + 'content@': { + templateUrl: 'templates/music.html', + controller: 'MusicController' + } + } + }) + .state('app.email', { + url: 'email', + views: { + 'content@': { + templateUrl: 'templates/email.html', + controller: 'EmailController' + } + } + }) + .state('app.website', { + url: 'website', + views: { + 'content@': { + templateUrl: 'templates/website.html', + controller: 'WebsiteController' + } + } + }) + .state('app.dns', { + url: 'dns', + views: { + 'content@': { + templateUrl: 'templates/dns.html', + controller: 'DnsController' + } + } + }); +}]) +.run(['$rootScope', '$state', 'Auth', function($rootScope, $state, Auth) { + + // Change title based on the `data` object in routes + $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) { + console.log('things'); + // var requiresLogin = toState.data.requiresLogin; + // + // if (requiresLogin && !LoginService.check()) { + // event.preventDefault(); + // $state.go('splash-page', {'toState': toState.name, 'toParams': toParams}); + // } + }); - $stateProvider - .state('splash-page', { - url: '/splash-page', - templateUrl: '/templates/splash-page.html', - }) - .state('app',{ - url: '/launchpad-', - views: { - 'header': { - templateUrl: '/templates/partials/header.html', - controller: 'HomeController', - controllerAs: 'vm' - }, - 'menu': { - templateUrl: '/templates/partials/menu.html' - }, - 'content': { - templateUrl: '/templates/home.html' - }, - 'notifications': { - templateUrl: '/templates/partials/notifications.html' - } - } - }) - .state('app.home', { - url: 'home', - views: { - 'content@': { - templateUrl: 'templates/home.html', - controller: 'HomeController', - controllerAs: 'vm' - } - } - }) - .state('app.sign-in', { - url: 'sign-in', - views: { - 'content@': { - templateUrl: 'templates/sign-in.html', - controller: 'SignInController', - controllerAs: 'vm' - } - } - }) - .state('app.bolt', { - url: 'bolt', - views: { - 'content@': { - templateUrl: 'templates/bolt.html', - controller: 'BoltController' - } - } - }) - .state('app.files', { - url: 'files', - views: { - 'content@': { - templateUrl: 'templates/files.html', - controller: 'FilesController' - } - } - }) - .state('app.contacts', { - url: 'contacts', - views: { - 'content@': { - templateUrl: 'templates/contacts.html', - controller: 'ContactController' - } - } - }) - .state('app.contacts.detail', { - url: '/:id', - /* - templateUrl: 'templates/partials/subscriber-detail.html', - controller: 'SubscriberDetailController' - */ - views: { - 'detail@app.contacts': { - templateUrl: 'templates/partials/contact-detail.html', - controller: 'ContactDetailController' - } - } - }) - .state('app.music', { - url: 'music', - views: { - 'content@': { - templateUrl: 'templates/music.html', - controller: 'MusicController' - } - } - }) - .state('app.email', { - url: 'email', - views: { - 'content@': { - templateUrl: 'templates/email.html', - controller: 'EmailController' - } - } - }) - .state('app.website', { - url: 'website', - views: { - 'content@': { - templateUrl: 'templates/website.html', - controller: 'WebsiteController' - } - } - }) - .state('app.dns', { - url: 'dns', - views: { - 'content@': { - templateUrl: 'templates/dns.html', - controller: 'DnsController' - } - } - }); -}]); - -app.run(['$rootScope', '$location', 'Auth', function ($rootScope, $location, Auth) { - $rootScope.$on('$routeChangeStart', function (event) { - if (!Auth.isLoggedIn()) { - console.log('DENY'); - event.preventDefault(); - $location.path('/login'); - } - else { - console.log('ALLOW'); - $location.path('/home'); - } - }); }]); diff --git a/js/controllers/HomeController.js b/js/controllers/HomeController.js index 549b3b8..f5506fe 100644 --- a/js/controllers/HomeController.js +++ b/js/controllers/HomeController.js @@ -1,19 +1,19 @@ app.controller('HomeController', ['$scope', 'Auth', 'localStorageService', '$location', function ($scope, Auth, localStorageService, $location) { - var vm = this; + var vm = this; - vm.signOut = function () { - localStorageService.remove('userAuth'); - $location.path('/splash-page'); - } + vm.signOut = function () { + localStorageService.remove('userAuth'); + $location.path('/splash-page'); + } - function userAuth() { - return JSON.parse(localStorageService.get('userAuth')); - } + function userAuth() { + return JSON.parse(localStorageService.get('userAuth')); + } - $scope.$watch(Auth.isLoggedIn, function (value, oldValue) { - if (!value && !oldValue) { - $location.path('/splash-page'); - } - }, true); + $scope.$watch(Auth.isLoggedIn, function (value, oldValue) { + if (!value && !oldValue) { + $location.path('/splash-page'); + } + }, true); }]); diff --git a/js/controllers/boltController.js b/js/controllers/boltController.js index 74f121f..02a32fc 100644 --- a/js/controllers/boltController.js +++ b/js/controllers/boltController.js @@ -1,3 +1,2 @@ app.controller('BoltController', [function($scope) { - }]); diff --git a/js/controllers/contactController.js b/js/controllers/contactController.js index 36a604e..324307e 100644 --- a/js/controllers/contactController.js +++ b/js/controllers/contactController.js @@ -1,3 +1,3 @@ -app.controller('ContactController', ['$scope', function($scope) { +app.controller('ContactController', ['$scope', 'ContactsService', function($scope, ContactsService) { $scope.contacts = ContactsService.list(); }]); diff --git a/js/services/auth.js b/js/services/auth.js index 2d18613..4dfdf6d 100644 --- a/js/services/auth.js +++ b/js/services/auth.js @@ -1,12 +1,12 @@ app.factory('Auth', ['localStorageService', function(localStorageService){ - var user; - return{ - setUser : function(currentUser){ - user = currentUser; - }, - isLoggedIn : function(){ - user = JSON.parse(localStorageService.get('userAuth')); - return (user) ? user : false; - } - }; + var user; + return{ + setUser : function(currentUser){ + user = currentUser; + }, + isLoggedIn : function(){ + user = JSON.parse(localStorageService.get('userAuth')); + return (user) ? user : false; + } + }; }]); diff --git a/templates/partials/header.html b/templates/partials/header.html index a22ad6b..ee9110b 100644 --- a/templates/partials/header.html +++ b/templates/partials/header.html @@ -23,9 +23,9 @@ diff --git a/templates/sign-in.html b/templates/sign-in.html deleted file mode 100644 index fd36a18..0000000 --- a/templates/sign-in.html +++ /dev/null @@ -1,11 +0,0 @@ -
-
- - -
-
- - -
- -