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

92 lines
2.3 KiB
JavaScript
Raw Normal View History

2014-10-13 13:14:53 -07:00
(function () {
function load(page, device, capabilities) {
if (capabilities.SupportsContentUploading) {
2014-10-30 21:57:24 -07:00
$('#fldCameraUploadPath', page).show();
2014-10-13 13:14:53 -07:00
} else {
2014-10-30 21:57:24 -07:00
$('#fldCameraUploadPath', page).hide();
2014-10-13 13:14:53 -07:00
}
$('#txtCustomName', page).val(device.CustomName || '');
2014-11-25 21:12:29 -07:00
$('#txtUploadPath', page).val(device.CameraUploadPath || '');
2014-10-30 21:57:24 -07:00
$('.reportedName', page).html(device.ReportedName || '');
2014-10-13 13:14:53 -07:00
}
function loadData(page) {
Dashboard.showLoadingMsg();
var id = getParameterByName('id');
var promise1 = ApiClient.getJSON(ApiClient.getUrl('Devices/Info', { Id: id }));
var promise2 = ApiClient.getJSON(ApiClient.getUrl('Devices/Capabilities', { Id: id }));
$.when(promise1, promise2).done(function (response1, response2) {
load(page, response1[0], response2[0]);
Dashboard.hideLoadingMsg();
});
}
function save(page) {
var id = getParameterByName('id');
ApiClient.ajax({
url: ApiClient.getUrl('Devices/Options', { Id: id }),
type: 'POST',
data: JSON.stringify({
CustomName: $('#txtCustomName', page).val(),
CameraUploadPath: $('#txtUploadPath', page).val()
}),
contentType: "application/json"
}).done(Dashboard.processServerConfigurationUpdateResult);
}
2015-05-15 08:46:20 -07:00
function onSubmit() {
var form = this;
var page = $(form).parents('.page');
save(page);
return false;
}
$(document).on('pageinitdepends', "#devicePage", function () {
2014-10-13 13:14:53 -07:00
var page = this;
$('#btnSelectUploadPath', page).on("click.selectDirectory", function () {
var picker = new DirectoryBrowser(page);
picker.show({
callback: function (path) {
if (path) {
$('#txtUploadPath', page).val(path);
}
picker.close();
},
header: Globalize.translate('HeaderSelectUploadPath')
});
});
2015-05-15 08:46:20 -07:00
$('.deviceForm').off('submit', onSubmit).on('submit', onSubmit);
2014-10-13 13:14:53 -07:00
2015-05-19 12:15:40 -07:00
}).on('pageshowready', "#devicePage", function () {
2014-10-13 13:14:53 -07:00
var page = this;
loadData(page);
});
})();