Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added Working Logout buttons
  • Loading branch information
adl13006 committed Nov 29, 2015
1 parent fa73a90 commit bcc30ef
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 130 deletions.
Binary file modified API_REF.xlsx
Binary file not shown.
132 changes: 50 additions & 82 deletions TeamDBAwesome/TeamDBAwesome/js/adminController.js
@@ -1,99 +1,67 @@
// 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) {
/* Retrieve Url */
var url = urlService.web;
$cookies.put('PAGE','Admin');
angular.module('routerApp').controller('adminController', function ($scope, $http, $log, $timeout, $cookies, urlService, $anchorScroll, $location, $q, $state, $rootScope) {
/* Retrieve Url */
var url = urlService.web;
$cookies.put('PAGE', 'Admin');

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

$scope.authenticateAdmin = function(id,pass){
console.log("Authenticating");
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.logoutAdmin = function(){
$scope.messages = 'You have been logged out.';
$cookies.remove("PWD");
$cookies.remove("ADMIN");
$cookies.remove("LOGIN");
$state.go('home');
}




/* BEGIN LOGIC */
var promise = $scope.authenticateAdmin($cookies.get('ADMIN'),$cookies.get('PWD'));
promise.then(function(){
if($scope.authenticated == true){
$scope.initAdmin();
}
else if ($scope.authenticated == false)$scope.logoutAdmin();
});
// Logging out
$scope.logout = function () {
$cookies.remove('userid');
$state.go('home');
}

$scope.showMediaOptions = true;
$scope.showTrackFields = false;
$scope.showAlbumFields = false;
$scope.showArtistFields = false;
$scope.showGenreFields = false;
$scope.showMediaTypeFields = false;

/* BEGIN LOGIC */

$scope.back = function () {
$scope.showMediaOptions = true;
$scope.showTrackFields = false;
$scope.showAlbumFields = false;
$scope.showArtistFields = false;
$scope.showGenreFields = false;
$scope.showMediaTypeFields = false;
}
$scope.toCreateTrack = function () {
$scope.showMediaOptions = false;
$scope.showTrackFields = true;
};
$scope.toCreateAlbum = function () {
$scope.showMediaOptions = false;
};
$scope.toCreateArtist = function () {
$scope.showMediaOptions = false;
};
$scope.toCreateGenre = function () {
$scope.showMediaOptions = false;
};
$scope.toCreateMediaType = function () {
$scope.showMediaOptions = false;
};

$scope.playlists = [
{
"playlistId": "1",
"name":"test1"
},
{
"playlistId": "2",
"name":"test2"
},
{
"playlistId": "3",
"name":"test3"

$scope.back = function () {
$scope.showMediaOptions = true;
$scope.showTrackFields = false;
$scope.showAlbumFields = false;
$scope.showArtistFields = false;
$scope.showGenreFields = false;
$scope.showMediaTypeFields = false;
}
];
$scope.toCreateTrack = function () {
$scope.showMediaOptions = false;
$scope.showTrackFields = true;
};
$scope.toCreateAlbum = function () {
$scope.showMediaOptions = false;
};
$scope.toCreateArtist = function () {
$scope.showMediaOptions = false;
};
$scope.toCreateGenre = function () {
$scope.showMediaOptions = false;
};
$scope.toCreateMediaType = function () {
$scope.showMediaOptions = false;
};

$scope.playlists = [
{
"playlistId": "1",
"name": "test1"
},
{
"playlistId": "2",
"name": "test2"
},
{
"playlistId": "3",
"name": "test3"
}
];

});
16 changes: 3 additions & 13 deletions TeamDBAwesome/TeamDBAwesome/js/homeController.js
Expand Up @@ -61,7 +61,6 @@ angular.module('routerApp').controller('homeController', function ($scope, $http
}

$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){
Expand All @@ -77,19 +76,10 @@ angular.module('routerApp').controller('homeController', function ($scope, $http
}

$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('PWD',user.password);
// $scope.messages = null;
// need to get userid from username
$cookies.put("userid", user.username);
$state.go('user-home');
//}
// else if ($scope.authenticated == false){
// $scope.messages = 'Incorrect Login Information.';
// }
// });

}

/* BEGIN LOGIC */
Expand Down
8 changes: 7 additions & 1 deletion TeamDBAwesome/TeamDBAwesome/js/userController.js
Expand Up @@ -5,6 +5,12 @@ angular.module('routerApp').controller('userController', function ($q, $window,
$location.hash("top");
$scope.COOKIE = $cookies.getAll();

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

// Customer Information Editing
// Retrieve Data
$scope.getUserInfo = function () {
Expand Down Expand Up @@ -125,4 +131,4 @@ angular.module('routerApp').controller('userController', function ($q, $window,

/* Begin Logic */

});
});
Expand Up @@ -22,7 +22,7 @@
<li><a ui-sref='admin-view'>
<center><span class="glyphicon glyphicon glyphicon-stats" aria-hidden="true"><br></span>&nbsp;View Reports</center>
</a></li>
<li><a ng-click="logoutAdmin()">
<li><a ng-click="logout()">
<center><span class="glyphicon glyphicon glyphicon-log-out" aria-hidden="true"><br></span>&nbsp;Logout</center>
</a></li>
</ul>
Expand Down
65 changes: 32 additions & 33 deletions TeamDBAwesome/TeamDBAwesome/pages/templates/user-header.html
Expand Up @@ -17,37 +17,36 @@
}
</style>


<nav class="navbar navbar-inverse navbar-fixed-top navbar-xs" role="navigation">
<div class="container">
<div class="navbar ">
<ul class="nav navbar-nav navbar-right navbar-xs" style="margin-top: 12px;">
<li>
<a ui-sref="user-home">
<center><span class="glyphicon glyphicon glyphicon-home" aria-hidden="true"><br></span>&nbsp;User Portal</center>
</a>
</li>
<li>
<a ui-sref="user-account">
<center><span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true"><br></span>&nbsp;Manage Account</center>
</a>
</li>
<li>
<a ui-sref="user-playlists">
<center><span class="glyphicon glyphicon glyphicon glyphicon-equalizer" aria-hidden="true"><br></span>&nbsp;Playlist Editor</center>
</a>
</li>
<li>
<a ui-sref="user-orders">
<center><span class="glyphicon glyphicon glyphicon-shopping-cart" aria-hidden="true"><br></span>&nbsp;My Orders</center>
</a>
</li>
<li>
<a ui-sref="home">
<center> <span class="glyphicon glyphicon glyphicon glyphicon-console" aria-hidden="true"><br></span>&nbsp;Logout</center>
</a>
</li>
</ul>
<div ng-controller='userController'>
<nav class="navbar navbar-inverse navbar-fixed-top navbar-xs" role="navigation">
<div class="container">
<div class="navbar ">
<ul class="nav navbar-nav navbar-right navbar-xs" style="margin-top: 12px;">
<li>
<a ui-sref="user-home">
<center><span class="glyphicon glyphicon glyphicon-home" aria-hidden="true"><br></span>&nbsp;User Portal</center>
</a>
</li>
<li>
<a ui-sref="user-account">
<center><span class="glyphicon glyphicon glyphicon-edit" aria-hidden="true"><br></span>&nbsp;Manage Account</center>
</a>
</li>
<li>
<a ui-sref="user-playlists">
<center><span class="glyphicon glyphicon glyphicon glyphicon-equalizer" aria-hidden="true"><br></span>&nbsp;Playlist Editor</center>
</a>
</li>
<li>
<a ui-sref="user-orders">
<center><span class="glyphicon glyphicon glyphicon-shopping-cart" aria-hidden="true"><br></span>&nbsp;My Orders</center>
</a>
</li>
<li>
<center> <span class="glyphicon glyphicon glyphicon glyphicon-console" aria-hidden="true" ng-click="logout()"><br></span>&nbsp;Logout</center>
</li>
</ul>
</div>
</div>
</div>
</nav>
</nav>
</div>

0 comments on commit bcc30ef

Please sign in to comment.