Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
TeamDbAwesome/TeamDBAwesome/TeamDBAwesome/js/adminController.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
233 lines (203 sloc)
7.4 KB
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 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'); | |
/* Functions Defined */ | |
// Logging out | |
$scope.logout = function () { | |
$cookies.remove('userid'); | |
$state.go('home'); | |
} | |
/* Dealing with Order Processing */ | |
/* BEGIN LOGIC */ | |
//New Media | |
$scope.showMediaOptions = true; | |
$scope.showTrackFields = false; | |
$scope.showAlbumFields = false; | |
$scope.showArtistFields = false; | |
$scope.showGenreFields = false; | |
$scope.showMediaTypeFields = false; | |
$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; | |
window.alert("CAUTION: Make sure that the Artist, Album, and Genre fields already exist in the database before creating the track") | |
}; | |
$scope.toCreateAlbum = function () { | |
$scope.showMediaOptions = false; | |
}; | |
$scope.toCreateArtist = function () { | |
$scope.showMediaOptions = false; | |
}; | |
$scope.toCreateGenre = function () { | |
$scope.showMediaOptions = false; | |
}; | |
$scope.toCreateMediaType = function () { | |
$scope.showMediaOptions = false; | |
}; | |
//End New Media | |
//CustomerDemographics | |
$scope.custInfoGridOptions = { | |
enableFiltering: true, | |
columnDefs: [ | |
{field: 'Fname', displayName: 'First Name'}, | |
{field: 'Lname', displayName: 'Last Name'}, | |
{field: 'Address'}, | |
{field: 'City'}, | |
{field: 'State'}, | |
{field: 'Post'}, | |
{field: 'Country'}, | |
{field: 'Phone'}, | |
{field: 'Fax'}, | |
{field: 'Email'}, | |
{field: 'Company'} | |
] | |
} | |
//End Customer Demographics | |
//Playlist Editor | |
$scope.editing = false; | |
$scope.currentPlaylist = 0; | |
$scope.addingTrack = false; | |
$scope.addPlaylist = function () { | |
var name = prompt("Enter the name of the playlist"); | |
if (name != null) { | |
$http.get("http://localhost:50031/api/AddPlaylist?playlistname=" + name) | |
.success(function (response) { | |
console.log(response); | |
}) | |
} | |
$scope.getPlaylists(); | |
$state.go($state.current, {}, { reload: true }); | |
} | |
$scope.toEdit = function (playlistID) { | |
$scope.editing = true; | |
$scope.currentPlaylist = playlistID; | |
$scope.getPlaylistTracks(playlistID); | |
} | |
$scope.getPlaylists = function () { | |
$scope.playlists = []; | |
$http.get("http://localhost:50031/api/GetPlaylistList") | |
.success(function (response) { | |
$scope.playlists = angular.copy(response); | |
console.log(response); | |
}) | |
} | |
$scope.deletePlaylist = function (playlistID) { | |
if (confirm("Are you sure you want to delete this playlist? \nPress OK to confirm") == true) { | |
$scope.dropPlaylist(playlistID); | |
} | |
$scope.getPlaylists(); | |
$state.go($state.current, {}, { reload: true }); | |
} | |
$scope.dropPlaylist = function (playlistID) { | |
$http.get("http://localhost:50031/api/DropPlaylist?PlaylistID="+ playlistID) | |
.success(function (response) { | |
console.log(response); | |
}) | |
} | |
$scope.getPlaylistTracks = function (playlistID) { | |
$scope.playlistTracks = []; | |
$http.get("http://localhost:50031/api/GetPlaylist?PlaylistID="+ playlistID) | |
.success(function (response) { | |
$scope.playlistTracks = angular.copy(response); | |
console.log(response); | |
}) | |
} | |
$scope.addToPlaylist = function (trackID) { | |
console.log(trackID); | |
$http.get("http://localhost:50031/api/AddTrackPlaylist?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID) | |
.success(function (response) { | |
console.log(response); | |
}) | |
$scope.getPlaylistTracks($scope.currentPlaylist); | |
} | |
$scope.deleteTrack = function (trackID) { | |
if (confirm("Are you sure you want to delete this track from this playlist? \nPress OK to confirm") == true) { | |
$scope.dropTrack(trackID); | |
} | |
} | |
$scope.dropTrack = function (trackID) | |
{ | |
$http.get("http://localhost:50031/api/RemoveTrack?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID) | |
.success(function (response) { | |
console.log(response); | |
}) | |
} | |
$scope.searchGridOptions = { | |
enableSorting: true, | |
columnDefs: [ | |
{ field: 'TrackId', displayName: ' ', width: "5%", cellTemplate: '<center><button ng-click="grid.appScope.addToPlaylist(row.entity.TrackId);" class="btn btn-success btn-xs"> + </button></center>' }, | |
{ field: 'TrackName', displayName: ' Track Name', width: "20%" }, | |
{ field: 'artist', displayName: ' Artist Name', width: "20%" }, | |
{ field: 'AlbumTitle', displayName: ' Album ', width: "15%" }, | |
{ field: 'MediaType', displayName: ' Media ', width: "10%" }, | |
{ field: 'Genre', displayName: ' Genre ', width: "10%" }, | |
{ field: 'Clip', displayName: ' Clip ', width: "10%" }, | |
{ field: 'UnitPrice', displayName: ' Price ', width: "10%" } | |
] | |
}; | |
$scope.search = function (token, category) { | |
console.log(token); | |
console.log(category); | |
console.log($scope.data); | |
$http.get("http://localhost:50031/api/Search?search=" + token) | |
.success(function (response) { | |
$scope.data = angular.copy(response); | |
console.log(response); | |
if (category == "Track") { | |
$scope.searchGridOptions.data = $scope.data.Track; | |
} | |
else if (category == "Artist") { | |
$scope.searchGridOptions.data = $scope.data.Artist; | |
} | |
else if (category == "Composer") { | |
$scope.searchGridOptions.data = $scope.data.Composer; | |
} | |
else if (category == "Genre") { | |
$scope.searchGridOptions.data = $scope.data.Genre; | |
} | |
else if (category == "Media") { | |
$scope.searchGridOptions.data = $scope.data.Media; | |
} | |
}); | |
} | |
//End Playlist Editor | |
//Reports | |
$scope.inventoryGridOptions = { | |
enableFiltering: true, | |
columnDefs: [ | |
{ field: 'Title', displayName: 'Track Title' }, | |
{ field: 'Artist' }, | |
{ field: 'Album' }, | |
{ field: 'MediaType', displayName: 'Track Title' }, | |
{ field: 'Genre' }, | |
{ field: 'Composer' }, | |
{ field: 'Milliseconds' }, | |
{ field: 'UnitPrice' }, | |
{ field: 'Bytes' } | |
] | |
} | |
$scope.inventoryGridOptions.data = [ | |
{ | |
"Title": "Test", | |
"Artist": "Test", | |
"Album": "Test", | |
"Address": "Test", | |
"MediaType": "Test", | |
"Genre": "Test", | |
"Composer": "Test", | |
"Milliseconds": "Test", | |
"UnitPrice": "Test", | |
"Bytes": "Test" | |
} | |
] | |
//End Reports | |
}); |