mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
There is no point resolving the playlists in the routes file. Loading playlists is what the controller is suppose to do
49 lines
1.2 KiB
JavaScript
49 lines
1.2 KiB
JavaScript
define([
|
|
'angular',
|
|
'lodash'
|
|
],
|
|
function (angular, _) {
|
|
'use strict';
|
|
|
|
var module = angular.module('grafana.controllers');
|
|
|
|
module.controller('PlaylistsCtrl', function(
|
|
$scope,
|
|
$location,
|
|
backendSrv
|
|
) {
|
|
$scope.playlists = backendSrv.get('/api/playlists');
|
|
|
|
$scope.playlistUrl = function(playlist) {
|
|
return '/playlists/play/' + playlist.id;
|
|
};
|
|
|
|
$scope.removePlaylist = function(playlist) {
|
|
var modalScope = $scope.$new(true);
|
|
|
|
modalScope.playlist = playlist;
|
|
modalScope.removePlaylist = function() {
|
|
modalScope.dismiss();
|
|
_.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', '']);
|
|
$scope.playlists.push(playlist);
|
|
});
|
|
};
|
|
|
|
$scope.appEvent('show-modal', {
|
|
src: './app/features/playlist/partials/playlist-remove.html',
|
|
scope: modalScope
|
|
});
|
|
};
|
|
|
|
$scope.createPlaylist = function() {
|
|
$location.path('/playlists/create');
|
|
};
|
|
});
|
|
});
|