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

93 lines
2.2 KiB
JavaScript
Raw Normal View History

define(['jQuery'], function ($) {
2016-10-22 22:11:46 -07:00
'use strict';
2015-08-20 13:54:00 -07:00
function save(page) {
Dashboard.showLoadingMsg();
var apiClient = ApiClient;
// After saving chapter task, now save server config
2015-12-14 08:43:03 -07:00
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
2015-08-20 13:54:00 -07:00
config.LiveTvTunerType = $('#selectTunerType', page).val();
config.LiveTvTunerPath = $('.txtDevicePath', page).val();
apiClient.ajax({
type: 'POST',
data: config,
url: apiClient.getUrl('Startup/Configuration')
2015-12-14 08:43:03 -07:00
}).then(function () {
2015-08-20 13:54:00 -07:00
Dashboard.hideLoadingMsg();
2015-08-21 19:59:10 -07:00
navigateToNextPage(config);
2015-08-22 11:15:35 -07:00
2015-12-14 08:43:03 -07:00
}, function () {
2015-08-22 11:15:35 -07:00
Dashboard.hideLoadingMsg();
Dashboard.alert({
message: Globalize.translate('ErrorSavingTvProvider')
});
2015-08-20 13:54:00 -07:00
});
});
}
function reload(page) {
Dashboard.showLoadingMsg();
var apiClient = ApiClient;
2015-12-14 08:43:03 -07:00
apiClient.getJSON(apiClient.getUrl('Startup/Configuration')).then(function (config) {
2015-08-20 13:54:00 -07:00
2015-09-03 10:01:51 -07:00
$('#selectTunerType', page).val(config.LiveTvTunerType || 'hdhomerun');
2015-08-20 13:54:00 -07:00
page.querySelector('.txtDevicePath').value = config.LiveTvTunerPath || '';
Dashboard.hideLoadingMsg();
});
}
2015-08-21 19:59:10 -07:00
function navigateToNextPage(config) {
if (config.LiveTvTunerPath && config.LiveTvTunerType) {
Dashboard.navigate('wizardlivetvguide.html');
} else {
skip();
}
2015-08-20 13:54:00 -07:00
}
function skip() {
2016-06-23 10:04:18 -07:00
require(['scripts/wizardcontroller'], function (wizardcontroller) {
wizardcontroller.navigateToComponents();
2015-08-20 13:54:00 -07:00
});
}
function onSubmit() {
var form = this;
save(form);
return false;
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#wizardTunerPage", function () {
2015-08-20 13:54:00 -07:00
var page = this;
$('form', page).off('submit', onSubmit).on('submit', onSubmit);
$('.btnSkip', page).on('click', skip);
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#wizardTunerPage", function () {
2015-08-20 13:54:00 -07:00
var page = this;
reload(page);
});
});