This repository has been archived by the owner on Aug 12, 2018. It is now read-only.
forked from 401ChemistryGenealogy/ChemistryGenealogy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
angular.module('chemGeno') | ||
.controller('loginDialogController', ['$scope', '$mdDialog', function($scope, $mdDialog) { | ||
.controller('loginDialogController', ['$scope', '$mdDialog', 'loginService', | ||
function($scope, $mdDialog, loginService) { | ||
$scope.master = {}; | ||
|
||
$scope.submit = function(user) { | ||
console.log(user); | ||
loginService.login(user); | ||
}; | ||
|
||
$scope.cancel = function() { | ||
$mdDialog.cancel(); | ||
$scope.user = angular.copy($scope.master); | ||
}; | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
angular.module('chemGeno') | ||
.service('loginService', function(store, $q) { | ||
var loggedIn = false; | ||
|
||
var userLoggedIn = function() { | ||
return loggedIn; | ||
}; | ||
|
||
var loginPromise = function(user) { | ||
var deferred = $q.defer(); | ||
|
||
setTimeout(function() { | ||
deferred.notify('About to login ' + user + '.'); | ||
|
||
if (user.username && user.password) { | ||
deferred.resolve('Hello, ' + user.username + ' with password: ' + user.password + '!'); | ||
loggedIn = true; | ||
} else { | ||
deferred.reject('Greeting ' + user.username + ' with ' + user.password + ' is not allowed.'); | ||
} | ||
}, 1000); | ||
|
||
return deferred.promise; | ||
}; | ||
|
||
var login = function(user) { | ||
var promise = loginPromise(user); | ||
promise.then(function(greeting) { | ||
alert('Success: ' + greeting + ' loggedIn === ' + loggedIn); | ||
}, function(reason) { | ||
alert('Failed: ' + reason); | ||
}); | ||
} | ||
|
||
return { | ||
userLoggedIn: userLoggedIn, | ||
login: login | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters