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

95 lines
2.4 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;
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#devicePage", function () {
2014-10-13 13:14:53 -07:00
var page = this;
$('#btnSelectUploadPath', page).on("click.selectDirectory", function () {
2015-10-13 12:22:45 -07:00
require(['directorybrowser'], function (directoryBrowser) {
2014-10-13 13:14:53 -07:00
2015-10-13 12:22:45 -07:00
var picker = new directoryBrowser();
2014-10-13 13:14:53 -07:00
2015-10-13 12:22:45 -07:00
picker.show({
2014-10-13 13:14:53 -07:00
2015-10-13 12:22:45 -07:00
callback: function (path) {
2014-10-13 13:14:53 -07:00
2015-10-13 12:22:45 -07:00
if (path) {
$('#txtUploadPath', page).val(path);
}
picker.close();
},
header: Globalize.translate('HeaderSelectUploadPath')
});
2014-10-13 13:14:53 -07:00
});
});
2015-05-15 08:46:20 -07:00
$('.deviceForm').off('submit', onSubmit).on('submit', onSubmit);
2014-10-13 13:14:53 -07:00
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#devicePage", function () {
2014-10-13 13:14:53 -07:00
var page = this;
loadData(page);
});
})();