mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
///<reference path="../../headers/common.d.ts" />
|
|
|
|
import angular from 'angular';
|
|
import _ from 'lodash';
|
|
import coreModule from '../../core/core_module';
|
|
|
|
export class PlaylistsCtrl {
|
|
playlists: any;
|
|
|
|
/** @ngInject */
|
|
constructor(private $scope, private $location, private backendSrv) {
|
|
backendSrv.get('/api/playlists')
|
|
.then((result) => {
|
|
this.playlists = result;
|
|
});
|
|
}
|
|
|
|
removePlaylistConfirmed(playlist) {
|
|
_.remove(this.playlists, { id: playlist.id });
|
|
|
|
this.backendSrv.delete('/api/playlists/' + playlist.id)
|
|
.then(() => {
|
|
this.$scope.appEvent('alert-success', ['Playlist deleted', '']);
|
|
}, () => {
|
|
this.$scope.appEvent('alert-error', ['Unable to delete playlist', '']);
|
|
this.playlists.push(playlist);
|
|
});
|
|
}
|
|
|
|
removePlaylist(playlist) {
|
|
|
|
this.$scope.appEvent('confirm-modal', {
|
|
title: 'Delete',
|
|
text: 'Are you sure you want to delete playlist ' + playlist.name + '?',
|
|
yesText: "Delete",
|
|
icon: "fa-trash",
|
|
onConfirm: () => {
|
|
this.removePlaylistConfirmed(playlist);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
coreModule.controller('PlaylistsCtrl', PlaylistsCtrl);
|