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

update sync

This commit is contained in:
Luke Pulverenti 2016-08-23 13:33:21 -04:00
parent 6ab4b313a1
commit 521b20f86a
2 changed files with 87 additions and 11 deletions

View file

@ -425,10 +425,7 @@ define(['apphost', 'globalize', 'connectionManager', 'itemHelper', 'embyRouter',
{ {
require(['syncDialog'], function (syncDialog) { require(['syncDialog'], function (syncDialog) {
syncDialog.showMenu({ syncDialog.showMenu({
items: [ items: [item],
{
Id: itemId
}],
serverId: serverId serverId: serverId
}); });
}); });
@ -439,10 +436,7 @@ define(['apphost', 'globalize', 'connectionManager', 'itemHelper', 'embyRouter',
{ {
require(['syncDialog'], function (syncDialog) { require(['syncDialog'], function (syncDialog) {
syncDialog.showMenu({ syncDialog.showMenu({
items: [ items: [item],
{
Id: itemId
}],
isLocalSync: true, isLocalSync: true,
serverId: serverId serverId: serverId
}); });

View file

@ -1,4 +1,4 @@
define(['apphost', 'globalize', 'connectionManager', 'layoutManager', 'shell', 'focusManager', 'scrollHelper', 'paper-icon-button-light', 'formDialogStyle'], function (appHost, globalize, connectionManager, layoutManager, shell, focusManager, scrollHelper) { define(['apphost', 'globalize', 'connectionManager', 'layoutManager', 'shell', 'focusManager', 'scrollHelper', 'appSettings', 'paper-icon-button-light', 'formDialogStyle'], function (appHost, globalize, connectionManager, layoutManager, shell, focusManager, scrollHelper, appSettings) {
var currentDialogOptions; var currentDialogOptions;
@ -66,6 +66,56 @@
return true; return true;
} }
function submitQuickSyncJob(apiClient, userId, targetId, syncOptions) {
if (!userId) {
throw new Error('userId cannot be null');
}
if (!syncOptions) {
throw new Error('syncOptions cannot be null');
}
if (!targetId) {
throw new Error('targetId cannot be null');
}
var options = {
userId: userId,
TargetId: targetId,
ParentId: syncOptions.ParentId,
Category: syncOptions.Category,
Quality: syncOptions.Quality,
Bitrate: syncOptions.Bitrate
};
if (syncOptions.items && syncOptions.items.length) {
options.ItemIds = (syncOptions.items || []).map(function (i) {
return i.Id || i;
}).join(',');
}
return apiClient.ajax({
type: "POST",
url: apiClient.getUrl("Sync/Jobs"),
data: JSON.stringify(options),
contentType: "application/json",
dataType: 'json'
}).then(function () {
require(['toast'], function (toast) {
var msg = targetId == apiClient.deviceId() ? globalize.translate('sharedcomponents#DownloadScheduled') : globalize.translate('sharedcomponents#SyncJobCreated');
toast(msg);
});
});
}
function setJobValues(job, form) { function setJobValues(job, form) {
var txtBitrate = form.querySelector('#txtBitrate'); var txtBitrate = form.querySelector('#txtBitrate');
@ -272,12 +322,44 @@
}); });
} }
function enableAutoSync(options) {
if (!options.isLocalSync) {
return false;
}
var firstItem = (options.items || [])[0] || {};
if (firstItem.Type == 'Audio') {
return true;
}
if (firstItem.Type == 'MusicAlbum') {
return true;
}
if (firstItem.Type == 'MusicArtist') {
return true;
}
if (firstItem.Type == 'MusicGenre') {
return true;
}
return false;
}
function showSyncMenuInternal(dialogHelper, options) { function showSyncMenuInternal(dialogHelper, options) {
var apiClient = connectionManager.getApiClient(options.serverId); var apiClient = connectionManager.getApiClient(options.serverId);
var userId = apiClient.getCurrentUserId(); var userId = apiClient.getCurrentUserId();
if (enableAutoSync(options)) {
return submitQuickSyncJob(apiClient, userId, apiClient.deviceId(), {
items: options.items,
Quality: 'custom',
Bitrate: appSettings.maxStaticMusicBitrate()
});
}
var dialogOptionsQuery = { var dialogOptionsQuery = {
UserId: userId, UserId: userId,
ItemIds: (options.items || []).map(function (i) { ItemIds: (options.items || []).map(function (i) {