1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/scripts/mysyncsettings.js

81 lines
2.3 KiB
JavaScript
Raw Normal View History

2016-06-19 12:53:53 -04:00
define(['appSettings'], function (appSettings) {
2015-07-29 22:35:11 -04:00
function loadForm(page, user) {
2016-06-14 00:06:57 -04:00
page.querySelector('#txtSyncPath').value = appSettings.syncPath() || '';
2016-03-01 01:02:03 -05:00
page.querySelector('#chkWifi').checked = appSettings.syncOnlyOnWifi();
2015-07-29 22:35:11 -04:00
Dashboard.hideLoadingMsg();
}
function saveUser(page, user) {
2016-05-17 13:44:17 -04:00
var syncPath = page.querySelector('#txtSyncPath').value;
appSettings.syncPath(syncPath);
2016-03-01 01:02:03 -05:00
appSettings.syncOnlyOnWifi(page.querySelector('#chkWifi').checked);
2015-08-12 17:39:02 -04:00
2015-07-29 22:35:11 -04:00
Dashboard.hideLoadingMsg();
2016-02-25 01:38:12 -05:00
require(['toast'], function (toast) {
toast(Globalize.translate('SettingsSaved'));
});
2016-05-17 13:44:17 -04:00
if (cameraUploadServers.length || syncPath) {
if (window.MainActivity) {
MainActivity.authorizeStorage();
}
}
2015-07-29 22:35:11 -04:00
}
2016-06-19 12:53:53 -04:00
return function (view, params) {
2015-07-29 22:35:11 -04:00
2016-06-19 12:53:53 -04:00
view.querySelector('form').addEventListener('submit', function (e) {
2015-07-29 22:35:11 -04:00
2016-06-19 12:53:53 -04:00
Dashboard.showLoadingMsg();
2015-07-29 22:35:11 -04:00
2016-06-19 12:53:53 -04:00
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
2015-07-29 22:35:11 -04:00
2016-06-19 12:53:53 -04:00
ApiClient.getUser(userId).then(function (user) {
2015-07-29 22:35:11 -04:00
2016-06-19 12:53:53 -04:00
saveUser(view, user);
2015-07-29 22:35:11 -04:00
2016-06-19 12:53:53 -04:00
});
2015-07-29 22:35:11 -04:00
2016-06-19 12:53:53 -04:00
// Disable default form submission
e.preventDefault();
return false;
});
2015-07-29 22:35:11 -04:00
2016-06-19 12:53:53 -04:00
view.querySelector('#btnSelectSyncPath').addEventListener('click', function () {
2015-07-29 22:35:11 -04:00
require(['nativedirectorychooser'], function () {
2015-12-14 10:43:03 -05:00
NativeDirectoryChooser.chooseDirectory().then(function (path) {
2016-06-13 15:02:48 -04:00
if (path) {
2016-06-19 12:53:53 -04:00
view.querySelector('#txtSyncPath').value = path;
2016-06-13 15:02:48 -04:00
}
2015-07-29 22:35:11 -04:00
});
});
});
2016-06-19 12:53:53 -04:00
view.addEventListener('viewshow', function () {
var page = this;
2015-07-29 22:35:11 -04:00
2016-06-19 12:53:53 -04:00
Dashboard.showLoadingMsg();
2015-07-29 22:35:11 -04:00
2016-06-19 12:53:53 -04:00
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
2015-07-29 22:35:11 -04:00
2016-06-19 12:53:53 -04:00
ApiClient.getUser(userId).then(function (user) {
2015-07-29 22:35:11 -04:00
2016-06-19 12:53:53 -04:00
loadForm(page, user);
});
2015-07-29 22:35:11 -04:00
2016-06-19 12:53:53 -04:00
if (AppInfo.supportsSyncPathSetting) {
page.querySelector('.fldSyncPath').classList.remove('hide');
} else {
page.querySelector('.fldSyncPath').classList.add('hide');
}
2015-07-29 22:35:11 -04:00
});
2016-06-19 12:53:53 -04:00
};
2015-07-29 22:35:11 -04:00
2016-03-01 01:02:03 -05:00
});