unify sync components

This commit is contained in:
Luke Pulverenti 2016-12-24 14:15:27 -05:00
parent 55b5cebda5
commit db403c3cd4
21 changed files with 447 additions and 279 deletions

View File

@ -16,12 +16,12 @@
},
"devDependencies": {},
"ignore": [],
"version": "1.1.105",
"_release": "1.1.105",
"version": "1.1.106",
"_release": "1.1.106",
"_resolution": {
"type": "version",
"tag": "1.1.105",
"commit": "d46515271d43d1b0f7dd19bb1834cfd457fb3326"
"tag": "1.1.106",
"commit": "2bed46ebe6ee1e213b5f89476ca8c285937ba343"
},
"_source": "https://github.com/MediaBrowser/Emby.ApiClient.Javascript.git",
"_target": "^1.1.51",

View File

@ -1,8 +1,12 @@
define([], function () {
'use strict';
function getLocalMediaSource(serverId, itemId) {
return Promise.resolve(null);
function getLocalItem(serverId, itemId) {
return Promise.resolve();
}
function getLocalItemById(id) {
return Promise.resolve();
}
function saveOfflineUser(user) {
@ -30,7 +34,6 @@
}
function deleteUserActions(actions) {
//TODO:
return Promise.resolve();
}
@ -38,11 +41,19 @@
return Promise.resolve([]);
}
function removeLocalItem(localItem) {
return Promise.resolve();
function getServerItems(serverId) {
return Promise.resolve([]);
}
function getLocalItem(itemId, serverId) {
function getViews(serverId, userId) {
return Promise.resolve([]);
}
function getViewItems(serverId, userId, parentId) {
return Promise.resolve([]);
}
function removeLocalItem(localItem) {
return Promise.resolve();
}
@ -51,45 +62,51 @@
}
function createLocalItem(libraryItem, serverInfo, jobItem) {
return Promise.resolve({});
}
function downloadFile(url, localPath) {
return Promise.resolve();
}
function downloadSubtitles(url, localItem, subtitleStreamh) {
return Promise.resolve('');
function getSubtitleSaveFileName(localItem, mediaPath, language, isForced, format) {
return null;
}
function hasImage(serverId, itemId, imageTag) {
return Promise.resolve(false);
function getItemFileSize(path) {
return Promise.resolve();
}
function downloadImage(url, serverId, itemId, imageTag) {
return Promise.resolve(false);
function downloadFile(url, localItem) {
return Promise.resolve();
}
function fileExists(path) {
return Promise.resolve(false);
function downloadSubtitles(url, fileName) {
return Promise.resolve();
}
function getImageUrl(serverId, itemId, imageType, index) {
return null;
}
function hasImage(serverId, itemId, imageType, index) {
return Promise.resolve();
}
function downloadImage(localItem, url, serverId, itemId, imageType, index) {
return Promise.resolve();
}
function isDownloadFileInQueue(path) {
return Promise.resolve();
}
function translateFilePath(path) {
return Promise.resolve(path);
}
function getLocalFilePath(path) {
return null;
}
function getLocalItemById(id) {
return null;
function resyncTransfers() {
return Promise.resolve();
}
return {
getLocalItem: getLocalItem,
saveOfflineUser: saveOfflineUser,
deleteOfflineUser: deleteOfflineUser,
@ -106,9 +123,15 @@
downloadSubtitles: downloadSubtitles,
hasImage: hasImage,
downloadImage: downloadImage,
fileExists: fileExists,
getImageUrl: getImageUrl,
translateFilePath: translateFilePath,
getLocalFilePath: getLocalFilePath,
getLocalItemById: getLocalItemById
getSubtitleSaveFileName: getSubtitleSaveFileName,
getLocalItemById: getLocalItemById,
getServerItems: getServerItems,
getItemFileSize: getItemFileSize,
isDownloadFileInQueue: isDownloadFileInQueue,
getViews: getViews,
getViewItems: getViewItems,
resyncTransfers: resyncTransfers
};
});

View File

@ -15,6 +15,13 @@
}
function getPathFromArray(pathArray) {
// TODO
return pathArray.join('/');
}
function deleteFile(path) {
return Promise.resolve();
}
@ -34,6 +41,7 @@
return {
getValidFileName: getValidFileName,
getFullLocalPath: getFullLocalPath,
getPathFromArray: getPathFromArray,
deleteFile: deleteFile,
deleteDirectory: deleteDirectory,
fileExists: fileExists,

View File

@ -35,6 +35,18 @@
});
}
function getServerItemTypes(serverId, userId) {
return dbPromise.then(function (db) {
return db.transaction(dbName).objectStore(dbName).getAll(null, 10000).then(function (all) {
return all.filter(function (item) {
return item.ServerId === serverId && (item.UserIdsWithAccess == null || item.UserIdsWithAccess.contains(userId));
}).map(function (item2) {
return (item2.Item.Type || '').toLowerCase();
}).filter(filterDistinct);
});
});
}
function getServerIds(serverId) {
return dbPromise.then(function (db) {
return db.transaction(dbName).objectStore(dbName).getAll(null, 10000).then(function (all) {
@ -83,6 +95,10 @@
});
}
function filterDistinct(value, index, self) {
return self.indexOf(value) === index;
}
setup();
return {
@ -92,6 +108,7 @@
clear: clear,
getAll: getAll,
getServerItemIds: getServerItemIds,
getServerIds: getServerIds
getServerIds: getServerIds,
getServerItemTypes: getServerItemTypes
};
});

View File

@ -5,27 +5,30 @@
console.log('[mediasync] Begin processDownloadStatus');
return localassetmanager.getServerItems(serverInfo.Id).then(function (items) {
return localassetmanager.resyncTransfers().then(function () {
console.log('[mediasync] Begin processDownloadStatus getServerItems completed');
return localassetmanager.getServerItems(serverInfo.Id).then(function (items) {
var progressItems = items.filter(function (item) {
return item.SyncStatus === 'transferring' || item.SyncStatus === 'queued';
});
console.log('[mediasync] Begin processDownloadStatus getServerItems completed');
var p = Promise.resolve();
var cnt = 0;
progressItems.forEach(function (item) {
p = p.then(function () {
return reportTransfer(apiClient, item);
var progressItems = items.filter(function (item) {
return item.SyncStatus === 'transferring' || item.SyncStatus === 'queued';
});
cnt++;
});
return p.then(function () {
console.log('[mediasync] Exit processDownloadStatus. Items reported: ' + cnt.toString());
return Promise.resolve();
var p = Promise.resolve();
var cnt = 0;
progressItems.forEach(function (item) {
p = p.then(function () {
return reportTransfer(apiClient, item);
});
cnt++;
});
return p.then(function () {
console.log('[mediasync] Exit processDownloadStatus. Items reported: ' + cnt.toString());
return Promise.resolve();
});
});
});
}
@ -40,23 +43,23 @@
item.SyncStatus = 'synced';
return localassetmanager.addOrUpdateLocalItem(item);
}, function (error) {
console.error("[mediasync] Mediasync error on reportSyncJobItemTransferred", error);
console.error('[mediasync] Mediasync error on reportSyncJobItemTransferred', error);
item.SyncStatus = 'error';
return localassetmanager.addOrUpdateLocalItem(item);
});
} else {
return localassetmanager.isDownloadInQueue(item.SyncJobItemId).then(function (result) {
return localassetmanager.isDownloadFileInQueue(item.LocalPath).then(function (result) {
if (result) {
// just wait for completion
return Promise.resolve();
}
console.log("[mediasync] reportTransfer: Size is 0 and download no longer in queue. Deleting item.");
console.log('[mediasync] reportTransfer: Size is 0 and download no longer in queue. Deleting item.');
return localassetmanager.removeLocalItem(item).then(function () {
console.log('[mediasync] reportTransfer: Item deleted.');
return Promise.resolve();
}, function (err2) {
console.log('[mediasync] reportTransfer: Failed to delete item.', error);
console.log('[mediasync] reportTransfer: Failed to delete item.', err2);
return Promise.resolve();
});
});
@ -123,8 +126,10 @@
return apiClient.syncData(request).then(function (result) {
return afterSyncData(apiClient, serverInfo, syncUserItemAccess, result).then(function () {
console.log('[mediasync] Exit syncData');
return Promise.resolve();
}, function () {
}, function (err) {
console.error('[mediasync] Error in syncData: ' + err.toString());
return Promise.resolve();
});
@ -202,20 +207,21 @@
return localassetmanager.getLocalItem(serverInfo.Id, libraryItem.Id).then(function (existingItem) {
console.log('[mediasync] getNewItem.getLocalItem completed');
if (existingItem) {
if (existingItem.SyncStatus === 'queued' || existingItem.SyncStatus === 'transferring' || existingItem.SyncStatus === 'synced') {
console.log('[mediasync] getNewItem.getLocalItem found existing item');
console.log('[mediasync] getNewItem: getLocalItem found existing item');
return Promise.resolve();
}
}
console.log('[mediasync] getNewItem.getLocalItem no existing item found');
libraryItem.CanDelete = false;
libraryItem.CanDownload = false;
libraryItem.People = [];
libraryItem.SpecialFeatureCount = null;
return localassetmanager.createLocalItem(libraryItem, serverInfo, jobItem).then(function (localItem) {
console.log('[mediasync] getNewItem.createLocalItem completed');
console.log('[mediasync] getNewItem: createLocalItem completed');
localItem.SyncStatus = 'queued';
@ -233,9 +239,7 @@
function downloadMedia(apiClient, jobItem, localItem, options) {
console.log('[mediasync] Begin downloadMedia');
var url = apiClient.getUrl("Sync/JobItems/" + jobItem.SyncJobItemId + "/File", {
var url = apiClient.getUrl('Sync/JobItems/' + jobItem.SyncJobItemId + '/File', {
api_key: apiClient.accessToken()
});
@ -256,88 +260,117 @@
console.log('[mediasync] Begin getImages');
return getNextImage(0, apiClient, localItem);
var p = Promise.resolve();
var libraryItem = localItem.Item;
var serverId = libraryItem.ServerId;
// case 0
var mainImageTag = (libraryItem.ImageTags || {})['Primary'];
if (libraryItem.Id && mainImageTag) {
p = p.then(function () {
return downloadImage(localItem, apiClient, serverId, libraryItem.Id, mainImageTag, 'Primary');
});
}
// case 0a
var logoImageTag = (libraryItem.ImageTags || {})['Logo'];
if (libraryItem.Id && logoImageTag) {
p = p.then(function () {
return downloadImage(localItem, apiClient, serverId, libraryItem.Id, logoImageTag, 'Logo');
});
}
// case 0b
var artImageTag = (libraryItem.ImageTags || {})['Art'];
if (libraryItem.Id && artImageTag) {
p = p.then(function () {
return downloadImage(localItem, apiClient, serverId, libraryItem.Id, artImageTag, 'Art');
});
}
// case 0c
var bannerImageTag = (libraryItem.ImageTags || {})['Banner'];
if (libraryItem.Id && bannerImageTag) {
p = p.then(function () {
return downloadImage(localItem, apiClient, serverId, libraryItem.Id, bannerImageTag, 'Banner');
});
}
// case 0d
var thumbImageTag = (libraryItem.ImageTags || {})['Thumb'];
if (libraryItem.Id && thumbImageTag) {
p = p.then(function () {
return downloadImage(localItem, apiClient, serverId, libraryItem.Id, thumbImageTag, 'Thumb');
});
}
// Backdrops
if (libraryItem.Id && libraryItem.BackdropImageTags) {
for (var i = 0; i < libraryItem.BackdropImageTags.length; i++) {
var backdropImageTag = libraryItem.BackdropImageTags[i];
// use self-invoking function to simulate block-level variable scope
(function (index, tag) {
p = p.then(function () {
return downloadImage(localItem, apiClient, serverId, libraryItem.Id, tag, 'backdrop', index);
});
})(i, backdropImageTag);
}
}
// case 1/2:
if (libraryItem.SeriesId && libraryItem.SeriesPrimaryImageTag) {
p = p.then(function () {
return downloadImage(localItem, apiClient, serverId, libraryItem.SeriesId, libraryItem.SeriesPrimaryImageTag, 'Primary');
});
p = p.then(function () {
return downloadImage(localItem, apiClient, serverId, libraryItem.SeriesId, libraryItem.SeriesPrimaryImageTag, 'Thumb');
});
}
// case 3:
if (libraryItem.AlbumId && libraryItem.AlbumPrimaryImageTag) {
p = p.then(function () {
return downloadImage(localItem, apiClient, serverId, libraryItem.AlbumId, libraryItem.AlbumPrimaryImageTag, 'Primary');
});
}
return p.then(function () {
console.log('[mediasync] Finished getImages');
return localassetmanager.addOrUpdateLocalItem(localItem);
}, function (err) {
console.log('[mediasync] Error getImages: ' + err.toString());
});
}
function getNextImage(index, apiClient, localItem) {
function downloadImage(localItem, apiClient, serverId, itemId, imageTag, imageType, index) {
console.log('[mediasync] Begin getNextImage');
//if (index >= 4) {
index = index || 0;
// deferred.resolve();
// return;
//}
// Just for now while media syncing gets worked out
return Promise.resolve();
//var libraryItem = localItem.Item;
//var serverId = libraryItem.ServerId;
//var itemId = null;
//var imageTag = null;
//var imageType = "Primary";
//switch (index) {
// case 0:
// itemId = libraryItem.Id;
// imageType = "Primary";
// imageTag = (libraryItem.ImageTags || {})["Primary"];
// break;
// case 1:
// itemId = libraryItem.SeriesId;
// imageType = "Primary";
// imageTag = libraryItem.SeriesPrimaryImageTag;
// break;
// case 2:
// itemId = libraryItem.SeriesId;
// imageType = "Thumb";
// imageTag = libraryItem.SeriesPrimaryImageTag;
// break;
// case 3:
// itemId = libraryItem.AlbumId;
// imageType = "Primary";
// imageTag = libraryItem.AlbumPrimaryImageTag;
// break;
// default:
// break;
//}
//if (!itemId || !imageTag) {
// getNextImage(index + 1, apiClient, localItem, deferred);
// return;
//}
//downloadImage(apiClient, serverId, itemId, imageTag, imageType).then(function () {
// // For the sake of simplicity, limit to one image
// deferred.resolve();
// return;
// getNextImage(index + 1, apiClient, localItem, deferred);
//}, getOnFail(deferred));
}
function downloadImage(apiClient, serverId, itemId, imageTag, imageType) {
console.log('[mediasync] Begin downloadImage');
return localassetmanager.hasImage(serverId, itemId, imageTag).then(function (hasImage) {
return localassetmanager.hasImage(serverId, itemId, imageType, index).then(function (hasImage) {
if (hasImage) {
console.log('[mediasync] downloadImage - skip existing: ' + itemId + ' ' + imageType + '_' + index.toString());
return Promise.resolve();
}
var imageUrl = apiClient.getImageUrl(itemId, {
tag: imageTag,
type: imageType,
format: 'png',
api_key: apiClient.accessToken()
});
return localassetmanager.downloadImage(imageUrl, serverId, itemId, imageTag);
console.log('[mediasync] downloadImage ' + itemId + ' ' + imageType + '_' + index.toString());
return localassetmanager.downloadImage(localItem, imageUrl, serverId, itemId, imageType, index);
}, function (err) {
console.log('[mediasync] Error downloadImage: ' + err.toString());
});
}
@ -346,7 +379,7 @@
console.log('[mediasync] Begin getSubtitles');
if (!jobItem.Item.MediaSources.length) {
console.log("[mediasync] Cannot download subtitles because video has no media source info.");
console.log('[mediasync] Cannot download subtitles because video has no media source info.');
return Promise.resolve();
}
@ -381,19 +414,26 @@
if (!subtitleStream) {
// We shouldn't get in here, but let's just be safe anyway
console.log("[mediasync] Cannot download subtitles because matching stream info wasn't found.");
console.log('[mediasync] Cannot download subtitles because matching stream info was not found.');
return Promise.resolve();
}
var url = apiClient.getUrl("Sync/JobItems/" + jobItem.SyncJobItemId + "/AdditionalFiles", {
var url = apiClient.getUrl('Sync/JobItems/' + jobItem.SyncJobItemId + '/AdditionalFiles', {
Name: file.Name,
api_key: apiClient.accessToken()
});
var fileName = localassetmanager.getSubtitleSaveFileName(jobItem.OriginalFileName, subtitleStream.Language, subtitleStream.IsForced, subtitleStream.Codec);
var localFilePath = localassetmanager.getLocalFilePath(localItem, fileName);
var fileName = localassetmanager.getSubtitleSaveFileName(localItem, jobItem.OriginalFileName, subtitleStream.Language, subtitleStream.IsForced, subtitleStream.Codec);
return localassetmanager.downloadSubtitles(url, localFilePath).then(function (subtitlePath) {
return localassetmanager.downloadSubtitles(url, fileName).then(function (subtitlePath) {
if (localItem.AdditionalFiles) {
localItem.AdditionalFiles.forEach(function (item) {
if (item.Name === file.Name) {
item.Path = subtitlePath;
}
});
}
subtitleStream.Path = subtitlePath;
return localassetmanager.addOrUpdateLocalItem(localItem);
@ -406,10 +446,14 @@
self.sync = function (apiClient, serverInfo, options) {
console.log("[mediasync]************************************* Start sync");
console.log('[mediasync]************************************* Start sync');
return processDownloadStatus(apiClient, serverInfo, options).then(function () {
if (options.syncCheckProgressOnly === true) {
return Promise.resolve();
}
return reportOfflineActions(apiClient, serverInfo).then(function () {
//// Do the first data sync
@ -420,7 +464,8 @@
// Do the second data sync
return syncData(apiClient, serverInfo, false).then(function () {
console.log("[mediasync]************************************* Exit sync");
console.log('[mediasync]************************************* Exit sync');
return Promise.resolve();
});
});
//});

View File

@ -14,12 +14,12 @@
},
"devDependencies": {},
"ignore": [],
"version": "1.4.397",
"_release": "1.4.397",
"version": "1.4.399",
"_release": "1.4.399",
"_resolution": {
"type": "version",
"tag": "1.4.397",
"commit": "9adcc0001dbf032595448070447de469a8f24130"
"tag": "1.4.399",
"commit": "b926b582df014a7b2b54e93dca167db73d59bbcb"
},
"_source": "https://github.com/MediaBrowser/emby-webcomponents.git",
"_target": "^1.2.1",

View File

@ -16,6 +16,11 @@ define(['apphost', 'globalize', 'connectionManager', 'itemHelper', 'embyRouter',
var commands = [];
if (itemHelper.isLocalItem(item)) {
return commands;
}
if (itemHelper.supportsAddingToCollection(item)) {
commands.push({
name: globalize.translate('sharedcomponents#AddToCollection'),

View File

@ -111,10 +111,20 @@ define(['apphost'], function (appHost) {
return user.Policy.IsAdministrator;
}
function isLocalItem(item) {
if (item && item.Id && item.Id.indexOf('local') === 0) {
return true;
}
return false;
}
return {
getDisplayName: getDisplayName,
supportsAddingToCollection: supportsAddingToCollection,
supportsAddingToPlaylist: supportsAddingToPlaylist,
isLocalItem: isLocalItem,
canIdentify: function (user, itemType) {

View File

@ -353,6 +353,6 @@
"HeaderPlayMyMedia": "\u041c\u0435\u043d\u0456\u04a3 \u0442\u0430\u0441\u044b\u0493\u044b\u0448\u0434\u0435\u0440\u0435\u043a\u0442\u0435\u0440\u0456\u043c\u0434\u0456 \u043e\u0439\u043d\u0430\u0442\u0443",
"HeaderDiscoverEmbyPremiere": "Emby Premiere \u0430\u0448\u044b\u04a3\u044b\u0437",
"OneChannel": "\u0411\u0456\u0440 \u0430\u0440\u043d\u0430\u0434\u0430\u043d",
"ConfirmRemoveDownload": "Remove download?",
"ConfirmRemoveDownload": "\u0416\u04af\u043a\u0442\u0435\u0443\u0434\u0456 \u0430\u043b\u0430\u0441\u0442\u0430\u0439\u043c\u044b\u0437 \u0431\u0430?",
"AddedOnValue": "\u04ae\u0441\u0442\u0435\u043b\u0433\u0435\u043d\u0456 {0}"
}

View File

@ -353,6 +353,6 @@
"HeaderPlayMyMedia": "Reproduzir minha M\u00eddia",
"HeaderDiscoverEmbyPremiere": "Descobrir o Emby Premiere",
"OneChannel": "Um canal",
"ConfirmRemoveDownload": "Remove download?",
"AddedOnValue": "Adicionado em {0}"
"ConfirmRemoveDownload": "Remover download?",
"AddedOnValue": "Adicionado {0}"
}

View File

@ -353,6 +353,6 @@
"HeaderPlayMyMedia": "\u0412\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u043c\u043e\u0438 \u043c\u0435\u0434\u0438\u0430\u0434\u0430\u043d\u043d\u044b\u0435",
"HeaderDiscoverEmbyPremiere": "\u041e\u0442\u043a\u0440\u043e\u0439\u0442\u0435 Emby Premiere",
"OneChannel": "\u041e\u0434\u0438\u043d \u043a\u0430\u043d\u0430\u043b",
"ConfirmRemoveDownload": "Remove download?",
"ConfirmRemoveDownload": "\u0418\u0437\u044a\u044f\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443?",
"AddedOnValue": "\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e {0}"
}

View File

@ -68,8 +68,8 @@
"ConfirmDeleteItem": "Deleting this item will delete it from both the file system and your media library. Are you sure you wish to continue?",
"Refresh": "\u5237\u65b0",
"RefreshQueued": "\u5217\u961f\u5df2\u5237\u65b0\u3002",
"AddToCollection": "Add to collection",
"HeaderAddToCollection": "Add to Collection",
"AddToCollection": "\u52a0\u5165\u5408\u96c6",
"HeaderAddToCollection": "\u52a0\u5165\u5408\u96c6",
"NewCollection": "\u65b0\u5408\u96c6",
"LabelCollection": "Collection:",
"Help": "\u5e2e\u52a9",
@ -114,7 +114,7 @@
"Open": "\u6253\u5f00",
"Play": "\u64ad\u653e",
"Queue": "\u52a0\u5165\u961f\u5217",
"Shuffle": "\u6401\u7f6e",
"Shuffle": "\u968f\u673a\u64ad\u653e",
"Identify": "\u8bc6\u522b",
"EditImages": "\u4fee\u6539\u56fe\u7247",
"EditInfo": "\u7f16\u8f91\u4fe1\u606f",
@ -162,7 +162,7 @@
"LabelOverview": "\u5185\u5bb9\u6982\u8ff0\uff1a",
"LabelShortOverview": "\u7b80\u4ecb\uff1a",
"LabelReleaseDate": "\u53d1\u884c\u65e5\u671f\uff1a",
"LabelYear": "Year:",
"LabelYear": "\u5e74\u4efd\uff1a",
"LabelPlaceOfBirth": "\u51fa\u751f\u5730\uff1a",
"LabelAirDays": "\u64ad\u51fa\u65e5\u671f\uff1a",
"LabelAirTime": "\u64ad\u51fa\u65f6\u95f4\uff1a",
@ -213,14 +213,14 @@
"Continuing": "\u7ee7\u7eed",
"Ended": "\u7ed3\u675f",
"HeaderEnabledFields": "\u5df2\u542f\u7528\u7684\u680f",
"HeaderEnabledFieldsHelp": "Uncheck a field to lock it and prevent it's data from being changed.",
"HeaderEnabledFieldsHelp": "\u53cd\u9009\u680f\u4ee5\u9501\u5b9a\u5e76\u4e0d\u8ba9\u5176\u6570\u636e\u88ab\u66f4\u6539\u3002",
"Backdrops": "\u80cc\u666f",
"Images": "\u56fe\u7247",
"Keywords": "\u5173\u952e\u8bcd",
"Runtime": "\u64ad\u653e\u65f6\u95f4",
"Runtime": "\u64ad\u653e\u65f6\u957f",
"ProductionLocations": "Production locations",
"BirthLocation": "\u51fa\u751f\u5730",
"ParentalRating": "Parental Rating",
"ParentalRating": "\u5bb6\u957f\u5206\u7ea7",
"Name": "\u540d\u79f0",
"Overview": "\u6982\u8ff0",
"LabelType": "\u7c7b\u578b\uff1a",
@ -256,7 +256,7 @@
"PleaseEnterNameOrId": "\u8bf7\u8f93\u5165\u4e00\u4e2a\u540d\u79f0\u6216\u4e00\u4e2a\u5916\u90e8ID\u3002",
"MessageItemSaved": "\u9879\u76ee\u5df2\u4fdd\u5b58\u3002",
"SearchResults": "\u641c\u7d22\u7ed3\u679c",
"SyncToOtherDevice": "Sync to other device",
"SyncToOtherDevice": "\u540c\u6b65\u5230\u5176\u4ed6\u8bbe\u5907",
"MakeAvailableOffline": "Make available offline",
"ServerNameIsRestarting": "Emby Server - {0} is restarting.",
"ServerNameIsShuttingDown": "Emby Server - {0} is shutting down.",
@ -264,7 +264,7 @@
"ConfirmDeleteItems": "Deleting these items will delete them from both the file system and your media library. Are you sure you wish to continue?",
"PleaseRestartServerName": "Please restart Emby Server - {0}.",
"SyncJobCreated": "Sync job created.",
"LabelSyncTo": "Sync to:",
"LabelSyncTo": "\u540c\u6b65\u5230\uff1a",
"LabelSyncJobName": "Sync job name:",
"LabelQuality": "Quality:",
"LabelSyncNoTargetsHelp": "It looks like you don't currently have any apps that support sync.",
@ -278,7 +278,7 @@
"AutomaticallySyncNewContentHelp": "New content added to this folder will be automatically synced to the device.",
"LabelItemLimit": "Item limit:",
"LabelItemLimitHelp": "Optional. Set a limit to the number of items that will be synced.",
"PleaseSelectDeviceToSyncTo": "Please select a device to sync to.",
"PleaseSelectDeviceToSyncTo": "\u8bf7\u9009\u62e9\u60a8\u60f3\u8981\u540c\u6b65\u5230\u7684\u8bbe\u5907\u3002",
"Screenshots": "Screenshots",
"MoveRight": "Move right",
"MoveLeft": "Move left",

View File

@ -455,6 +455,10 @@
});
return promise.then(function () {
if (layoutManager.tv) {
scrollHelper.centerFocus.off(dlg.querySelector('.formDialogContent'), false);
}
if (submitted) {
return Promise.resolve();
}

View File

@ -1,31 +1,17 @@
define(['connectionManager', 'serverNotifications', 'events', 'datetime', 'dom', 'imageLoader', 'loading', 'globalize', 'apphost', 'listViewStyle', 'paper-icon-button-light', 'emby-button'], function (connectionManager, serverNotifications, events, datetime, dom, imageLoader, loading, globalize, appHost) {
define(['connectionManager', 'serverNotifications', 'events', 'datetime', 'dom', 'imageLoader', 'loading', 'globalize', 'apphost', 'layoutManager', 'scrollHelper', 'dialogHelper', 'shell', 'listViewStyle', 'paper-icon-button-light', 'emby-button', 'formDialogStyle'], function (connectionManager, serverNotifications, events, datetime, dom, imageLoader, loading, globalize, appHost, layoutManager, scrollHelper, dialogHelper, shell) {
'use strict';
function renderJob(page, job, dialogOptions) {
var html = '';
html += '<div>';
html += globalize.translate('ValueDateCreated', datetime.parseISO8601Date(job.DateCreated, true).toLocaleString());
html += '</div>';
html += '<br/>';
html += '<div class="formFields"></div>';
html += '<br/>';
html += '<br/>';
html += '<button is="emby-button" type="submit" class="raised button-submit block"><span>' + globalize.translate('ButtonSave') + '</span></button>';
page.querySelector('.syncJobForm').innerHTML = html;
function renderJob(context, job, dialogOptions) {
require(['syncDialog'], function (syncDialog) {
syncDialog.renderForm({
elem: page.querySelector('.formFields'),
elem: context.querySelector('.syncJobFormContent'),
dialogOptions: dialogOptions,
dialogOptionsFn: getTargetDialogOptionsFn(dialogOptions),
showName: true,
readOnlySyncTarget: true
}).then(function () {
fillJobValues(page, job, dialogOptions);
fillJobValues(context, job, dialogOptions);
});
});
}
@ -102,7 +88,7 @@
return html;
}
function renderJobItems(page, items, apiClient) {
function renderJobItems(context, items, apiClient) {
var html = '';
@ -119,7 +105,7 @@
html += '</div>';
var elem = page.querySelector('.jobItems');
var elem = context.querySelector('.jobItems');
elem.innerHTML = html;
imageLoader.lazyChildren(elem);
}
@ -139,7 +125,7 @@
function showJobItemMenu(elem, jobId, apiClient) {
var page = parentWithClass(elem, 'page');
var context = parentWithClass(elem, 'page');
var listItem = parentWithClass(elem, 'listItem');
var jobItemId = listItem.getAttribute('data-itemid');
var status = listItem.getAttribute('data-status');
@ -188,16 +174,16 @@
switch (id) {
case 'cancel':
cancelJobItem(page, jobId, jobItemId, apiClient);
cancelJobItem(context, jobId, jobItemId, apiClient);
break;
case 'retry':
retryJobItem(page, jobId, jobItemId, apiClient);
retryJobItem(context, jobId, jobItemId, apiClient);
break;
case 'markforremoval':
markForRemoval(page, jobId, jobItemId, apiClient);
markForRemoval(context, jobId, jobItemId, apiClient);
break;
case 'unmarkforremoval':
unMarkForRemoval(page, jobId, jobItemId, apiClient);
unMarkForRemoval(context, jobId, jobItemId, apiClient);
break;
default:
break;
@ -208,7 +194,7 @@
});
}
function cancelJobItem(page, jobId, jobItemId, apiClient) {
function cancelJobItem(context, jobId, jobItemId, apiClient) {
// Need a timeout because jquery mobile will not show a popup while another is in the act of closing
@ -221,12 +207,12 @@
}).then(function () {
loadJob(page, jobId, apiClient);
loadJob(context, jobId, apiClient);
});
}
function markForRemoval(page, jobId, jobItemId, apiClient) {
function markForRemoval(context, jobId, jobItemId, apiClient) {
apiClient.ajax({
@ -235,11 +221,11 @@
}).then(function () {
loadJob(page, jobId, apiClient);
loadJob(context, jobId, apiClient);
});
}
function unMarkForRemoval(page, jobId, jobItemId, apiClient) {
function unMarkForRemoval(context, jobId, jobItemId, apiClient) {
apiClient.ajax({
@ -248,11 +234,11 @@
}).then(function () {
loadJob(page, jobId, apiClient);
loadJob(context, jobId, apiClient);
});
}
function retryJobItem(page, jobId, jobItemId, apiClient) {
function retryJobItem(context, jobId, jobItemId, apiClient) {
apiClient.ajax({
@ -261,43 +247,43 @@
}).then(function () {
loadJob(page, jobId, apiClient);
loadJob(context, jobId, apiClient);
});
}
function fillJobValues(page, job, editOptions) {
function fillJobValues(context, job, editOptions) {
var txtSyncJobName = page.querySelector('#txtSyncJobName');
var txtSyncJobName = context.querySelector('#txtSyncJobName');
if (txtSyncJobName) {
txtSyncJobName.value = job.Name;
}
var selectProfile = page.querySelector('#selectProfile');
var selectProfile = context.querySelector('#selectProfile');
if (selectProfile) {
selectProfile.value = job.Profile || '';
}
var selectQuality = page.querySelector('#selectQuality');
var selectQuality = context.querySelector('#selectQuality');
if (selectQuality) {
selectQuality.value = job.Quality || '';
}
var chkUnwatchedOnly = page.querySelector('#chkUnwatchedOnly');
var chkUnwatchedOnly = context.querySelector('#chkUnwatchedOnly');
if (chkUnwatchedOnly) {
chkUnwatchedOnly.checked = job.UnwatchedOnly;
}
var chkSyncNewContent = page.querySelector('#chkSyncNewContent');
var chkSyncNewContent = context.querySelector('#chkSyncNewContent');
if (chkSyncNewContent) {
chkSyncNewContent.checked = job.SyncNewContent;
}
var txtItemLimit = page.querySelector('#txtItemLimit');
var txtItemLimit = context.querySelector('#txtItemLimit');
if (txtItemLimit) {
txtItemLimit.value = job.ItemLimit;
}
var txtBitrate = page.querySelector('#txtBitrate');
var txtBitrate = context.querySelector('#txtBitrate');
if (job.Bitrate) {
txtBitrate.value = job.Bitrate / 1000000;
} else {
@ -309,14 +295,14 @@
})[0];
var targetName = target ? target.Name : '';
var selectSyncTarget = page.querySelector('#selectSyncTarget');
var selectSyncTarget = context.querySelector('#selectSyncTarget');
if (selectSyncTarget) {
selectSyncTarget.value = targetName;
}
}
var _jobOptions;
function loadJob(page, id, apiClient) {
function loadJob(context, id, apiClient) {
loading.show();
@ -334,7 +320,7 @@
})).then(function (options) {
_jobOptions = options;
renderJob(page, job, options);
renderJob(context, job, options);
loading.hide();
});
});
@ -346,26 +332,26 @@
})).then(function (result) {
renderJobItems(page, result.Items, apiClient);
renderJobItems(context, result.Items, apiClient);
loading.hide();
});
}
function loadJobInfo(page, job, jobItems, apiClient) {
function loadJobInfo(context, job, jobItems, apiClient) {
//renderJob(page, job, _jobOptions);
renderJobItems(page, jobItems, apiClient);
renderJobItems(context, jobItems, apiClient);
loading.hide();
}
function saveJob(page, id, apiClient) {
function saveJob(context, id, apiClient) {
loading.show();
apiClient.getJSON(apiClient.getUrl('Sync/Jobs/' + id)).then(function (job) {
require(['syncDialog'], function (syncDialog) {
syncDialog.setJobValues(job, page);
syncDialog.setJobValues(job, context);
apiClient.ajax({
@ -377,75 +363,150 @@
}).then(function () {
loading.hide();
require(['toast'], function (toast) {
toast(globalize.translate('SettingsSaved'));
});
dialogHelper.close(context);
});
});
});
}
return function (view, params) {
function onHelpLinkClick(e) {
function getApiClient() {
return connectionManager.getApiClient(params.serverId);
shell.openUrl(this.href);
e.preventDefault();
return false;
}
function startListening(apiClient, jobId) {
var startParams = "0,1500";
startParams += "," + jobId;
if (apiClient.isWebSocketOpen()) {
apiClient.sendWebSocketMessage("SyncJobStart", startParams);
}
}
function stopListening(apiClient) {
if (apiClient.isWebSocketOpen()) {
apiClient.sendWebSocketMessage("SyncJobStop", "");
}
view.querySelector('.syncJobForm').addEventListener('submit', function (e) {
}
saveJob(view, params.id, getApiClient());
function bindEvents(context, jobId, apiClient) {
context.querySelector('.jobItems').addEventListener('click', function (e) {
var btnJobItemMenu = dom.parentWithClass(e.target, 'btnJobItemMenu');
if (btnJobItemMenu) {
showJobItemMenu(btnJobItemMenu, jobId, apiClient);
}
});
}
function showEditor(options) {
var apiClient = connectionManager.getApiClient(options.serverId);
var id = options.jobId;
var dlgElementOptions = {
removeOnClose: true,
scrollY: false,
autoFocus: false
};
if (layoutManager.tv) {
dlgElementOptions.size = 'fullscreen';
} else {
dlgElementOptions.size = 'medium';
}
var dlg = dialogHelper.createDialog(dlgElementOptions);
dlg.classList.add('formDialog');
var html = '';
html += '<div class="formDialogHeader">';
html += '<button is="paper-icon-button-light" class="btnCancel autoSize" tabindex="-1"><i class="md-icon">&#xE5C4;</i></button>';
html += '<h3 class="formDialogHeaderTitle">';
html += globalize.translate('sharedcomponents#Sync');
html += '</h3>';
html += '<a href="https://github.com/MediaBrowser/Wiki/wiki/Sync" target="_blank" class="clearLink lnkHelp" style="margin-top:0;display:inline-block;vertical-align:middle;margin-left:auto;"><button is="emby-button" type="button" class="button-accent-flat button-flat"><i class="md-icon">info</i><span>' + globalize.translate('sharedcomponents#Help') + '</span></button></a>';
html += '</div>';
html += '<div class="formDialogContent smoothScrollY" style="padding-top:2em;">';
html += '<div class="dialogContentInner dialog-content-centered">';
html += '<form class="syncJobForm" style="margin: auto;">';
html += '<div class="syncJobFormContent"></div>';
html += '<div class="jobItems"></div>';
html += '<div class="formDialogFooter">';
html += '<button is="emby-button" type="submit" class="raised button-submit block formDialogFooterItem"><span>' + globalize.translate('sharedcomponents#Save') + '</span></button>';
html += '</div>';
html += '</form>';
html += '</div>';
html += '</div>';
dlg.innerHTML = html;
dlg.querySelector('.lnkHelp').addEventListener('click', onHelpLinkClick);
var submitted = false;
dlg.querySelector('form').addEventListener('submit', function (e) {
saveJob(dlg, id, apiClient);
e.preventDefault();
return false;
});
dlg.querySelector('.btnCancel').addEventListener('click', function () {
dialogHelper.close(dlg);
});
if (layoutManager.tv) {
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
}
function onSyncJobMessage(e, apiClient, msg) {
loadJobInfo(view, msg.Job, msg.JobItems, apiClient);
loadJobInfo(dlg, msg.Job, msg.JobItems, apiClient);
}
function startListening(page) {
loadJob(dlg, id, apiClient);
bindEvents(dlg, id, apiClient);
var startParams = "0,1500";
var promise = dialogHelper.open(dlg);
startParams += "," + params.id;
startListening(apiClient, id);
events.on(serverNotifications, "SyncJob", onSyncJobMessage);
var apiClient = getApiClient();
return promise.then(function () {
if (apiClient.isWebSocketOpen()) {
apiClient.sendWebSocketMessage("SyncJobStart", startParams);
}
}
function stopListening() {
var apiClient = getApiClient();
if (apiClient.isWebSocketOpen()) {
apiClient.sendWebSocketMessage("SyncJobStop", "");
}
}
view.querySelector('.jobItems').addEventListener('click', function (e) {
var btnJobItemMenu = dom.parentWithClass(e.target, 'btnJobItemMenu');
if (btnJobItemMenu) {
showJobItemMenu(btnJobItemMenu, params.id);
}
});
view.addEventListener('viewshow', function () {
var page = this;
loadJob(page, params.id, getApiClient());
startListening(page);
events.on(serverNotifications, "SyncJob", onSyncJobMessage);
});
view.addEventListener('viewbeforehide', function () {
stopListening();
stopListening(apiClient);
events.off(serverNotifications, "SyncJob", onSyncJobMessage);
if (layoutManager.tv) {
scrollHelper.centerFocus.off(dlg.querySelector('.formDialogContent'), false);
}
if (submitted) {
return Promise.resolve();
}
return Promise.reject();
});
}
return {
show: showEditor
};
});

View File

@ -69,8 +69,10 @@
syncToggle.prototype.refresh = function(item) {
this.options.item = item;
updateSyncStatus(this.options.container, item);
if (this.options) {
this.options.item = item;
updateSyncStatus(this.options.container, item);
}
};
syncToggle.prototype.destroy = function () {

View File

@ -1,4 +1,4 @@
define(['connectionManager', 'globalize', 'dom', 'paper-icon-button-light', 'material-icons', 'emby-button', 'css!./userdatabuttons'], function (connectionManager, globalize, dom) {
define(['connectionManager', 'globalize', 'dom', 'itemHelper', 'paper-icon-button-light', 'material-icons', 'emby-button', 'css!./userdatabuttons'], function (connectionManager, globalize, dom, itemHelper) {
'use strict';
var userDataMethods = {
@ -86,6 +86,10 @@ define(['connectionManager', 'globalize', 'dom', 'paper-icon-button-light', 'mat
var itemId = item.Id;
if (itemHelper.isLocalItem(item)) {
return html;
}
var btnCssClass = "btnUserData";
if (cssClass) {

View File

@ -81,7 +81,12 @@
events.on(mySyncJobList, 'jobedit', function (e, jobId, serverId) {
Dashboard.navigate('mysyncjob.html?serverId=' + ApiClient.serverId() + '&id=' + jobId);
require(['syncJobEditor'], function (syncJobEditor) {
syncJobEditor.show({
serverId: ApiClient.serverId(),
jobId: jobId
});
});
});
view.addEventListener('viewbeforeshow', function () {

View File

@ -1234,7 +1234,6 @@ var AppInfo = {};
define("lazyLoader", [embyWebComponentsBowerPath + "/lazyloader/lazyloader-scroll"], returnFirstDependency);
}
define("imageLoader", [embyWebComponentsBowerPath + "/images/imagehelper"], returnFirstDependency);
define("syncJobList", ["components/syncjoblist/syncjoblist"], returnFirstDependency);
define("appfooter", ["components/appfooter/appfooter"], returnFirstDependency);
define("dockedtabs", ["components/dockedtabs/dockedtabs"], returnFirstDependency);
define("directorybrowser", ["components/directorybrowser/directorybrowser"], returnFirstDependency);
@ -1290,6 +1289,8 @@ var AppInfo = {};
define("guide-settings-dialog", [embyWebComponentsBowerPath + "/guide/guide-settings"], returnFirstDependency);
define("syncDialog", [embyWebComponentsBowerPath + "/sync/sync"], returnFirstDependency);
define("syncToggle", [embyWebComponentsBowerPath + "/sync/synctoggle"], returnFirstDependency);
define("syncJobEditor", [embyWebComponentsBowerPath + "/sync/syncjobeditor"], returnFirstDependency);
define("syncJobList", [embyWebComponentsBowerPath + "/sync/syncjoblist"], returnFirstDependency);
define("voiceDialog", [embyWebComponentsBowerPath + "/voice/voicedialog"], returnFirstDependency);
define("voiceReceiver", [embyWebComponentsBowerPath + "/voice/voicereceiver"], returnFirstDependency);
define("voiceProcessor", [embyWebComponentsBowerPath + "/voice/voiceprocessor"], returnFirstDependency);
@ -2490,14 +2491,6 @@ var AppInfo = {};
controller: 'scripts/syncactivity'
});
defineRoute({
path: '/syncjob.html',
dependencies: [],
autoFocus: false,
transition: 'fade',
controller: 'scripts/syncjob'
});
defineRoute({
path: '/syncsettings.html',
dependencies: [],

View File

@ -52,7 +52,12 @@
events.on(mySyncJobList, 'jobedit', function (e, jobId, serverId) {
Dashboard.navigate('syncjob.html?serverId=' + ApiClient.serverId() + '&id=' + jobId);
require(['syncJobEditor'], function (syncJobEditor) {
syncJobEditor.show({
serverId: ApiClient.serverId(),
jobId: jobId
});
});
});
view.addEventListener('viewshow', function () {

View File

@ -1,14 +0,0 @@
<div id="syncJobPage" data-role="page" class="page type-interior syncConfigurationPage syncJobPage withTabs" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Sync">
<div data-role="content">
<div class="content-primary">
<div class="readOnlyContent">
<form class="syncJobForm"></form>
<br />
<br />
<div class="jobItems"></div>
</div>
</div>
</div>
</div>