mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 02:48:19 -07:00
Merge pull request #51 from dkanada/clean
remove more code for sync and camera roll
This commit is contained in:
commit
2257110992
@ -1,8 +0,0 @@
|
||||
define([], function() {
|
||||
"use strict";
|
||||
|
||||
function CameraRoll() {}
|
||||
return CameraRoll.prototype.getFiles = function() {
|
||||
return Promise.resolve([])
|
||||
}, new CameraRoll
|
||||
});
|
@ -1,57 +0,0 @@
|
||||
define(["localassetmanager", "cameraRoll"], function(localAssetManager, cameraRoll) {
|
||||
"use strict";
|
||||
|
||||
function getFilesToUpload(files, uploadHistory) {
|
||||
return files.filter(function(file) {
|
||||
if (!file) return !1;
|
||||
var uploadId = getUploadId(file);
|
||||
return 0 === uploadHistory.FilesUploaded.filter(function(u) {
|
||||
return uploadId === u.Id
|
||||
}).length
|
||||
})
|
||||
}
|
||||
|
||||
function getUploadId(file) {
|
||||
return btoa(file.Id + "1")
|
||||
}
|
||||
|
||||
function uploadNext(files, index, server, apiClient, resolve, reject) {
|
||||
var length = files.length;
|
||||
if (index >= length) return void resolve();
|
||||
uploadFile(files[index], apiClient).then(function() {
|
||||
uploadNext(files, index + 1, server, apiClient, resolve, reject)
|
||||
}, function() {
|
||||
uploadNext(files, index + 1, server, apiClient, resolve, reject)
|
||||
})
|
||||
}
|
||||
|
||||
function uploadFile(file, apiClient) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
require(["fileupload"], function(FileUpload) {
|
||||
var url = apiClient.getUrl("Devices/CameraUploads", {
|
||||
DeviceId: apiClient.deviceId(),
|
||||
Name: file.Name,
|
||||
Album: "Camera Roll",
|
||||
Id: getUploadId(file),
|
||||
api_key: apiClient.accessToken()
|
||||
});
|
||||
console.log("Uploading file to " + url), (new FileUpload).upload(file, url).then(resolve, reject)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function ContentUploader() {}
|
||||
return ContentUploader.prototype.uploadImages = function(connectionManager, server) {
|
||||
return cameraRoll.getFiles().then(function(photos) {
|
||||
if (!photos.length) return Promise.resolve();
|
||||
var apiClient = connectionManager.getApiClient(server.Id);
|
||||
return apiClient.getContentUploadHistory().then(function(uploadHistory) {
|
||||
return photos = getFilesToUpload(photos, uploadHistory), console.log("Found " + photos.length + " files to upload"), new Promise(function(resolve, reject) {
|
||||
uploadNext(photos, 0, server, apiClient, resolve, reject)
|
||||
})
|
||||
}, function() {
|
||||
return Promise.resolve()
|
||||
})
|
||||
})
|
||||
}, ContentUploader
|
||||
});
|
@ -12,11 +12,7 @@ define([], function() {
|
||||
}
|
||||
|
||||
function uploadContent(connectionManager, server, options) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
require(["contentuploader"], function(ContentUploader) {
|
||||
(new ContentUploader).uploadImages(connectionManager, server).then(resolve, reject)
|
||||
})
|
||||
})
|
||||
return new Promise().reject();
|
||||
}
|
||||
|
||||
function syncMedia(connectionManager, server, options) {
|
||||
|
@ -1,504 +0,0 @@
|
||||
define(['connectionManager', 'serverNotifications', 'events', 'datetime', 'dom', 'imageLoader', 'loading', 'globalize', 'apphost', 'layoutManager', 'scrollHelper', 'dialogHelper', 'listViewStyle', 'paper-icon-button-light', 'emby-button', 'formDialogStyle', 'emby-linkbutton'], function (connectionManager, serverNotifications, events, datetime, dom, imageLoader, loading, globalize, appHost, layoutManager, scrollHelper, dialogHelper) {
|
||||
'use strict';
|
||||
|
||||
function syncNow() {
|
||||
require(['localsync'], function (localSync) {
|
||||
localSync.sync();
|
||||
});
|
||||
}
|
||||
|
||||
function renderJob(context, job, dialogOptions) {
|
||||
|
||||
require(['syncDialog'], function (syncDialog) {
|
||||
syncDialog.renderForm({
|
||||
elem: context.querySelector('.syncJobFormContent'),
|
||||
dialogOptions: dialogOptions,
|
||||
dialogOptionsFn: getTargetDialogOptionsFn(dialogOptions),
|
||||
readOnlySyncTarget: true
|
||||
}).then(function () {
|
||||
fillJobValues(context, job, dialogOptions);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getTargetDialogOptionsFn(dialogOptions) {
|
||||
|
||||
return function (targetId) {
|
||||
|
||||
return Promise.resolve(dialogOptions);
|
||||
};
|
||||
}
|
||||
|
||||
function getJobItemHtml(jobItem, apiClient, index) {
|
||||
|
||||
var html = '';
|
||||
var status = jobItem.Status;
|
||||
|
||||
var nextAction;
|
||||
|
||||
if (status === 'Failed') {
|
||||
nextAction = 'retry';
|
||||
}
|
||||
else if (status === 'Cancelled') {
|
||||
nextAction = 'retry';
|
||||
}
|
||||
else if (status === 'Queued' || status === 'Transferring' || status === 'Converting' || status === 'ReadyToTransfer') {
|
||||
nextAction = 'cancel';
|
||||
}
|
||||
else if (status === 'Synced' && !jobItem.IsMarkedForRemoval) {
|
||||
nextAction = 'remove';
|
||||
}
|
||||
|
||||
var listItemClass = 'listItem listItem-border';
|
||||
if (layoutManager.tv && nextAction) {
|
||||
listItemClass += ' btnJobItemMenu';
|
||||
}
|
||||
|
||||
if (layoutManager.tv) {
|
||||
listItemClass += ' listItem-button';
|
||||
}
|
||||
|
||||
var tagName = layoutManager.tv ? 'button' : 'div';
|
||||
html += '<' + tagName + ' type="button" class="' + listItemClass + '" data-itemid="' + jobItem.Id + '" data-status="' + jobItem.Status + '" data-action="' + nextAction + '">';
|
||||
|
||||
var imgUrl;
|
||||
|
||||
if (jobItem.PrimaryImageItemId) {
|
||||
|
||||
imgUrl = apiClient.getImageUrl(jobItem.PrimaryImageItemId, {
|
||||
type: "Primary",
|
||||
width: 80,
|
||||
tag: jobItem.PrimaryImageTag,
|
||||
minScale: 1.5
|
||||
});
|
||||
}
|
||||
|
||||
if (imgUrl) {
|
||||
html += '<div class="listItemImage" style="background-image:url(\'' + imgUrl + '\');background-repeat:no-repeat;background-position:center center;background-size: cover;"></div>';
|
||||
}
|
||||
else {
|
||||
html += '<i class="md-icon listItemIcon">sync</i>';
|
||||
}
|
||||
|
||||
html += '<div class="listItemBody three-line">';
|
||||
|
||||
html += '<h3 class="listItemBodyText">';
|
||||
html += jobItem.ItemName;
|
||||
html += '</h3>';
|
||||
|
||||
if (jobItem.Status === 'Failed') {
|
||||
html += '<div class="secondary listItemBodyText" style="color:red;">';
|
||||
} else {
|
||||
html += '<div class="secondary listItemBodyText">';
|
||||
}
|
||||
html += globalize.translate('sharedcomponents#SyncJobItemStatus' + jobItem.Status);
|
||||
if (jobItem.Status === 'Synced' && jobItem.IsMarkedForRemoval) {
|
||||
html += '<br/>';
|
||||
html += globalize.translate('sharedcomponents#RemovingFromDevice');
|
||||
}
|
||||
html += '</div>';
|
||||
|
||||
html += '<div class="secondary listItemBodyText" style="padding-top:5px;">';
|
||||
html += '<div style="background:#e0e0e0;height:2px;"><div style="background:#00a4dc;width:' + (jobItem.Progress || 0) + '%;height:100%;"></div></div>';
|
||||
html += '</div>';
|
||||
|
||||
html += '</div>';
|
||||
|
||||
var moreIcon = '';
|
||||
|
||||
if (!layoutManager.tv) {
|
||||
|
||||
if (nextAction === 'retry') {
|
||||
html += '<button type="button" is="paper-icon-button-light" class="btnJobItemMenu" data-action="' + nextAction + '"><i class="md-icon"></i></button>';
|
||||
}
|
||||
else if (nextAction === 'cancel') {
|
||||
html += '<button type="button" is="paper-icon-button-light" class="btnJobItemMenu" data-action="' + nextAction + '"><i class="md-icon"></i></button>';
|
||||
}
|
||||
else if (nextAction === 'remove') {
|
||||
html += '<button type="button" is="paper-icon-button-light" class="btnJobItemMenu" data-action="' + nextAction + '"><i class="md-icon"></i></button>';
|
||||
}
|
||||
}
|
||||
|
||||
html += '</' + tagName + '>';
|
||||
return html;
|
||||
}
|
||||
|
||||
function renderJobItems(context, items, apiClient) {
|
||||
|
||||
var html = '';
|
||||
|
||||
html += '<h1>' + globalize.translate('sharedcomponents#Items') + '</h1>';
|
||||
|
||||
html += '<div class="paperList">';
|
||||
|
||||
var index = 0;
|
||||
html += items.map(function (i) {
|
||||
|
||||
return getJobItemHtml(i, apiClient, index++);
|
||||
|
||||
}).join('');
|
||||
|
||||
html += '</div>';
|
||||
|
||||
var elem = context.querySelector('.jobItems');
|
||||
elem.innerHTML = html;
|
||||
imageLoader.lazyChildren(elem);
|
||||
}
|
||||
|
||||
function parentWithClass(elem, className) {
|
||||
|
||||
while (!elem.classList || !elem.classList.contains(className)) {
|
||||
elem = elem.parentNode;
|
||||
|
||||
if (!elem) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return elem;
|
||||
}
|
||||
|
||||
function showJobItemMenu(elem, jobId, apiClient) {
|
||||
|
||||
var action = elem.getAttribute('data-action');
|
||||
var context = parentWithClass(elem, 'formDialog');
|
||||
var listItem = parentWithClass(elem, 'listItem');
|
||||
var jobItemId = listItem.getAttribute('data-itemid');
|
||||
|
||||
var menuItems = [];
|
||||
|
||||
if (action === 'retry') {
|
||||
retryJobItem(context, jobId, jobItemId, apiClient);
|
||||
}
|
||||
else if (action === 'cancel' || action === 'remove') {
|
||||
cancelJobItem(context, jobId, jobItemId, apiClient);
|
||||
}
|
||||
}
|
||||
|
||||
function cancelJobItem(context, jobId, jobItemId, apiClient) {
|
||||
|
||||
showRemoveConfirm(function () {
|
||||
loading.show();
|
||||
|
||||
apiClient.ajax({
|
||||
|
||||
type: "DELETE",
|
||||
url: apiClient.getUrl('Sync/JobItems/' + jobItemId)
|
||||
|
||||
}).then(function () {
|
||||
|
||||
// TODO this should check editor options.mode === 'download'
|
||||
if (appHost.supports('sync')) {
|
||||
syncNow();
|
||||
}
|
||||
|
||||
loadJob(context, jobId, apiClient);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function retryJobItem(context, jobId, jobItemId, apiClient) {
|
||||
|
||||
showRetryConfirm(function () {
|
||||
apiClient.ajax({
|
||||
|
||||
type: "POST",
|
||||
url: apiClient.getUrl('Sync/JobItems/' + jobItemId + '/Enable')
|
||||
|
||||
}).then(function () {
|
||||
|
||||
// TODO this should check editor options.mode === 'download'
|
||||
if (appHost.supports('sync')) {
|
||||
syncNow();
|
||||
}
|
||||
|
||||
loadJob(context, jobId, apiClient);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function showRetryConfirm(callback) {
|
||||
|
||||
// TODO Implement this as a retry dialog
|
||||
require(['confirm'], function (confirm) {
|
||||
|
||||
confirm({
|
||||
|
||||
text: globalize.translate('sharedcomponents#ConfirmRemoveDownload'),
|
||||
confirmText: globalize.translate('sharedcomponents#RemoveDownload'),
|
||||
cancelText: globalize.translate('sharedcomponents#KeepDownload'),
|
||||
primary: 'cancel'
|
||||
|
||||
}).then(callback);
|
||||
});
|
||||
}
|
||||
|
||||
function showRemoveConfirm(callback) {
|
||||
|
||||
require(['confirm'], function (confirm) {
|
||||
|
||||
confirm({
|
||||
|
||||
text: globalize.translate('sharedcomponents#ConfirmRemoveDownload'),
|
||||
confirmText: globalize.translate('sharedcomponents#RemoveDownload'),
|
||||
cancelText: globalize.translate('sharedcomponents#KeepDownload'),
|
||||
primary: 'cancel'
|
||||
|
||||
}).then(callback);
|
||||
});
|
||||
}
|
||||
|
||||
function showConfirm(text, callback) {
|
||||
|
||||
require(['confirm'], function (confirm) {
|
||||
|
||||
confirm(text).then(callback);
|
||||
});
|
||||
}
|
||||
|
||||
function fillJobValues(context, job, editOptions) {
|
||||
|
||||
var selectProfile = context.querySelector('#selectProfile');
|
||||
if (selectProfile) {
|
||||
selectProfile.value = job.Profile || '';
|
||||
}
|
||||
|
||||
var selectQuality = context.querySelector('#selectQuality');
|
||||
if (selectQuality) {
|
||||
selectQuality.value = job.Quality || '';
|
||||
}
|
||||
|
||||
var chkUnwatchedOnly = context.querySelector('#chkUnwatchedOnly');
|
||||
if (chkUnwatchedOnly) {
|
||||
chkUnwatchedOnly.checked = job.UnwatchedOnly;
|
||||
}
|
||||
|
||||
var chkSyncNewContent = context.querySelector('#chkSyncNewContent');
|
||||
if (chkSyncNewContent) {
|
||||
chkSyncNewContent.checked = job.SyncNewContent;
|
||||
}
|
||||
|
||||
var txtItemLimit = context.querySelector('#txtItemLimit');
|
||||
if (txtItemLimit) {
|
||||
txtItemLimit.value = job.ItemLimit;
|
||||
}
|
||||
|
||||
var txtBitrate = context.querySelector('#txtBitrate');
|
||||
if (job.Bitrate) {
|
||||
txtBitrate.value = job.Bitrate / 1000000;
|
||||
} else {
|
||||
txtBitrate.value = '';
|
||||
}
|
||||
|
||||
var target = editOptions.Targets.filter(function (t) {
|
||||
return t.Id === job.TargetId;
|
||||
})[0];
|
||||
var targetName = target ? target.Name : '';
|
||||
|
||||
var selectSyncTarget = context.querySelector('#selectSyncTarget');
|
||||
if (selectSyncTarget) {
|
||||
selectSyncTarget.value = targetName;
|
||||
}
|
||||
}
|
||||
|
||||
var _jobOptions;
|
||||
function loadJob(context, id, apiClient) {
|
||||
|
||||
loading.show();
|
||||
|
||||
apiClient.getJSON(apiClient.getUrl('Sync/Jobs/' + id)).then(function (job) {
|
||||
|
||||
apiClient.getJSON(apiClient.getUrl('Sync/Options', {
|
||||
|
||||
UserId: job.UserId,
|
||||
ItemIds: (job.RequestedItemIds && job.RequestedItemIds.length ? job.RequestedItemIds.join('') : null),
|
||||
|
||||
ParentId: job.ParentId,
|
||||
Category: job.Category,
|
||||
TargetId: job.TargetId
|
||||
|
||||
})).then(function (options) {
|
||||
|
||||
_jobOptions = options;
|
||||
renderJob(context, job, options);
|
||||
loading.hide();
|
||||
});
|
||||
});
|
||||
|
||||
apiClient.getJSON(apiClient.getUrl('Sync/JobItems', {
|
||||
|
||||
JobId: id,
|
||||
AddMetadata: true
|
||||
|
||||
})).then(function (result) {
|
||||
|
||||
renderJobItems(context, result.Items, apiClient);
|
||||
loading.hide();
|
||||
});
|
||||
}
|
||||
|
||||
function loadJobInfo(context, job, jobItems, apiClient) {
|
||||
|
||||
//renderJob(page, job, _jobOptions);
|
||||
renderJobItems(context, jobItems, apiClient);
|
||||
loading.hide();
|
||||
}
|
||||
|
||||
function saveJob(context, id, apiClient) {
|
||||
|
||||
loading.show();
|
||||
|
||||
apiClient.getJSON(apiClient.getUrl('Sync/Jobs/' + id)).then(function (job) {
|
||||
|
||||
require(['syncDialog'], function (syncDialog) {
|
||||
syncDialog.setJobValues(job, context);
|
||||
|
||||
apiClient.ajax({
|
||||
|
||||
url: apiClient.getUrl('Sync/Jobs/' + id),
|
||||
type: 'POST',
|
||||
data: JSON.stringify(job),
|
||||
contentType: "application/json"
|
||||
|
||||
}).then(function () {
|
||||
|
||||
// TODO this should check editor options.mode === 'download'
|
||||
if (appHost.supports('sync')) {
|
||||
syncNow();
|
||||
}
|
||||
|
||||
loading.hide();
|
||||
dialogHelper.close(context);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function startListening(apiClient, jobId) {
|
||||
|
||||
var startParams = "0,1500";
|
||||
|
||||
startParams += "," + jobId;
|
||||
|
||||
apiClient.sendMessage("SyncJobStart", startParams);
|
||||
}
|
||||
|
||||
function stopListening(apiClient) {
|
||||
|
||||
apiClient.sendMessage("SyncJobStop", "");
|
||||
}
|
||||
|
||||
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"></i></button>';
|
||||
html += '<h3 class="formDialogHeaderTitle">';
|
||||
html += globalize.translate('sharedcomponents#Sync');
|
||||
html += '</h3>';
|
||||
|
||||
if (appHost.supports('externallinks')) {
|
||||
html += '<a href="https://github.com/MediaBrowser/Wiki/wiki/Sync" target="_blank" is="emby-linkbutton" class="button-link lnkHelp" style="margin-top:0;display:inline-block;vertical-align:middle;margin-left:auto;"><i class="md-icon">info</i><span>' + globalize.translate('sharedcomponents#Help') + '</span></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;
|
||||
|
||||
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(dlg, msg.Job, msg.JobItems, apiClient);
|
||||
}
|
||||
|
||||
loadJob(dlg, id, apiClient);
|
||||
bindEvents(dlg, id, apiClient);
|
||||
|
||||
var promise = dialogHelper.open(dlg);
|
||||
|
||||
startListening(apiClient, id);
|
||||
events.on(serverNotifications, "SyncJob", onSyncJobMessage);
|
||||
|
||||
return promise.then(function () {
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
});
|
@ -1,455 +0,0 @@
|
||||
define(['serverNotifications', 'events', 'loading', 'connectionManager', 'imageLoader', 'dom', 'globalize', 'registrationServices', 'layoutManager', 'listViewStyle'], function (serverNotifications, events, loading, connectionManager, imageLoader, dom, globalize, registrationServices, layoutManager) {
|
||||
'use strict';
|
||||
|
||||
function onSyncJobCreated(e, apiClient, data) {
|
||||
var listInstance = this;
|
||||
fetchData(listInstance);
|
||||
}
|
||||
function onSyncJobUpdated(e, apiClient, data) {
|
||||
var listInstance = this;
|
||||
|
||||
refreshJob(listInstance, data);
|
||||
}
|
||||
function onSyncJobCancelled(e, apiClient, data) {
|
||||
var listInstance = this;
|
||||
fetchData(listInstance);
|
||||
}
|
||||
|
||||
function refreshList(listInstance, jobs) {
|
||||
for (var i = 0, length = jobs.length; i < length; i++) {
|
||||
|
||||
var job = jobs[i];
|
||||
refreshJob(listInstance, job);
|
||||
}
|
||||
}
|
||||
|
||||
function syncNow() {
|
||||
require(['localsync'], function (localSync) {
|
||||
localSync.sync();
|
||||
});
|
||||
}
|
||||
|
||||
function cancelJob(listInstance, id) {
|
||||
|
||||
require(['confirm'], function (confirm) {
|
||||
|
||||
var msg = globalize.translate('sharedcomponents#ConfirmRemoveDownload');
|
||||
|
||||
confirm({
|
||||
|
||||
text: msg,
|
||||
primary: 'cancel'
|
||||
|
||||
}).then(function () {
|
||||
|
||||
loading.show();
|
||||
var apiClient = getApiClient(listInstance);
|
||||
|
||||
apiClient.ajax({
|
||||
|
||||
url: apiClient.getUrl('Sync/Jobs/' + id),
|
||||
type: 'DELETE'
|
||||
|
||||
}).then(function () {
|
||||
|
||||
if (listInstance.options.mode === 'download') {
|
||||
syncNow();
|
||||
}
|
||||
|
||||
fetchData(listInstance);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function refreshJob(listInstance, job) {
|
||||
|
||||
var listItem = listInstance.options.element.querySelector('.listItem[data-id=\'' + job.Id + '\']');
|
||||
|
||||
if (!listItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
listItem.querySelector('.jobStatus').innerHTML = getProgressText(job);
|
||||
}
|
||||
|
||||
function getProgressText(job) {
|
||||
|
||||
var status = job.Status;
|
||||
|
||||
if (status === 'Completed') {
|
||||
status = 'Synced';
|
||||
}
|
||||
|
||||
var html = globalize.translate('sharedcomponents#SyncJobItemStatus' + status);
|
||||
|
||||
if (job.Status === 'Transferring' || job.Status === 'Converting' || job.Status === 'Completed') {
|
||||
html += ' ';
|
||||
|
||||
var progress = job.Progress || 0;
|
||||
if (progress > 0 && progress < 100) {
|
||||
progress = progress.toFixed(1);
|
||||
}
|
||||
html += progress + '%';
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
function getSyncJobHtml(listInstance, job, apiClient) {
|
||||
|
||||
var html = '';
|
||||
|
||||
var tagName = layoutManager.tv ? 'button' : 'div';
|
||||
var typeAttribute = tagName === 'button' ? ' type="button"' : '';
|
||||
|
||||
var listItemClass = 'listItem listItem-border';
|
||||
|
||||
if (layoutManager.tv) {
|
||||
listItemClass += ' listItem-button listItem-focusscale';
|
||||
|
||||
listItemClass += ' btnJobMenu';
|
||||
}
|
||||
|
||||
var canEdit = (job.ItemCount || 1) > 1 || job.Status === 'Queued';
|
||||
html += '<' + tagName + typeAttribute + ' class="' + listItemClass + '" data-canedit="' + canEdit + '" data-id="' + job.Id + '" data-status="' + job.Status + '">';
|
||||
|
||||
var imgUrl;
|
||||
|
||||
if (job.PrimaryImageItemId) {
|
||||
|
||||
imgUrl = apiClient.getImageUrl(job.PrimaryImageItemId, {
|
||||
type: "Primary",
|
||||
width: 80,
|
||||
tag: job.PrimaryImageTag,
|
||||
minScale: 1.5
|
||||
});
|
||||
}
|
||||
|
||||
if (imgUrl) {
|
||||
html += '<div class="listItemImage lazy" data-src="' + imgUrl + '" item-icon>';
|
||||
html += '</div>';
|
||||
}
|
||||
else {
|
||||
html += '<i class="md-icon listItemIcon">file_download</i>';
|
||||
}
|
||||
|
||||
var textLines = [];
|
||||
|
||||
var name = job.Name;
|
||||
|
||||
if (job.ParentName) {
|
||||
name += ' - ' + job.ParentName;
|
||||
}
|
||||
|
||||
textLines.push(name);
|
||||
|
||||
if (job.ItemCount === 1) {
|
||||
//textLines.push(globalize.translate('sharedcomponents#ValueOneItem'));
|
||||
} else {
|
||||
textLines.push(globalize.translate('sharedcomponents#ItemCount', job.ItemCount));
|
||||
}
|
||||
|
||||
html += '<div class="listItemBody three-line">';
|
||||
|
||||
for (var i = 0, length = textLines.length; i < length; i++) {
|
||||
|
||||
if (i === 0) {
|
||||
html += '<h3 class="listItemBodyText">';
|
||||
html += textLines[i];
|
||||
html += '</h3>';
|
||||
} else {
|
||||
html += '<div class="listItemBodyText secondary">';
|
||||
html += textLines[i];
|
||||
html += '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
html += '<div class="secondary listItemBodyText jobStatus">';
|
||||
html += getProgressText(job);
|
||||
html += '</div>';
|
||||
|
||||
html += '</div>';
|
||||
|
||||
if (!layoutManager.tv) {
|
||||
|
||||
if (canEdit) {
|
||||
html += '<button type="button" is="paper-icon-button-light" class="btnJobMenu listItemButton"><i class="md-icon">more_horiz</i></button>';
|
||||
} else {
|
||||
html += '<button type="button" is="paper-icon-button-light" class="btnCancelJob listItemButton"><i class="md-icon">delete</i></button>';
|
||||
}
|
||||
}
|
||||
|
||||
html += '</' + tagName + '>';
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
function renderList(listInstance, jobs, apiClient) {
|
||||
|
||||
if ((new Date().getTime() - listInstance.lastDataLoad) < 60000) {
|
||||
refreshList(listInstance, jobs);
|
||||
return;
|
||||
}
|
||||
|
||||
listInstance.lastDataLoad = new Date().getTime();
|
||||
|
||||
var html = '';
|
||||
var lastTargetName = '';
|
||||
|
||||
var mode = listInstance.options.mode;
|
||||
var showTargetName = mode !== 'download';
|
||||
|
||||
var hasOpenSection = false;
|
||||
|
||||
for (var i = 0, length = jobs.length; i < length; i++) {
|
||||
|
||||
var job = jobs[i];
|
||||
if (showTargetName) {
|
||||
var targetName = job.TargetName || 'Unknown';
|
||||
|
||||
if (targetName !== lastTargetName) {
|
||||
|
||||
if (lastTargetName) {
|
||||
html += '</div>';
|
||||
html += '<br/>';
|
||||
hasOpenSection = false;
|
||||
}
|
||||
|
||||
lastTargetName = targetName;
|
||||
|
||||
html += '<div class="verticalSection">';
|
||||
html += '<div class="sectionTitleContainer">';
|
||||
|
||||
html += '<h2 class="sectionTitle">' + targetName + '</h2>';
|
||||
|
||||
html += '</div>';
|
||||
html += '<div class="itemsContainer vertical-list paperList">';
|
||||
hasOpenSection = true;
|
||||
}
|
||||
}
|
||||
|
||||
html += getSyncJobHtml(listInstance, job, apiClient);
|
||||
}
|
||||
|
||||
if (hasOpenSection) {
|
||||
html += '</div>';
|
||||
html += '</div>';
|
||||
}
|
||||
|
||||
var elem = listInstance.options.element.querySelector('.syncJobListContent');
|
||||
|
||||
if (!html) {
|
||||
if (mode === 'download') {
|
||||
html = '<div style="padding:1em .25em;">' + globalize.translate('sharedcomponents#MessageNoDownloadsFound') + '</div>';
|
||||
} else {
|
||||
html = '<div style="padding:1em .25em;">' + globalize.translate('sharedcomponents#MessageNoSyncJobsFound') + '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
elem.innerHTML = html;
|
||||
|
||||
imageLoader.lazyChildren(elem);
|
||||
}
|
||||
|
||||
function fetchData(listInstance) {
|
||||
|
||||
listInstance.lastDataLoad = 0;
|
||||
loading.show();
|
||||
|
||||
var options = {};
|
||||
var apiClient = getApiClient(listInstance);
|
||||
|
||||
if (listInstance.options.userId) {
|
||||
options.UserId = listInstance.options.userId;
|
||||
}
|
||||
|
||||
if (listInstance.options.mode === 'download') {
|
||||
options.TargetId = apiClient.deviceId();
|
||||
}
|
||||
|
||||
return apiClient.getJSON(apiClient.getUrl('Sync/Jobs', options)).then(function (response) {
|
||||
|
||||
renderList(listInstance, response.Items, apiClient);
|
||||
loading.hide();
|
||||
});
|
||||
}
|
||||
|
||||
function getApiClient(listInstance) {
|
||||
return connectionManager.getApiClient(listInstance.options.serverId);
|
||||
}
|
||||
|
||||
function showJobMenu(listInstance, elem) {
|
||||
|
||||
var item = dom.parentWithClass(elem, 'listItem');
|
||||
var jobId = item.getAttribute('data-id');
|
||||
var status = item.getAttribute('data-status');
|
||||
|
||||
var menuItems = [];
|
||||
|
||||
if (item.getAttribute('data-canedit') === 'true') {
|
||||
menuItems.push({
|
||||
name: globalize.translate('sharedcomponents#Edit'),
|
||||
id: 'edit'
|
||||
});
|
||||
}
|
||||
|
||||
var txt = globalize.translate('sharedcomponents#RemoveDownload');
|
||||
|
||||
menuItems.push({
|
||||
name: txt,
|
||||
id: 'cancel'
|
||||
});
|
||||
|
||||
require(['actionsheet'], function (actionsheet) {
|
||||
|
||||
actionsheet.show({
|
||||
items: menuItems,
|
||||
positionTo: elem,
|
||||
callback: function (id) {
|
||||
|
||||
switch (id) {
|
||||
|
||||
case 'delete':
|
||||
cancelJob(listInstance, jobId);
|
||||
break;
|
||||
case 'cancel':
|
||||
cancelJob(listInstance, jobId);
|
||||
break;
|
||||
case 'edit':
|
||||
showJobEditor(listInstance, elem);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function onElementClick(e) {
|
||||
|
||||
var listInstance = this;
|
||||
|
||||
var btnJobMenu = dom.parentWithClass(e.target, 'btnJobMenu');
|
||||
if (btnJobMenu) {
|
||||
showJobMenu(listInstance, btnJobMenu);
|
||||
return;
|
||||
}
|
||||
|
||||
var btnCancelJob = dom.parentWithClass(e.target, 'btnCancelJob');
|
||||
if (btnCancelJob) {
|
||||
var listItem = dom.parentWithClass(btnCancelJob, 'listItem');
|
||||
if (listItem) {
|
||||
var jobId = listItem.getAttribute('data-id');
|
||||
cancelJob(listInstance, jobId);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
showJobEditor(listInstance, e.target);
|
||||
}
|
||||
|
||||
function showJobEditor(listInstance, elem) {
|
||||
|
||||
var listItem = dom.parentWithClass(elem, 'listItem');
|
||||
if (listItem && listItem.getAttribute('data-canedit') === 'true') {
|
||||
var jobId = listItem.getAttribute('data-id');
|
||||
// edit job
|
||||
require(['syncJobEditor'], function (syncJobEditor) {
|
||||
syncJobEditor.show({
|
||||
|
||||
serverId: listInstance.options.serverId,
|
||||
jobId: jobId,
|
||||
mode: listInstance.options.mode
|
||||
|
||||
}).then(function () {
|
||||
fetchData(listInstance);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function syncJobList(options) {
|
||||
this.options = options;
|
||||
|
||||
var onSyncJobCreatedHandler = onSyncJobCreated.bind(this);
|
||||
this.onSyncJobCreatedHandler = onSyncJobCreatedHandler;
|
||||
events.on(serverNotifications, 'SyncJobCreated', onSyncJobCreatedHandler);
|
||||
|
||||
var onSyncJobCancelledHandler = onSyncJobCancelled.bind(this);
|
||||
this.onSyncJobCancelledHandler = onSyncJobCancelledHandler;
|
||||
events.on(serverNotifications, 'SyncJobCancelled', onSyncJobCancelledHandler);
|
||||
|
||||
var onSyncJobUpdatedHandler = onSyncJobUpdated.bind(this);
|
||||
this.onSyncJobUpdatedHandler = onSyncJobUpdatedHandler;
|
||||
events.on(serverNotifications, 'SyncJobUpdated', onSyncJobUpdatedHandler);
|
||||
|
||||
var onClickHandler = onElementClick.bind(this);
|
||||
options.element.addEventListener('click', onClickHandler);
|
||||
this.onClickHandler = onClickHandler;
|
||||
|
||||
options.element.innerHTML = '<div class="syncJobListContent"></div>';
|
||||
|
||||
fetchData(this);
|
||||
|
||||
initSupporterInfo(options.element, getApiClient(this));
|
||||
}
|
||||
|
||||
function showSupporterInfo(context) {
|
||||
|
||||
var html = '<button is="emby-button" class="raised button-submit block btnSyncSupporter" style="margin:1em 0;">';
|
||||
|
||||
html += '<div>';
|
||||
html += globalize.translate('sharedcomponents#HeaderSyncRequiresSub');
|
||||
html += '</div>';
|
||||
html += '<div style="margin-top:.5em;">';
|
||||
html += globalize.translate('sharedcomponents#LearnMore');
|
||||
html += '</div>';
|
||||
|
||||
html += '</button';
|
||||
|
||||
context.insertAdjacentHTML('afterbegin', html);
|
||||
|
||||
context.querySelector('.btnSyncSupporter').addEventListener('click', function () {
|
||||
|
||||
registrationServices.validateFeature('sync');
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function initSupporterInfo(context, apiClient) {
|
||||
|
||||
registrationServices.validateFeature('sync',
|
||||
{
|
||||
showDialog: false
|
||||
|
||||
}).catch(function () {
|
||||
showSupporterInfo(context, apiClient);
|
||||
});
|
||||
}
|
||||
|
||||
syncJobList.prototype.destroy = function () {
|
||||
|
||||
var onSyncJobCreatedHandler = this.onSyncJobCreatedHandler;
|
||||
this.onSyncJobCreatedHandler = null;
|
||||
events.off(serverNotifications, 'SyncJobCreated', onSyncJobCreatedHandler);
|
||||
|
||||
var onSyncJobCancelledHandler = this.onSyncJobCancelledHandler;
|
||||
this.onSyncJobCancelledHandler = null;
|
||||
events.off(serverNotifications, 'SyncJobCancelled', onSyncJobCancelledHandler);
|
||||
|
||||
var onSyncJobUpdatedHandler = this.onSyncJobUpdatedHandler;
|
||||
this.onSyncJobUpdatedHandler = null;
|
||||
events.off(serverNotifications, 'SyncJobUpdated', onSyncJobUpdatedHandler);
|
||||
|
||||
var onClickHandler = this.onClickHandler;
|
||||
this.onClickHandler = null;
|
||||
this.options.element.removeEventListener('click', onClickHandler);
|
||||
|
||||
this.options = null;
|
||||
};
|
||||
|
||||
return syncJobList;
|
||||
});
|
@ -108,84 +108,131 @@ define(["appSettings", "browser", "events", "htmlMediaHelper"], function(appSett
|
||||
}
|
||||
|
||||
function onAppVisible() {
|
||||
_isHidden && (_isHidden = !1, console.log("triggering app resume event"), events.trigger(appHost, "resume"))
|
||||
if (isHidden) {
|
||||
isHidden = false;
|
||||
console.log("triggering app resume event");
|
||||
events.trigger(appHost, "resume");
|
||||
}
|
||||
}
|
||||
|
||||
function onAppHidden() {
|
||||
_isHidden || (_isHidden = !0, console.log("app is hidden"))
|
||||
if (!isHidden) {
|
||||
isHidden = true;
|
||||
console.log("app is hidden");
|
||||
}
|
||||
}
|
||||
var htmlMediaAutoplayAppStorageKey = "supportshtmlmediaautoplay0",
|
||||
supportedFeatures = function() {
|
||||
var features = [];
|
||||
return navigator.share && features.push("sharing"), browser.edgeUwp || browser.tv || browser.xboxOne || browser.ps4 || features.push("filedownload"), browser.operaTv || browser.tizen || browser.orsay || browser.web0s ? features.push("exit") : (features.push("exitmenu"), features.push("plugins")), browser.operaTv || browser.tizen || browser.orsay || browser.web0s || browser.ps4 || (features.push("externallinks"), features.push("externalpremium")), browser.operaTv || features.push("externallinkdisplay"), supportsVoiceInput() && features.push("voiceinput"), !browser.tv && !browser.xboxOne && browser.ps4, supportsHtmlMediaAutoplay() && (features.push("htmlaudioautoplay"), features.push("htmlvideoautoplay")), browser.edgeUwp && features.push("sync"), supportsFullscreen() && features.push("fullscreenchange"), (browser.chrome || browser.edge && !browser.slow) && (browser.noAnimation || browser.edgeUwp || browser.xboxOne || features.push("imageanalysis")), AppInfo.isNativeApp && features.push("multiserver"), (browser.tv || browser.xboxOne || browser.ps4 || browser.mobile) && features.push("physicalvolumecontrol"), browser.tv || browser.xboxOne || browser.ps4 || features.push("remotecontrol"), browser.operaTv || browser.tizen || browser.orsay || browser.web0s || browser.edgeUwp || features.push("remotevideo"), features.push("otherapppromotions"), features.push("targetblank"), browser.orsay || browser.tizen || browser.msie || !(browser.firefox || browser.ps4 || browser.edge || cueSupported()) || features.push("subtitleappearancesettings"), browser.orsay || browser.tizen || features.push("subtitleburnsettings"), browser.tv || browser.ps4 || browser.xboxOne || features.push("fileinput"), AppInfo.isNativeApp && features.push("displaylanguage"), browser.chrome && features.push("chromecast"), features
|
||||
}(); - 1 === supportedFeatures.indexOf("htmlvideoautoplay") && !1 !== supportsHtmlMediaAutoplay() && require(["autoPlayDetect"], function(autoPlayDetect) {
|
||||
autoPlayDetect.supportsHtmlMediaAutoplay().then(function() {
|
||||
appSettings.set(htmlMediaAutoplayAppStorageKey, "true"), supportedFeatures.push("htmlvideoautoplay"), supportedFeatures.push("htmlaudioautoplay")
|
||||
}, function() {
|
||||
appSettings.set(htmlMediaAutoplayAppStorageKey, "false")
|
||||
})
|
||||
|
||||
var htmlMediaAutoplayAppStorageKey = "supportshtmlmediaautoplay0";
|
||||
var supportedFeatures = function() {
|
||||
var features = [];
|
||||
navigator.share && features.push("sharing");
|
||||
browser.edgeUwp || browser.tv || browser.xboxOne || browser.ps4 || features.push("filedownload");
|
||||
browser.operaTv || browser.tizen || browser.orsay || browser.web0s
|
||||
? features.push("exit")
|
||||
: (features.push("exitmenu"), features.push("plugins"));
|
||||
browser.operaTv || browser.tizen || browser.orsay || browser.web0s || browser.ps4 || (features.push("externallinks"), features.push("externalpremium"));
|
||||
browser.operaTv || features.push("externallinkdisplay");
|
||||
supportsVoiceInput() && features.push("voiceinput");
|
||||
!browser.tv && !browser.xboxOne && browser.ps4, supportsHtmlMediaAutoplay() && (features.push("htmlaudioautoplay"), features.push("htmlvideoautoplay"));
|
||||
browser.edgeUwp && features.push("sync");
|
||||
supportsFullscreen() && features.push("fullscreenchange");
|
||||
(browser.chrome || browser.edge && !browser.slow) && (browser.noAnimation || browser.edgeUwp || browser.xboxOne || features.push("imageanalysis"));
|
||||
(browser.tv || browser.xboxOne || browser.ps4 || browser.mobile) && features.push("physicalvolumecontrol");
|
||||
browser.tv || browser.xboxOne || browser.ps4 || features.push("remotecontrol");
|
||||
browser.operaTv || browser.tizen || browser.orsay || browser.web0s || browser.edgeUwp || features.push("remotevideo");
|
||||
features.push("otherapppromotions");
|
||||
features.push("targetblank");
|
||||
browser.orsay || browser.tizen || browser.msie || !(browser.firefox || browser.ps4 || browser.edge || cueSupported()) || features.push("subtitleappearancesettings");
|
||||
browser.orsay || browser.tizen || features.push("subtitleburnsettings");
|
||||
browser.tv || browser.ps4 || browser.xboxOne || features.push("fileinput");
|
||||
browser.chrome && features.push("chromecast");
|
||||
return features;
|
||||
}();
|
||||
if (supportedFeatures.indexOf("htmlvideoautoplay") === -1 && supportsHtmlMediaAutoplay() !== false) {
|
||||
require(["autoPlayDetect"], function(autoPlayDetect) {
|
||||
autoPlayDetect.supportsHtmlMediaAutoplay().then(function() {
|
||||
appSettings.set(htmlMediaAutoplayAppStorageKey, "true");
|
||||
supportedFeatures.push("htmlvideoautoplay");
|
||||
supportedFeatures.push("htmlaudioautoplay");
|
||||
}, function() {
|
||||
appSettings.set(htmlMediaAutoplayAppStorageKey, "false");
|
||||
});
|
||||
}
|
||||
});
|
||||
var deviceId, deviceName, visibilityChange, visibilityState, appVersion = window.dashboardVersion || "3.0",
|
||||
appHost = {
|
||||
getWindowState: function() {
|
||||
return document.windowState || "Normal"
|
||||
},
|
||||
setWindowState: function(state) {
|
||||
alert("setWindowState is not supported and should not be called")
|
||||
},
|
||||
exit: function() {
|
||||
if (browser.tizen) try {
|
||||
tizen.application.getCurrentApplication().exit()
|
||||
} catch (err) {
|
||||
console.log("error closing application: " + err)
|
||||
} else window.close()
|
||||
},
|
||||
supports: function(command) {
|
||||
return -1 !== supportedFeatures.indexOf(command.toLowerCase())
|
||||
},
|
||||
preferVisualCards: browser.android || browser.chrome,
|
||||
moreIcon: browser.android ? "dots-vert" : "dots-horiz",
|
||||
getSyncProfile: getSyncProfile,
|
||||
getDefaultLayout: getDefaultLayout,
|
||||
getDeviceProfile: getDeviceProfile,
|
||||
init: function() {
|
||||
return deviceName = getDeviceName(), getDeviceId().then(function(resolvedDeviceId) {
|
||||
deviceId = resolvedDeviceId
|
||||
})
|
||||
},
|
||||
deviceName: function() {
|
||||
return deviceName
|
||||
},
|
||||
deviceId: function() {
|
||||
return deviceId
|
||||
},
|
||||
appName: function() {
|
||||
return "Jellyfin Web"
|
||||
},
|
||||
appVersion: function() {
|
||||
return appVersion
|
||||
},
|
||||
getPushTokenInfo: function() {
|
||||
return {}
|
||||
},
|
||||
setThemeColor: function(color) {
|
||||
var metaThemeColor = document.querySelector("meta[name=theme-color]");
|
||||
metaThemeColor && metaThemeColor.setAttribute("content", color)
|
||||
},
|
||||
setUserScalable: function(scalable) {
|
||||
if (!browser.tv) {
|
||||
var att = scalable ? "width=device-width, initial-scale=1, minimum-scale=1, user-scalable=yes" : "width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no";
|
||||
document.querySelector("meta[name=viewport]").setAttribute("content", att)
|
||||
}
|
||||
},
|
||||
deviceIconUrl: function() {
|
||||
return browser.edgeUwp, browser.edgeUwp ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/windowsrt.png" : browser.opera || browser.operaTv ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/opera.png" : browser.orsay || browser.tizen ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/samsungtv.png" : browser.web0s ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/lgtv.png" : browser.ps4 ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/ps4.png" : browser.chromecast ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/chromecast.png" : browser.chrome ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/chrome.png" : browser.edge ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/edge.png" : browser.firefox ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/firefox.png" : browser.msie ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/internetexplorer.png" : browser.safari ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/safari.png" : "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/html5.png"
|
||||
|
||||
var deviceId;
|
||||
var deviceName;
|
||||
var visibilityChange;
|
||||
var visibilityState;
|
||||
var appVersion = window.dashboardVersion || "3.0";
|
||||
var appHost = {
|
||||
getWindowState: function() {
|
||||
return document.windowState || "Normal"
|
||||
},
|
||||
setWindowState: function(state) {
|
||||
alert("setWindowState is not supported and should not be called")
|
||||
},
|
||||
exit: function() {
|
||||
if (browser.tizen) try {
|
||||
tizen.application.getCurrentApplication().exit()
|
||||
} catch (err) {
|
||||
console.log("error closing application: " + err)
|
||||
} else window.close()
|
||||
},
|
||||
supports: function(command) {
|
||||
return -1 !== supportedFeatures.indexOf(command.toLowerCase())
|
||||
},
|
||||
preferVisualCards: browser.android || browser.chrome,
|
||||
moreIcon: browser.android ? "dots-vert" : "dots-horiz",
|
||||
getSyncProfile: getSyncProfile,
|
||||
getDefaultLayout: getDefaultLayout,
|
||||
getDeviceProfile: getDeviceProfile,
|
||||
init: function() {
|
||||
return deviceName = getDeviceName(), getDeviceId().then(function(resolvedDeviceId) {
|
||||
deviceId = resolvedDeviceId
|
||||
})
|
||||
},
|
||||
deviceName: function() {
|
||||
return deviceName
|
||||
},
|
||||
deviceId: function() {
|
||||
return deviceId
|
||||
},
|
||||
appName: function() {
|
||||
return "Jellyfin Web"
|
||||
},
|
||||
appVersion: function() {
|
||||
return appVersion
|
||||
},
|
||||
getPushTokenInfo: function() {
|
||||
return {}
|
||||
},
|
||||
setThemeColor: function(color) {
|
||||
var metaThemeColor = document.querySelector("meta[name=theme-color]");
|
||||
metaThemeColor && metaThemeColor.setAttribute("content", color)
|
||||
},
|
||||
setUserScalable: function(scalable) {
|
||||
if (!browser.tv) {
|
||||
var att = scalable ? "width=device-width, initial-scale=1, minimum-scale=1, user-scalable=yes" : "width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no";
|
||||
document.querySelector("meta[name=viewport]").setAttribute("content", att)
|
||||
}
|
||||
},
|
||||
doc = self.document;
|
||||
deviceIconUrl: function() {
|
||||
return browser.edgeUwp, browser.edgeUwp ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/windowsrt.png" : browser.opera || browser.operaTv ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/opera.png" : browser.orsay || browser.tizen ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/samsungtv.png" : browser.web0s ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/lgtv.png" : browser.ps4 ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/ps4.png" : browser.chromecast ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/chromecast.png" : browser.chrome ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/chrome.png" : browser.edge ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/edge.png" : browser.firefox ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/firefox.png" : browser.msie ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/internetexplorer.png" : browser.safari ? "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/safari.png" : "https://github.com/MediaBrowser/Emby.Resources/raw/master/images/devices/html5.png"
|
||||
}
|
||||
};
|
||||
|
||||
var doc = self.document;
|
||||
doc && (void 0 !== doc.visibilityState ? (visibilityChange = "visibilitychange", visibilityState = "hidden") : void 0 !== doc.mozHidden ? (visibilityChange = "mozvisibilitychange", visibilityState = "mozVisibilityState") : void 0 !== doc.msHidden ? (visibilityChange = "msvisibilitychange", visibilityState = "msVisibilityState") : void 0 !== doc.webkitHidden && (visibilityChange = "webkitvisibilitychange", visibilityState = "webkitVisibilityState"));
|
||||
var _isHidden = !1;
|
||||
return doc && doc.addEventListener(visibilityChange, function() {
|
||||
document[visibilityState] ? onAppHidden() : onAppVisible()
|
||||
}), self.addEventListener && (self.addEventListener("focus", onAppVisible), self.addEventListener("blur", onAppHidden)), appHost
|
||||
var isHidden = false;
|
||||
if (doc) {
|
||||
doc.addEventListener(visibilityChange, function() {
|
||||
document[visibilityState] ? onAppHidden() : onAppVisible()
|
||||
});
|
||||
}
|
||||
if (self.addEventListener) {
|
||||
self.addEventListener("focus", onAppVisible);
|
||||
self.addEventListener("blur", onAppHidden);
|
||||
}
|
||||
return appHost;
|
||||
});
|
||||
|
@ -1,40 +0,0 @@
|
||||
define(["jQuery", "loading", "libraryMenu", "fnchecked"], function($, loading, libraryMenu) {
|
||||
"use strict";
|
||||
|
||||
function load(page, config) {
|
||||
$("#txtUploadPath", page).val(config.CameraUploadPath || ""), $("#chkSubfolder", page).checked(config.EnableCameraUploadSubfolders)
|
||||
}
|
||||
|
||||
function loadData(page) {
|
||||
loading.show(), ApiClient.getNamedConfiguration("devices").then(function(config) {
|
||||
load(page, config), loading.hide()
|
||||
})
|
||||
}
|
||||
|
||||
function save(page) {
|
||||
ApiClient.getNamedConfiguration("devices").then(function(config) {
|
||||
config.CameraUploadPath = $("#txtUploadPath", page).val(), config.EnableCameraUploadSubfolders = $("#chkSubfolder", page).checked(), ApiClient.updateNamedConfiguration("devices", config).then(Dashboard.processServerConfigurationUpdateResult)
|
||||
})
|
||||
}
|
||||
|
||||
function onSubmit() {
|
||||
return save($(this).parents(".page")), !1
|
||||
}
|
||||
$(document).on("pageinit", "#devicesUploadPage", function() {
|
||||
var page = this;
|
||||
$("#btnSelectUploadPath", page).on("click.selectDirectory", function() {
|
||||
require(["directorybrowser"], function(directoryBrowser) {
|
||||
var picker = new directoryBrowser;
|
||||
picker.show({
|
||||
callback: function(path) {
|
||||
path && $("#txtUploadPath", page).val(path), picker.close()
|
||||
},
|
||||
validateWriteable: !0,
|
||||
header: Globalize.translate("HeaderSelectUploadPath")
|
||||
})
|
||||
})
|
||||
}), $(".devicesUploadForm").off("submit", onSubmit).on("submit", onSubmit)
|
||||
}).on("pageshow", "#devicesUploadPage", function() {
|
||||
loadData(this)
|
||||
})
|
||||
});
|
@ -1,44 +0,0 @@
|
||||
<div id="devicesUploadPage" data-role="page" class="page type-interior devicesPage noSecondaryNavPage" data-require="dashboard/devicesupload,emby-input,emby-checkbox,emby-button">
|
||||
|
||||
<div>
|
||||
<div class="content-primary">
|
||||
|
||||
<form class="devicesUploadForm">
|
||||
|
||||
<div class="verticalSection">
|
||||
<div class="sectionTitleContainer flex align-items-center">
|
||||
<h2 class="sectionTitle">${TabCameraUpload}</h2>
|
||||
<a is="emby-linkbutton" class="raised button-alt headerHelpButton" target="_blank" href="https://web.archive.org/web/20181216120305/https://github.com/MediaBrowser/Wiki/wiki/Camera-upload">${Help}</a>
|
||||
</div>
|
||||
|
||||
<p>${HeaderCameraUploadHelp}</p>
|
||||
</div>
|
||||
|
||||
<div class="verticalSection">
|
||||
<div class="inputContainer">
|
||||
<div style="display: flex; align-items: center;">
|
||||
<div style="flex-grow:1;">
|
||||
<input is="emby-input" id="txtUploadPath" label="${LabelCameraUploadPath}" autocomplete="off" />
|
||||
</div>
|
||||
<button type="button" is="paper-icon-button-light" id="btnSelectUploadPath" title="${ButtonSelectDirectory}" class="emby-input-iconbutton"><i class="md-icon">search</i></button>
|
||||
</div>
|
||||
<div class="fieldDescription">${DefaultCameraUploadPathHelp}</div>
|
||||
</div>
|
||||
<div class="checkboxContainer checkboxContainer-withDescription">
|
||||
<label>
|
||||
<input type="checkbox" is="emby-checkbox" id="chkSubfolder" />
|
||||
<span>${LabelCreateCameraUploadSubfolder}</span>
|
||||
</label>
|
||||
<div class="fieldDescription checkboxFieldDescription">${LabelCreateCameraUploadSubfolderHelp}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button is="emby-button" type="submit" class="raised button-submit block">
|
||||
<span>${ButtonSave}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,13 +0,0 @@
|
||||
<div id="mySyncJobPage" data-role="page" class="page libraryPage syncJobPage mySyncPage noSecondaryNavPage" data-title="${TitleSync}" data-menubutton="false">
|
||||
|
||||
<div class="padded-left padded-right padded-bottom-page">
|
||||
|
||||
<div class="readOnlyContent" style="margin: 0 auto;">
|
||||
<h1>${HeaderSyncJobInfo}</h1>
|
||||
<form class="syncJobForm"></form>
|
||||
<br />
|
||||
<br />
|
||||
<div class="jobItems"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -311,12 +311,6 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
|
||||
pageIds: ["devicesPage", "devicePage"],
|
||||
icon: "devices"
|
||||
});
|
||||
links.push({
|
||||
name: globalize.translate("TabCameraUpload"),
|
||||
href: "devicesupload.html",
|
||||
pageIds: ["devicesUploadPage"],
|
||||
icon: "photo_camera"
|
||||
});
|
||||
links.push({
|
||||
name: globalize.translate("DLNA"),
|
||||
href: "dlnasettings.html",
|
||||
@ -925,7 +919,7 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
|
||||
html += '<button is="paper-icon-button-light" class="headerButton headerButtonRight headerUserButton hide"><i class="md-icon"></i></button>';
|
||||
|
||||
if (!layoutManager.mobile) {
|
||||
html += '<button is="paper-icon-button-light" class="headerButton headerButtonRight headerSettingsButton hide"><i class="md-icon"></i></button>';
|
||||
html += '<button is="paper-icon-button-light" class="headerButton headerButtonRight headerSettingsButton hide"><i class="md-icon">dashboard</i></button>';
|
||||
}
|
||||
|
||||
html += "</div>";
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,18 +0,0 @@
|
||||
<div id="syncActivityPage" data-role="page" class="page type-interior syncConfigurationPage syncActivityPage withTabs fullWidthContent" data-helpurl="https://web.archive.org/web/20181216120305/https://github.com/MediaBrowser/Wiki/wiki/Sync">
|
||||
|
||||
<div>
|
||||
<div class="content-primary">
|
||||
|
||||
<div style="text-align:right;">
|
||||
<button is="emby-button" type="button" class="raised btnSync subdued">
|
||||
<span>${ButtonConvertMedia}</span>
|
||||
</button>
|
||||
<progress max="100" min="0" style="width:100px;display:none;" class="syncProgress"></progress>
|
||||
</div>
|
||||
<br />
|
||||
<div class="syncActivity">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user