Merge pull request #292 from dkanada/auto

Fix some issues with the user preference page
This commit is contained in:
Joshua M. Boniface 2019-04-30 23:50:05 -04:00 committed by GitHub
commit 8b703187d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 67 deletions

View File

@ -146,12 +146,8 @@ define(["apphost", "appSettings", "dom", "connectionManager", "loading", "cardSt
var apiClient = getApiClient(); var apiClient = getApiClient();
apiClient.getPublicUsers().then(function(users) { apiClient.getPublicUsers().then(function(users) {
if (users.length) { if (users.length) {
if (users[0].EnableAutoLogin) {
authenticateUserByName(view, apiClient, users[0].Name, "");
} else {
showVisualForm(); showVisualForm();
loadUserList(view, apiClient, users); loadUserList(view, apiClient, users);
}
} else { } else {
view.querySelector("#txtManualName").value = ""; view.querySelector("#txtManualName").value = "";
showManualForm(view, false, false); showManualForm(view, false, false);

View File

@ -7,14 +7,15 @@ define(["apphost", "connectionManager", "listViewStyle", "emby-button"], functio
}); });
view.addEventListener("viewshow", function() { view.addEventListener("viewshow", function() {
var page = this; // this page can also be used by admins to change user preferences from the user edit page
var userId = params.userId || Dashboard.getCurrentUserId(); var userId = params.userId || Dashboard.getCurrentUserId();
var page = this;
page.querySelector(".lnkDisplayPreferences").setAttribute("href", "mypreferencesdisplay.html?userId=" + userId);
page.querySelector(".lnkLanguagePreferences").setAttribute("href", "mypreferenceslanguages.html?userId=" + userId);
page.querySelector(".lnkSubtitleSettings").setAttribute("href", "mypreferencessubtitles.html?userId=" + userId);
page.querySelector(".lnkHomeScreenPreferences").setAttribute("href", "mypreferenceshome.html?userId=" + userId);
page.querySelector(".lnkMyProfile").setAttribute("href", "myprofile.html?userId=" + userId); page.querySelector(".lnkMyProfile").setAttribute("href", "myprofile.html?userId=" + userId);
page.querySelector(".lnkDisplayPreferences").setAttribute("href", "mypreferencesdisplay.html?userId=" + userId);
page.querySelector(".lnkHomePreferences").setAttribute("href", "mypreferenceshome.html?userId=" + userId);
page.querySelector(".lnkLanguagePreferences").setAttribute("href", "mypreferenceslanguages.html?userId=" + userId);
page.querySelector(".lnkSubtitlePreferences").setAttribute("href", "mypreferencessubtitles.html?userId=" + userId);
if (appHost.supports("multiserver")) { if (appHost.supports("multiserver")) {
page.querySelector(".selectServer").classList.remove("hide") page.querySelector(".selectServer").classList.remove("hide")
@ -22,19 +23,15 @@ define(["apphost", "connectionManager", "listViewStyle", "emby-button"], functio
page.querySelector(".selectServer").classList.add("hide"); page.querySelector(".selectServer").classList.add("hide");
} }
connectionManager.user(ApiClient).then(function(user) { // hide the actions if user preferences are being edited for a different user
if (user.localUser && !user.localUser.EnableAutoLogin) { if (params.userId && params.userId !== Dashboard.getCurrentUserId) {
view.querySelector(".btnLogout").classList.remove("hide"); page.querySelector(".userSection").classList.add("hide");
} else { page.querySelector(".adminSection").classList.add("hide");
view.querySelector(".btnLogout").classList.add("hide");
} }
});
Dashboard.getCurrentUser().then(function(user) { ApiClient.getUser(userId).then(function(user) {
page.querySelector(".headerUsername").innerHTML = user.Name; page.querySelector(".headerUsername").innerHTML = user.Name;
if (user.Policy.IsAdministrator) { if (!user.Policy.IsAdministrator) {
page.querySelector(".adminSection").classList.remove("hide");
} else {
page.querySelector(".adminSection").classList.add("hide"); page.querySelector(".adminSection").classList.add("hide");
} }
}); });

View File

@ -22,7 +22,7 @@
</div> </div>
</a> </a>
<a is="emby-linkbutton" style="display:block; padding: 0; margin:0;" data-ripple="false" href="#" class="lnkHomeScreenPreferences listItem-border"> <a is="emby-linkbutton" style="display:block; padding: 0; margin:0;" data-ripple="false" href="#" class="lnkHomePreferences listItem-border">
<div class="listItem"> <div class="listItem">
<i class="md-icon listItemIcon listItemIcon-transparent">home</i> <i class="md-icon listItemIcon listItemIcon-transparent">home</i>
<div class="listItemBody"> <div class="listItemBody">
@ -40,7 +40,7 @@
</div> </div>
</a> </a>
<a is="emby-linkbutton" style="display:block; padding: 0; margin:0;" data-ripple="false" href="#" class="lnkSubtitleSettings listItem-border"> <a is="emby-linkbutton" style="display:block; padding: 0; margin:0;" data-ripple="false" href="#" class="lnkSubtitlePreferences listItem-border">
<div class="listItem"> <div class="listItem">
<i class="md-icon listItemIcon listItemIcon-transparent">closed_caption</i> <i class="md-icon listItemIcon listItemIcon-transparent">closed_caption</i>
<div class="listItemBody"> <div class="listItemBody">
@ -49,9 +49,8 @@
</div> </div>
</a> </a>
</div> </div>
<div class="verticalSection verticalSection-extrabottompadding"> <div class="adminSection verticalSection verticalSection-extrabottompadding">
<h2 class="sectionTitle" style="padding-left:.25em;">${HeaderAdmin}</h2> <h2 class="sectionTitle" style="padding-left:.25em;">${HeaderAdmin}</h2>
<div>
<a is="emby-linkbutton" href="dashboard.html" style="display: block; padding: 0; margin:0;" class="listItem-border"> <a is="emby-linkbutton" href="dashboard.html" style="display: block; padding: 0; margin:0;" class="listItem-border">
<div class="listItem"> <div class="listItem">
<i class="md-icon listItemIcon listItemIcon-transparent">dashboard</i> <i class="md-icon listItemIcon listItemIcon-transparent">dashboard</i>
@ -60,8 +59,6 @@
</div> </div>
</div> </div>
</a> </a>
</div>
<div>
<a is="emby-linkbutton" href="edititemmetadata.html" style="display: block; padding: 0; margin:0;" class="listItem-border"> <a is="emby-linkbutton" href="edititemmetadata.html" style="display: block; padding: 0; margin:0;" class="listItem-border">
<div class="listItem"> <div class="listItem">
<i class="md-icon listItemIcon listItemIcon-transparent">mode_edit</i> <i class="md-icon listItemIcon listItemIcon-transparent">mode_edit</i>
@ -71,11 +68,8 @@
</div> </div>
</a> </a>
</div> </div>
</div> <div class="userSection verticalSection verticalSection-extrabottompadding">
<div class="adminSection hide verticalSection verticalSection-extrabottompadding">
<h2 class="sectionTitle" style="padding-left:.25em;">${HeaderUser}</h2> <h2 class="sectionTitle" style="padding-left:.25em;">${HeaderUser}</h2>
<div>
<a is="emby-linkbutton" style="display:block; padding: 0; margin:0;" data-ripple="false" href="selectserver.html" class="selectServer hide listItem-border"> <a is="emby-linkbutton" style="display:block; padding: 0; margin:0;" data-ripple="false" href="selectserver.html" class="selectServer hide listItem-border">
<div class="listItem"> <div class="listItem">
<i class="md-icon listItemIcon listItemIcon-transparent">wifi</i> <i class="md-icon listItemIcon listItemIcon-transparent">wifi</i>
@ -84,9 +78,7 @@
</div> </div>
</div> </div>
</a> </a>
</div> <a is="emby-linkbutton" style="display:block; padding: 0; margin:0;" data-ripple="false" href="#" class="btnLogout listItem-border">
<div>
<a is="emby-linkbutton" style="display:block; padding: 0; margin:0;" data-ripple="false" href="#" class="btnLogout hide listItem-border">
<div class="listItem"> <div class="listItem">
<i class="md-icon listItemIcon listItemIcon-transparent">exit_to_app</i> <i class="md-icon listItemIcon listItemIcon-transparent">exit_to_app</i>
<div class="listItemBody"> <div class="listItemBody">
@ -97,5 +89,4 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>

View File

@ -201,11 +201,9 @@ define(["dom", "layoutManager", "inputManager", "connectionManager", "events", "
if (appHost.supports("multiserver")) { if (appHost.supports("multiserver")) {
html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder" data-itemid="selectserver" href="selectserver.html?showuser=1"><i class="md-icon navMenuOptionIcon">wifi</i><span class="navMenuOptionText">' + globalize.translate("ButtonSelectServer") + "</span></a>"; html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder" data-itemid="selectserver" href="selectserver.html?showuser=1"><i class="md-icon navMenuOptionIcon">wifi</i><span class="navMenuOptionText">' + globalize.translate("ButtonSelectServer") + "</span></a>";
} }
if (!user.localUser.EnableAutoLogin) {
html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder btnLogout" data-itemid="logout" href="#"><i class="md-icon navMenuOptionIcon">exit_to_app</i><span class="navMenuOptionText">' + globalize.translate("ButtonSignOut") + "</span></a>"; html += '<a is="emby-linkbutton" class="navMenuOption lnkMediaFolder btnLogout" data-itemid="logout" href="#"><i class="md-icon navMenuOptionIcon">exit_to_app</i><span class="navMenuOptionText">' + globalize.translate("ButtonSignOut") + "</span></a>";
}
}
html += "</div>"; html += "</div>";
}
// add buttons to navigation drawer // add buttons to navigation drawer
navDrawerScrollContainer.innerHTML = html; navDrawerScrollContainer.innerHTML = html;