mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
copy dashboard to the output folder and load from the file system, instead of using embedded resources
This commit is contained in:
parent
799eebc9ed
commit
4dd9477bcd
137 changed files with 1424 additions and 1438 deletions
119
dashboard-ui/scripts/LoginPage.js
Normal file
119
dashboard-ui/scripts/LoginPage.js
Normal file
|
@ -0,0 +1,119 @@
|
|||
var LoginPage = {
|
||||
|
||||
onPageShow: function () {
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
ApiClient.getUsers().done(LoginPage.loadUserList);
|
||||
},
|
||||
|
||||
getLastSeenText: function (lastActivityDate) {
|
||||
|
||||
if (!lastActivityDate) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return "Last seen " + humane_date(lastActivityDate);
|
||||
},
|
||||
|
||||
getImagePath: function (user) {
|
||||
|
||||
if (!user.PrimaryImageTag) {
|
||||
return "css/images/logindefault.png";
|
||||
}
|
||||
|
||||
return ApiClient.getUserImageUrl(user.Id, {
|
||||
width: 240,
|
||||
tag: user.PrimaryImageTag,
|
||||
type: "Primary"
|
||||
});
|
||||
},
|
||||
|
||||
authenticateUserLink: function (link) {
|
||||
|
||||
LoginPage.authenticateUser(link.getAttribute('data-username'), link.getAttribute('data-userid'));
|
||||
},
|
||||
|
||||
authenticateUser: function (username, userId, password) {
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
ApiClient.authenticateUser(userId, password).done(function () {
|
||||
|
||||
Dashboard.setCurrentUser(userId);
|
||||
|
||||
window.location = "index.html?u=" + userId;
|
||||
|
||||
}).fail(function () {
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
setTimeout(function () {
|
||||
Dashboard.showError("Invalid user or password.");
|
||||
}, 300);
|
||||
});
|
||||
},
|
||||
|
||||
loadUserList: function (users) {
|
||||
var html = "";
|
||||
|
||||
for (var i = 0, length = users.length; i < length; i++) {
|
||||
var user = users[i];
|
||||
|
||||
var linkId = "lnkUser" + i;
|
||||
|
||||
var background = Dashboard.getRandomMetroColor();
|
||||
|
||||
html += '<div class="posterViewItem posterViewItemWithDualText">';
|
||||
|
||||
if (user.HasPassword) {
|
||||
html += "<a id='" + linkId + "' data-userid='" + user.Id + "' data-username='" + user.Name + "' href='#popupLogin' data-rel='popup' onclick='LoginPage.authenticatingLinkId=this.id;' \">";
|
||||
} else {
|
||||
html += "<a id='" + linkId + "' data-userid='" + user.Id + "' data-username='" + user.Name + "' href='#' onclick='LoginPage.authenticateUserLink(this);' \">";
|
||||
}
|
||||
|
||||
if (user.PrimaryImageTag) {
|
||||
|
||||
var imgUrl = ApiClient.getUserImageUrl(user.Id, {
|
||||
width: 500,
|
||||
tag: user.PrimaryImageTag,
|
||||
type: "Primary"
|
||||
});
|
||||
|
||||
html += '<img src="' + imgUrl + '" />';
|
||||
} else {
|
||||
html += '<img style="background:' + background + ';" src="css/images/logindefault.png"/>';
|
||||
}
|
||||
|
||||
html += '<div class="posterViewItemText posterViewItemPrimaryText">' + user.Name + '</div>';
|
||||
html += '<div class="posterViewItemText">';
|
||||
var lastSeen = LoginPage.getLastSeenText(user.LastActivityDate);
|
||||
if (lastSeen != "") {
|
||||
html += lastSeen;
|
||||
}
|
||||
else {
|
||||
html += " ";
|
||||
}
|
||||
html += '</div>';
|
||||
|
||||
html += '</a>';
|
||||
|
||||
html += '</div>';
|
||||
}
|
||||
|
||||
$('#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());
|
||||
|
||||
// Disable default form submission
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
$(document).on('pageshow', "#loginPage", LoginPage.onPageShow);
|
Loading…
Add table
Add a link
Reference in a new issue