Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add and delete playlist are working
There is a bug where the list doesn't update until the page is reloaded
most of the time
  • Loading branch information
sec11008 committed Dec 8, 2015
1 parent b0d9c00 commit 85976a1
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
47 changes: 45 additions & 2 deletions TeamDBAwesome/TeamDBAwesome/js/adminController.js
Expand Up @@ -16,13 +16,14 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt


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


//New Media
$scope.showMediaOptions = true; $scope.showMediaOptions = true;
$scope.showTrackFields = false; $scope.showTrackFields = false;
$scope.showAlbumFields = false; $scope.showAlbumFields = false;
$scope.showArtistFields = false; $scope.showArtistFields = false;
$scope.showGenreFields = false; $scope.showGenreFields = false;
$scope.showMediaTypeFields = false; $scope.showMediaTypeFields = false;
$scope.editing = false;




$scope.back = function () { $scope.back = function () {
Expand All @@ -49,7 +50,9 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
$scope.toCreateMediaType = function () { $scope.toCreateMediaType = function () {
$scope.showMediaOptions = false; $scope.showMediaOptions = false;
}; };
//End New Media


//CustomerDemographics
$scope.gridOptions = { $scope.gridOptions = {
enableFiltering: true, enableFiltering: true,
columnDefs: [ columnDefs: [
Expand Down Expand Up @@ -83,9 +86,26 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt


} }
] ]
//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();
}


$scope.toEdit = function (playlistID) { $scope.toEdit = function (playlistID) {
$scope.editing = true; $scope.editing = true;
$scope.currentPlaylist = playlistID;
$scope.getPlaylistTracks(playlistID); $scope.getPlaylistTracks(playlistID);
} }


Expand All @@ -97,6 +117,21 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
console.log(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();
}

$scope.dropPlaylist = function (playlistID) {
$http.get("http://localhost:50031/api/DropPlaylist?PlaylistID="+ playlistID)
.success(function (response) {
console.log(response);
})
}

$scope.getPlaylistTracks = function (playlistID) { $scope.getPlaylistTracks = function (playlistID) {
$scope.playlistTracks = []; $scope.playlistTracks = [];
$http.get("http://localhost:50031/api/GetPlaylist?PlaylistID="+ playlistID) $http.get("http://localhost:50031/api/GetPlaylist?PlaylistID="+ playlistID)
Expand All @@ -105,5 +140,13 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
console.log(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);
}
}

//End Playlist Editor
}); });
6 changes: 3 additions & 3 deletions TeamDBAwesome/TeamDBAwesome/pages/admin-playlist-manager.html
Expand Up @@ -4,7 +4,7 @@
</head> </head>
<div ng-controller="adminController"> <div ng-controller="adminController">
<div ng-hide="editing" ng-init="getPlaylists();"> <div ng-hide="editing" ng-init="getPlaylists();">
<a>Create New Playlist</a> <a ng-click="addPlaylist();">Create New Playlist</a>
<table> <table>
<tr> <tr>
<td>Playlist Id</td> <td>Playlist Id</td>
Expand All @@ -16,7 +16,7 @@
<td>{{ playlist.PlaylistID }}</td> <td>{{ playlist.PlaylistID }}</td>
<td>{{ playlist.Name }}</td> <td>{{ playlist.Name }}</td>
<td><a ng-click="toEdit(playlist.PlaylistID);">Edit</a></td> <td><a ng-click="toEdit(playlist.PlaylistID);">Edit</a></td>
<td><a ui-sref="admin-delete-playlist">Delete</a></td> <td><a ng-click="deletePlaylist(playlist.PlaylistID)">Delete</a></td>
</tr> </tr>
</table> </table>
</div> </div>
Expand All @@ -37,7 +37,7 @@
<td>{{ track.artist }}</td> <td>{{ track.artist }}</td>
<td>{{ track.Milliseconds }}</td> <td>{{ track.Milliseconds }}</td>
<td>{{ track.UnitPrice | currency }}</td> <td>{{ track.UnitPrice | currency }}</td>
<td><a ui-sref="admin-delete-playlist">Delete</a></td> <td><a ng-click="deleteTrack(track.TrackId)">Delete</a></td>
</tr> </tr>
</table> </table>
</div> </div>
Expand Down

0 comments on commit 85976a1

Please sign in to comment.