mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update password page to new js format
This commit is contained in:
parent
9e3190a060
commit
05a6467c35
5 changed files with 97 additions and 54 deletions
|
@ -12,7 +12,7 @@
|
||||||
<a href="#" data-role="button" class="ui-btn-active">Profile</a>
|
<a href="#" data-role="button" class="ui-btn-active">Profile</a>
|
||||||
<a href="#" data-role="button" onclick="Dashboard.navigate('userimage.html', true);">Image</a>
|
<a href="#" data-role="button" onclick="Dashboard.navigate('userimage.html', true);">Image</a>
|
||||||
<a href="#" data-role="button" onclick="Dashboard.navigate('updatepassword.html', true);">Password</a>
|
<a href="#" data-role="button" onclick="Dashboard.navigate('updatepassword.html', true);">Password</a>
|
||||||
<a class="lnkMediaLibrary" style="display:none;" href="#" data-role="button" onclick="Dashboard.navigate('library.html', true);">Media Library</a>
|
<a href="#" data-role="button" onclick="Dashboard.navigate('library.html', true);" class="lnkMediaLibrary" style="display:none;">Media Library</a>
|
||||||
</div>
|
</div>
|
||||||
<form id="editUserProfileForm">
|
<form id="editUserProfileForm">
|
||||||
<ul data-role="listview" class="ulForm">
|
<ul data-role="listview" class="ulForm">
|
||||||
|
|
|
@ -34,10 +34,6 @@
|
||||||
|
|
||||||
function loadUser(page, user, loggedInUser, parentalRatingsPromise, allCulturesPromise) {
|
function loadUser(page, user, loggedInUser, parentalRatingsPromise, allCulturesPromise) {
|
||||||
|
|
||||||
if (loggedInUser.Configuration.IsAdministrator) {
|
|
||||||
$('.lnkMediaLibrary', page).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!loggedInUser.Configuration.IsAdministrator || user.Id == loggedInUser.Id) {
|
if (!loggedInUser.Configuration.IsAdministrator || user.Id == loggedInUser.Id) {
|
||||||
|
|
||||||
$('#fldIsAdmin', page).hide();
|
$('#fldIsAdmin', page).hide();
|
||||||
|
@ -155,12 +151,10 @@
|
||||||
|
|
||||||
window.EditUserPage = new editUserPage();
|
window.EditUserPage = new editUserPage();
|
||||||
|
|
||||||
$(document).on('pageshow', "#editUserPage", function () {
|
$(document).on('pagebeforeshow', "#editUserPage", function () {
|
||||||
|
|
||||||
var page = this;
|
var page = this;
|
||||||
|
|
||||||
Dashboard.showLoadingMsg();
|
|
||||||
|
|
||||||
var userId = getParameterByName("userId");
|
var userId = getParameterByName("userId");
|
||||||
|
|
||||||
if (userId) {
|
if (userId) {
|
||||||
|
@ -169,6 +163,23 @@
|
||||||
$('#userProfileNavigation', page).hide();
|
$('#userProfileNavigation', page).hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Dashboard.getCurrentUser().done(function (loggedInUser) {
|
||||||
|
|
||||||
|
if (loggedInUser.Configuration.IsAdministrator) {
|
||||||
|
$('.lnkMediaLibrary', page).show().prev().removeClass('ui-last-child');
|
||||||
|
} else {
|
||||||
|
$('.lnkMediaLibrary', page).hide().prev().addClass('ui-last-child');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}).on('pageshow', "#editUserPage", function () {
|
||||||
|
|
||||||
|
var page = this;
|
||||||
|
|
||||||
|
Dashboard.showLoadingMsg();
|
||||||
|
|
||||||
|
var userId = getParameterByName("userId");
|
||||||
|
|
||||||
var promise1;
|
var promise1;
|
||||||
|
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
|
@ -188,7 +199,7 @@
|
||||||
var promise2 = Dashboard.getCurrentUser();
|
var promise2 = Dashboard.getCurrentUser();
|
||||||
|
|
||||||
var parentalRatingsPromise = ApiClient.getParentalRatings();
|
var parentalRatingsPromise = ApiClient.getParentalRatings();
|
||||||
|
|
||||||
var allCulturesPromise = ApiClient.getCultures();
|
var allCulturesPromise = ApiClient.getCultures();
|
||||||
|
|
||||||
$.when(promise1, promise2).done(function (response1, response2) {
|
$.when(promise1, promise2).done(function (response1, response2) {
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
var UpdatePasswordPage = {
|
(function ($, document, window) {
|
||||||
|
|
||||||
onPageShow: function () {
|
function loadUser(page) {
|
||||||
UpdatePasswordPage.loadUser();
|
|
||||||
},
|
|
||||||
|
|
||||||
loadUser: function() {
|
|
||||||
var page = $.mobile.activePage;
|
|
||||||
|
|
||||||
var userid = getParameterByName("userId");
|
var userid = getParameterByName("userId");
|
||||||
|
|
||||||
|
@ -28,65 +23,96 @@
|
||||||
$('#txtCurrentPassword', page).val('');
|
$('#txtCurrentPassword', page).val('');
|
||||||
$('#txtNewPassword', page).val('');
|
$('#txtNewPassword', page).val('');
|
||||||
$('#txtNewPasswordConfirm', page).val('');
|
$('#txtNewPasswordConfirm', page).val('');
|
||||||
},
|
}
|
||||||
|
|
||||||
save: function () {
|
function save(page) {
|
||||||
|
|
||||||
var userId = getParameterByName("userId");
|
var userId = getParameterByName("userId");
|
||||||
|
|
||||||
var page = $($.mobile.activePage);
|
|
||||||
var currentPassword = $('#txtCurrentPassword', page).val();
|
var currentPassword = $('#txtCurrentPassword', page).val();
|
||||||
var newPassword = $('#txtNewPassword', page).val();
|
var newPassword = $('#txtNewPassword', page).val();
|
||||||
|
|
||||||
ApiClient.updateUserPassword(userId, currentPassword, newPassword).done(UpdatePasswordPage.saveComplete);
|
ApiClient.updateUserPassword(userId, currentPassword, newPassword).done(function () {
|
||||||
},
|
|
||||||
|
|
||||||
saveComplete: function () {
|
Dashboard.hideLoadingMsg();
|
||||||
|
|
||||||
Dashboard.hideLoadingMsg();
|
Dashboard.alert("Password saved.");
|
||||||
|
loadUser(page);
|
||||||
|
|
||||||
Dashboard.alert("Password saved.");
|
});
|
||||||
UpdatePasswordPage.loadUser();
|
|
||||||
},
|
|
||||||
|
|
||||||
resetPassword: function () {
|
}
|
||||||
|
|
||||||
var msg = "Are you sure you wish to reset the password?";
|
function updatePasswordPage() {
|
||||||
|
|
||||||
Dashboard.confirm(msg, "Password Reset", function (result) {
|
var self = this;
|
||||||
|
|
||||||
if (result) {
|
self.onSubmit = function () {
|
||||||
var userId = getParameterByName("userId");
|
|
||||||
|
|
||||||
Dashboard.showLoadingMsg();
|
var page = $.mobile.activePage;
|
||||||
|
|
||||||
ApiClient.resetUserPassword(userId).done(function () {
|
if ($('#txtNewPassword', page).val() != $('#txtNewPasswordConfirm', page).val()) {
|
||||||
|
|
||||||
Dashboard.hideLoadingMsg();
|
Dashboard.showError("Password and password confirmation must match.");
|
||||||
Dashboard.alert("The password has been reset.");
|
return false;
|
||||||
UpdatePasswordPage.loadUser();
|
}
|
||||||
|
|
||||||
});
|
Dashboard.showLoadingMsg();
|
||||||
|
|
||||||
|
save(page);
|
||||||
|
|
||||||
|
// Disable default form submission
|
||||||
|
return false;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
self.resetPassword = function () {
|
||||||
|
|
||||||
|
var msg = "Are you sure you wish to reset the password?";
|
||||||
|
|
||||||
|
var page = $.mobile.activePage;
|
||||||
|
|
||||||
|
Dashboard.confirm(msg, "Password Reset", function (result) {
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
var userId = getParameterByName("userId");
|
||||||
|
|
||||||
|
Dashboard.showLoadingMsg();
|
||||||
|
|
||||||
|
ApiClient.resetUserPassword(userId).done(function () {
|
||||||
|
|
||||||
|
Dashboard.hideLoadingMsg();
|
||||||
|
Dashboard.alert("The password has been reset.");
|
||||||
|
loadUser(page);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
window.UpdatePasswordPage = new updatePasswordPage();
|
||||||
|
|
||||||
|
$(document).on('pagebeforeshow', "#updatePasswordPage", function () {
|
||||||
|
|
||||||
|
var page = this;
|
||||||
|
|
||||||
|
Dashboard.getCurrentUser().done(function (loggedInUser) {
|
||||||
|
|
||||||
|
if (loggedInUser.Configuration.IsAdministrator) {
|
||||||
|
$('.lnkMediaLibrary', page).show().prev().removeClass('ui-last-child');
|
||||||
|
} else {
|
||||||
|
$('.lnkMediaLibrary', page).hide().prev().addClass('ui-last-child');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
|
||||||
|
|
||||||
onSubmit: function () {
|
}).on('pageshow', "#updatePasswordPage", function () {
|
||||||
var page = $($.mobile.activePage);
|
|
||||||
|
|
||||||
if ($('#txtNewPassword', page).val() != $('#txtNewPasswordConfirm', page).val()) {
|
var page = this;
|
||||||
|
|
||||||
Dashboard.showError("Password and password confirmation must match.");
|
loadUser(page);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dashboard.showLoadingMsg();
|
});
|
||||||
|
|
||||||
UpdatePasswordPage.save();
|
})(jQuery, document, window);
|
||||||
|
|
||||||
// Disable default form submission
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$(document).on('pageshow', "#updatePasswordPage", UpdatePasswordPage.onPageShow);
|
|
|
@ -21,6 +21,12 @@
|
||||||
|
|
||||||
var page = $($.mobile.activePage);
|
var page = $($.mobile.activePage);
|
||||||
|
|
||||||
|
if (user.Configuration.IsAdministrator) {
|
||||||
|
$('.lnkMediaLibrary', page).show();
|
||||||
|
} else {
|
||||||
|
$('.lnkMediaLibrary', page).hide();
|
||||||
|
}
|
||||||
|
|
||||||
$('#uploadUserImage', page).val('').trigger('change');
|
$('#uploadUserImage', page).val('').trigger('change');
|
||||||
|
|
||||||
Dashboard.setPageTitle(user.Name);
|
Dashboard.setPageTitle(user.Name);
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<a href="#" onclick="Dashboard.navigate('edituser.html', true);" data-role="button">Profile</a>
|
<a href="#" onclick="Dashboard.navigate('edituser.html', true);" data-role="button">Profile</a>
|
||||||
<a href="#" data-role="button" onclick="Dashboard.navigate('userimage.html', true);">Image</a>
|
<a href="#" data-role="button" onclick="Dashboard.navigate('userimage.html', true);">Image</a>
|
||||||
<a href="#" data-role="button" class="ui-btn-active">Password</a>
|
<a href="#" data-role="button" class="ui-btn-active">Password</a>
|
||||||
<a href="#" data-role="button" onclick="Dashboard.navigate('library.html', true);">Media Library</a>
|
<a href="#" data-role="button" class="lnkMediaLibrary" style="display:none;" onclick="Dashboard.navigate('library.html', true);">Media Library</a>
|
||||||
</div>
|
</div>
|
||||||
<h3 style="display: none;">Create Password</h3>
|
<h3 style="display: none;">Create Password</h3>
|
||||||
<form id="updatePasswordForm">
|
<form id="updatePasswordForm">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue