mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
define([
|
|
'angular',
|
|
'lodash'
|
|
],
|
|
function (angular, _) {
|
|
'use strict';
|
|
|
|
var module = angular.module('grafana.controllers');
|
|
|
|
module.controller('PlaylistsCtrl', function($scope, $location, backendSrv) {
|
|
backendSrv.get('/api/playlists')
|
|
.then(function(result) {
|
|
$scope.playlists = result;
|
|
});
|
|
|
|
$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');
|
|
};
|
|
});
|
|
});
|