Commit 01a910fe by bergquist

style(playlists): use backendsrv direct

There is no point resolving the playlists in the routes file.
Loading playlists is what the controller is suppose to do
parent 8c05067f
...@@ -12,12 +12,7 @@ function (angular, config, _) { ...@@ -12,12 +12,7 @@ function (angular, config, _) {
$routeProvider $routeProvider
.when('/playlists', { .when('/playlists', {
templateUrl: 'app/features/playlist/partials/playlists.html', templateUrl: 'app/features/playlist/partials/playlists.html',
controller : 'PlaylistsCtrl', controller : 'PlaylistsCtrl'
resolve: {
playlists: function (backendSrv) {
return backendSrv.get('/api/playlists');
}
}
}) })
.when('/playlists/create', { .when('/playlists/create', {
templateUrl: 'app/features/playlist/partials/playlist.html', templateUrl: 'app/features/playlist/partials/playlist.html',
......
...@@ -8,13 +8,11 @@ function (angular, _) { ...@@ -8,13 +8,11 @@ function (angular, _) {
var module = angular.module('grafana.controllers'); var module = angular.module('grafana.controllers');
module.controller('PlaylistsCtrl', function( module.controller('PlaylistsCtrl', function(
playlists,
$scope, $scope,
$location, $location,
backendSrv backendSrv
) { ) {
$scope.playlists = backendSrv.get('/api/playlists');
$scope.playlists = playlists;
$scope.playlistUrl = function(playlist) { $scope.playlistUrl = function(playlist) {
return '/playlists/play/' + playlist.id; return '/playlists/play/' + playlist.id;
...@@ -26,14 +24,14 @@ function (angular, _) { ...@@ -26,14 +24,14 @@ function (angular, _) {
modalScope.playlist = playlist; modalScope.playlist = playlist;
modalScope.removePlaylist = function() { modalScope.removePlaylist = function() {
modalScope.dismiss(); modalScope.dismiss();
_.remove(playlists, {id: playlist.id}); _.remove($scope.playlists, {id: playlist.id});
backendSrv.delete('/api/playlists/' + playlist.id) backendSrv.delete('/api/playlists/' + playlist.id)
.then(function() { .then(function() {
$scope.appEvent('alert-success', ['Playlist deleted', '']); $scope.appEvent('alert-success', ['Playlist deleted', '']);
}, function() { }, function() {
$scope.appEvent('alert-error', ['Unable to delete playlist', '']); $scope.appEvent('alert-error', ['Unable to delete playlist', '']);
playlists.push(playlist); $scope.playlists.push(playlist);
}); });
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment