Kaynağa Gözat

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
bergquist 10 yıl önce
ebeveyn
işleme
01a910fedc

+ 1 - 6
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',

+ 3 - 5
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);
           });
       };