2020-07-31 23:27:51 +02:00
|
|
|
import $ from 'jQuery';
|
|
|
|
import loading from 'loading';
|
|
|
|
import globalize from 'globalize';
|
|
|
|
import 'emby-button';
|
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 || '';
|
|
|
|
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();
|
|
|
|
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-07-31 23:31:32 +02:00
|
|
|
import('alert').then(({default: alert}) => {
|
|
|
|
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-07-31 23:27:51 +02:00
|
|
|
export default function () {
|
2020-05-04 12:44:12 +02:00
|
|
|
$(document).on('pageinit', '#liveTvSettingsPage', function () {
|
2020-07-31 23:27:51 +02:00
|
|
|
const page = this;
|
2020-05-04 12:44:12 +02:00
|
|
|
$('.liveTvSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
|
|
|
|
$('#btnSelectRecordingPath', page).on('click.selectDirectory', function () {
|
2020-07-31 23:27:51 +02:00
|
|
|
import('directorybrowser').then(({default: directoryBrowser}) => {
|
|
|
|
const picker = new directoryBrowser();
|
2018-10-23 01:05:09 +03:00
|
|
|
picker.show({
|
2019-11-06 13:43:39 +03:00
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#txtRecordingPath', page).val(path);
|
2019-11-06 13:43:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
picker.close();
|
2018-10-23 01:05:09 +03:00
|
|
|
},
|
2019-11-06 13:43:39 +03:00
|
|
|
validateWriteable: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#btnSelectMovieRecordingPath', page).on('click.selectDirectory', function () {
|
2020-07-31 23:27:51 +02:00
|
|
|
import('directorybrowser').then(({default: directoryBrowser}) => {
|
|
|
|
const picker = new directoryBrowser();
|
2018-10-23 01:05:09 +03:00
|
|
|
picker.show({
|
2019-11-06 13:43:39 +03:00
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#txtMovieRecordingPath', page).val(path);
|
2019-11-06 13:43:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
picker.close();
|
2018-10-23 01:05:09 +03:00
|
|
|
},
|
2019-11-06 13:43:39 +03:00
|
|
|
validateWriteable: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#btnSelectSeriesRecordingPath', page).on('click.selectDirectory', function () {
|
2020-07-31 23:27:51 +02:00
|
|
|
import('directorybrowser').then(({default: directoryBrowser}) => {
|
|
|
|
const picker = new directoryBrowser();
|
2018-10-23 01:05:09 +03:00
|
|
|
picker.show({
|
2019-11-06 13:43:39 +03:00
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#txtSeriesRecordingPath', page).val(path);
|
2019-11-06 13:43:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
picker.close();
|
2018-10-23 01:05:09 +03:00
|
|
|
},
|
2019-11-06 13:43:39 +03:00
|
|
|
validateWriteable: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#btnSelectPostProcessorPath', page).on('click.selectDirectory', function () {
|
2020-07-31 23:27:51 +02:00
|
|
|
import('directorybrowser').then(({default: directoryBrowser}) => {
|
|
|
|
const picker = new directoryBrowser();
|
2018-10-23 01:05:09 +03:00
|
|
|
picker.show({
|
2019-11-06 13:43:39 +03:00
|
|
|
includeFiles: true,
|
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#txtPostProcessor', page).val(path);
|
2019-11-06 13:43:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
picker.close();
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-11-06 13:43:39 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2020-05-04 12:44:12 +02:00
|
|
|
}).on('pageshow', '#liveTvSettingsPage', function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
loading.show();
|
2020-07-31 23:27:51 +02:00
|
|
|
const page = this;
|
2020-05-04 12:44:12 +02:00
|
|
|
ApiClient.getNamedConfiguration('livetv').then(function (config) {
|
2019-11-06 13:43:39 +03:00
|
|
|
loadPage(page, config);
|
|
|
|
});
|
|
|
|
});
|
2020-07-31 23:27:51 +02:00
|
|
|
}
|