jellyfin-web/dashboard-ui/scripts/syncactivity.js

85 lines
2.6 KiB
JavaScript
Raw Normal View History

2016-08-17 13:32:39 -07:00
define(['loading', 'apphost', 'globalize', 'syncJobList', 'events', 'scripts/taskbutton', 'localsync', 'emby-button', 'paper-icon-button-light'], function (loading, appHost, globalize, syncJobList, events, taskButton) {
2016-10-22 22:11:46 -07:00
'use strict';
2015-02-04 12:13:00 -07:00
2016-04-12 23:02:07 -07:00
function getTabs() {
return [
{
href: 'syncactivity.html',
name: Globalize.translate('TabSyncJobs')
},
{
href: 'devicesupload.html',
name: Globalize.translate('TabCameraUpload')
},
2016-07-04 15:53:40 -07:00
{
href: 'appservices.html?context=sync',
name: Globalize.translate('TabServices')
},
2016-04-12 23:02:07 -07:00
{
href: 'syncsettings.html',
name: Globalize.translate('TabSettings')
}];
}
2016-08-16 22:46:15 -07:00
function initSupporterInfo(view, params) {
2015-10-02 11:30:27 -07:00
2016-08-16 22:46:15 -07:00
view.querySelector('.supporterPromotion .mainText').innerHTML = globalize.translate('HeaderSyncRequiresSupporterMembership');
2015-10-02 11:30:27 -07:00
2016-08-16 22:46:15 -07:00
var apiClient = ApiClient;
apiClient.getPluginSecurityInfo().then(function (regInfo) {
2015-10-02 11:30:27 -07:00
2016-08-16 22:46:15 -07:00
if (regInfo.IsMBSupporter) {
view.querySelector('.supporterPromotionContainer').classList.add('hide');
} else {
view.querySelector('.supporterPromotionContainer').classList.remove('hide');
}
2015-10-02 11:30:27 -07:00
2016-08-16 22:46:15 -07:00
}, function () {
2014-12-10 23:20:28 -07:00
2016-08-16 22:46:15 -07:00
view.querySelector('.supporterPromotionContainer').classList.remove('hide');
});
}
2014-12-10 23:20:28 -07:00
2016-08-16 22:46:15 -07:00
return function (view, params) {
2015-01-24 15:33:26 -07:00
2016-08-16 22:46:15 -07:00
initSupporterInfo(view, params);
var mySyncJobList = new syncJobList({
isLocalSync: params.mode === 'offline',
serverId: ApiClient.serverId(),
userId: params.mode === 'offline' ? null : ApiClient.getCurrentUserId(),
element: view.querySelector('.syncActivity')
2015-01-24 15:33:26 -07:00
});
2016-08-16 22:46:15 -07:00
events.on(mySyncJobList, 'jobedit', function (e, jobId, serverId) {
2014-07-26 10:30:15 -07:00
2016-08-16 22:46:15 -07:00
Dashboard.navigate('syncjob.html?id=' + jobId);
2015-01-20 13:19:54 -07:00
});
2016-08-16 22:46:15 -07:00
view.addEventListener('viewshow', function () {
2015-01-20 13:19:54 -07:00
2016-08-16 22:46:15 -07:00
LibraryMenu.setTabs('syncadmin', 0, getTabs);
2016-08-17 13:32:39 -07:00
taskButton({
mode: 'on',
progressElem: view.querySelector('.syncProgress'),
taskKey: 'SyncPrepare',
button: view.querySelector('.btnSync')
});
});
view.addEventListener('viewbeforehide', function () {
taskButton({
mode: 'off',
taskKey: 'SyncPrepare',
button: view.querySelector('.btnSync')
});
2016-08-16 22:46:15 -07:00
});
2015-01-20 13:19:54 -07:00
2016-08-16 22:46:15 -07:00
view.addEventListener('viewdestroy', function () {
2015-01-20 13:19:54 -07:00
2016-08-16 22:46:15 -07:00
mySyncJobList.destroy();
2015-01-20 13:19:54 -07:00
});
2016-08-16 22:46:15 -07:00
};
2014-07-26 10:30:15 -07:00
});