diff --git a/src/components/categorysyncbuttons.js b/src/components/categorysyncbuttons.js deleted file mode 100644 index 5a6075b196..0000000000 --- a/src/components/categorysyncbuttons.js +++ /dev/null @@ -1,31 +0,0 @@ -define(["itemHelper", "libraryMenu", "apphost"], function(itemHelper, libraryMenu, appHost) { - "use strict"; - - function initSyncButtons(view) { - var apiClient = window.ApiClient; - apiClient && apiClient.getCurrentUserId() && apiClient.getCurrentUser().then(function(user) { - for (var item = { - SupportsSync: !0 - }, categorySyncButtons = view.querySelectorAll(".categorySyncButton"), i = 0, length = categorySyncButtons.length; i < length; i++) categorySyncButtons[i].addEventListener("click", onCategorySyncButtonClick), itemHelper.canSync(user, item) ? categorySyncButtons[i].classList.remove("hide") : categorySyncButtons[i].classList.add("hide") - }) - } - - function onCategorySyncButtonClick(e) { - var button = this, - category = button.getAttribute("data-category"), - parentId = libraryMenu.getTopParentId(); - require(["syncDialog"], function(syncDialog) { - syncDialog.showMenu({ - ParentId: parentId, - Category: category, - serverId: ApiClient.serverId(), - mode: appHost.supports("sync") ? "download" : "sync" - }) - }) - } - return { - init: function(view) { - initSyncButtons(view) - } - } -}); \ No newline at end of file diff --git a/src/components/itemcontextmenu.js b/src/components/itemcontextmenu.js index 270345d3b7..6bc81f62b2 100644 --- a/src/components/itemcontextmenu.js +++ b/src/components/itemcontextmenu.js @@ -118,13 +118,6 @@ define(['apphost', 'globalize', 'connectionManager', 'itemHelper', 'appRouter', }); } - if (itemHelper.canConvert(item, user, connectionManager.getApiClient(item))) { - commands.push({ - name: globalize.translate('Convert'), - id: 'convert' - }); - } - if (item.CanDelete && options.deleteItem !== false) { if (item.Type === 'Playlist' || item.Type === 'BoxSet') { @@ -147,15 +140,6 @@ define(['apphost', 'globalize', 'connectionManager', 'itemHelper', 'appRouter', }); } - if (appHost.supports('sync') && options.syncLocal !== false) { - if (itemHelper.canSync(user, item)) { - commands.push({ - name: globalize.translate('Download'), - id: 'synclocal' - }); - } - } - var canEdit = itemHelper.canEdit(user, item); if (canEdit) { @@ -328,17 +312,13 @@ define(['apphost', 'globalize', 'connectionManager', 'itemHelper', 'appRouter', { require(['fileDownloader'], function (fileDownloader) { var downloadHref = apiClient.getItemDownloadUrl(itemId); - - fileDownloader.download([ - { - url: downloadHref, - itemId: itemId, - serverId: serverId - }]); - + fileDownloader.download([{ + url: downloadHref, + itemId: itemId, + serverId: serverId + }]); getResolveFunction(getResolveFunction(resolve, id), id)(); }); - break; } case 'editsubtitles': @@ -433,102 +413,48 @@ define(['apphost', 'globalize', 'connectionManager', 'itemHelper', 'appRouter', break; } case 'share': - { navigator.share({ title: item.Name, text: item.Overview, url: "https://github.com/jellyfin/jellyfin" }); break; - } case 'album': - { - appRouter.showItem(item.AlbumId, item.ServerId); - getResolveFunction(resolve, id)(); - break; - } + appRouter.showItem(item.AlbumId, item.ServerId); + getResolveFunction(resolve, id)(); + break; case 'artist': - { - appRouter.showItem(item.ArtistItems[0].Id, item.ServerId); - getResolveFunction(resolve, id)(); + appRouter.showItem(item.ArtistItems[0].Id, item.ServerId); + getResolveFunction(resolve, id)(); break; - } case 'playallfromhere': - { - getResolveFunction(resolve, id)(); + getResolveFunction(resolve, id)(); break; - } case 'queueallfromhere': { getResolveFunction(resolve, id)(); break; } - case 'convert': - { - require(['syncDialog'], function (syncDialog) { - syncDialog.showMenu({ - items: [item], - serverId: serverId, - mode: 'convert' - }); - }); - getResolveFunction(resolve, id)(); - break; - } - case 'sync': - { - require(['syncDialog'], function (syncDialog) { - syncDialog.showMenu({ - items: [item], - serverId: serverId, - mode: 'sync' - }); - }); - getResolveFunction(resolve, id)(); - break; - } - case 'synclocal': - { - require(['syncDialog'], function (syncDialog) { - syncDialog.showMenu({ - items: [item], - serverId: serverId, - mode: 'download' - }); - }); - getResolveFunction(resolve, id)(); - break; - } case 'removefromplaylist': - apiClient.ajax({ - url: apiClient.getUrl('Playlists/' + options.playlistId + '/Items', { EntryIds: [item.PlaylistItemId].join(',') }), - type: 'DELETE' - }).then(function () { - getResolveFunction(resolve, id, true)(); }); - break; case 'removefromcollection': - apiClient.ajax({ type: "DELETE", url: apiClient.getUrl("Collections/" + options.collectionId + "/Items", { Ids: [item.Id].join(',') }) - }).then(function () { - getResolveFunction(resolve, id, true)(); }); - break; case 'canceltimer': deleteTimer(apiClient, item, resolve, id); diff --git a/src/components/multiselect/multiselect.js b/src/components/multiselect/multiselect.js index 32e3ab9f82..6eace46c7c 100644 --- a/src/components/multiselect/multiselect.js +++ b/src/components/multiselect/multiselect.js @@ -218,13 +218,6 @@ define(['browser', 'appStorage', 'apphost', 'loading', 'connectionManager', 'glo }); } - if (user.Policy.EnableContentDownloading && appHost.supports('sync')) { - menuItems.push({ - name: globalize.translate('Download'), - id: 'synclocal' - }); - } - menuItems.push({ name: globalize.translate('GroupVersions'), id: 'groupvideos', @@ -254,20 +247,16 @@ define(['browser', 'appStorage', 'apphost', 'loading', 'connectionManager', 'glo } require(['actionsheet'], function (actionsheet) { - actionsheet.show({ items: menuItems, positionTo: e.target, callback: function (id) { - var items = selectedItems.slice(0); var serverId = apiClient.serverInfo().Id; switch (id) { - case 'addtocollection': require(['collectionEditor'], function (collectionEditor) { - new collectionEditor().show({ items: items, serverId: serverId @@ -318,35 +307,6 @@ define(['browser', 'appStorage', 'apphost', 'loading', 'connectionManager', 'glo hideSelections(); dispatchNeedsRefresh(); break; - case 'sync': - require(['syncDialog'], function (syncDialog) { - syncDialog.showMenu({ - items: items.map(function (i) { - return { - Id: i - }; - }), - serverId: serverId - }); - }); - hideSelections(); - dispatchNeedsRefresh(); - break; - case 'synclocal': - require(['syncDialog'], function (syncDialog) { - syncDialog.showMenu({ - items: items.map(function (i) { - return { - Id: i - }; - }), - isLocalSync: true, - serverId: serverId - }); - }); - hideSelections(); - dispatchNeedsRefresh(); - break; default: break; } diff --git a/src/components/serviceworker/notifications.js b/src/components/serviceworker/notifications.js index c566715bb7..9c5be840bf 100644 --- a/src/components/serviceworker/notifications.js +++ b/src/components/serviceworker/notifications.js @@ -4,20 +4,14 @@ var connectionManager; function getApiClient(serverId) { - if (connectionManager) { return Promise.resolve(connectionManager.getApiClient(serverId)); } - - //importScripts('serviceworker-cache-polyfill.js'); - return Promise.reject(); } function executeAction(action, data, serverId) { - return getApiClient(serverId).then(function (apiClient) { - switch (action) { case 'cancel-install': var id = data.id; @@ -32,7 +26,6 @@ } self.addEventListener('notificationclick', function (event) { - var notification = event.notification; notification.close(); @@ -47,6 +40,5 @@ } event.waitUntil(executeAction(action, data, serverId)); - }, false); })(); \ No newline at end of file diff --git a/src/components/serviceworker/sync.js b/src/components/serviceworker/sync.js deleted file mode 100644 index 3dcff8f363..0000000000 --- a/src/components/serviceworker/sync.js +++ /dev/null @@ -1,6 +0,0 @@ -self.addEventListener('sync', function (event) { - 'use strict'; - - if (event.tag === 'emby-sync') { - } -}); \ No newline at end of file diff --git a/src/components/sync/emby-downloadbutton.js b/src/components/sync/emby-downloadbutton.js deleted file mode 100644 index 74a9f6b3bb..0000000000 --- a/src/components/sync/emby-downloadbutton.js +++ /dev/null @@ -1,188 +0,0 @@ -define(['connectionManager', 'serverNotifications', 'events', 'globalize', 'emby-button'], function (connectionManager, serverNotifications, events, globalize, EmbyButtonPrototype) { - 'use strict'; - - function onClick(e) { - - var button = this; - var id = button.getAttribute('data-id'); - var serverId = button.getAttribute('data-serverid'); - var apiClient = connectionManager.getApiClient(serverId); - - if (!button.classList.contains('downloadbutton-on')) { - - require(['syncDialog'], function (syncDialog) { - syncDialog.showMenu({ - - items: [id], - mode: 'download', - serverId: serverId - - }).then(function () { - - button.dispatchEvent(new CustomEvent('download', { - cancelable: false - })); - - }); - }); - - } else { - - require(['confirm'], function (confirm) { - - confirm({ - - text: globalize.translate('ConfirmRemoveDownload'), - confirmText: globalize.translate('RemoveDownload'), - cancelText: globalize.translate('KeepDownload'), - primary: 'cancel' - - }).then(function () { - apiClient.cancelSyncItems([id]); - - button.dispatchEvent(new CustomEvent('download-cancel', { - cancelable: false - })); - }); - }); - } - } - - function updateSyncStatus(button, syncPercent) { - - var icon = button.iconElement; - if (!icon) { - button.iconElement = button.querySelector('i'); - icon = button.iconElement; - } - - if (syncPercent != null) { - button.classList.add('downloadbutton-on'); - - if (icon) { - icon.classList.add('downloadbutton-icon-on'); - } - - } else { - button.classList.remove('downloadbutton-on'); - - if (icon) { - icon.classList.remove('downloadbutton-icon-on'); - } - } - - if ((syncPercent || 0) >= 100) { - button.classList.add('downloadbutton-complete'); - - if (icon) { - icon.classList.add('downloadbutton-icon-complete'); - } - } else { - button.classList.remove('downloadbutton-complete'); - - if (icon) { - icon.classList.remove('downloadbutton-icon-complete'); - } - } - - var text; - if ((syncPercent || 0) >= 100) { - text = globalize.translate('Downloaded'); - } else if (syncPercent != null) { - text = globalize.translate('Downloading'); - } else { - text = globalize.translate('Download'); - } - - var textElement = button.querySelector('.emby-downloadbutton-downloadtext'); - if (textElement) { - textElement.innerHTML = text; - } - - button.title = text; - } - - function clearEvents(button) { - - button.removeEventListener('click', onClick); - } - - function bindEvents(button) { - - clearEvents(button); - - button.addEventListener('click', onClick); - } - - var EmbyDownloadButtonPrototype = Object.create(EmbyButtonPrototype); - - EmbyDownloadButtonPrototype.createdCallback = function () { - - // base method - if (EmbyButtonPrototype.createdCallback) { - EmbyButtonPrototype.createdCallback.call(this); - } - }; - - EmbyDownloadButtonPrototype.attachedCallback = function () { - - // base method - if (EmbyButtonPrototype.attachedCallback) { - EmbyButtonPrototype.attachedCallback.call(this); - } - - var itemId = this.getAttribute('data-id'); - var serverId = this.getAttribute('data-serverid'); - if (itemId && serverId) { - - bindEvents(this); - } - }; - - EmbyDownloadButtonPrototype.detachedCallback = function () { - - // base method - if (EmbyButtonPrototype.detachedCallback) { - EmbyButtonPrototype.detachedCallback.call(this); - } - - clearEvents(this); - - this.iconElement = null; - }; - - function fetchAndUpdate(button, item) { - - connectionManager.getApiClient(item.ServerId).getSyncStatus(item.Id).then(function (result) { - - updateSyncStatus(button, result.Progress); - - }, function () { - - }); - } - - EmbyDownloadButtonPrototype.setItem = function (item) { - - if (item) { - - this.setAttribute('data-id', item.Id); - this.setAttribute('data-serverid', item.ServerId); - - fetchAndUpdate(this, item); - - bindEvents(this); - - } else { - - this.removeAttribute('data-id'); - this.removeAttribute('data-serverid'); - clearEvents(this); - } - }; - - document.registerElement('emby-downloadbutton', { - prototype: EmbyDownloadButtonPrototype, - extends: 'button' - }); -}); \ No newline at end of file diff --git a/src/components/sync/sync.js b/src/components/sync/sync.js deleted file mode 100644 index e7c51e3dc5..0000000000 --- a/src/components/sync/sync.js +++ /dev/null @@ -1,736 +0,0 @@ -define(['apphost', 'globalize', 'connectionManager', 'layoutManager', 'focusManager', 'scrollHelper', 'appSettings', 'registrationServices', 'dialogHelper', 'paper-icon-button-light', 'formDialogStyle'], function (appHost, globalize, connectionManager, layoutManager, focusManager, scrollHelper, appSettings, registrationServices, dialogHelper) { - 'use strict'; - - var currentDialogOptions; - - function submitJob(dlg, apiClient, userId, syncOptions, form) { - - if (!userId) { - throw new Error('userId cannot be null'); - } - - if (!syncOptions) { - throw new Error('syncOptions cannot be null'); - } - - if (!form) { - throw new Error('form cannot be null'); - } - - var selectSyncTarget = form.querySelector('#selectSyncTarget'); - var target = selectSyncTarget ? selectSyncTarget.value : null; - - if (!target) { - - require(['toast'], function (toast) { - toast(globalize.translate('PleaseSelectDeviceToSyncTo')); - }); - return false; - } - - var options = { - - userId: userId, - TargetId: target, - - ParentId: syncOptions.ParentId, - Category: syncOptions.Category - }; - - setJobValues(options, form); - - if (syncOptions.items && syncOptions.items.length) { - options.ItemIds = (syncOptions.items || []).map(function (i) { - return i.Id || i; - }).join(','); - } - - apiClient.ajax({ - - type: "POST", - url: apiClient.getUrl("Sync/Jobs"), - data: JSON.stringify(options), - contentType: "application/json", - dataType: 'json' - - }).then(function () { - - dialogHelper.close(dlg); - require(['toast'], function (toast) { - - showSubmissionToast(target, apiClient); - - if (syncOptions.mode === 'download') { - syncNow(); - } - }); - }); - - return true; - } - - - function showSubmissionToast(targetId, apiClient) { - - require(['toast'], function (toast) { - - var msg = targetId === apiClient.deviceId() ? - globalize.translate('DownloadingDots') : - globalize.translate('SyncingDots'); - - toast(msg); - }); - } - - function syncNow() { - require(['localsync'], function (localSync) { - localSync.sync(); - }); - } - - 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) { - - showSubmissionToast(targetId, apiClient); - - if (syncOptions.mode === 'download') { - syncNow(); - } - }); - }); - } - - function setJobValues(job, form) { - - var txtBitrate = form.querySelector('#txtBitrate'); - var bitrate = txtBitrate ? txtBitrate.value : null; - - if (bitrate) { - bitrate = parseFloat(bitrate) * 1000000; - } - job.Bitrate = bitrate; - - var selectQuality = form.querySelector('#selectQuality'); - if (selectQuality) { - job.Quality = selectQuality.value; - - appSettings.set('sync-lastquality', job.Quality || ''); - } - - var selectProfile = form.querySelector('#selectProfile'); - if (selectProfile) { - job.Profile = selectProfile.value; - } - - var txtItemLimit = form.querySelector('#txtItemLimit'); - if (txtItemLimit) { - job.ItemLimit = txtItemLimit.value || null; - } - - var chkSyncNewContent = form.querySelector('#chkSyncNewContent'); - if (chkSyncNewContent) { - job.SyncNewContent = chkSyncNewContent.checked; - } - - var chkUnwatchedOnly = form.querySelector('#chkUnwatchedOnly'); - if (chkUnwatchedOnly) { - job.UnwatchedOnly = chkUnwatchedOnly.checked; - } - } - - function renderForm(options) { - - return new Promise(function (resolve, reject) { - - require(['emby-checkbox', 'emby-input', 'emby-select'], function () { - - renderFormInternal(options, connectionManager.deviceId(), resolve); - }); - }); - } - - function renderFormInternal(options, defaultTargetId, resolve) { - - var elem = options.elem; - var dialogOptions = options.dialogOptions; - - var targets = dialogOptions.Targets; - - var html = ''; - - var mode = options.mode; - var targetContainerClass = mode === 'download' ? ' hide' : ''; - - var syncTargetLabel = mode === 'convert' ? globalize.translate('LabelConvertTo') : globalize.translate('LabelSyncTo'); - - if (options.readOnlySyncTarget) { - html += '