controllers created

This commit is contained in:
Jon Lambson 2017-08-08 14:54:25 -06:00
parent 2fab69cfdc
commit 84db0f96b1
19 changed files with 80 additions and 49 deletions

View File

@ -30,8 +30,9 @@
<script src="/js/app.js" charset="utf-8"></script> <script src="/js/app.js" charset="utf-8"></script>
<!-- Services --> <!-- Services -->
<script src="/js/services/contacts.js" charset="utf-8"></script> <script src="/js/services/contacts.js" charset="utf-8"></script>
<script src="/js/services/auth.js" charset="utf-8"></script>
<!-- Controllers --> <!-- Controllers -->
<script src="/js/controllers/loginController.js" charset="utf-8"></script> <script src="/js/controllers/signInController.js" charset="utf-8"></script>
<script src="/js/controllers/homeController.js" charset="utf-8"></script> <script src="/js/controllers/homeController.js" charset="utf-8"></script>
<script src="/js/controllers/boltController.js" charset="utf-8"></script> <script src="/js/controllers/boltController.js" charset="utf-8"></script>
<script src="/js/controllers/filesController.js" charset="utf-8"></script> <script src="/js/controllers/filesController.js" charset="utf-8"></script>

View File

@ -3,13 +3,15 @@
var app = angular.module('launchpad', ['ui.router']); var app = angular.module('launchpad', ['ui.router']);
app.config(function($stateProvider, $urlRouterProvider){ app.config(function($stateProvider, $urlRouterProvider){
$urlRouterProvider.otherwise('/login'); $urlRouterProvider.otherwise('/sign-in');
$stateProvider $stateProvider
.state('app',{ .state('app',{
url: '/', url: '/',
views: { views: {
'header': { 'header': {
templateUrl: '/templates/partials/header.html' templateUrl: '/templates/partials/header.html',
controller: 'HomeController',
controllerAs: 'vm'
}, },
'menu': { 'menu': {
templateUrl: '/templates/partials/menu.html' templateUrl: '/templates/partials/menu.html'
@ -27,16 +29,23 @@ app.config(function($stateProvider, $urlRouterProvider){
views: { views: {
'content@': { 'content@': {
templateUrl: 'templates/home.html', templateUrl: 'templates/home.html',
controller: 'HomeController' controller: 'HomeController',
controllerAs: 'vm'
} }
} }
}) })
.state('app.login', { .state('app.sign-in', {
url: 'login', url: 'sign-in',
views: { views: {
'content@': { 'content@': {
templateUrl: 'templates/login.html', templateUrl: 'templates/sign-in.html',
controller: 'LoginController' controller: 'SignInController',
controllerAs: 'vm'
}
},
resolve: {
loginStatus: function(authService) {
return authService.getUser();
} }
} }
}) })

View File

@ -1,3 +1,3 @@
app.controller('EmailController', function($scope) { app.controller('EmailController', [function($scope) {
}); }]);

View File

@ -1,3 +1,4 @@
app.controller('HomeController', function($scope) { app.controller('HomeController', ['$scope', function ($scope) {
var vm = this;
}); }]);

View File

@ -1,3 +1,3 @@
app.controller('BoltController', function($scope) { app.controller('BoltController', [function($scope) {
}); }]);

View File

@ -1,3 +1,3 @@
app.controller('ContactController', function($scope, ContactsService) { app.controller('ContactController', ['$scope', function($scope) {
$scope.contacts = ContactsService.list(); $scope.contacts = ContactsService.list();
}); }]);

View File

@ -1,3 +1,3 @@
app.controller('ContactDetailController', function($scope, $stateParams, ContactsService) { app.controller('ContactDetailController', ['$scope', '$stateParams', 'ContactsService', function($scope, $stateParams, ContactsService) {
$scope.selected = ContactsService.find($stateParams.id); $scope.selected = ContactsService.find($stateParams.id);
}); }]);

View File

@ -1,3 +1,3 @@
app.controller('DnsController', function($scope) { app.controller('DnsController', [function($scope) {
}); }]);

View File

@ -1,3 +1,3 @@
app.controller('FilesController', function($scope) { app.controller('FilesController', [function($scope) {
}); }]);

View File

@ -1,3 +0,0 @@
app.controller('LoginController', function($scope) {
});

View File

@ -1,3 +1,3 @@
app.controller('MusicController', function($scope) { app.controller('MusicController', [function($scope) {
}); }]);

View File

@ -0,0 +1,17 @@
app.controller('SignInController', ['$scope', 'loginStatus', '$location', function ($scope, loginStatus, $location) {
var vm = this;
vm.userProfile = {};
// vm.message = loginStatus;
vm.sign_in = function() {
vm.userProfile.email = vm.userAuthEmail;
vm.userProfile.password = vm.userAuthPassword;
if (vm.userProfile.email === loginStatus.email && vm.userProfile.password === loginStatus.password) {
console.log('yes!');
$location.path('/home');
} else {
alert("wrong")
}
};
}]);

View File

@ -1,3 +1,3 @@
app.controller('WebsiteController', function($scope) { app.controller('WebsiteController', [function($scope) {
}); }]);

11
js/services/auth.js Normal file
View File

@ -0,0 +1,11 @@
app.factory('authService', function($q){
return {
getUser: function(){
var user = {
email: 'jane@doe.com',
password: 'password'
}
return $q.when(user);
}
};
});

View File

@ -1,4 +1,4 @@
app.factory('ContactsService',function(){ app.factory('ContactsService', [function(){
var contacts = [ var contacts = [
{ {
id: 1, id: 1,
@ -30,4 +30,4 @@ app.factory('ContactsService',function(){
}) })
} }
} }
}); }]);

View File

@ -19,7 +19,7 @@
</form> </form>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-user" aria-hidden="true"></i> <span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ vm.message }} <i class="fa fa-user" aria-hidden="true"></i> <span class="caret"></span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="feed.html" target="_blank">Preview My Public Site</a></li> <li><a href="feed.html" target="_blank">Preview My Public Site</a></li>
<li><a>Account Settings</a></li> <li><a>Account Settings</a></li>

View File

@ -1,60 +1,60 @@
<div class="side-menu"> <div class="side-menu">
<div class="button-container"> <div class="button-container" ui-sref-active="active">
<a ui-sref=".home"> <a ui-sref=".home">
<button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-home fa-2x" aria-hidden="true"></i></button> <button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-home fa-2x" aria-hidden="true"></i></button>
<p class="button-title">Home</p> <p class="button-title">Home</p>
</a> </a>
</div> </div>
<div class="button-container"> <div class="button-container" ui-sref-active="active">
<a ui-sref=".bolt"> <a ui-sref=".bolt">
<button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-bolt fa-2x" aria-hidden="true"></i></button> <button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-bolt fa-2x" aria-hidden="true"></i></button>
<p class="button-title">Bolt</p> <p class="button-title">Bolt</p>
</a> </a>
</div> </div>
<div class="button-container"> <div class="button-container" ui-sref-active="active">
<a ui-sref=".contacts"> <a ui-sref=".contacts">
<button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-users fa-2x" aria-hidden="true"></i></button> <button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-users fa-2x" aria-hidden="true"></i></button>
<p class="button-title">Contacts</p> <p class="button-title">Contacts</p>
</a> </a>
</div> </div>
<div class="button-container"> <div class="button-container" ui-sref-active="active">
<a ui-sref=".files"> <a ui-sref=".files">
<button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-file-text-o fa-2x" aria-hidden="true"></i></button> <button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-file-text-o fa-2x" aria-hidden="true"></i></button>
<p class="button-title">Files</p> <p class="button-title">Files</p>
</a> </a>
</div> </div>
<div class="button-container"> <div class="button-container" ui-sref-active="active">
<a ui-sref=".music"> <a ui-sref=".music">
<button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-music fa-2x" aria-hidden="true"></i></button> <button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-music fa-2x" aria-hidden="true"></i></button>
<p class="button-title">Music</p> <p class="button-title">Music</p>
</a> </a>
</div> </div>
<div class="button-container"> <div class="button-container" ui-sref-active="active">
<a ui-sref=".email"> <a ui-sref=".email">
<button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-envelope-o fa-2x" aria-hidden="true"></i></button> <button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-envelope-o fa-2x" aria-hidden="true"></i></button>
<p class="button-title">Email</p> <p class="button-title">Email</p>
</a> </a>
</div> </div>
<div class="button-container"> <div class="button-container" ui-sref-active="active">
<a ui-sref=".website"> <a ui-sref=".website">
<button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-globe fa-2x" aria-hidden="true"></i></button> <button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-globe fa-2x" aria-hidden="true"></i></button>
<p class="button-title">Website</p> <p class="button-title">Website</p>
</a> </a>
</div> </div>
<div class="button-container"> <div class="button-container" ui-sref-active="active">
<a ui-sref=".dns"> <a ui-sref=".dns">
<button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-connectdevelop fa-2x" aria-hidden="true"></i></button> <button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-connectdevelop fa-2x" aria-hidden="true"></i></button>
<p class="button-title">DNS</p> <p class="button-title">DNS</p>
</a> </a>
</div> </div>
<!-- <!--
<div class="button-container"> <div class="button-container" ui-sref-active="active">
<a ui-sref=".sync"> <a ui-sref=".sync">
<button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-tablet fa-2x" aria-hidden="true"></i></button> <button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-tablet fa-2x" aria-hidden="true"></i></button>
<p class="button-title">Sync</p> <p class="button-title">Sync</p>
</a> </a>
</div> </div>
<div class="button-container"> <div class="button-container" ui-sref-active="active">
<a ui-sref=".photo"> <a ui-sref=".photo">
<button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-picture-o fa-2x" aria-hidden="true"></i></button> <button type="button" name="button" class="btn btn-default side-menu-button"><i class="fa fa-picture-o fa-2x" aria-hidden="true"></i></button>
<p class="button-title">Photo</p> <p class="button-title">Photo</p>

View File

@ -1,5 +1,5 @@
<div class="alert alert-success" role="alert"> <div class="alert alert-success" role="alert">
<i class="fa fa-check"></i> <i class="fa fa-check"></i>
<span class="sr-only">Congrats:</span> <span class="sr-only">Congrats:</span>
Something cool Cool Story Bro...
</div> </div>

View File

@ -7,10 +7,5 @@
<label for="exampleInputPassword1">Password</label> <label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" placeholder="Password" ng-model="vm.userAuthPassword"> <input type="password" class="form-control" placeholder="Password" ng-model="vm.userAuthPassword">
</div> </div>
<div class="checkbox"> <button type="submit" class="btn btn-default" ng-click="vm.sign_in()">Submit</button>
<label>
<input type="checkbox"> Remember me
</label>
</div>
<button type="submit" class="btn btn-default" ng-click="vm.submit()">Submit</button>
</form> </form>