Skip to content
Permalink
Browse files

Fixed playlist editor not updating changes

  • Loading branch information
sec11008 committed Dec 11, 2015
1 parent 78c8a4f commit 400cfa02e16d875173a9cda87f5ec2f680d0ef1e
@@ -302,14 +302,14 @@ angular.module('routerApp').controller('adminController', function ($scope, $htt
$http.get("http://localhost:50031/api/AddPlaylist?playlistname=" + name)
.success(function (response) {
console.log(response);
window.setTimeout($scope.getPlaylists(),1000);
})
}
window.setTimeout($scope.getPlaylists(),1000);


}

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

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


}

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

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

}
})

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

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


$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);
}
window.setTimeout($scope.getPlaylistTracks($scope.currentPlaylist), 1000);


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

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


//End Playlist Editor

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


}

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

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

}

})
}

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

}

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

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

}
})

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

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

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

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

})
}

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



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

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

</div>

</div>

0 comments on commit 400cfa0

Please sign in to comment.
You can’t perform that action at this time.