2019-01-23 11:33:34 +00:00
|
|
|
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) {
|
2019-01-10 15:39:37 +03:00
|
|
|
'use strict';
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function syncNow() {
|
2019-01-10 15:39:37 +03:00
|
|
|
require(['localsync'], function (localSync) {
|
|
|
|
localSync.sync();
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderJob(context, job, dialogOptions) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
require(['syncDialog'], function (syncDialog) {
|
2018-10-23 01:05:09 +03:00
|
|
|
syncDialog.renderForm({
|
2019-01-10 15:39:37 +03:00
|
|
|
elem: context.querySelector('.syncJobFormContent'),
|
2018-10-23 01:05:09 +03:00
|
|
|
dialogOptions: dialogOptions,
|
|
|
|
dialogOptionsFn: getTargetDialogOptionsFn(dialogOptions),
|
2019-01-10 15:39:37 +03:00
|
|
|
readOnlySyncTarget: true
|
|
|
|
}).then(function () {
|
|
|
|
fillJobValues(context, job, dialogOptions);
|
|
|
|
});
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getTargetDialogOptionsFn(dialogOptions) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
return function (targetId) {
|
|
|
|
|
|
|
|
return Promise.resolve(dialogOptions);
|
|
|
|
};
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getJobItemHtml(jobItem, apiClient, index) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
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 + '">';
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var imgUrl;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
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;">';
|
2019-01-10 15:41:25 +03:00
|
|
|
html += '<div style="background:#e0e0e0;height:2px;"><div style="background:#00a4dc;width:' + (jobItem.Progress || 0) + '%;height:100%;"></div></div>';
|
2019-01-10 15:39:37 +03:00
|
|
|
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;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function renderJobItems(context, items, apiClient) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
html += '<h1>' + globalize.translate('sharedcomponents#Items') + '</h1>';
|
|
|
|
|
|
|
|
html += '<div class="paperList">';
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var index = 0;
|
2019-01-10 15:39:37 +03:00
|
|
|
html += items.map(function (i) {
|
|
|
|
|
|
|
|
return getJobItemHtml(i, apiClient, index++);
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
var elem = context.querySelector('.jobItems');
|
|
|
|
elem.innerHTML = html;
|
|
|
|
imageLoader.lazyChildren(elem);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function parentWithClass(elem, className) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
while (!elem.classList || !elem.classList.contains(className)) {
|
|
|
|
elem = elem.parentNode;
|
|
|
|
|
|
|
|
if (!elem) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return elem;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function showJobItemMenu(elem, jobId, apiClient) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function cancelJobItem(context, jobId, jobItemId, apiClient) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
showRemoveConfirm(function () {
|
|
|
|
loading.show();
|
|
|
|
|
|
|
|
apiClient.ajax({
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
type: "DELETE",
|
2019-01-10 15:39:37 +03:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function retryJobItem(context, jobId, jobItemId, apiClient) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
showRetryConfirm(function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
apiClient.ajax({
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
type: "POST",
|
2019-01-10 15:39:37 +03:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function showRetryConfirm(callback) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
// TODO Implement this as a retry dialog
|
|
|
|
require(['confirm'], function (confirm) {
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
confirm({
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
text: globalize.translate('sharedcomponents#ConfirmRemoveDownload'),
|
|
|
|
confirmText: globalize.translate('sharedcomponents#RemoveDownload'),
|
|
|
|
cancelText: globalize.translate('sharedcomponents#KeepDownload'),
|
|
|
|
primary: 'cancel'
|
|
|
|
|
|
|
|
}).then(callback);
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function showRemoveConfirm(callback) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
require(['confirm'], function (confirm) {
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
confirm({
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function fillJobValues(context, job, editOptions) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
2019-01-10 15:39:37 +03:00
|
|
|
var _jobOptions;
|
2018-10-23 01:05:09 +03:00
|
|
|
function loadJob(context, id, apiClient) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
loading.show();
|
|
|
|
|
|
|
|
apiClient.getJSON(apiClient.getUrl('Sync/Jobs/' + id)).then(function (job) {
|
|
|
|
|
|
|
|
apiClient.getJSON(apiClient.getUrl('Sync/Options', {
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
UserId: job.UserId,
|
2019-01-10 15:39:37 +03:00
|
|
|
ItemIds: (job.RequestedItemIds && job.RequestedItemIds.length ? job.RequestedItemIds.join('') : null),
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
ParentId: job.ParentId,
|
|
|
|
Category: job.Category,
|
|
|
|
TargetId: job.TargetId
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
})).then(function (options) {
|
|
|
|
|
|
|
|
_jobOptions = options;
|
|
|
|
renderJob(context, job, options);
|
|
|
|
loading.hide();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
apiClient.getJSON(apiClient.getUrl('Sync/JobItems', {
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
JobId: id,
|
2019-01-10 15:39:37 +03:00
|
|
|
AddMetadata: true
|
|
|
|
|
|
|
|
})).then(function (result) {
|
|
|
|
|
|
|
|
renderJobItems(context, result.Items, apiClient);
|
|
|
|
loading.hide();
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadJobInfo(context, job, jobItems, apiClient) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
//renderJob(page, job, _jobOptions);
|
|
|
|
renderJobItems(context, jobItems, apiClient);
|
|
|
|
loading.hide();
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function saveJob(context, id, apiClient) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
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',
|
2018-10-23 01:05:09 +03:00
|
|
|
data: JSON.stringify(job),
|
|
|
|
contentType: "application/json"
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
}).then(function () {
|
|
|
|
|
|
|
|
// TODO this should check editor options.mode === 'download'
|
|
|
|
if (appHost.supports('sync')) {
|
|
|
|
syncNow();
|
|
|
|
}
|
|
|
|
|
|
|
|
loading.hide();
|
|
|
|
dialogHelper.close(context);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function startListening(apiClient, jobId) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var startParams = "0,1500";
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
startParams += "," + jobId;
|
|
|
|
|
|
|
|
apiClient.sendMessage("SyncJobStart", startParams);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function stopListening(apiClient) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
apiClient.sendMessage("SyncJobStop", "");
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function bindEvents(context, jobId, apiClient) {
|
2019-01-10 15:39:37 +03:00
|
|
|
context.querySelector('.jobItems').addEventListener('click', function (e) {
|
|
|
|
var btnJobItemMenu = dom.parentWithClass(e.target, 'btnJobItemMenu');
|
|
|
|
if (btnJobItemMenu) {
|
|
|
|
showJobItemMenu(btnJobItemMenu, jobId, apiClient);
|
|
|
|
}
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function showEditor(options) {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
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';
|
|
|
|
}
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var dlg = dialogHelper.createDialog(dlgElementOptions);
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var promise = dialogHelper.open(dlg);
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
return {
|
|
|
|
show: showEditor
|
2019-01-10 15:39:37 +03:00
|
|
|
};
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
});
|