mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 19:08:18 -07:00
fix sync task button
This commit is contained in:
parent
f6b89286dc
commit
9ebe643e87
@ -1,4 +1,4 @@
|
||||
<div id="libraryFileOrganizerLogPage" data-role="page" class="page type-interior organizePage withTabs fullWidthContent" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Auto-Organize" data-require="jqmtable,scripts/autoorganizelog,scripts/taskbutton,detailtablecss">
|
||||
<div id="libraryFileOrganizerLogPage" data-role="page" class="page type-interior organizePage withTabs fullWidthContent" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Auto-Organize" data-require="jqmtable,scripts/autoorganizelog,detailtablecss">
|
||||
<div data-role="content">
|
||||
<div class="content-primary">
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div id="mediaLibraryPage" data-role="page" class="page type-interior mediaLibraryPage librarySectionPage withTabs fullWidthContent" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Library%20setup" data-require="scripts/medialibrarypage,scripts/taskbutton">
|
||||
<div id="mediaLibraryPage" data-role="page" class="page type-interior mediaLibraryPage librarySectionPage withTabs fullWidthContent" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Library%20setup" data-require="scripts/medialibrarypage">
|
||||
|
||||
<div data-role="content">
|
||||
<div class="content-primary">
|
||||
|
@ -1,4 +1,4 @@
|
||||
<div id="liveTvStatusPage" data-role="page" class="page type-interior liveTvSettingsPage withTabs" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Live%20TV" data-require="scripts/livetvstatus,scripts/taskbutton,emby-button">
|
||||
<div id="liveTvStatusPage" data-role="page" class="page type-interior liveTvSettingsPage withTabs" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Live%20TV" data-require="scripts/livetvstatus,emby-button">
|
||||
|
||||
<div data-role="content">
|
||||
<div class="content-primary">
|
||||
|
@ -1,4 +1,4 @@
|
||||
define(['jQuery', 'datetime', 'paper-icon-button-light'], function ($, datetime) {
|
||||
define(['jQuery', 'scripts/taskbutton', 'datetime', 'paper-icon-button-light'], function ($, taskButton, datetime) {
|
||||
|
||||
var query = {
|
||||
|
||||
@ -309,11 +309,12 @@
|
||||
reloadItems(page);
|
||||
|
||||
// on here
|
||||
$('.btnOrganize', page).taskButton({
|
||||
taskButton({
|
||||
mode: 'on',
|
||||
progressElem: page.querySelector('.organizeProgress'),
|
||||
panel: page.querySelector('.organizeTaskPanel'),
|
||||
taskKey: 'AutoOrganize'
|
||||
taskKey: 'AutoOrganize',
|
||||
button: page.querySelector('.btnOrganize')
|
||||
});
|
||||
|
||||
Events.on(ApiClient, 'websocketmessage', onWebSocketMessage);
|
||||
@ -325,8 +326,9 @@
|
||||
currentResult = null;
|
||||
|
||||
// off here
|
||||
$('.btnOrganize', page).taskButton({
|
||||
mode: 'off'
|
||||
taskButton({
|
||||
mode: 'off',
|
||||
button: page.querySelector('.btnOrganize')
|
||||
});
|
||||
|
||||
Events.off(ApiClient, 'websocketmessage', onWebSocketMessage);
|
||||
|
@ -674,7 +674,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
viewMenuBarTabs.querySelector('is=["emby-tabs"]').selectedIndex(selectedIndex);
|
||||
viewMenuBarTabs.querySelector('[is="emby-tabs"]').selectedIndex(selectedIndex);
|
||||
|
||||
LibraryMenu.tabType = type;
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
define(['jQuery', 'listViewStyle'], function ($) {
|
||||
define(['jQuery', 'scripts/taskbutton', 'listViewStyle'], function ($, taskButton) {
|
||||
|
||||
function resetTuner(page, id) {
|
||||
|
||||
@ -595,10 +595,11 @@
|
||||
reload(page);
|
||||
|
||||
// on here
|
||||
$('.btnRefresh', page).taskButton({
|
||||
taskButton({
|
||||
mode: 'on',
|
||||
progressElem: page.querySelector('.refreshGuideProgress'),
|
||||
taskKey: 'RefreshGuide'
|
||||
taskKey: 'RefreshGuide',
|
||||
button: page.querySelector('.btnRefresh')
|
||||
});
|
||||
|
||||
}).on('pagehide', "#liveTvStatusPage", function () {
|
||||
@ -606,8 +607,11 @@
|
||||
var page = this;
|
||||
|
||||
// off here
|
||||
$('.btnRefreshGuide', page).taskButton({
|
||||
mode: 'off'
|
||||
taskButton({
|
||||
mode: 'off',
|
||||
progressElem: page.querySelector('.refreshGuideProgress'),
|
||||
taskKey: 'RefreshGuide',
|
||||
button: page.querySelector('.btnRefresh')
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
define(['jQuery', 'apphost', 'cardStyle'], function ($, appHost) {
|
||||
define(['jQuery', 'apphost', 'scripts/taskbutton', 'cardStyle'], function ($, appHost, taskButton) {
|
||||
|
||||
function changeCollectionType(page, virtualFolder) {
|
||||
|
||||
@ -461,10 +461,11 @@
|
||||
var page = this;
|
||||
|
||||
// on here
|
||||
$('.btnRefresh', page).taskButton({
|
||||
taskButton({
|
||||
mode: 'on',
|
||||
progressElem: page.querySelector('.refreshProgress'),
|
||||
taskKey: 'RefreshLibrary'
|
||||
taskKey: 'RefreshLibrary',
|
||||
button: page.querySelector('.btnRefresh')
|
||||
});
|
||||
|
||||
});
|
||||
@ -474,8 +475,11 @@
|
||||
var page = this;
|
||||
|
||||
// off here
|
||||
$('.btnRefresh', page).taskButton({
|
||||
mode: 'off'
|
||||
taskButton({
|
||||
mode: 'off',
|
||||
progressElem: page.querySelector('.refreshProgress'),
|
||||
taskKey: 'RefreshLibrary',
|
||||
button: page.querySelector('.btnRefresh')
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
define(['loading', 'apphost', 'globalize', 'syncJobList', 'events', 'localsync', 'emby-button', 'paper-icon-button-light'], function (loading, appHost, globalize, syncJobList, events) {
|
||||
define(['loading', 'apphost', 'globalize', 'syncJobList', 'events', 'scripts/taskbutton', 'localsync', 'emby-button', 'paper-icon-button-light'], function (loading, appHost, globalize, syncJobList, events, taskButton) {
|
||||
|
||||
function getTabs() {
|
||||
return [
|
||||
@ -57,6 +57,22 @@
|
||||
view.addEventListener('viewshow', function () {
|
||||
|
||||
LibraryMenu.setTabs('syncadmin', 0, getTabs);
|
||||
|
||||
taskButton({
|
||||
mode: 'on',
|
||||
progressElem: view.querySelector('.syncProgress'),
|
||||
taskKey: 'SyncPrepare',
|
||||
button: view.querySelector('.btnSync')
|
||||
});
|
||||
});
|
||||
|
||||
view.addEventListener('viewbeforehide', function () {
|
||||
|
||||
taskButton({
|
||||
mode: 'off',
|
||||
taskKey: 'SyncPrepare',
|
||||
button: view.querySelector('.btnSync')
|
||||
});
|
||||
});
|
||||
|
||||
view.addEventListener('viewdestroy', function () {
|
||||
|
@ -1,21 +1,19 @@
|
||||
define(['appStorage', 'jQuery', 'emby-button'], function (appStorage, $) {
|
||||
define(['appStorage', 'emby-button'], function (appStorage) {
|
||||
|
||||
$.fn.taskButton = function (options) {
|
||||
return function (options) {
|
||||
|
||||
function pollTasks(button) {
|
||||
var button = options.button;
|
||||
|
||||
function pollTasks() {
|
||||
|
||||
ApiClient.getScheduledTasks({
|
||||
|
||||
IsEnabled: true
|
||||
|
||||
}).then(function (tasks) {
|
||||
|
||||
updateTasks(button, tasks);
|
||||
});
|
||||
|
||||
}).then(updateTasks);
|
||||
}
|
||||
|
||||
function updateTasks(button, tasks) {
|
||||
function updateTasks(tasks) {
|
||||
|
||||
var task = tasks.filter(function (t) {
|
||||
|
||||
@ -36,12 +34,12 @@
|
||||
}
|
||||
|
||||
if (task.State == 'Idle') {
|
||||
$(button).removeAttr('disabled');
|
||||
button.removeAttribute('disabled');
|
||||
} else {
|
||||
$(button).attr('disabled', 'disabled');
|
||||
button.setAttribute('disabled', 'disabled');
|
||||
}
|
||||
|
||||
$(button).attr('data-taskid', task.Id);
|
||||
button.setAttribute('data-taskid', task.Id);
|
||||
|
||||
var progress = (task.CurrentProgressPercentage || 0).toFixed(1);
|
||||
|
||||
@ -72,11 +70,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
function onScheduledTaskMessageConfirmed(instance, id) {
|
||||
ApiClient.startScheduledTask(id).then(function () {
|
||||
|
||||
pollTasks(instance);
|
||||
});
|
||||
function onScheduledTaskMessageConfirmed(id) {
|
||||
ApiClient.startScheduledTask(id).then(pollTasks);
|
||||
}
|
||||
|
||||
function onButtonClick() {
|
||||
@ -88,7 +83,7 @@
|
||||
var expectedValue = new Date().getMonth() + '6';
|
||||
|
||||
if (appStorage.getItem(key) == expectedValue) {
|
||||
onScheduledTaskMessageConfirmed(button, id);
|
||||
onScheduledTaskMessageConfirmed(id);
|
||||
} else {
|
||||
|
||||
var msg = Globalize.translate('ConfirmMessageScheduledTaskButton');
|
||||
@ -107,7 +102,7 @@
|
||||
|
||||
}).then(function () {
|
||||
appStorage.setItem(key, expectedValue);
|
||||
onScheduledTaskMessageConfirmed(button, id);
|
||||
onScheduledTaskMessageConfirmed(id);
|
||||
});
|
||||
|
||||
});
|
||||
@ -123,17 +118,16 @@
|
||||
|
||||
var tasks = msg.Data;
|
||||
|
||||
updateTasks(self, tasks);
|
||||
updateTasks(tasks);
|
||||
}
|
||||
}
|
||||
|
||||
var self = this;
|
||||
var pollInterval;
|
||||
|
||||
function onPollIntervalFired() {
|
||||
|
||||
if (!ApiClient.isWebSocketOpen()) {
|
||||
pollTasks(self);
|
||||
pollTasks();
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,23 +156,21 @@
|
||||
|
||||
if (options.mode == 'off') {
|
||||
|
||||
this.off('click', onButtonClick);
|
||||
button.removeEventListener('click', onButtonClick);
|
||||
Events.off(ApiClient, 'websocketmessage', onSocketMessage);
|
||||
Events.off(ApiClient, 'websocketopen', onSocketOpen);
|
||||
stopInterval();
|
||||
|
||||
} else if (this.length) {
|
||||
} else {
|
||||
|
||||
this.on('click', onButtonClick);
|
||||
button.addEventListener('click', onButtonClick);
|
||||
|
||||
pollTasks(self);
|
||||
pollTasks();
|
||||
|
||||
startInterval();
|
||||
|
||||
Events.on(ApiClient, 'websocketmessage', onSocketMessage);
|
||||
Events.on(ApiClient, 'websocketopen', onSocketOpen);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
});
|
Loading…
Reference in New Issue
Block a user