Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Registration Page Updated
- Loading branch information
Showing
4 changed files
with
190 additions
and
87 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
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 |
---|---|---|
@@ -1,73 +1,113 @@ | ||
angular.module('routerApp').controller('homeController', function($scope, $http,urlService,$q,$state,$cookies,$rootScope) { | ||
angular.module('routerApp').controller('homeController', function ($scope, $http, urlService, $q, $state, $cookies, $rootScope) { | ||
|
||
/* BEGIN FUNCTIONS FUNCTIONS */ | ||
/* BEGIN FUNCTIONS FUNCTIONS */ | ||
|
||
$scope.authenticateAdmin = function(id,pass){ | ||
return $q(function(resolve,reject){ | ||
var param = id + " " + pass; | ||
var promise = $http.post(url + "/authenticateAdmin",param) | ||
.success(function(data) { | ||
if (data.STATUS == 555) { | ||
$scope.authenticated = false; | ||
resolve('We did it'); | ||
} else { | ||
$scope.authenticated = true; | ||
resolve('We did it'); | ||
} | ||
}) | ||
.error(function(data, status, headers, config) { | ||
$scope.messages = 'There was a network error. Try again later.'; | ||
reject('We did not do it'); | ||
}); | ||
}) | ||
} | ||
$scope.authenticateAdmin = function (id, pass) { | ||
return $q(function (resolve, reject) { | ||
var param = id + " " + pass; | ||
var promise = $http.post(url + "/authenticateAdmin", param) | ||
.success(function (data) { | ||
if (data.STATUS == 555) { | ||
$scope.authenticated = false; | ||
resolve('We did it'); | ||
} else { | ||
$scope.authenticated = true; | ||
resolve('We did it'); | ||
} | ||
}) | ||
.error(function (data, status, headers, config) { | ||
$scope.messages = 'There was a network error. Try again later.'; | ||
reject('We did not do it'); | ||
}); | ||
}) | ||
} | ||
|
||
$scope.toAdminPage = function (user) { | ||
//$cookies.put('LOGIN','ADMIN ' + $cookies.get('DEPID') + ' ' + $cookies.get('PWD') ) | ||
//var promise = $scope.authenticateAdmin(user.username,user.password); | ||
//promise.then(function(){ | ||
// if($scope.authenticated == true){ | ||
// $cookies.put('ADMIN',user.username); | ||
// Function to register new users. | ||
$scope.createUser = function (newUser) { | ||
// TODO: Make Service fit into things. | ||
var sub = { | ||
FName: null, | ||
LName: null, | ||
Address: null, | ||
City: null, | ||
State: null, | ||
Post: null, | ||
Country: null, | ||
Phone: null, | ||
Fax: null, | ||
Email: null, | ||
Company: null, | ||
//SUPPORT REP ID SHOULD BE 0 for NEW customer | ||
SupportRepID: null, | ||
PersonID: null, | ||
CustomerID: null | ||
}; | ||
|
||
if (newUser.company == null) { | ||
newUser.company = null; | ||
} | ||
|
||
sub.FName = newUser.firstName; | ||
sub.LName = newUser.lastName; | ||
sub.Address = newUser.addr; | ||
sub.City = newUser.city; | ||
sub.State = newUser.state; | ||
sub.Post = newUser.postal; | ||
sub.Country = newUser.country; | ||
sub.Phone = newUser.phone; | ||
sub.Fax = newUser.fax; | ||
sub.Email = newUser.email; | ||
sub.Company = newUser.company; | ||
sub.SupportRepID = 0; | ||
|
||
console.log(sub); | ||
//Unsure of how to handle local host for now | ||
$http.post(localhost/api/newCustomer,sub) | ||
.success(function (data, status, headers, config) { | ||
$scope.messages = 'You are now registered!'; | ||
|
||
}) | ||
.error(function (data, status, headers, config) { | ||
$scope.messages = 'There was a network error. Try again later.'; | ||
$log.error(status); | ||
}); | ||
} | ||
|
||
$scope.toAdminPage = function (user) { | ||
//$cookies.put('LOGIN','ADMIN ' + $cookies.get('DEPID') + ' ' + $cookies.get('PWD') ) | ||
//var promise = $scope.authenticateAdmin(user.username,user.password); | ||
//promise.then(function(){ | ||
// if($scope.authenticated == true){ | ||
// $cookies.put('ADMIN',user.username); | ||
//$cookies.put('PWD',user.password); | ||
// $scope.messages = null; | ||
// $scope.messages = null; | ||
$state.go('admin-home'); | ||
//} | ||
// else if ($scope.authenticated == false){ | ||
// $scope.messages = 'Incorrect Login Information.'; | ||
// } | ||
// }); | ||
} | ||
//} | ||
// else if ($scope.authenticated == false){ | ||
// $scope.messages = 'Incorrect Login Information.'; | ||
// } | ||
// }); | ||
} | ||
|
||
$scope.toUserPage = function (user) { | ||
//$cookies.put('LOGIN','ADMIN ' + $cookies.get('DEPID') + ' ' + $cookies.get('PWD') ) | ||
//var promise = $scope.authenticateAdmin(user.username,user.password); | ||
//promise.then(function(){ | ||
// if($scope.authenticated == true){ | ||
// $cookies.put('ADMIN',user.username); | ||
//$cookies.put('LOGIN','ADMIN ' + $cookies.get('DEPID') + ' ' + $cookies.get('PWD') ) | ||
//var promise = $scope.authenticateAdmin(user.username,user.password); | ||
//promise.then(function(){ | ||
// if($scope.authenticated == true){ | ||
// $cookies.put('ADMIN',user.username); | ||
//$cookies.put('PWD',user.password); | ||
// $scope.messages = null; | ||
// $scope.messages = null; | ||
$state.go('user-home'); | ||
//} | ||
// else if ($scope.authenticated == false){ | ||
// $scope.messages = 'Incorrect Login Information.'; | ||
// } | ||
// }); | ||
} | ||
//} | ||
// else if ($scope.authenticated == false){ | ||
// $scope.messages = 'Incorrect Login Information.'; | ||
// } | ||
// }); | ||
} | ||
|
||
/* BEGIN LOGIC */ | ||
var url = urlService.web; | ||
|
||
/* BEGIN LOGIC */ | ||
var url = urlService.web; | ||
$scope.myInterval = 5000; | ||
$scope.noWrapSlides = false; | ||
var slides = $scope.slides = [{image: '../../images/C1.JPG', text: 'Hello'},{image: '../../images/C2.JPG', text: 'Hello'},{image: '../../images/C3.JPG', text: 'Hello'}, | ||
{image: '../../images/C4.JPG', text: 'Hello'},{image: '../../images/C5.JPG', text: 'Hello'}]; | ||
$scope.addSlide = function() { | ||
var newWidth = 600 + slides.length + 1; | ||
slides.push({ | ||
image: '//placekitten.com/' + newWidth + '/300', | ||
text: ['More','Extra','Lots of','Surplus'][slides.length % 4] + ' ' + | ||
['Cats', 'Kittys', 'Felines', 'Cutes'][slides.length % 4] | ||
}); | ||
}; | ||
/* END LOGIC */ | ||
/* END LOGIC */ | ||
|
||
}); |
Oops, something went wrong.