From 01a910fedc0a5959298a82d951db9d6816ecc35e Mon Sep 17 00:00:00 2001 From: bergquist Date: Fri, 8 Jan 2016 13:33:24 +0100 Subject: [PATCH] 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 --- public/app/features/playlist/playlist_routes.js | 7 +------ public/app/features/playlist/playlists_ctrl.js | 8 +++----- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/public/app/features/playlist/playlist_routes.js b/public/app/features/playlist/playlist_routes.js index 0a40bfe2114..cd19a20d686 100644 --- a/public/app/features/playlist/playlist_routes.js +++ b/public/app/features/playlist/playlist_routes.js @@ -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', diff --git a/public/app/features/playlist/playlists_ctrl.js b/public/app/features/playlist/playlists_ctrl.js index 26d3cfaf175..f9aa62f59ef 100644 --- a/public/app/features/playlist/playlists_ctrl.js +++ b/public/app/features/playlist/playlists_ctrl.js @@ -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); }); };