Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed playlist editor not updating changes
  • Loading branch information
sec11008 committed Dec 11, 2015
1 parent 78c8a4f commit 400cfa0
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 11 deletions.
28 changes: 22 additions & 6 deletions TeamDBAwesome/TeamDBAwesome/js/adminController.js
Expand Up @@ -302,14 +302,14 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
$http.get("http://localhost:50031/api/AddPlaylist?playlistname=" + name) $http.get("http://localhost:50031/api/AddPlaylist?playlistname=" + name)
.success(function (response) { .success(function (response) {
console.log(response); console.log(response);
window.setTimeout($scope.getPlaylists(),1000);
}) })
} }
window.setTimeout($scope.getPlaylists(),1000);


} }


$scope.toEdit = function (playlistID) { $scope.toEdit = function (playlistID) {
alert("edit");
$scope.editing = true; $scope.editing = true;
$scope.currentPlaylist = playlistID; $scope.currentPlaylist = playlistID;
$scope.getPlaylistTracks(playlistID); $scope.getPlaylistTracks(playlistID);
Expand All @@ -326,18 +326,18 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
} }


$scope.deletePlaylist = function (playlistID) { $scope.deletePlaylist = function (playlistID) {
alert("delete");
if (confirm("Are you sure you want to delete this playlist? \nPress OK to confirm") == true) { if (confirm("Are you sure you want to delete this playlist? \nPress OK to confirm") == true) {
$scope.dropPlaylist(playlistID); $scope.dropPlaylist(playlistID);
} }
window.setTimeout($scope.getPlaylists(),1000);


} }


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


Expand All @@ -347,6 +347,13 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
.success(function (response) { .success(function (response) {
$scope.playlistTracks = angular.copy(response); $scope.playlistTracks = angular.copy(response);
console.log(response); console.log(response);
if ($scope.playlistTracks.length == 0) {
$scope.emptyPlaylist = true;
}
else {
$scope.emptyPlaylist = false;

}
}) })


} }
Expand All @@ -356,22 +363,25 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
$http.get("http://localhost:50031/api/AddTrackPlaylist?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID) $http.get("http://localhost:50031/api/AddTrackPlaylist?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID)
.success(function (response) { .success(function (response) {
console.log(response); console.log(response);
window.setTimeout($scope.getPlaylistTracks($scope.currentPlaylist), 1000);

}) })
window.setTimeout($scope.getPlaylistTracks($scope.currentPlaylist),1000);
} }



$scope.deleteTrack = function (trackID) { $scope.deleteTrack = function (trackID) {
if (confirm("Are you sure you want to delete this track from this playlist? \nPress OK to confirm") == true) { if (confirm("Are you sure you want to delete this track from this playlist? \nPress OK to confirm") == true) {
$scope.dropTrack(trackID); $scope.dropTrack(trackID);
} }
window.setTimeout($scope.getPlaylistTracks($scope.currentPlaylist), 1000);


} }
$scope.dropTrack = function (trackID) $scope.dropTrack = function (trackID)
{ {
$http.get("http://localhost:50031/api/RemoveTrack?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID) $http.get("http://localhost:50031/api/RemoveTrack?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID)
.success(function (response) { .success(function (response) {
console.log(response); console.log(response);
window.setTimeout($scope.getPlaylistTracks($scope.currentPlaylist), 1000);
}) })
} }


Expand Down Expand Up @@ -416,6 +426,7 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
}); });
} }



//End Playlist Editor //End Playlist Editor


//Reports //Reports
Expand Down Expand Up @@ -554,6 +565,11 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
], ],
aggregationType: uiGridConstants.aggregationTypes.sum, aggregationType: uiGridConstants.aggregationTypes.sum,
width: '15%' width: '15%'
},
{
field: 'total', displayName:'Total (avg)',
aggregationType: uiGridConstants.aggregationTypes.avg,
width: '15%'
} }
] ]
} }
Expand Down
29 changes: 24 additions & 5 deletions TeamDBAwesome/TeamDBAwesome/js/userController.js
Expand Up @@ -437,21 +437,21 @@ angular.module('routerApp').controller('userController', function ($q, $window,
success(function (data, status, headers, config) { success(function (data, status, headers, config) {
$scope.messages = 'You created a playlist!'; $scope.messages = 'You created a playlist!';
alert($scope.messages); alert($scope.messages);
window.setTimeout($scope.getCustomPlaylists(), 1000);
}). }).
error(function (error, status, headers, config) { error(function (error, status, headers, config) {
$scope.messages = 'There was a network error. Try again later.'; $scope.messages = 'There was a network error. Try again later.';
alert($scope.messages); alert($scope.messages);
}); });
} }
window.setTimeout($scope.getCustomPlaylists(), 1000);


} }


$scope.toEdit = function (playlistID) { $scope.toEdit = function (playlistID) {
$scope.editing = true; $scope.editing = true;
$scope.currentPlaylist = playlistID; $scope.currentPlaylist = playlistID;
$scope.getCustomPlaylistTracks(playlistID); $scope.getCustomPlaylistTracks(playlistID);
alert($scope.currentPlaylist + "");
} }


