2016-09-15 14:28:46 -04:00
|
|
|
|
define(['jQuery', 'fnchecked'], function ($) {
|
2016-10-23 01:11:46 -04:00
|
|
|
|
'use strict';
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2015-07-23 09:23:22 -04:00
|
|
|
|
function loadPage(page, config) {
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2015-07-23 09:23:22 -04:00
|
|
|
|
$('.liveTvSettingsForm', page).show();
|
|
|
|
|
$('.noLiveTvServices', page).hide();
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2015-09-03 13:01:51 -04:00
|
|
|
|
$('#selectGuideDays', page).val(config.GuideDays || '');
|
2014-01-16 17:49:31 -05:00
|
|
|
|
|
2016-05-23 13:51:33 -04:00
|
|
|
|
$('#chkMovies', page).checked(config.EnableMovieProviders);
|
2015-08-22 15:46:55 -04:00
|
|
|
|
$('#chkOrganize', page).checked(config.EnableAutoOrganize);
|
2016-02-12 02:01:38 -05:00
|
|
|
|
$('#chkConvertRecordings', page).checked(config.EnableRecordingEncoding);
|
2016-04-27 17:26:28 -04:00
|
|
|
|
$('#chkPreserveAudio', page).checked(config.EnableOriginalAudioWithEncodedRecordings || false);
|
2014-01-16 17:49:31 -05:00
|
|
|
|
|
2015-08-23 22:08:20 -04:00
|
|
|
|
$('#txtPrePaddingMinutes', page).val(config.PrePaddingSeconds / 60);
|
|
|
|
|
$('#txtPostPaddingMinutes', page).val(config.PostPaddingSeconds / 60);
|
|
|
|
|
|
2016-05-04 16:50:47 -04:00
|
|
|
|
page.querySelector('#txtRecordingPath').value = config.RecordingPath || '';
|
|
|
|
|
page.querySelector('#txtMovieRecordingPath').value = config.MovieRecordingPath || '';
|
|
|
|
|
page.querySelector('#txtSeriesRecordingPath').value = config.SeriesRecordingPath || '';
|
2016-09-08 02:41:49 -04:00
|
|
|
|
page.querySelector('#selectConversionFormat').value = config.RecordingEncodingFormat || '';
|
2016-05-04 16:50:47 -04:00
|
|
|
|
|
|
|
|
|
page.querySelector('#chkEnableRecordingSubfolders').checked = config.EnableRecordingSubfolders || false;
|
|
|
|
|
|
2014-01-12 11:55:38 -05:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-06 22:51:04 -04:00
|
|
|
|
function onSubmit() {
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2016-02-12 13:12:59 -05:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2016-02-12 13:12:59 -05:00
|
|
|
|
var form = this;
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2016-02-12 13:12:59 -05:00
|
|
|
|
ApiClient.getNamedConfiguration("livetv").then(function (config) {
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2016-02-12 13:12:59 -05:00
|
|
|
|
config.GuideDays = $('#selectGuideDays', form).val() || null;
|
2016-05-23 13:51:33 -04:00
|
|
|
|
config.EnableMovieProviders = $('#chkMovies', form).checked();
|
2016-02-12 13:12:59 -05:00
|
|
|
|
config.EnableAutoOrganize = $('#chkOrganize', form).checked();
|
|
|
|
|
config.EnableRecordingEncoding = $('#chkConvertRecordings', form).checked();
|
2016-04-27 17:26:28 -04:00
|
|
|
|
config.EnableOriginalAudioWithEncodedRecordings = $('#chkPreserveAudio', form).checked();
|
2016-05-20 11:57:07 -04:00
|
|
|
|
|
|
|
|
|
var recordingPath = form.querySelector('#txtRecordingPath').value || null;
|
|
|
|
|
var movieRecordingPath = form.querySelector('#txtMovieRecordingPath').value || null;
|
|
|
|
|
var seriesRecordingPath = form.querySelector('#txtSeriesRecordingPath').value || null;
|
|
|
|
|
|
|
|
|
|
var recordingPathChanged = recordingPath != config.RecordingPath ||
|
|
|
|
|
movieRecordingPath != config.MovieRecordingPath ||
|
|
|
|
|
seriesRecordingPath != config.SeriesRecordingPath;
|
|
|
|
|
|
|
|
|
|
config.RecordingPath = recordingPath;
|
|
|
|
|
config.MovieRecordingPath = movieRecordingPath;
|
|
|
|
|
config.SeriesRecordingPath = seriesRecordingPath;
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2016-09-08 02:41:49 -04:00
|
|
|
|
config.RecordingEncodingFormat = form.querySelector('#selectConversionFormat').value;
|
2016-02-12 13:12:59 -05:00
|
|
|
|
config.PrePaddingSeconds = $('#txtPrePaddingMinutes', form).val() * 60;
|
|
|
|
|
config.PostPaddingSeconds = $('#txtPostPaddingMinutes', form).val() * 60;
|
2016-05-04 16:50:47 -04:00
|
|
|
|
config.EnableRecordingSubfolders = form.querySelector('#chkEnableRecordingSubfolders').checked;
|
2015-08-23 22:08:20 -04:00
|
|
|
|
|
2016-05-20 11:57:07 -04:00
|
|
|
|
ApiClient.updateNamedConfiguration("livetv", config).then(function () {
|
|
|
|
|
Dashboard.processServerConfigurationUpdateResult();
|
|
|
|
|
|
|
|
|
|
showSaveMessage(recordingPathChanged);
|
|
|
|
|
});
|
2016-02-12 13:12:59 -05:00
|
|
|
|
});
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2016-02-12 13:12:59 -05:00
|
|
|
|
// Disable default form submission
|
|
|
|
|
return false;
|
2015-06-06 22:51:04 -04:00
|
|
|
|
}
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2016-05-20 11:57:07 -04:00
|
|
|
|
function showSaveMessage(recordingPathChanged) {
|
|
|
|
|
|
|
|
|
|
var msg = '';
|
|
|
|
|
|
|
|
|
|
if (recordingPathChanged) {
|
|
|
|
|
msg += Globalize.translate('RecordingPathChangeMessage');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (msg) {
|
|
|
|
|
require(['alert'], function (alert) {
|
|
|
|
|
alert(msg);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-13 02:02:07 -04:00
|
|
|
|
function getTabs() {
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
href: 'livetvstatus.html',
|
|
|
|
|
name: Globalize.translate('TabDevices')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
href: 'livetvsettings.html',
|
|
|
|
|
name: Globalize.translate('TabSettings')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
href: 'appservices.html?context=livetv',
|
|
|
|
|
name: Globalize.translate('TabServices')
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 10:01:59 -04:00
|
|
|
|
$(document).on('pageinit', "#liveTvSettingsPage", function () {
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2015-07-23 10:58:27 -04:00
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-06-06 22:51:04 -04:00
|
|
|
|
$('.liveTvSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2015-07-23 10:58:27 -04:00
|
|
|
|
$('#btnSelectRecordingPath', page).on("click.selectDirectory", function () {
|
|
|
|
|
|
2015-10-13 15:22:45 -04:00
|
|
|
|
require(['directorybrowser'], function (directoryBrowser) {
|
2015-07-23 10:58:27 -04:00
|
|
|
|
|
2015-10-13 15:22:45 -04:00
|
|
|
|
var picker = new directoryBrowser();
|
2015-07-23 10:58:27 -04:00
|
|
|
|
|
2015-10-13 15:22:45 -04:00
|
|
|
|
picker.show({
|
2015-07-23 10:58:27 -04:00
|
|
|
|
|
2015-10-13 15:22:45 -04:00
|
|
|
|
callback: function (path) {
|
|
|
|
|
|
|
|
|
|
if (path) {
|
|
|
|
|
$('#txtRecordingPath', page).val(path);
|
|
|
|
|
}
|
|
|
|
|
picker.close();
|
2015-07-23 10:58:27 -04:00
|
|
|
|
}
|
2015-10-13 15:22:45 -04:00
|
|
|
|
});
|
2015-07-23 10:58:27 -04:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2016-05-04 16:50:47 -04:00
|
|
|
|
$('#btnSelectMovieRecordingPath', page).on("click.selectDirectory", function () {
|
|
|
|
|
|
|
|
|
|
require(['directorybrowser'], function (directoryBrowser) {
|
|
|
|
|
|
|
|
|
|
var picker = new directoryBrowser();
|
|
|
|
|
|
|
|
|
|
picker.show({
|
|
|
|
|
|
|
|
|
|
callback: function (path) {
|
|
|
|
|
|
|
|
|
|
if (path) {
|
|
|
|
|
$('#txtMovieRecordingPath', page).val(path);
|
|
|
|
|
}
|
|
|
|
|
picker.close();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#btnSelectSeriesRecordingPath', page).on("click.selectDirectory", function () {
|
|
|
|
|
|
|
|
|
|
require(['directorybrowser'], function (directoryBrowser) {
|
|
|
|
|
|
|
|
|
|
var picker = new directoryBrowser();
|
|
|
|
|
|
|
|
|
|
picker.show({
|
|
|
|
|
|
|
|
|
|
callback: function (path) {
|
|
|
|
|
|
|
|
|
|
if (path) {
|
|
|
|
|
$('#txtSeriesRecordingPath', page).val(path);
|
|
|
|
|
}
|
|
|
|
|
picker.close();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2015-09-24 13:08:10 -04:00
|
|
|
|
}).on('pageshow', "#liveTvSettingsPage", function () {
|
2014-01-16 17:49:31 -05:00
|
|
|
|
|
2016-04-13 02:02:07 -04:00
|
|
|
|
LibraryMenu.setTabs('livetvadmin', 1, getTabs);
|
2015-06-06 22:51:04 -04:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2014-01-16 17:49:31 -05:00
|
|
|
|
|
2015-06-06 22:51:04 -04:00
|
|
|
|
var page = this;
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
ApiClient.getNamedConfiguration("livetv").then(function (config) {
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2015-07-23 09:23:22 -04:00
|
|
|
|
loadPage(page, config);
|
2015-06-06 22:51:04 -04:00
|
|
|
|
});
|
|
|
|
|
|
2016-02-12 02:08:55 -05:00
|
|
|
|
if (AppInfo.enableSupporterMembership) {
|
2016-02-13 02:19:49 -05:00
|
|
|
|
page.querySelector('.btnSupporterForConverting a').href = 'https://emby.media/premiere';
|
2016-02-12 02:08:55 -05:00
|
|
|
|
} else {
|
2016-02-13 02:19:49 -05:00
|
|
|
|
page.querySelector('.btnSupporterForConverting a').href = '#';
|
2016-02-12 02:08:55 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-06 22:51:04 -04:00
|
|
|
|
});
|
2014-01-12 11:55:38 -05:00
|
|
|
|
|
2016-03-19 05:26:17 +01:00
|
|
|
|
});
|