Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Employee Login is now functional
  • Loading branch information
adl13006 committed Dec 10, 2015
1 parent f909655 commit 621bd8b
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 74 deletions.
54 changes: 52 additions & 2 deletions TeamDBAwesome/TeamDBAwesome/js/adminController.js
@@ -1,20 +1,70 @@
// This controller will hold logic for the employee Portal homepage (Order List, Logout), Customer Info, Media Center, and Reports // This controller will hold logic for the employee Portal homepage (Order List, Logout), Customer Info, Media Center, and Reports


angular.module('routerApp').controller('adminController', function ($scope, $http, $log, $timeout, $cookies, urlService, $anchorScroll, $location, $q, $state, $rootScope, HolderService) { angular.module('routerApp').controller('adminController', function ($scope, $http, $log, $timeout, $cookies, urlService, $anchorScroll, $location, $q, $state, $rootScope, HolderService, $uibModal) {
/* Retrieve Url */ /* Retrieve Url */
var url = urlService.web; var url = urlService.web;
$cookies.put('PAGE', 'Admin'); $scope.name = $cookies.get('name');


/* Functions Defined */ /* Functions Defined */


// Logging out // Logging out
$scope.logout = function () { $scope.logout = function () {
$cookies.remove('userid'); $cookies.remove('userid');
$cookies.remove('isAdmin');
$cookies.remove('name');
$state.go('home'); $state.go('home');
} }



/* Dealing with Order Processing */ /* Dealing with Order Processing */


// Initialize Employee Portal
$scope.initPortal = function () {
$scope.getAllInvoices();
}

// Return all invoices
$scope.getAllInvoices = function () {
/* $http.get("http://localhost:50031/api/GetAllInvoices")
.success(function (response) {
$scope.currInvoices = angular.copy(response);
})*/

//Currently not working
$http.get("http://localhost:50031/api/GetCustomerInvoice?custId=" + 1)
.success(function (response) {
$scope.currInvoices = angular.copy(response);
console.log($scope.currorders);
})
}

// Open window for orders
$scope.openOrder = function (orderid) {
console.log(orderid);
$scope.catcats = orderid;
$scope.getCustomerInfo(orderid.customerId);
//$scope.getOrderTracks(orderid.invoiceId);
var modalInstance = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'pages/user-ordermodal.html',
scope: $scope,
controller: 'userController',
resolve: {
items: function () {
return $scope.items;
}
}
});
}

// Get information on the customer
$scope.getCustomerInfo = function(customerId){
$http.get("http://localhost:50031/api/GetCustomer?PersonID=" + customerId)
.success(function (response) {
$scope.currOrderCustomer = angular.copy(response);
})
}



/* BEGIN LOGIC */ /* BEGIN LOGIC */


Expand Down
42 changes: 23 additions & 19 deletions TeamDBAwesome/TeamDBAwesome/js/homeController.js
Expand Up @@ -4,7 +4,6 @@ angular.module('routerApp').controller('homeController', function ($scope, $http
console.log($cookies.get('userid')); console.log($cookies.get('userid'));
// Function to register new users. // Function to register new users.
$scope.createUser = function (newUser) { $scope.createUser = function (newUser) {
// TODO: Make Service fit into things.
var sub = HolderService.getBlankCustomer(); var sub = HolderService.getBlankCustomer();
if (newUser.company == null) { if (newUser.company == null) {
newUser.company = null; newUser.company = null;
Expand Down Expand Up @@ -33,29 +32,38 @@ angular.module('routerApp').controller('homeController', function ($scope, $http
data: sub data: sub
}). }).
success(function (data, status, headers, config) { success(function (data, status, headers, config) {
console.log(data);
$scope.messages = 'You are now registered and may now log in. '; $scope.messages = 'You are now registered and may now log in. ';
}). }).
error(function (error, status, headers, config) { error(function (error, status, headers, config) {
$scope.messages = 'There was a network error. Try again later.'; $scope.messages = 'There was a network error. Try again later.';
}); });
} }


// Log in admins
$scope.toAdminPage = function (user) { $scope.toAdminPage = function (user) {
// we need a get employee console.log(user);
if (!angular.isNumber(user.username)) $scope.messages = 'Please enter your person number'; console.log(!user.password);
/* $http.get("http://localhost:50031/api/GetCustomer?PersonID=" + user.username) if (!user.password) $scope.messages = "Please enter a password.";
.success(function (response) { else {
if (response.employeeID == null) { $http.get("http://localhost:50031/api/GetEmployee?PersonID=" + user.username)
$scope.messages = 'You have entered an incorrect Employee username'; .success(function (response) {
} if (response.employeeid == 0) {
else {*/ $scope.messages = 'You have entered an incorrect Employee username';
$cookies.put('userid', user.username); }
console.log($cookies.get('userid')); else {
$state.go('admin-home'); console.log(response);
//} $cookies.put('userid', user.username);
//}) $cookies.put('name', response.firstname);
$cookies.put('isAdmin', response.isAdmin);
console.log($cookies.get('userid'));
$state.go('admin-home');
}
})
}
} }


// Log in Users
$scope.toUserPage = function (user) { $scope.toUserPage = function (user) {
if (!user.password) $scope.messages = "Please enter a password."; if (!user.password) $scope.messages = "Please enter a password.";
else { else {
Expand All @@ -67,6 +75,7 @@ angular.module('routerApp').controller('homeController', function ($scope, $http
else { else {
$cookies.put("userid", user.username); $cookies.put("userid", user.username);
console.log($cookies.get('userid')); console.log($cookies.get('userid'));
$cookies.put('name', response.firstname);
$state.go('user-home'); $state.go('user-home');
} }
}) })
Expand All @@ -76,9 +85,4 @@ angular.module('routerApp').controller('homeController', function ($scope, $http
} }
} }


/* BEGIN LOGIC */
var url = urlService.web;

/* END LOGIC */

}); });
15 changes: 7 additions & 8 deletions TeamDBAwesome/TeamDBAwesome/js/userController.js
@@ -1,15 +1,13 @@
// The user controller will deal with // The user controller will deal with
angular.module('routerApp').controller('userController', function ($q, $window, $scope, $state, $stateParams, $location, $http, $cookies, urlService, $rootScope, HolderService, $uibModal) { angular.module('routerApp').controller('userController', function ($q, $window, $scope, $state, $stateParams, $location, $http, $cookies, urlService, $rootScope, HolderService, $uibModal) {
/* Retrieve Url */
var url = urlService.web; /* Begin Function Definitions */
$location.hash("top");
$scope.COOKIE = $cookies.getAll();


// Logging out // Logging out
$scope.logout = function () { $scope.logout = function () {
$cookies.remove('userid'); $cookies.remove('userid');
$state.go('home'); $state.go('home');
console.log("Happening");
} }


// Customer Information Editing // Customer Information Editing
Expand Down Expand Up @@ -148,7 +146,7 @@ angular.module('routerApp').controller('userController', function ($q, $window,
}); });
} }


