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

96 lines
2.3 KiB
JavaScript
Raw Normal View History

define(['jQuery'], function ($) {
2014-10-11 13:38:13 -07:00
2016-06-03 09:24:04 -07:00
function load(page, config) {
2014-10-11 13:38:13 -07:00
$('#txtUploadPath', page).val(config.CameraUploadPath || '');
2016-04-15 12:20:04 -07:00
$('#chkSubfolder', page).checked(config.EnableCameraUploadSubfolders);
2014-10-11 13:38:13 -07:00
}
function loadData(page) {
Dashboard.showLoadingMsg();
2016-06-03 09:24:04 -07:00
ApiClient.getNamedConfiguration("devices").then(function (config) {
load(page, config);
2014-10-11 13:38:13 -07:00
Dashboard.hideLoadingMsg();
});
}
function save(page) {
2015-12-14 08:43:03 -07:00
ApiClient.getNamedConfiguration("devices").then(function (config) {
2014-10-11 13:38:13 -07:00
config.CameraUploadPath = $('#txtUploadPath', page).val();
2014-10-11 18:46:02 -07:00
config.EnableCameraUploadSubfolders = $('#chkSubfolder', page).checked();
2015-12-14 08:43:03 -07:00
ApiClient.updateNamedConfiguration("devices", config).then(Dashboard.processServerConfigurationUpdateResult);
2014-10-11 13:38:13 -07:00
});
}
2015-06-07 21:47:19 -07:00
function onSubmit() {
var form = this;
var page = $(form).parents('.page');
save(page);
return false;
}
2016-04-12 23:02:07 -07:00
function getTabs() {
return [
{
href: 'syncactivity.html',
name: Globalize.translate('TabSyncJobs')
},
{
href: 'devicesupload.html',
name: Globalize.translate('TabCameraUpload')
},
{
href: 'syncsettings.html',
name: Globalize.translate('TabSettings')
}];
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#devicesUploadPage", function () {
2014-10-11 13:38:13 -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-11 13:38:13 -07:00
2015-10-13 12:22:45 -07:00
var picker = new directoryBrowser();
2014-10-11 13:38:13 -07:00
2015-10-13 12:22:45 -07:00
picker.show({
2014-10-11 13:38:13 -07:00
2015-10-13 12:22:45 -07:00
callback: function (path) {
2014-10-11 13:38:13 -07:00
2015-10-13 12:22:45 -07:00
if (path) {
$('#txtUploadPath', page).val(path);
}
picker.close();
},
header: Globalize.translate('HeaderSelectUploadPath')
});
2014-10-11 13:38:13 -07:00
});
});
2015-06-07 21:47:19 -07:00
$('.devicesUploadForm').off('submit', onSubmit).on('submit', onSubmit);
2014-10-11 13:38:13 -07:00
2015-09-24 10:08:10 -07:00
}).on('pageshow', "#devicesUploadPage", function () {
2014-10-11 13:38:13 -07:00
2016-04-12 23:02:07 -07:00
LibraryMenu.setTabs('syncadmin', 1, getTabs);
2014-10-11 13:38:13 -07:00
var page = this;
loadData(page);
});
});