mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
trim loaded sync scripts
This commit is contained in:
parent
f220653d1b
commit
c49de6a93e
6 changed files with 124 additions and 121 deletions
|
@ -112,7 +112,7 @@
|
|||
$('.btnPlayTrailer', page).addClass('hide');
|
||||
}
|
||||
|
||||
if (SyncManager.isAvailable(item, user)) {
|
||||
if (LibraryBrowser.enableSync(item, user)) {
|
||||
$('.btnSync', page).removeClass('hide');
|
||||
} else {
|
||||
$('.btnSync', page).addClass('hide');
|
||||
|
@ -1987,8 +1987,10 @@
|
|||
|
||||
$('.btnSync', page).on('click', function () {
|
||||
|
||||
SyncManager.showMenu({
|
||||
items: [currentItem]
|
||||
require(['syncDialog'], function (syncDialog) {
|
||||
syncDialog.showMenu({
|
||||
items: [currentItem]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -809,7 +809,7 @@
|
|||
commands.push('refresh');
|
||||
}
|
||||
|
||||
if (SyncManager.isAvailable(item, user)) {
|
||||
if (LibraryBrowser.enableSync(item, user)) {
|
||||
commands.push('sync');
|
||||
}
|
||||
|
||||
|
@ -1581,6 +1581,18 @@
|
|||
return !item.CollectionType && invalidTypes.indexOf(item.Type) == -1 && item.MediaType != 'Photo';
|
||||
},
|
||||
|
||||
enableSync: function(item, user) {
|
||||
if (AppInfo.isNativeApp && !Dashboard.capabilities().SupportsSync) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (user && !user.Policy.EnableSync) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return item.SupportsSync;
|
||||
},
|
||||
|
||||
getItemCommands: function (item, options) {
|
||||
|
||||
var itemCommands = [];
|
||||
|
@ -1633,7 +1645,7 @@
|
|||
itemCommands.push('delete');
|
||||
}
|
||||
|
||||
if (SyncManager.isAvailable(item)) {
|
||||
if (LibraryBrowser.enableSync(item)) {
|
||||
itemCommands.push('sync');
|
||||
}
|
||||
|
||||
|
|
|
@ -542,11 +542,13 @@
|
|||
playAllFromHere(index, $(card).parents('.itemsContainer'), 'queue');
|
||||
break;
|
||||
case 'sync':
|
||||
SyncManager.showMenu({
|
||||
items: [
|
||||
{
|
||||
Id: itemId
|
||||
}]
|
||||
require(['syncDialog'], function (syncDialog) {
|
||||
syncDialog.showMenu({
|
||||
items: [
|
||||
{
|
||||
Id: itemId
|
||||
}]
|
||||
});
|
||||
});
|
||||
break;
|
||||
case 'editsubtitles':
|
||||
|
@ -1199,12 +1201,14 @@
|
|||
hideSelections();
|
||||
break;
|
||||
case 'sync':
|
||||
SyncManager.showMenu({
|
||||
items: items.map(function (i) {
|
||||
return {
|
||||
Id: i
|
||||
};
|
||||
})
|
||||
require(['syncDialog'], function (syncDialog) {
|
||||
syncDialog.showMenu({
|
||||
items: items.map(function (i) {
|
||||
return {
|
||||
Id: i
|
||||
};
|
||||
})
|
||||
});
|
||||
});
|
||||
hideSelections();
|
||||
break;
|
||||
|
@ -1325,6 +1329,41 @@
|
|||
});
|
||||
}
|
||||
|
||||
function showSyncButtonsPerUser(page) {
|
||||
|
||||
var apiClient = window.ApiClient;
|
||||
|
||||
if (!apiClient || !apiClient.getCurrentUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Dashboard.getCurrentUser().then(function (user) {
|
||||
|
||||
var item = {
|
||||
SupportsSync: true
|
||||
};
|
||||
|
||||
if (LibraryBrowser.enableSync(item, user)) {
|
||||
$('.categorySyncButton', page).removeClass('hide');
|
||||
} else {
|
||||
$('.categorySyncButton', page).addClass('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onCategorySyncButtonClick(page, button) {
|
||||
|
||||
var category = button.getAttribute('data-category');
|
||||
var parentId = LibraryMenu.getTopParentId();
|
||||
|
||||
require(['syncDialog'], function (syncDialog) {
|
||||
syncDialog.showMenu({
|
||||
ParentId: parentId,
|
||||
Category: category
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
pageClassOn('pageinit', "libraryPage", function () {
|
||||
|
||||
var page = this;
|
||||
|
@ -1336,6 +1375,20 @@
|
|||
$(itemsContainers[i]).createCardMenus();
|
||||
}
|
||||
|
||||
$('.categorySyncButton', page).on('click', function () {
|
||||
|
||||
onCategorySyncButtonClick(page, this);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
pageClassOn('pageshow', "libraryPage", function () {
|
||||
|
||||
var page = this;
|
||||
|
||||
if (!Dashboard.isServerlessPage()) {
|
||||
showSyncButtonsPerUser(page);
|
||||
}
|
||||
});
|
||||
|
||||
pageClassOn('pagebeforehide', "libraryPage", function () {
|
||||
|
|
|
@ -1846,6 +1846,7 @@ var AppInfo = {};
|
|||
}
|
||||
|
||||
paths.playlistManager = "scripts/playlistmanager";
|
||||
paths.syncDialog = "scripts/sync";
|
||||
|
||||
var sha1Path = bowerPath + "/cryptojslib/components/sha1-min";
|
||||
var md5Path = bowerPath + "/cryptojslib/components/md5-min";
|
||||
|
@ -2258,7 +2259,6 @@ var AppInfo = {};
|
|||
deps.push('scripts/search');
|
||||
deps.push('scripts/librarylist');
|
||||
deps.push('scripts/alphapicker');
|
||||
deps.push('scripts/sync');
|
||||
deps.push('scripts/backdrops');
|
||||
deps.push('scripts/librarymenu');
|
||||
deps.push('scripts/librarybrowser');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(function (window, $) {
|
||||
define([], function () {
|
||||
|
||||
var currentDialogOptions;
|
||||
|
||||
|
@ -52,7 +52,6 @@
|
|||
}).then(function () {
|
||||
|
||||
paperDialogHelper.close(dlg);
|
||||
$(window.SyncManager).trigger('jobsubmit');
|
||||
Dashboard.alert(Globalize.translate('MessageSyncJobCreated'));
|
||||
});
|
||||
}
|
||||
|
@ -299,6 +298,17 @@
|
|||
};
|
||||
}
|
||||
|
||||
function setQualityFieldVisible(form, visible) {
|
||||
|
||||
if (visible) {
|
||||
$('.fldQuality', form).show();
|
||||
$('#selectQuality', form).attr('required', 'required');
|
||||
} else {
|
||||
$('.fldQuality', form).hide();
|
||||
$('#selectQuality', form).removeAttr('required');
|
||||
}
|
||||
}
|
||||
|
||||
function onProfileChange(form, profileId) {
|
||||
|
||||
var options = currentDialogOptions || {};
|
||||
|
@ -337,25 +347,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
function loadQualityOptions(form, targetId, dialogOptionsFn) {
|
||||
|
||||
dialogOptionsFn(targetId).then(function (options) {
|
||||
|
||||
renderTargetDialogOptions(form, options);
|
||||
});
|
||||
}
|
||||
|
||||
function setQualityFieldVisible(form, visible) {
|
||||
|
||||
if (visible) {
|
||||
$('.fldQuality', form).show();
|
||||
$('#selectQuality', form).attr('required', 'required');
|
||||
} else {
|
||||
$('.fldQuality', form).hide();
|
||||
$('#selectQuality', form).removeAttr('required');
|
||||
}
|
||||
}
|
||||
|
||||
function renderTargetDialogOptions(form, options) {
|
||||
|
||||
currentDialogOptions = options;
|
||||
|
@ -385,78 +376,18 @@
|
|||
}).join('')).trigger('change');
|
||||
}
|
||||
|
||||
function isAvailable(item, user) {
|
||||
function loadQualityOptions(form, targetId, dialogOptionsFn) {
|
||||
|
||||
if (AppInfo.isNativeApp && !Dashboard.capabilities().SupportsSync) {
|
||||
return false;
|
||||
}
|
||||
dialogOptionsFn(targetId).then(function (options) {
|
||||
|
||||
if (user && !user.Policy.EnableSync) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return item.SupportsSync;
|
||||
renderTargetDialogOptions(form, options);
|
||||
});
|
||||
}
|
||||
|
||||
window.SyncManager = {
|
||||
return {
|
||||
|
||||
showMenu: showSyncMenu,
|
||||
isAvailable: isAvailable,
|
||||
renderForm: renderForm,
|
||||
setJobValues: setJobValues
|
||||
};
|
||||
|
||||
function showSyncButtonsPerUser(page) {
|
||||
|
||||
var apiClient = window.ApiClient;
|
||||
|
||||
if (!apiClient || !apiClient.getCurrentUserId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Dashboard.getCurrentUser().then(function (user) {
|
||||
|
||||
var item = {
|
||||
SupportsSync: true
|
||||
};
|
||||
|
||||
if (isAvailable(item, user)) {
|
||||
$('.categorySyncButton', page).removeClass('hide');
|
||||
} else {
|
||||
$('.categorySyncButton', page).addClass('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onCategorySyncButtonClick(page, button) {
|
||||
|
||||
var category = button.getAttribute('data-category');
|
||||
var parentId = LibraryMenu.getTopParentId();
|
||||
|
||||
SyncManager.showMenu({
|
||||
ParentId: parentId,
|
||||
Category: category
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('pageinit', ".libraryPage", function () {
|
||||
|
||||
var page = this;
|
||||
|
||||
$('.categorySyncButton', page).on('click', function () {
|
||||
|
||||
onCategorySyncButtonClick(page, this);
|
||||
});
|
||||
|
||||
}).on('pageshow', ".libraryPage", function () {
|
||||
|
||||
var page = this;
|
||||
|
||||
if (!Dashboard.isServerlessPage()) {
|
||||
showSyncButtonsPerUser(page);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
})(window, jQuery);
|
||||
});
|
|
@ -17,14 +17,17 @@
|
|||
html += '</button>';
|
||||
|
||||
$('.syncJobForm', page).html(html);
|
||||
SyncManager.renderForm({
|
||||
elem: $('.formFields', page),
|
||||
dialogOptions: dialogOptions,
|
||||
dialogOptionsFn: getTargetDialogOptionsFn(dialogOptions),
|
||||
showName: true,
|
||||
readOnlySyncTarget: true
|
||||
}).then(function () {
|
||||
fillJobValues(page, job, dialogOptions);
|
||||
|
||||
require(['syncDialog'], function (syncDialog) {
|
||||
syncDialog.renderForm({
|
||||
elem: $('.formFields', page),
|
||||
dialogOptions: dialogOptions,
|
||||
dialogOptionsFn: getTargetDialogOptionsFn(dialogOptions),
|
||||
showName: true,
|
||||
readOnlySyncTarget: true
|
||||
}).then(function () {
|
||||
fillJobValues(page, job, dialogOptions);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -344,19 +347,21 @@
|
|||
|
||||
ApiClient.getJSON(ApiClient.getUrl('Sync/Jobs/' + id)).then(function (job) {
|
||||
|
||||
SyncManager.setJobValues(job, page);
|
||||
require(['syncDialog'], function (syncDialog) {
|
||||
syncDialog.setJobValues(job, page);
|
||||
|
||||
ApiClient.ajax({
|
||||
ApiClient.ajax({
|
||||
|
||||
url: ApiClient.getUrl('Sync/Jobs/' + id),
|
||||
type: 'POST',
|
||||
data: JSON.stringify(job),
|
||||
contentType: "application/json"
|
||||
url: ApiClient.getUrl('Sync/Jobs/' + id),
|
||||
type: 'POST',
|
||||
data: JSON.stringify(job),
|
||||
contentType: "application/json"
|
||||
|
||||
}).then(function () {
|
||||
}).then(function () {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
Dashboard.alert(Globalize.translate('SettingsSaved'));
|
||||
Dashboard.hideLoadingMsg();
|
||||
Dashboard.alert(Globalize.translate('SettingsSaved'));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue