2016-08-22 13:47:16 -07:00
|
|
|
|
define(['appSettings', 'emby-checkbox'], function (appSettings) {
|
2016-10-22 22:11:46 -07:00
|
|
|
|
'use strict';
|
2016-08-22 11:28:24 -07:00
|
|
|
|
|
|
|
|
|
function loadForm(page, user) {
|
|
|
|
|
|
|
|
|
|
var uploadServers = appSettings.cameraUploadServers();
|
|
|
|
|
|
|
|
|
|
page.querySelector('.uploadServerList').innerHTML = ConnectionManager.getSavedServers().map(function (s) {
|
|
|
|
|
|
|
|
|
|
var checkedHtml = uploadServers.indexOf(s.Id) == -1 ? '' : ' checked';
|
|
|
|
|
var html = '<label><input type="checkbox" is="emby-checkbox"' + checkedHtml + ' class="chkUploadServer" data-id="' + s.Id + '"/><span>' + s.Name + '</span></label>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
|
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-22 22:08:07 -07:00
|
|
|
|
function saveUser(page) {
|
2016-08-22 11:28:24 -07:00
|
|
|
|
|
|
|
|
|
var chkUploadServer = page.querySelectorAll('.chkUploadServer');
|
|
|
|
|
var cameraUploadServers = [];
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = chkUploadServer.length; i < length; i++) {
|
|
|
|
|
if (chkUploadServer[i].checked) {
|
|
|
|
|
cameraUploadServers.push(chkUploadServer[i].getAttribute('data-id'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
appSettings.cameraUploadServers(cameraUploadServers);
|
|
|
|
|
|
2016-10-03 22:15:39 -07:00
|
|
|
|
if (window.MainActivity) {
|
|
|
|
|
// TODO: isolate into android app
|
|
|
|
|
MainActivity.authorizeStorage();
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-22 11:28:24 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return function (view, params) {
|
|
|
|
|
|
|
|
|
|
view.querySelector('form').addEventListener('submit', function (e) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2016-08-22 22:08:07 -07:00
|
|
|
|
saveUser(view);
|
2016-08-22 11:28:24 -07:00
|
|
|
|
|
|
|
|
|
// Disable default form submission
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
view.addEventListener('viewshow', function () {
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2016-08-23 23:13:15 -07:00
|
|
|
|
var userId = params.userId || Dashboard.getCurrentUserId();
|
2016-08-22 11:28:24 -07:00
|
|
|
|
|
|
|
|
|
ApiClient.getUser(userId).then(function (user) {
|
|
|
|
|
|
|
|
|
|
loadForm(page, user);
|
|
|
|
|
});
|
|
|
|
|
});
|
2016-08-22 22:08:07 -07:00
|
|
|
|
|
|
|
|
|
view.addEventListener('viewbeforehide', function () {
|
|
|
|
|
|
|
|
|
|
saveUser(this);
|
|
|
|
|
});
|
2016-08-22 11:28:24 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
});
|