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
Added Working Logout buttons
- Loading branch information
Showing
6 changed files
with
93 additions
and
130 deletions.
There are no files selected for viewing
Binary file not shown.
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,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" | ||
} | ||
]; | ||
|
||
}); |
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
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