Skip to content
Permalink
1a4351be05
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
197 lines (170 sloc) 5.58 KB
// 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;
};
$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'}
]
}
$scope.custInfoGridOptions.data = [
{
"Fname": "Test",
"Lname": "Test",
"Address": "Test",
"City": "Test",
"State": "Test",
"Post": "Test",
"Country": "Test",
"Phone": "Test",
"Fax": "Test",
"Email": "Test",
"Company": "Test"
}
]
//End Customer Demographics
//Playlist Editor
$scope.editing = false;
$scope.currentPlaylist = 0;
$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.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);
})
}
//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
});