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

fix bdinfo path

This commit is contained in:
Luke Pulverenti 2016-12-24 02:41:25 -05:00
parent 47c6980d11
commit 7f30965695
3 changed files with 79 additions and 74 deletions

View file

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

View file

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

View file

@ -1,4 +1,4 @@
define(['datetime', 'dom', 'imageLoader', 'listViewStyle', 'paper-icon-button-light', 'emby-button'], function (datetime, dom, imageLoader) { 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) {
'use strict'; 'use strict';
function renderJob(page, job, dialogOptions) { function renderJob(page, job, dialogOptions) {
@ -6,14 +6,14 @@
var html = ''; var html = '';
html += '<div>'; html += '<div>';
html += Globalize.translate('ValueDateCreated', datetime.parseISO8601Date(job.DateCreated, true).toLocaleString()); html += globalize.translate('ValueDateCreated', datetime.parseISO8601Date(job.DateCreated, true).toLocaleString());
html += '</div>'; html += '</div>';
html += '<br/>'; html += '<br/>';
html += '<div class="formFields"></div>'; html += '<div class="formFields"></div>';
html += '<br/>'; html += '<br/>';
html += '<br/>'; html += '<br/>';
html += '<button is="emby-button" type="submit" class="raised button-submit block"><span>' + Globalize.translate('ButtonSave') + '</span></button>'; html += '<button is="emby-button" type="submit" class="raised button-submit block"><span>' + globalize.translate('ButtonSave') + '</span></button>';
page.querySelector('.syncJobForm').innerHTML = html; page.querySelector('.syncJobForm').innerHTML = html;
@ -38,7 +38,7 @@
}; };
} }
function getJobItemHtml(jobItem, index) { function getJobItemHtml(jobItem, apiClient, index) {
var html = ''; var html = '';
@ -50,7 +50,7 @@
if (jobItem.PrimaryImageItemId) { if (jobItem.PrimaryImageItemId) {
imgUrl = ApiClient.getImageUrl(jobItem.PrimaryImageItemId, { imgUrl = apiClient.getImageUrl(jobItem.PrimaryImageItemId, {
type: "Primary", type: "Primary",
width: 80, width: 80,
tag: jobItem.PrimaryImageTag, tag: jobItem.PrimaryImageTag,
@ -76,10 +76,10 @@
} else { } else {
html += '<div class="secondary">'; html += '<div class="secondary">';
} }
html += Globalize.translate('SyncJobItemStatus' + jobItem.Status); html += globalize.translate('SyncJobItemStatus' + jobItem.Status);
if (jobItem.Status == 'Synced' && jobItem.IsMarkedForRemoval) { if (jobItem.Status == 'Synced' && jobItem.IsMarkedForRemoval) {
html += '<br/>'; html += '<br/>';
html += Globalize.translate('SyncJobItemStatusSyncedMarkForRemoval'); html += globalize.translate('SyncJobItemStatusSyncedMarkForRemoval');
} }
html += '</div>'; html += '</div>';
@ -89,29 +89,31 @@
html += '</div>'; html += '</div>';
var moreIcon = appHost.moreIcon === 'dots-horiz' ? '&#xE5D3;' : '&#xE5D4;';
if (hasActions) { if (hasActions) {
html += '<button type="button" is="paper-icon-button-light" class="btnJobItemMenu autoSize"><i class="md-icon">' + AppInfo.moreIcon.replace('-', '_') + '</i></button>'; html += '<button type="button" is="paper-icon-button-light" class="btnJobItemMenu autoSize"><i class="md-icon">' + moreIcon + '</i></button>';
} else { } else {
html += '<button type="button" is="paper-icon-button-light" class="btnJobItemMenu autoSize" disabled><i class="md-icon">' + AppInfo.moreIcon.replace('-', '_') + '</i></button>'; html += '<button type="button" is="paper-icon-button-light" class="btnJobItemMenu autoSize" disabled><i class="md-icon">' + moreIcon + '</i></button>';
} }
html += '</div>'; html += '</div>';
return html; return html;
} }
function renderJobItems(page, items) { function renderJobItems(page, items, apiClient) {
var html = ''; var html = '';
html += '<h1>' + Globalize.translate('HeaderItems') + '</h1>'; html += '<h1>' + globalize.translate('HeaderItems') + '</h1>';
html += '<div class="paperList">'; html += '<div class="paperList">';
var index = 0; var index = 0;
html += items.map(function (i) { html += items.map(function (i) {
return getJobItemHtml(i, index++); return getJobItemHtml(i, apiClient, index++);
}).join(''); }).join('');
@ -135,7 +137,7 @@
return elem; return elem;
} }
function showJobItemMenu(elem) { function showJobItemMenu(elem, jobId, apiClient) {
var page = parentWithClass(elem, 'page'); var page = parentWithClass(elem, 'page');
var listItem = parentWithClass(elem, 'listItem'); var listItem = parentWithClass(elem, 'listItem');
@ -147,31 +149,31 @@
if (status == 'Failed') { if (status == 'Failed') {
menuItems.push({ menuItems.push({
name: Globalize.translate('ButtonQueueForRetry'), name: globalize.translate('ButtonQueueForRetry'),
id: 'retry' id: 'retry'
}); });
} }
else if (status == 'Cancelled') { else if (status == 'Cancelled') {
menuItems.push({ menuItems.push({
name: Globalize.translate('ButtonReenable'), name: globalize.translate('ButtonReenable'),
id: 'retry' id: 'retry'
}); });
} }
else if (status == 'Queued' || status == 'Transferring' || status == 'Converting' || status == 'ReadyToTransfer') { else if (status == 'Queued' || status == 'Transferring' || status == 'Converting' || status == 'ReadyToTransfer') {
menuItems.push({ menuItems.push({
name: Globalize.translate('ButtonCancelItem'), name: globalize.translate('ButtonCancelItem'),
id: 'cancel' id: 'cancel'
}); });
} }
else if (status == 'Synced' && remove) { else if (status == 'Synced' && remove) {
menuItems.push({ menuItems.push({
name: Globalize.translate('ButtonUnmarkForRemoval'), name: globalize.translate('ButtonUnmarkForRemoval'),
id: 'unmarkforremoval' id: 'unmarkforremoval'
}); });
} }
else if (status == 'Synced') { else if (status == 'Synced') {
menuItems.push({ menuItems.push({
name: Globalize.translate('ButtonMarkForRemoval'), name: globalize.translate('ButtonMarkForRemoval'),
id: 'markforremoval' id: 'markforremoval'
}); });
} }
@ -186,16 +188,16 @@
switch (id) { switch (id) {
case 'cancel': case 'cancel':
cancelJobItem(page, jobItemId); cancelJobItem(page, jobId, jobItemId, apiClient);
break; break;
case 'retry': case 'retry':
retryJobItem(page, jobItemId); retryJobItem(page, jobId, jobItemId, apiClient);
break; break;
case 'markforremoval': case 'markforremoval':
markForRemoval(page, jobItemId); markForRemoval(page, jobId, jobItemId, apiClient);
break; break;
case 'unmarkforremoval': case 'unmarkforremoval':
unMarkForRemoval(page, jobItemId); unMarkForRemoval(page, jobId, jobItemId, apiClient);
break; break;
default: default:
break; break;
@ -206,60 +208,60 @@
}); });
} }
function cancelJobItem(page, jobItemId) { function cancelJobItem(page, jobId, jobItemId, apiClient) {
// Need a timeout because jquery mobile will not show a popup while another is in the act of closing // Need a timeout because jquery mobile will not show a popup while another is in the act of closing
Dashboard.showLoadingMsg(); loading.show();
ApiClient.ajax({ apiClient.ajax({
type: "DELETE", type: "DELETE",
url: ApiClient.getUrl('Sync/JobItems/' + jobItemId) url: apiClient.getUrl('Sync/JobItems/' + jobItemId)
}).then(function () { }).then(function () {
loadJob(page); loadJob(page, jobId, apiClient);
}); });
} }
function markForRemoval(page, jobItemId) { function markForRemoval(page, jobId, jobItemId, apiClient) {
ApiClient.ajax({ apiClient.ajax({
type: "POST", type: "POST",
url: ApiClient.getUrl('Sync/JobItems/' + jobItemId + '/MarkForRemoval') url: apiClient.getUrl('Sync/JobItems/' + jobItemId + '/MarkForRemoval')
}).then(function () { }).then(function () {
loadJob(page); loadJob(page, jobId, apiClient);
}); });
} }
function unMarkForRemoval(page, jobItemId) { function unMarkForRemoval(page, jobId, jobItemId, apiClient) {
ApiClient.ajax({ apiClient.ajax({
type: "POST", type: "POST",
url: ApiClient.getUrl('Sync/JobItems/' + jobItemId + '/UnmarkForRemoval') url: apiClient.getUrl('Sync/JobItems/' + jobItemId + '/UnmarkForRemoval')
}).then(function () { }).then(function () {
loadJob(page); loadJob(page, jobId, apiClient);
}); });
} }
function retryJobItem(page, jobItemId) { function retryJobItem(page, jobId, jobItemId, apiClient) {
ApiClient.ajax({ apiClient.ajax({
type: "POST", type: "POST",
url: ApiClient.getUrl('Sync/JobItems/' + jobItemId + '/Enable') url: apiClient.getUrl('Sync/JobItems/' + jobItemId + '/Enable')
}).then(function () { }).then(function () {
loadJob(page); loadJob(page, jobId, apiClient);
}); });
} }
@ -314,14 +316,13 @@
} }
var _jobOptions; var _jobOptions;
function loadJob(page) { function loadJob(page, id, apiClient) {
Dashboard.showLoadingMsg(); loading.show();
var id = getParameterByName('id');
ApiClient.getJSON(ApiClient.getUrl('Sync/Jobs/' + id)).then(function (job) { apiClient.getJSON(apiClient.getUrl('Sync/Jobs/' + id)).then(function (job) {
ApiClient.getJSON(ApiClient.getUrl('Sync/Options', { apiClient.getJSON(apiClient.getUrl('Sync/Options', {
UserId: job.UserId, UserId: job.UserId,
ItemIds: (job.RequestedItemIds && job.RequestedItemIds.length ? job.RequestedItemIds.join('') : null), ItemIds: (job.RequestedItemIds && job.RequestedItemIds.length ? job.RequestedItemIds.join('') : null),
@ -334,19 +335,19 @@
_jobOptions = options; _jobOptions = options;
renderJob(page, job, options); renderJob(page, job, options);
Dashboard.hideLoadingMsg(); loading.hide();
}); });
}); });
ApiClient.getJSON(ApiClient.getUrl('Sync/JobItems', { apiClient.getJSON(apiClient.getUrl('Sync/JobItems', {
JobId: id, JobId: id,
AddMetadata: true AddMetadata: true
})).then(function (result) { })).then(function (result) {
renderJobItems(page, result.Items); renderJobItems(page, result.Items, apiClient);
Dashboard.hideLoadingMsg(); loading.hide();
}); });
} }
@ -354,31 +355,30 @@
//renderJob(page, job, _jobOptions); //renderJob(page, job, _jobOptions);
renderJobItems(page, jobItems); renderJobItems(page, jobItems);
Dashboard.hideLoadingMsg(); loading.hide();
} }
function saveJob(page) { function saveJob(page, id, apiClient) {
Dashboard.showLoadingMsg(); loading.show();
var id = getParameterByName('id');
ApiClient.getJSON(ApiClient.getUrl('Sync/Jobs/' + id)).then(function (job) { apiClient.getJSON(apiClient.getUrl('Sync/Jobs/' + id)).then(function (job) {
require(['syncDialog'], function (syncDialog) { require(['syncDialog'], function (syncDialog) {
syncDialog.setJobValues(job, page); syncDialog.setJobValues(job, page);
ApiClient.ajax({ apiClient.ajax({
url: ApiClient.getUrl('Sync/Jobs/' + id), url: apiClient.getUrl('Sync/Jobs/' + id),
type: 'POST', type: 'POST',
data: JSON.stringify(job), data: JSON.stringify(job),
contentType: "application/json" contentType: "application/json"
}).then(function () { }).then(function () {
Dashboard.hideLoadingMsg(); loading.hide();
require(['toast'], function (toast) { require(['toast'], function (toast) {
toast(Globalize.translate('SettingsSaved')); toast(globalize.translate('SettingsSaved'));
}); });
}); });
}); });
@ -388,35 +388,40 @@
return function (view, params) { return function (view, params) {
function getApiClient() {
return connectionManager.getApiClient(params.serverId);
}
view.querySelector('.syncJobForm').addEventListener('submit', function (e) { view.querySelector('.syncJobForm').addEventListener('submit', function (e) {
saveJob(view); saveJob(view, params.id, getApiClient());
e.preventDefault(); e.preventDefault();
return false; return false;
}); });
function onWebSocketMessage(e, msg) { function onSyncJobMessage(e, msg) {
loadJobInfo(view, msg.Data.Job, msg.Data.JobItems);
if (msg.MessageType == "SyncJob") {
loadJobInfo(view, msg.Data.Job, msg.Data.JobItems);
}
} }
function startListening(page) { function startListening(page) {
var startParams = "0,1500"; var startParams = "0,1500";
startParams += "," + getParameterByName('id'); startParams += "," + params.id;
if (ApiClient.isWebSocketOpen()) { var apiClient = getApiClient();
ApiClient.sendWebSocketMessage("SyncJobStart", startParams);
if (apiClient.isWebSocketOpen()) {
apiClient.sendWebSocketMessage("SyncJobStart", startParams);
} }
} }
function stopListening() { function stopListening() {
if (ApiClient.isWebSocketOpen()) { var apiClient = getApiClient();
ApiClient.sendWebSocketMessage("SyncJobStop", "");
if (apiClient.isWebSocketOpen()) {
apiClient.sendWebSocketMessage("SyncJobStop", "");
} }
} }
@ -424,22 +429,22 @@
view.querySelector('.jobItems').addEventListener('click', function (e) { view.querySelector('.jobItems').addEventListener('click', function (e) {
var btnJobItemMenu = dom.parentWithClass(e.target, 'btnJobItemMenu'); var btnJobItemMenu = dom.parentWithClass(e.target, 'btnJobItemMenu');
if (btnJobItemMenu) { if (btnJobItemMenu) {
showJobItemMenu(btnJobItemMenu); showJobItemMenu(btnJobItemMenu, params.id);
} }
}); });
view.addEventListener('viewshow', function () { view.addEventListener('viewshow', function () {
var page = this; var page = this;
loadJob(page); loadJob(page, params.id, getApiClient());
startListening(page); startListening(page);
Events.on(ApiClient, "websocketmessage", onWebSocketMessage); events.on(serverNotifications, "SyncJob", onSyncJobMessage);
}); });
view.addEventListener('viewbeforehide', function () { view.addEventListener('viewbeforehide', function () {
stopListening(); stopListening();
Events.off(ApiClient, "websocketmessage", onWebSocketMessage); events.off(serverNotifications, "SyncJob", onSyncJobMessage);
}); });
}; };