mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* wip: design update for navbar with kiosk mode button * feat: progress on new view mode button * css: view state refactorings * feat: kiosk modes & playlist support * feature: cycle tv mode feature, renamed view modes to TV, and Kiosk * fix: updated the alert notification message * fix: removed unused parameter * fix: correct the css class set for tv mode * some minor improvements to playlist
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import _ from 'lodash';
|
|
import coreModule from '../../core/core_module';
|
|
|
|
export class PlaylistsCtrl {
|
|
playlists: any;
|
|
navModel: any;
|
|
|
|
/** @ngInject */
|
|
constructor(private $scope, private backendSrv, navModelSrv) {
|
|
this.navModel = navModelSrv.getNav('dashboards', 'playlists', 0);
|
|
|
|
backendSrv.get('/api/playlists').then(result => {
|
|
this.playlists = result.map(item => {
|
|
item.startUrl = `playlists/play/${item.id}`;
|
|
return item;
|
|
});
|
|
});
|
|
}
|
|
|
|
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);
|