update buttons immediately when starting/stopping tasks

This commit is contained in:
Luke Pulverenti 2013-04-16 14:20:07 -04:00
parent 3544f24448
commit 4ced71186b

View File

@ -135,22 +135,26 @@
var btnTask = $('#btnTask' + task.Id, page);
if (task.State == "Idle") {
btnTask.addClass('btnStartTask').removeClass('btnStopTask').show().data('icon', 'play').buttonMarkup("refresh");
}
else if (task.State == "Running") {
btnTask.addClass('btnStopTask').removeClass('btnStartTask').show().data('icon', 'stop').buttonMarkup("refresh");
} else {
btnTask.addClass('btnStartTask').removeClass('btnStopTask').hide().data('icon', 'play').buttonMarkup("refresh");
}
updateTaskButton(btnTask, task.State);
}
}
}
function updateTaskButton(btnTask, state) {
if (state == "Idle") {
btnTask.addClass('btnStartTask').removeClass('btnStopTask').show().data('icon', 'play').buttonMarkup("refresh");
}
else if (state == "Running") {
btnTask.addClass('btnStopTask').removeClass('btnStartTask').show().data('icon', 'stop').buttonMarkup("refresh");
} else {
btnTask.addClass('btnStartTask').removeClass('btnStopTask').hide().data('icon', 'play').buttonMarkup("refresh");
}
}
function onWebSocketConnectionChange() {
reloadList($.mobile.activePage, true);
}
@ -179,17 +183,21 @@
$('#divScheduledTasks', page).on('click', '.btnStartTask', function () {
var id = this.getAttribute('data-taskid');
var button = this;
var id = button.getAttribute('data-taskid');
ApiClient.startScheduledTask(id).done(function () {
updateTaskButton($(button), "Running");
reloadList(page);
});
}).on('click', '.btnStopTask', function () {
var id = this.getAttribute('data-taskid');
var button = this;
var id = button.getAttribute('data-taskid');
ApiClient.stopScheduledTask(id).done(function () {
updateTaskButton($(button), "");
reloadList(page);
});
});