/* Begin Function Definitions */
$scope.authenticateUser = function (id, pass) { $scope.authenticateUser = function (id, pass) {
return $q(function (resolve, reject) { return $q(function (resolve, reject) {
var param = id + " " + pass; var param = id + " " + pass;
Expand Down Expand Up @@ -262,7 +260,8 @@ angular.module('routerApp').controller('userController', function ($q, $window,


// Get CustomPlaylist Tracks // Get CustomPlaylist Tracks
$scope.getMyPlaylistTracks = function (id) { $scope.getMyPlaylistTracks = function (id) {
$http.get("http://localhost:50031/api/GetPlaylist?PlaylistID=" + id) console.log("Custom Playlist tracks");
$http.get("http://localhost:50031/api/GetCustomPlaylist?PlaylistID=" + id)
.success(function (response) { .success(function (response) {
$scope.currplaylist = angular.copy(response); $scope.currplaylist = angular.copy(response);
console.log($scope.currplaylist); console.log($scope.currplaylist);
Expand All @@ -287,7 +286,7 @@ angular.module('routerApp').controller('userController', function ($q, $window,
} }


// Open window for custom playlist // Open window for custom playlist
$scope.openCustom = function (size, playlist) { $scope.openCustom = function (playlist) {
$scope.getMyPlaylistTracks(playlist.PlaylistID); $scope.getMyPlaylistTracks(playlist.PlaylistID);
$scope.currname = playlist.Name; $scope.currname = playlist.Name;
var modalInstance = $uibModal.open({ var modalInstance = $uibModal.open({
Expand Down
18 changes: 9 additions & 9 deletions TeamDBAwesome/TeamDBAwesome/pages/admin-home.html
@@ -1,15 +1,15 @@
<div ng-controller="adminController"> <div ng-controller="adminController" data-ng-init="initPortal()">
<div class="text-center"> <div class="text-center">
<div class='jumbotron text-center'> <div class='jumbotron text-center'>
<h2>Welcome Admin</h2> <h2>Welcome {{name}}</h2>
<h3>Display Orders to move to invoice</h3>
<br><br> <br><br>
Active Order Screen - where clicking an order from the dashboard goes to another screen to
show the status and content of each order. This should have a similar content and structure
to the “Pending/Completed Orders and Status Screen” of the Customer. This will also
involve additional capabilities for processing the order and interacting with customers on
screen that is enabled from the click.
</div> </div>
</div> </div>
<div ui-view></div> <table>
<tr><th><center><h2>Current Orders</h2><br />Click an order to see details</center></th></tr>
<td><center>Invoice Number</center></td>
<tr ng-repeat="x in currInvoices">
<td> <center><text ng-click="openOrder(x)"><b>{{x.invoiceId}}</b></text></center> </td>
</tr>
</table>
</div> </div>
65 changes: 33 additions & 32 deletions TeamDBAwesome/TeamDBAwesome/pages/partial-home.html
@@ -1,39 +1,40 @@


<div ng-controller='homeController'> <div ng-controller='homeController'>


<div class="text-center"> <div class="text-center">
<div class="vid_img" style="background-image: url('http://i42.tinypic.com/124bst0.jpg');"></div> <div class="vid_img" style="background-image: url('http://i42.tinypic.com/124bst0.jpg');"></div>
<div class=''> <div class=''>


<div class='jumbotron'> <div class='jumbotron'>
<h2 class=''>~Home Page ~</h2> <h2 class=''>~Home Page ~</h2>
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </div> <div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </div>
<table class="table table-striped"> <table class="table table-striped">
<tr>Duis pellentesque, erat ut imperdiet sollicitudin, neque sapien tristique nibh, ac luctus ante augue a nulla.</tr> <tr>Duis pellentesque, erat ut imperdiet sollicitudin, neque sapien tristique nibh, ac luctus ante augue a nulla.</tr>
<tr> Phasellus in purus augue. Fusce ac lectus euismod, maximus elit ac, eleifend nulla. </tr> <tr> Phasellus in purus augue. Fusce ac lectus euismod, maximus elit ac, eleifend nulla. </tr>
<tr>Donec ultrices ut enim at suscipit. Aenean ac pharetra sem, nec convallis dolor.</tr> <tr>Donec ultrices ut enim at suscipit. Aenean ac pharetra sem, nec convallis dolor.</tr>
<tr>Duis non nibh pharetra, dapibus diam sagittis, dictum urna. Duis aliquet vitae eros quis vestibulum.</tr> <tr>Duis non nibh pharetra, dapibus diam sagittis, dictum urna. Duis aliquet vitae eros quis vestibulum.</tr>
</table> <tr>Duis pellentesque, erat ut imperdiet sollicitudin, neque sapien tristique nibh, ac luctus ante augue a nulla.</tr>
</div> <tr> Phasellus in purus augue. Fusce ac lectus euismod, maximus elit ac, eleifend nulla. </tr>
<h2>Links Maybe Eventually</h2> <tr>Donec ultrices ut enim at suscipit. Aenean ac pharetra sem, nec convallis dolor.</tr>
<div> <tr>Duis non nibh pharetra, dapibus diam sagittis, dictum urna. Duis aliquet vitae eros quis vestibulum.</tr>
<table class="table table-striped"> <tr>Duis pellentesque, erat ut imperdiet sollicitudin, neque sapien tristique nibh, ac luctus ante augue a nulla.</tr>
<td>Donec nisi lorem, maximus at augue eu, efficitur blandit justo. </td> <tr> Phasellus in purus augue. Fusce ac lectus euismod, maximus elit ac, eleifend nulla. </tr>
<td>Praesent placerat lacus non pretium blandit. </td> <tr>Donec ultrices ut enim at suscipit. Aenean ac pharetra sem, nec convallis dolor.</tr>
<td>Praesent mauris nibh, facilisis in est non, aliquam accumsan mi.</td> <tr>Duis non nibh pharetra, dapibus diam sagittis, dictum urna. Duis aliquet vitae eros quis.</tr>
</table> </table>
</div> </div>
</div>


<h2 class='blink'>HOT SINGLES IN YOUR AREA</h2> </div>
<div>
<table class="table table-striped">
<td>Start: Jan 2015</td>
<td>End: April 2015</td>
</table>
</div>


</div> <h2 class='blink'>HOT SINGLES IN YOUR AREA</h2>
<div>
<table class="table table-striped">
<td>Like us on Facebook</td>
<td>Follow us on twitter</td>
</table>
</div>

</div>


<div ui-view></div> <div ui-view></div>
</div> </div>
6 changes: 5 additions & 1 deletion TeamDBAwesome/TeamDBAwesome/pages/user-ordermodal.html
@@ -1,9 +1,13 @@
 
<div ng-controller='userController'> <div ng-controller='userController'>


<center> <h4>Invoice ID {{catcats.invoiceId}}</h4> </center>

<table> <table>
<tr><td><h4>Invoice ID</h4> </td><td>{{catcats.invoiceId}}</td> </tr>
<tr ng-show="currOrderCustomer"><td><h4>Customer Name </h4> </td><td>{{currOrderCustomer.FName}} {{currOrderCustomer.LName}}</td> </tr>
<tr><td><h4>Invoice Address :</h4> </td><td>{{catcats.address}} {{catcats.city}} {{catcats.state}}</td> </tr> <tr><td><h4>Invoice Address :</h4> </td><td>{{catcats.address}} {{catcats.city}} {{catcats.state}}</td> </tr>
<tr ng-show="currOrderCustomer"><td><h4>Customer Phone Number </h4> </td><td>{{currOrderCustomer.Phone}}</td> </tr>
<tr ng-show="catcats.payment.token"><td><h4>Apple token </h4> </td><td>{{catcats.paymment.token}}</td> </tr> <tr ng-show="catcats.payment.token"><td><h4>Apple token </h4> </td><td>{{catcats.paymment.token}}</td> </tr>
<tr ng-show="catcats.payment.email"><td><h4>Email Address </h4> </td><td>{{catcats.payment.email}}</td> </tr> <tr ng-show="catcats.payment.email"><td><h4>Email Address </h4> </td><td>{{catcats.payment.email}}</td> </tr>
<tr ng-show="catcats.payment.cardnum"><td><h4>Card number </h4> </td><td>{{catcats.payment.cardnum}}</td> </tr> <tr ng-show="catcats.payment.cardnum"><td><h4>Card number </h4> </td><td>{{catcats.payment.cardnum}}</td> </tr>
Expand Down
6 changes: 3 additions & 3 deletions TeamDBAwesome/TeamDBAwesome/pages/user-orders.html
Expand Up @@ -11,7 +11,7 @@
<center>Click a playlist to see track listing</center> <center>Click a playlist to see track listing</center>
<tr ng-repeat="x in myPlaylists"> <tr ng-repeat="x in myPlaylists">
<td width="80%"> <td width="80%">
<text ng-click="open(x)">{{x.Name}}</text> <text ng-click="openCustom(x)">{{x.Name}}</text>
</td> </td>
<td width="20%"><center><button data-ng-click="addMPLToCart({{x.PlaylistID}})" class="btn btn-success btn-xs"> Add to cart </button></center></td></td> <td width="20%"><center><button data-ng-click="addMPLToCart({{x.PlaylistID}})" class="btn btn-success btn-xs"> Add to cart </button></center></td></td>
</tr> </tr>
Expand Down Expand Up @@ -65,7 +65,7 @@
<td width="16%">{{x.MediaType}}</td> <td width="16%">{{x.MediaType}}</td>
<td width="8%">{{x.Genre}}</td> <td width="8%">{{x.Genre}}</td>
<td width="5%"> <td width="5%">
<audio id="audio1"> <audio id="audio1">{{x.url}}
<source src="http://a1310.phobos.apple.com/us/r1000/167/Music3/v4/00/23/38/0023383d-1616-fbe2-b3a3-7f2de268911b/mzaf_7209253486009554987.plus.aac.p.m4a"></source> <source src="http://a1310.phobos.apple.com/us/r1000/167/Music3/v4/00/23/38/0023383d-1616-fbe2-b3a3-7f2de268911b/mzaf_7209253486009554987.plus.aac.p.m4a"></source>
Your browser isn't invited for super fun audio time. Your browser isn't invited for super fun audio time.
</audio> </audio>
Expand Down Expand Up @@ -108,7 +108,7 @@
</ul> </ul>


</form> </form>
<div ng-show="pay" align="right"><button ng-disabled="myForm.$invalid" data-ng-click="buy(pay)" class="btn btn-primary btn-lg"> Purchase Cart </button></div> <div ng-show="pay" align="right"> <button ng-disabled="myForm.$invalid" data-ng-click="buy(pay)" class="btn btn-primary btn-lg"> Purchase Cart </button> </div>
<div ng-show="!pay" align="right"> <b>You have no payment method selected! <br />Please select a payment method or add one in Manage account.</b> </div> <div ng-show="!pay" align="right"> <b>You have no payment method selected! <br />Please select a payment method or add one in Manage account.</b> </div>




Expand Down

0 comments on commit 621bd8b

Please sign in to comment.