mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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
This commit is contained in:
parent
8c05067f88
commit
01a910fedc
@ -12,12 +12,7 @@ function (angular, config, _) {
|
||||
$routeProvider
|
||||
.when('/playlists', {
|
||||
templateUrl: 'app/features/playlist/partials/playlists.html',
|
||||
controller : 'PlaylistsCtrl',
|
||||
resolve: {
|
||||
playlists: function (backendSrv) {
|
||||
return backendSrv.get('/api/playlists');
|
||||
}
|
||||
}
|
||||
controller : 'PlaylistsCtrl'
|
||||
})
|
||||
.when('/playlists/create', {
|
||||
templateUrl: 'app/features/playlist/partials/playlist.html',
|
||||
|
@ -8,13 +8,11 @@ function (angular, _) {
|
||||
var module = angular.module('grafana.controllers');
|
||||
|
||||
module.controller('PlaylistsCtrl', function(
|
||||
playlists,
|
||||
$scope,
|
||||
$location,
|
||||
backendSrv
|
||||
) {
|
||||
|
||||
$scope.playlists = playlists;
|
||||
$scope.playlists = backendSrv.get('/api/playlists');
|
||||
|
||||
$scope.playlistUrl = function(playlist) {
|
||||
return '/playlists/play/' + playlist.id;
|
||||
@ -26,14 +24,14 @@ function (angular, _) {
|
||||
modalScope.playlist = playlist;
|
||||
modalScope.removePlaylist = function() {
|
||||
modalScope.dismiss();
|
||||
_.remove(playlists, {id: playlist.id});
|
||||
_.remove($scope.playlists, {id: playlist.id});
|
||||
|
||||
backendSrv.delete('/api/playlists/' + playlist.id)
|
||||
.then(function() {
|
||||
$scope.appEvent('alert-success', ['Playlist deleted', '']);
|
||||
}, function() {
|
||||
$scope.appEvent('alert-error', ['Unable to delete playlist', '']);
|
||||
playlists.push(playlist);
|
||||
$scope.playlists.push(playlist);
|
||||
});
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user