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

added some user access settings

This commit is contained in:
Luke Pulverenti 2013-07-08 12:13:21 -04:00
parent 1663b40737
commit a2ce0bdce6
10 changed files with 252 additions and 19 deletions

View file

@ -0,0 +1,68 @@
(function ($, document, window) {
function loadPage(page, config) {
var clients = config.ManualLoginClients;
$('#chkMobileClients', page).checked(clients.filter(function (i) {
return i == "Mobile";
}).length > 0).checkboxradio("refresh");
$('#chkMBT', page).checked(clients.filter(function (i) {
return i == "MediaBrowserTheater";
}).length > 0).checkboxradio("refresh");
Dashboard.hideLoadingMsg();
}
$(document).on('pageshow', "#allUserSettingsPage", function () {
Dashboard.showLoadingMsg();
var page = this;
ApiClient.getServerConfiguration().done(function (config) {
loadPage(page, config);
});
});
function allUserSettingsPage() {
var self = this;
self.onSubmit = function () {
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getServerConfiguration().done(function (config) {
var clients = [];
if ($('#chkMobileClients', form).checked()) {
clients.push("Mobile");
}
if ($('#chkMBT', form).checked()) {
clients.push("MediaBrowserTheater");
}
config.ManualLoginClients = clients;
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
};
}
window.AllUserSettingsPage = new allUserSettingsPage();
})(jQuery, document, window);

View file

@ -59,8 +59,10 @@
if (!loggedInUser.Configuration.IsAdministrator) {
$('#parentalControlDiv', page).hide();
$('#fldIsAdmin', page).hide();
$('#accessControlDiv', page).show();
} else {
$('#parentalControlDiv', page).show();
$('#accessControlDiv', page).show();
$('#fldIsAdmin', page).show();
}
@ -102,6 +104,9 @@
$('#chkIsAdmin', page).checked(user.Configuration.IsAdministrator || false).checkboxradio("refresh");
$('#chkBlockNotRated', page).checked(user.Configuration.BlockNotRated || false).checkboxradio("refresh");
$('#chkDisabled', page).checked(user.Configuration.IsDisabled || false).checkboxradio("refresh");
$('#chkIsHidden', page).checked(user.Configuration.IsHidden || false).checkboxradio("refresh");
Dashboard.hideLoadingMsg();
}
@ -132,6 +137,9 @@
user.Configuration.UseForcedSubtitlesOnly = $('#chkForcedSubtitlesOnly', page).checked();
user.Configuration.BlockNotRated = $('#chkBlockNotRated', page).checked();
user.Configuration.IsHidden = $('#chkIsHidden', page).checked();
user.Configuration.IsDisabled = $('#chkDisabled', page).checked();
var userId = getParameterByName("userId");
if (userId) {

View file

@ -3,7 +3,37 @@
onPageShow: function () {
Dashboard.showLoadingMsg();
ApiClient.getUsers().done(LoginPage.loadUserList);
var promise1 = ApiClient.getUsers({ IsHidden: false });
var promise2 = ApiClient.getServerConfiguration();
$.when(promise1, promise2).done(function (response1, response2) {
var users = response1[0];
var config = response2[0];
var showManualForm = config.ManualLoginClients.filter(function (i) {
return i == "Mobile";
}).length || !users.length;
showManualForm &= window.location.toString().toLowerCase().indexOf('localhost') == -1;
if (showManualForm) {
$('#divUsers', '#loginPage').hide();
$('#manualLoginForm', '#loginPage').show();
} else {
$('#divUsers', '#loginPage').show();
$('#manualLoginForm', '#loginPage').hide();
LoginPage.loadUserList(users);
}
Dashboard.hideLoadingMsg();
});
},
getLastSeenText: function (lastActivityDate) {
@ -33,17 +63,20 @@
LoginPage.authenticateUser(link.getAttribute('data-username'), link.getAttribute('data-userid'));
},
authenticateUser: function (username, userId, password) {
authenticateUser: function (username, password) {
Dashboard.showLoadingMsg();
ApiClient.authenticateUser(userId, password).done(function () {
ApiClient.authenticateUserByName(username, password).done(function (result) {
Dashboard.setCurrentUser(userId);
Dashboard.setCurrentUser(result.User.Id);
window.location = "index.html?u=" + userId;
window.location = "index.html?u=" + result.User.Id;
}).fail(function () {
$('#pw', '#loginPage').val('');
Dashboard.hideLoadingMsg();
setTimeout(function () {
@ -61,9 +94,9 @@
var linkId = "lnkUser" + i;
if (user.HasPassword) {
html += "<a class='posterItem squarePosterItem' id='" + linkId + "' data-userid='" + user.Id + "' data-username='" + user.Name + "' href='#popupLogin' data-rel='popup' onclick='LoginPage.authenticatingLinkId=this.id;' \">";
html += "<a class='posterItem squarePosterItem' id='" + linkId + "' data-username='" + user.Name + "' href='#popupLogin' data-rel='popup' onclick='LoginPage.authenticatingLinkId=this.id;' \">";
} else {
html += "<a class='posterItem squarePosterItem' id='" + linkId + "' data-userid='" + user.Id + "' data-username='" + user.Name + "' href='#' onclick='LoginPage.authenticateUserLink(this);' \">";
html += "<a class='posterItem squarePosterItem' id='" + linkId + "' data-username='" + user.Name + "' href='#' onclick='LoginPage.authenticateUserLink(this);' \">";
}
if (user.PrimaryImageTag) {
@ -100,15 +133,23 @@
$('#divUsers', '#loginPage').html(html);
Dashboard.hideLoadingMsg();
},
onSubmit: function () {
$('#popupLogin', '#loginPage').popup('close');
var link = $('#' + LoginPage.authenticatingLinkId)[0];
LoginPage.authenticateUser(link.getAttribute('data-username'), link.getAttribute('data-userid'), $('#pw', '#loginPage').val());
LoginPage.authenticateUser(link.getAttribute('data-username'), $('#pw', '#loginPage').val());
// Disable default form submission
return false;
},
onManualSubmit: function () {
LoginPage.authenticateUser($('#txtManualName', '#loginPage').val(), $('#txtManualPassword', '#loginPage').val());
// Disable default form submission
return false;