2020-08-14 08:46:34 +02:00
|
|
|
import 'jquery';
|
|
|
|
import loading from '../components/loading/loading';
|
|
|
|
import globalize from '../scripts/globalize';
|
|
|
|
import '../elements/emby-button/emby-button';
|
2022-04-10 02:22:13 -04:00
|
|
|
import Dashboard from '../utils/dashboard';
|
2020-10-18 15:18:15 +01:00
|
|
|
import alert from '../components/alert';
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2020-07-31 23:27:51 +02:00
|
|
|
function loadPage(page, config) {
|
|
|
|
$('.liveTvSettingsForm', page).show();
|
|
|
|
$('.noLiveTvServices', page).hide();
|
|
|
|
$('#selectGuideDays', page).val(config.GuideDays || '');
|
|
|
|
$('#txtPrePaddingMinutes', page).val(config.PrePaddingSeconds / 60);
|
|
|
|
$('#txtPostPaddingMinutes', page).val(config.PostPaddingSeconds / 60);
|
|
|
|
page.querySelector('#txtRecordingPath').value = config.RecordingPath || '';
|
|
|
|
page.querySelector('#txtMovieRecordingPath').value = config.MovieRecordingPath || '';
|
|
|
|
page.querySelector('#txtSeriesRecordingPath').value = config.SeriesRecordingPath || '';
|
|
|
|
page.querySelector('#txtPostProcessor').value = config.RecordingPostProcessor || '';
|
|
|
|
page.querySelector('#txtPostProcessorArguments').value = config.RecordingPostProcessorArguments || '';
|
2022-11-19 15:23:31 -06:00
|
|
|
page.querySelector('#chkSaveRecordingNFO').checked = config.SaveRecordingNFO;
|
|
|
|
page.querySelector('#chkSaveRecordingImages').checked = config.SaveRecordingImages;
|
2020-07-31 23:27:51 +02:00
|
|
|
loading.hide();
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2020-07-31 23:27:51 +02:00
|
|
|
function onSubmit() {
|
|
|
|
loading.show();
|
|
|
|
const form = this;
|
|
|
|
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
|
|
|
config.GuideDays = $('#selectGuideDays', form).val() || null;
|
|
|
|
const recordingPath = form.querySelector('#txtRecordingPath').value || null;
|
|
|
|
const movieRecordingPath = form.querySelector('#txtMovieRecordingPath').value || null;
|
|
|
|
const seriesRecordingPath = form.querySelector('#txtSeriesRecordingPath').value || null;
|
|
|
|
const recordingPathChanged = recordingPath != config.RecordingPath || movieRecordingPath != config.MovieRecordingPath || seriesRecordingPath != config.SeriesRecordingPath;
|
|
|
|
config.RecordingPath = recordingPath;
|
|
|
|
config.MovieRecordingPath = movieRecordingPath;
|
|
|
|
config.SeriesRecordingPath = seriesRecordingPath;
|
|
|
|
config.RecordingEncodingFormat = 'mkv';
|
|
|
|
config.PrePaddingSeconds = 60 * $('#txtPrePaddingMinutes', form).val();
|
|
|
|
config.PostPaddingSeconds = 60 * $('#txtPostPaddingMinutes', form).val();
|
|
|
|
config.RecordingPostProcessor = $('#txtPostProcessor', form).val();
|
|
|
|
config.RecordingPostProcessorArguments = $('#txtPostProcessorArguments', form).val();
|
2022-11-19 15:23:31 -06:00
|
|
|
config.SaveRecordingNFO = form.querySelector('#chkSaveRecordingNFO').checked;
|
|
|
|
config.SaveRecordingImages = form.querySelector('#chkSaveRecordingImages').checked;
|
2020-07-31 23:27:51 +02:00
|
|
|
ApiClient.updateNamedConfiguration('livetv', config).then(function () {
|
|
|
|
Dashboard.processServerConfigurationUpdateResult();
|
|
|
|
showSaveMessage(recordingPathChanged);
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
2020-07-31 23:27:51 +02:00
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2020-07-31 23:27:51 +02:00
|
|
|
function showSaveMessage(recordingPathChanged) {
|
|
|
|
let msg = '';
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-07-31 23:27:51 +02:00
|
|
|
if (recordingPathChanged) {
|
2020-08-02 16:57:13 +09:00
|
|
|
msg += globalize.translate('MessageChangeRecordingPath');
|
2020-07-31 23:27:51 +02:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-07-31 23:27:51 +02:00
|
|
|
if (msg) {
|
2020-10-18 15:18:15 +01:00
|
|
|
alert(msg);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2020-07-31 23:27:51 +02:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-12-10 11:27:51 +03:00
|
|
|
$(document).on('pageinit', '#liveTvSettingsPage', function () {
|
|
|
|
const page = this;
|
|
|
|
$('.liveTvSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
|
|
|
|
$('#btnSelectRecordingPath', page).on('click.selectDirectory', function () {
|
2023-03-29 00:38:22 -04:00
|
|
|
import('../components/directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
|
2021-09-08 02:46:43 +03:00
|
|
|
const picker = new DirectoryBrowser();
|
2020-12-10 11:27:51 +03:00
|
|
|
picker.show({
|
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
|
|
|
$('#txtRecordingPath', page).val(path);
|
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-12-10 11:27:51 +03:00
|
|
|
picker.close();
|
|
|
|
},
|
|
|
|
validateWriteable: true
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
|
|
|
});
|
2020-12-10 11:27:51 +03:00
|
|
|
});
|
|
|
|
$('#btnSelectMovieRecordingPath', page).on('click.selectDirectory', function () {
|
2023-03-29 00:38:22 -04:00
|
|
|
import('../components/directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
|
2021-09-08 02:46:43 +03:00
|
|
|
const picker = new DirectoryBrowser();
|
2020-12-10 11:27:51 +03:00
|
|
|
picker.show({
|
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
|
|
|
$('#txtMovieRecordingPath', page).val(path);
|
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-12-10 11:27:51 +03:00
|
|
|
picker.close();
|
|
|
|
},
|
|
|
|
validateWriteable: true
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
|
|
|
});
|
2020-12-10 11:27:51 +03:00
|
|
|
});
|
|
|
|
$('#btnSelectSeriesRecordingPath', page).on('click.selectDirectory', function () {
|
2023-03-29 00:38:22 -04:00
|
|
|
import('../components/directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
|
2021-09-08 02:46:43 +03:00
|
|
|
const picker = new DirectoryBrowser();
|
2020-12-10 11:27:51 +03:00
|
|
|
picker.show({
|
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
|
|
|
$('#txtSeriesRecordingPath', page).val(path);
|
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
|
2020-12-10 11:27:51 +03:00
|
|
|
picker.close();
|
|
|
|
},
|
|
|
|
validateWriteable: true
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
|
|
|
});
|
2020-12-10 11:27:51 +03:00
|
|
|
});
|
|
|
|
$('#btnSelectPostProcessorPath', page).on('click.selectDirectory', function () {
|
2023-03-29 00:38:22 -04:00
|
|
|
import('../components/directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
|
2021-09-08 02:46:43 +03:00
|
|
|
const picker = new DirectoryBrowser();
|
2020-12-10 11:27:51 +03:00
|
|
|
picker.show({
|
|
|
|
includeFiles: true,
|
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
|
|
|
$('#txtPostProcessor', page).val(path);
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2020-12-10 11:27:51 +03:00
|
|
|
|
|
|
|
picker.close();
|
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-12-10 11:27:51 +03:00
|
|
|
}).on('pageshow', '#liveTvSettingsPage', function () {
|
|
|
|
loading.show();
|
|
|
|
const page = this;
|
|
|
|
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
|
|
|
loadPage(page, config);
|
|
|
|
});
|
|
|
|
});
|