1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

update task buttons

This commit is contained in:
Luke Pulverenti 2015-01-22 11:41:34 -05:00
parent 3dcd5b04d5
commit 4b51e69e53
6 changed files with 52 additions and 14 deletions

View file

@ -65,6 +65,39 @@ $.fn.taskButton = function (options) {
}
}
function onScheduledTaskMessageConfirmed(instance, id) {
ApiClient.startScheduledTask(id).done(function () {
pollTasks(instance);
});
}
function onButtonClick(instance, id) {
var key = 'scheduledTaskButton' + options.taskKey;
var expectedValue = '4';
if (store.getItem(key) == expectedValue) {
onScheduledTaskMessageConfirmed(instance, id);
} else {
var msg = Globalize.translate('ConfirmMessageScheduledTaskButton');
msg += '<br/>';
msg += '<br/>';
msg += '<a href="scheduledtasks.html">' + Globalize.translate('ButtonScheduledTasks') + '</a>';
Dashboard.confirm(msg, Globalize.translate('HeaderConfirmation'), function (result) {
if (result) {
store.setItem(key, expectedValue);
onScheduledTaskMessageConfirmed(instance, id);
}
});
}
}
var self = this;
if (options.panel) {
@ -73,24 +106,21 @@ $.fn.taskButton = function (options) {
if (options.mode == 'off') {
this.off(".taskbutton");
$(ApiClient).off(".taskbutton");
if (ApiClient.isWebSocketOpen()) {
ApiClient.sendWebSocketMessage("ScheduledTasksInfoStop");
}
$(ApiClient).off(".taskbutton");
} else {
this.on('click', function () {
this.on('click.taskbutton', function () {
var button = this;
var id = button.getAttribute('data-taskid');
ApiClient.startScheduledTask(id).done(function () {
pollTasks(self);
});
onButtonClick(self, id);
});
pollTasks(self);