jellyfin-web/dashboard-ui/scripts/livetvtunerprovider-hdhomerun.js

80 lines
2.3 KiB
JavaScript
Raw Normal View History

2016-03-16 14:30:49 -07:00
define(['jQuery'], function ($) {
2015-07-25 11:11:46 -07:00
function reload(page, providerId) {
2015-07-25 13:41:29 -07:00
page.querySelector('.txtDevicePath').value = '';
page.querySelector('.chkFavorite').checked = false;
2015-07-25 11:11:46 -07:00
if (providerId) {
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration("livetv").then(function (config) {
2015-07-25 11:11:46 -07:00
var info = config.TunerHosts.filter(function (i) {
return i.Id == providerId;
})[0];
2015-07-25 13:41:29 -07:00
page.querySelector('.txtDevicePath').value = info.Url || '';
page.querySelector('.chkFavorite').checked = info.ImportFavoritesOnly;
page.querySelector('.chkTranscode').checked = info.AllowHWTranscoding;
2015-07-27 09:25:45 -07:00
page.querySelector('.chkEnabled').checked = info.IsEnabled;
2015-07-25 11:11:46 -07:00
});
2015-08-20 10:40:11 -07:00
} else {
page.querySelector('.chkEnabled').checked = true;
2015-07-25 11:11:46 -07:00
}
}
function submitForm(page) {
Dashboard.showLoadingMsg();
var info = {
Type: 'hdhomerun',
2015-07-25 13:41:29 -07:00
Url: page.querySelector('.txtDevicePath').value,
2015-07-27 09:25:45 -07:00
ImportFavoritesOnly: page.querySelector('.chkFavorite').checked,
AllowHWTranscoding: page.querySelector('.chkTranscode').checked,
2016-02-25 13:29:38 -07:00
IsEnabled: page.querySelector('.chkEnabled').checked,
DataVersion: 1
2015-07-25 11:11:46 -07:00
};
var id = getParameterByName('id');
if (id) {
info.Id = id;
}
ApiClient.ajax({
type: "POST",
url: ApiClient.getUrl('LiveTv/TunerHosts'),
data: JSON.stringify(info),
contentType: "application/json"
2015-12-14 08:43:03 -07:00
}).then(function (result) {
2015-07-25 11:11:46 -07:00
Dashboard.processServerConfigurationUpdateResult();
Dashboard.navigate('livetvstatus.html');
2015-12-14 08:43:03 -07:00
}, function () {
2015-07-25 11:11:46 -07:00
Dashboard.alert({
message: Globalize.translate('ErrorSavingTvProvider')
});
});
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#liveTvTunerProviderHdHomerunPage", function () {
2015-07-25 11:11:46 -07:00
var page = this;
$('form', page).on('submit', function () {
submitForm(page);
return false;
});
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#liveTvTunerProviderHdHomerunPage", function () {
2015-07-25 11:11:46 -07:00
var providerId = getParameterByName('id');
var page = this;
reload(page, providerId);
});
2016-03-16 14:30:49 -07:00
});