$scope.getCustomPlaylists = function () { $scope.getCustomPlaylists = function () {
Expand All @@ -461,21 +461,29 @@ angular.module('routerApp').controller('userController', function ($q, $window,
$scope.playlists = angular.copy(response); $scope.playlists = angular.copy(response);
$scope.playlistGridOptions.data = angular.copy(response); $scope.playlistGridOptions.data = angular.copy(response);
console.log(response); console.log(response);
if ($scope.playlists.length == 0) {
$scope.noPlaylists = true;
}
else {
$scope.noPlaylists = false;

}

}) })
} }


$scope.deletePlaylist = function (playlistID) { $scope.deletePlaylist = function (playlistID) {
if (confirm("Are you sure you want to delete this playlist? \nPress OK to confirm") == true) { if (confirm("Are you sure you want to delete this playlist? \nPress OK to confirm") == true) {
$scope.dropCustomPlaylist(playlistID); $scope.dropCustomPlaylist(playlistID);
} }
window.setTimeout($scope.getCustomPlaylists(), 1000);


} }


$scope.dropCustomPlaylist = function (playlistID) { $scope.dropCustomPlaylist = function (playlistID) {
$http.get("http://localhost:50031/api/DropCustomPlaylist?PlaylistID=" + playlistID) $http.get("http://localhost:50031/api/DropCustomPlaylist?PlaylistID=" + playlistID)
.success(function (response) { .success(function (response) {
console.log(response); console.log(response);
window.setTimeout($scope.getCustomPlaylists(), 1000);
}) })
} }


Expand All @@ -486,6 +494,13 @@ angular.module('routerApp').controller('userController', function ($q, $window,
.success(function (response) { .success(function (response) {
$scope.playlistTracks = angular.copy(response); $scope.playlistTracks = angular.copy(response);
console.log(response); console.log(response);
if ($scope.playlistTracks.length == 0) {
$scope.emptyPlaylist = true;
}
else {
$scope.emptyPlaylist = false;

}
}) })


} }
Expand All @@ -495,21 +510,23 @@ angular.module('routerApp').controller('userController', function ($q, $window,
$http.get("http://localhost:50031/api/AddTrackCustomPlaylist?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID) $http.get("http://localhost:50031/api/AddTrackCustomPlaylist?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID)
.success(function (response) { .success(function (response) {
console.log(response); console.log(response);
window.setTimeout($scope.getCustomPlaylistTracks($scope.currentPlaylist), 1000);

}) })
window.setTimeout($scope.getCustomPlaylistTracks($scope.currentPlaylist), 1000);
} }


$scope.deleteTrack = function (trackID) { $scope.deleteTrack = function (trackID) {
if (confirm("Are you sure you want to delete this track from this playlist? \nPress OK to confirm") == true) { if (confirm("Are you sure you want to delete this track from this playlist? \nPress OK to confirm") == true) {
$scope.dropCustomTrack(trackID); $scope.dropCustomTrack(trackID);
} }
window.setTimeout($scope.getCustomPlaylistTracks($scope.currentPlaylist), 1000);


} }
$scope.dropCustomTrack = function (trackID) { $scope.dropCustomTrack = function (trackID) {
$http.get("http://localhost:50031/api/RemoveCustomTrack?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID) $http.get("http://localhost:50031/api/RemoveCustomTrack?PlaylistID=" + $scope.currentPlaylist + "&TrackID=" + trackID)
.success(function (response) { .success(function (response) {
console.log(response); console.log(response);
window.setTimeout($scope.getCustomPlaylistTracks($scope.currentPlaylist), 1000);

}) })
} }


Expand Down Expand Up @@ -554,6 +571,8 @@ angular.module('routerApp').controller('userController', function ($q, $window,
}); });
} }




//End Playlist Editor //End Playlist Editor
$scope.name = $cookies.get('name'); $scope.name = $cookies.get('name');
}); });
Expand Up @@ -77,5 +77,6 @@
<td><a ng-click="deleteTrack(track.TrackId)">Delete</a></td> <td><a ng-click="deleteTrack(track.TrackId)">Delete</a></td>
</tr> </tr>
</table> </table>
<h1 ng-show="emptyPlaylist">This playlist is empty, try adding a track</h1>
</div> </div>
</div> </div>
4 changes: 4 additions & 0 deletions TeamDBAwesome/TeamDBAwesome/pages/user-playlists.html
Expand Up @@ -35,6 +35,8 @@
<td><a ng-click="deletePlaylist(playlist.PlaylistID)">Delete</a></td> <td><a ng-click="deletePlaylist(playlist.PlaylistID)">Delete</a></td>
</tr> </tr>
</table> </table>
<h1 ng-show="noPlaylists">You don't have any playlists, try making a new one</h1>

</div> </div>
<!--Edit Playlist view--> <!--Edit Playlist view-->
<div ng-show="editing"> <div ng-show="editing">
Expand Down Expand Up @@ -91,6 +93,8 @@
<td><a ng-click="deleteTrack(track.TrackId)">Delete</a></td> <td><a ng-click="deleteTrack(track.TrackId)">Delete</a></td>
</tr> </tr>
</table> </table>
<h1 ng-show="emptyPlaylist">This playlist is empty, try adding a track</h1>

</div> </div>


</div> </div>

0 comments on commit 400cfa0

Please sign in to comment.