continue jquery removal
This commit is contained in:
parent
75a40a8dbb
commit
31dc3c06e1
14 changed files with 352 additions and 375 deletions
|
@ -617,6 +617,11 @@
|
|||
return getParameterByName('topParentId') || null;
|
||||
}
|
||||
|
||||
function getNavigateDelay() {
|
||||
// On mobile devices don't navigate until after the closing animation has completed or it may stutter
|
||||
return browserInfo.mobile ? 320 : 200;;
|
||||
}
|
||||
|
||||
window.LibraryMenu = {
|
||||
getTopParentId: getTopParentId,
|
||||
|
||||
|
@ -632,8 +637,6 @@
|
|||
setTimeout(function () {
|
||||
closeMainDrawer();
|
||||
|
||||
// On mobile devices don't navigate until after the closing animation has completed or it may stutter
|
||||
var delay = browserInfo.mobile ? 350 : 200;
|
||||
|
||||
setTimeout(function () {
|
||||
if (action) {
|
||||
|
@ -641,7 +644,7 @@
|
|||
} else {
|
||||
Dashboard.navigate(link.href);
|
||||
}
|
||||
}, delay);
|
||||
}, getNavigateDelay());
|
||||
|
||||
}, 50);
|
||||
}
|
||||
|
@ -657,12 +660,9 @@
|
|||
|
||||
closeMainDrawer();
|
||||
|
||||
// On mobile devices don't navigate until after the closing animation has completed or it may stutter
|
||||
var delay = browserInfo.mobile ? 350 : 200;
|
||||
|
||||
setTimeout(function () {
|
||||
Dashboard.logout();
|
||||
}, delay);
|
||||
}, getNavigateDelay());
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
define(['scripts/livetvcomponents'], function () {
|
||||
define(['scripts/livetvcomponents', 'emby-button'], function () {
|
||||
|
||||
function getRecordingGroupHtml(group) {
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
|||
|
||||
html += '<paper-icon-item>';
|
||||
|
||||
html += '<paper-fab mini class="blue" icon="live-tv" item-icon></paper-fab>';
|
||||
html += '<button type="button" is="emby-button" class="fab mini autoSize blue" item-icon><i class="md-icon">live_tv</i></button>';
|
||||
|
||||
html += '<paper-item-body two-line>';
|
||||
html += '<a href="livetvrecordinglist.html?groupid=' + group.Id + '" class="clearLink">';
|
||||
|
@ -177,7 +177,7 @@
|
|||
|
||||
}).then(function (result) {
|
||||
|
||||
require(['paper-fab', 'paper-item-body', 'paper-icon-item'], function () {
|
||||
require(['paper-item-body', 'paper-icon-item'], function () {
|
||||
renderRecordingGroups(context, result.Items);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
define(['datetime', 'paper-icon-button-light'], function (datetime) {
|
||||
define(['datetime', 'paper-icon-button-light', 'emby-button', 'listViewStyle'], function (datetime) {
|
||||
|
||||
var query = {
|
||||
|
||||
|
@ -38,18 +38,17 @@
|
|||
|
||||
var timer = timers[i];
|
||||
|
||||
html += '<paper-icon-item>';
|
||||
html += '<div class="listItem">';
|
||||
|
||||
html += '<paper-fab mini icon="live-tv" item-icon></paper-fab>';
|
||||
html += '<button type="button" is="emby-button" class="fab mini autoSize blue" item-icon><i class="md-icon">live_tv</i></button>';
|
||||
|
||||
html += '<paper-item-body three-line>';
|
||||
html += '<div class="listItemBody">';
|
||||
html += '<a class="clearLink" href="livetvseriestimer.html?id=' + timer.Id + '">';
|
||||
|
||||
html += '<div>';
|
||||
html += '<h3>';
|
||||
html += timer.Name;
|
||||
html += '</div>';
|
||||
html += '</h3>';
|
||||
|
||||
html += '<div secondary>';
|
||||
html += '<div class="secondary">';
|
||||
if (timer.DayPattern) {
|
||||
html += timer.DayPattern;
|
||||
}
|
||||
|
@ -67,7 +66,7 @@
|
|||
}
|
||||
html += '</div>';
|
||||
|
||||
html += '<div secondary>';
|
||||
html += '<div class="secondary">';
|
||||
if (timer.RecordAnyChannel) {
|
||||
html += Globalize.translate('LabelAllChannels');
|
||||
}
|
||||
|
@ -75,13 +74,13 @@
|
|||
html += timer.ChannelName;
|
||||
}
|
||||
html += '</div>';
|
||||
html += '</a>';
|
||||
|
||||
html += '</paper-item-body>';
|
||||
html += '</a>';
|
||||
html += '</div>';
|
||||
|
||||
html += '<button type="button" is="paper-icon-button-light" data-seriestimerid="' + timer.Id + '" title="' + Globalize.translate('ButtonCancelSeries') + '" class="btnCancelSeries autoSize"><i class="md-icon">cancel</i></button>';
|
||||
|
||||
html += '</paper-icon-item>';
|
||||
html += '</div>';
|
||||
}
|
||||
|
||||
if (timers.length) {
|
||||
|
@ -123,9 +122,7 @@
|
|||
|
||||
ApiClient.getLiveTvSeriesTimers(query).then(function (result) {
|
||||
|
||||
require(['paper-fab', 'paper-item-body', 'paper-icon-item'], function () {
|
||||
renderTimers(context, result.Items);
|
||||
});
|
||||
renderTimers(context, result.Items);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
define(['jQuery'], function ($) {
|
||||
define(['scripts/userpasswordpage'], function (Userpasswordpage) {
|
||||
|
||||
var currentFile;
|
||||
|
||||
|
@ -10,8 +10,10 @@
|
|||
|
||||
ApiClient.getUser(userId).then(function (user) {
|
||||
|
||||
$('.username', page).html(user.Name);
|
||||
$('#uploadUserImage', page).val('').trigger('change');
|
||||
page.querySelector('.username').innerHTML = user.Name;
|
||||
var uploadUserImage = page.querySelector('#uploadUserImage');
|
||||
uploadUserImage.value = '';
|
||||
uploadUserImage.dispatchEvent(new CustomEvent('change', {}));
|
||||
|
||||
Dashboard.setPageTitle(user.Name);
|
||||
|
||||
|
@ -29,34 +31,34 @@
|
|||
imageUrl = "css/images/logindefault.png";
|
||||
}
|
||||
|
||||
$('#fldImage', page).show().html('').html("<img width='140px' src='" + imageUrl + "' />");
|
||||
var fldImage = page.querySelector('#fldImage');
|
||||
fldImage.classList.remove('hide');
|
||||
fldImage.innerHTML = "<img width='140px' src='" + imageUrl + "' />";
|
||||
|
||||
var showImageEditing = false;
|
||||
|
||||
if (user.ConnectLinkType == 'Guest') {
|
||||
|
||||
$('.connectMessage', page).show();
|
||||
page.querySelector('.connectMessage').classList.remove('hide');
|
||||
}
|
||||
else if (user.PrimaryImageTag) {
|
||||
|
||||
$('#headerUploadNewImage', page).show();
|
||||
showImageEditing = true;
|
||||
$('.connectMessage', page).hide();
|
||||
page.querySelector('.connectMessage').classList.add('hide');
|
||||
|
||||
} else {
|
||||
showImageEditing = true;
|
||||
$('#headerUploadNewImage', page).show();
|
||||
$('.connectMessage', page).hide();
|
||||
page.querySelector('.connectMessage').classList.add('hide');
|
||||
}
|
||||
|
||||
Dashboard.getCurrentUser().then(function (loggedInUser) {
|
||||
|
||||
if (showImageEditing && AppInfo.supportsFileInput && (loggedInUser.Policy.IsAdministrator || user.Policy.EnableUserPreferenceAccess)) {
|
||||
$('.newImageForm', page).show();
|
||||
$('#btnDeleteImage', page).removeClass('hide');
|
||||
page.querySelector('.newImageForm').classList.remove('hide');
|
||||
page.querySelector('#btnDeleteImage').classList.remove('hide');
|
||||
} else {
|
||||
$('.newImageForm', page).hide();
|
||||
$('#btnDeleteImage', page).addClass('hide');
|
||||
page.querySelector('.newImageForm').classList.add('hide');
|
||||
page.querySelector('#btnDeleteImage').classList.add('hide');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -105,8 +107,8 @@
|
|||
var file = files[0];
|
||||
|
||||
if (!file || !file.type.match('image.*')) {
|
||||
$('#userImageOutput', page).html('');
|
||||
$('#fldUpload', page).hide();
|
||||
page.querySelector('#userImageOutput').innerHTML = '';
|
||||
page.querySelector('#fldUpload').classList.add('hide');
|
||||
currentFile = null;
|
||||
return;
|
||||
}
|
||||
|
@ -117,7 +119,7 @@
|
|||
|
||||
reader.onerror = onFileReaderError;
|
||||
reader.onloadstart = function () {
|
||||
$('#fldUpload', page).hide();
|
||||
page.querySelector('#fldUpload').classList.add('hide');
|
||||
};
|
||||
reader.onabort = onFileReaderAbort;
|
||||
|
||||
|
@ -127,8 +129,8 @@
|
|||
// Render thumbnail.
|
||||
var html = ['<img style="max-width:500px;max-height:200px;" src="', e.target.result, '" title="', escape(file.name), '"/>'].join('');
|
||||
|
||||
$('#userImageOutput', page).html(html);
|
||||
$('#fldUpload', page).show();
|
||||
page.querySelector('#userImageOutput').innerHTML = html;
|
||||
page.querySelector('#fldUpload').classList.remove('hide');
|
||||
};
|
||||
|
||||
// Read in the image file as a data URL.
|
||||
|
@ -144,22 +146,24 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
$(document).on('pageinit', "#userImagePage", function () {
|
||||
return function (view, params) {
|
||||
|
||||
var page = this;
|
||||
reloadUser(view);
|
||||
|
||||
reloadUser(page);
|
||||
var userpasswordpage = new Userpasswordpage(view, params);
|
||||
|
||||
$("#userImageDropZone", page).on('dragover', onImageDragOver).on('drop', function (e) {
|
||||
var userImageDropZone = view.querySelector('#userImageDropZone');
|
||||
userImageDropZone.addEventListener('dragOver', onImageDragOver);
|
||||
userImageDropZone.addEventListener('drop', function (e) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
setFiles(page, e.originalEvent.dataTransfer.files);
|
||||
setFiles(view, e.originalEvent.dataTransfer.files);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#btnDeleteImage', page).on('click', function () {
|
||||
view.querySelector('#btnDeleteImage').addEventListener('click', function () {
|
||||
|
||||
require(['confirm'], function (confirm) {
|
||||
|
||||
|
@ -173,285 +177,41 @@
|
|||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
reloadUser(page);
|
||||
reloadUser(view);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('.newImageForm').on('submit', function () {
|
||||
view.querySelector('.newImageForm').addEventListener('submit', function (e) {
|
||||
|
||||
var self = this;
|
||||
|
||||
self.onImageSubmit = function () {
|
||||
|
||||
var file = currentFile;
|
||||
|
||||
if (!file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/jpeg") {
|
||||
return false;
|
||||
}
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
var userId = getParameterByName("userId");
|
||||
|
||||
ApiClient.uploadUserImage(userId, 'Primary', file).then(function () {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
reloadUser(page);
|
||||
});
|
||||
var file = currentFile;
|
||||
|
||||
if (!file) {
|
||||
return false;
|
||||
};
|
||||
});
|
||||
|
||||
page.querySelector('#uploadUserImage').addEventListener('change', function (e) {
|
||||
setFiles(page, e.target.files);
|
||||
});
|
||||
});
|
||||
|
||||
function loadUser(page) {
|
||||
|
||||
var userid = getParameterByName("userId");
|
||||
|
||||
ApiClient.getUser(userid).then(function (user) {
|
||||
|
||||
Dashboard.getCurrentUser().then(function (loggedInUser) {
|
||||
|
||||
Dashboard.setPageTitle(user.Name);
|
||||
|
||||
var showPasswordSection = true;
|
||||
var showLocalAccessSection = false;
|
||||
if (user.ConnectLinkType == 'Guest') {
|
||||
$('.localAccessSection', page).hide();
|
||||
showPasswordSection = false;
|
||||
}
|
||||
else if (user.HasConfiguredPassword) {
|
||||
$('#btnResetPassword', page).show();
|
||||
$('#fldCurrentPassword', page).show();
|
||||
showLocalAccessSection = true;
|
||||
} else {
|
||||
$('#btnResetPassword', page).hide();
|
||||
$('#fldCurrentPassword', page).hide();
|
||||
}
|
||||
|
||||
if (showPasswordSection && (loggedInUser.Policy.IsAdministrator || user.Policy.EnableUserPreferenceAccess)) {
|
||||
$('.passwordSection', page).show();
|
||||
} else {
|
||||
$('.passwordSection', page).hide();
|
||||
}
|
||||
|
||||
if (showLocalAccessSection && (loggedInUser.Policy.IsAdministrator || user.Policy.EnableUserPreferenceAccess)) {
|
||||
$('.localAccessSection', page).show();
|
||||
} else {
|
||||
$('.localAccessSection', page).hide();
|
||||
}
|
||||
|
||||
if (user.HasConfiguredEasyPassword) {
|
||||
$('#txtEasyPassword', page).val('').attr('placeholder', '******');
|
||||
$('#btnResetEasyPassword', page).removeClass('hide');
|
||||
} else {
|
||||
$('#txtEasyPassword', page).val('').attr('placeholder', '');
|
||||
$('#btnResetEasyPassword', page).addClass('hide');
|
||||
}
|
||||
|
||||
page.querySelector('.chkEnableLocalEasyPassword').checked = user.Configuration.EnableLocalPassword;
|
||||
});
|
||||
});
|
||||
|
||||
$('#txtCurrentPassword', page).val('');
|
||||
$('#txtNewPassword', page).val('');
|
||||
$('#txtNewPasswordConfirm', page).val('');
|
||||
}
|
||||
|
||||
function saveEasyPassword(page) {
|
||||
|
||||
var userId = getParameterByName("userId");
|
||||
|
||||
var easyPassword = $('#txtEasyPassword', page).val();
|
||||
|
||||
if (easyPassword) {
|
||||
|
||||
ApiClient.updateEasyPassword(userId, easyPassword).then(function () {
|
||||
|
||||
onEasyPasswordSaved(page, userId);
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
onEasyPasswordSaved(page, userId);
|
||||
}
|
||||
}
|
||||
|
||||
function onEasyPasswordSaved(page, userId) {
|
||||
|
||||
ApiClient.getUser(userId).then(function (user) {
|
||||
|
||||
user.Configuration.EnableLocalPassword = page.querySelector('.chkEnableLocalEasyPassword').checked;
|
||||
|
||||
ApiClient.updateUserConfiguration(user.Id, user.Configuration).then(function () {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
require(['toast'], function (toast) {
|
||||
toast(Globalize.translate('MessageSettingsSaved'));
|
||||
});
|
||||
loadUser(page);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function savePassword(page) {
|
||||
|
||||
var userId = getParameterByName("userId");
|
||||
|
||||
var currentPassword = page.querySelector('#txtCurrentPassword').value;
|
||||
var newPassword = page.querySelector('#txtNewPassword').value;
|
||||
|
||||
ApiClient.updateUserPassword(userId, currentPassword, newPassword).then(function () {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
require(['toast'], function (toast) {
|
||||
toast(Globalize.translate('PasswordSaved'));
|
||||
});
|
||||
loadUser(page);
|
||||
|
||||
}, function () {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
Dashboard.alert({
|
||||
title: Globalize.translate('HeaderLoginFailure'),
|
||||
message: Globalize.translate('MessageInvalidUser')
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function updatePasswordPage() {
|
||||
|
||||
var self = this;
|
||||
|
||||
self.onSubmit = function () {
|
||||
|
||||
var form = this;
|
||||
var page = $(form).parents('.page')[0];
|
||||
|
||||
if (page.querySelector('#txtNewPassword').value != page.querySelector('#txtNewPasswordConfirm').value) {
|
||||
|
||||
require(['toast'], function (toast) {
|
||||
toast(Globalize.translate('PasswordMatchError'));
|
||||
});
|
||||
} else {
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
savePassword(page);
|
||||
}
|
||||
|
||||
|
||||
// Disable default form submission
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
self.onLocalAccessSubmit = function () {
|
||||
|
||||
var form = this;
|
||||
var page = $(form).parents('.page')[0];
|
||||
if (file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/jpeg") {
|
||||
return false;
|
||||
}
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
saveEasyPassword(page);
|
||||
var userId = getParameterByName("userId");
|
||||
|
||||
// Disable default form submission
|
||||
ApiClient.uploadUserImage(userId, 'Primary', file).then(function () {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
reloadUser(view);
|
||||
});
|
||||
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
self.resetPassword = function () {
|
||||
|
||||
var msg = Globalize.translate('PasswordResetConfirmation');
|
||||
|
||||
var page = $($.mobile.activePage)[0];
|
||||
|
||||
require(['confirm'], function (confirm) {
|
||||
|
||||
confirm(msg, Globalize.translate('PasswordResetHeader')).then(function () {
|
||||
|
||||
var userId = getParameterByName("userId");
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
ApiClient.resetUserPassword(userId).then(function () {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
Dashboard.alert({
|
||||
message: Globalize.translate('PasswordResetComplete'),
|
||||
title: Globalize.translate('PasswordResetHeader')
|
||||
});
|
||||
|
||||
loadUser(page);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
self.resetEasyPassword = function () {
|
||||
|
||||
var msg = Globalize.translate('PinCodeResetConfirmation');
|
||||
|
||||
var page = $($.mobile.activePage)[0];
|
||||
|
||||
require(['confirm'], function (confirm) {
|
||||
|
||||
confirm(msg, Globalize.translate('HeaderPinCodeReset')).then(function () {
|
||||
|
||||
var userId = getParameterByName("userId");
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
ApiClient.resetEasyPassword(userId).then(function () {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
Dashboard.alert({
|
||||
message: Globalize.translate('PinCodeResetComplete'),
|
||||
title: Globalize.translate('HeaderPinCodeReset')
|
||||
});
|
||||
|
||||
loadUser(page);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
window.UpdatePasswordPage = new updatePasswordPage();
|
||||
|
||||
$(document).on('pageinit', ".userPasswordPage", function () {
|
||||
|
||||
var page = this;
|
||||
|
||||
$('.updatePasswordForm').off('submit', UpdatePasswordPage.onSubmit).on('submit', UpdatePasswordPage.onSubmit);
|
||||
$('.localAccessForm').off('submit', UpdatePasswordPage.onLocalAccessSubmit).on('submit', UpdatePasswordPage.onLocalAccessSubmit);
|
||||
|
||||
}).on('pageshow', ".userPasswordPage", function () {
|
||||
|
||||
var page = this;
|
||||
|
||||
loadUser(page);
|
||||
|
||||
});
|
||||
|
||||
view.querySelector('#uploadUserImage').addEventListener('change', function (e) {
|
||||
setFiles(view, e.target.files);
|
||||
});
|
||||
};
|
||||
});
|
|
@ -2771,9 +2771,10 @@ var AppInfo = {};
|
|||
|
||||
defineRoute({
|
||||
path: '/myprofile.html',
|
||||
dependencies: ['emby-button'],
|
||||
dependencies: ['emby-button', 'emby-collapsible', 'emby-checkbox', 'emby-input'],
|
||||
autoFocus: false,
|
||||
transition: 'fade'
|
||||
transition: 'fade',
|
||||
controller: 'scripts/myprofile'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
|
@ -2998,8 +2999,9 @@ var AppInfo = {};
|
|||
|
||||
defineRoute({
|
||||
path: '/userpassword.html',
|
||||
dependencies: [],
|
||||
autoFocus: false
|
||||
dependencies: ['emby-input', 'emby-button', 'emby-checkbox'],
|
||||
autoFocus: false,
|
||||
controller: 'scripts/userpasswordpage'
|
||||
});
|
||||
|
||||
defineRoute({
|
||||
|
|
|
@ -228,7 +228,7 @@
|
|||
|
||||
function showSyncMenuInternal(options) {
|
||||
|
||||
require(['dialogHelper', 'paper-fab'], function (dialogHelper) {
|
||||
require(['dialogHelper'], function (dialogHelper) {
|
||||
|
||||
var userId = Dashboard.getCurrentUserId();
|
||||
|
||||
|
|
226
dashboard-ui/scripts/userpasswordpage.js
Normal file
226
dashboard-ui/scripts/userpasswordpage.js
Normal file
|
@ -0,0 +1,226 @@
|
|||
define([], function () {
|
||||
|
||||
function loadUser(page, params) {
|
||||
|
||||
var userid = params.userId;
|
||||
|
||||
ApiClient.getUser(userid).then(function (user) {
|
||||
|
||||
Dashboard.getCurrentUser().then(function (loggedInUser) {
|
||||
|
||||
Dashboard.setPageTitle(user.Name);
|
||||
|
||||
var showPasswordSection = true;
|
||||
var showLocalAccessSection = false;
|
||||
if (user.ConnectLinkType == 'Guest') {
|
||||
page.querySelector('.localAccessSection').classList.add('hide');
|
||||
showPasswordSection = false;
|
||||
}
|
||||
else if (user.HasConfiguredPassword) {
|
||||
page.querySelector('#btnResetPassword').classList.remove('hide');
|
||||
page.querySelector('#fldCurrentPassword').classList.remove('hide');
|
||||
showLocalAccessSection = true;
|
||||
} else {
|
||||
page.querySelector('#btnResetPassword').classList.add('hide');
|
||||
page.querySelector('#fldCurrentPassword').classList.add('hide');
|
||||
}
|
||||
|
||||
if (showPasswordSection && (loggedInUser.Policy.IsAdministrator || user.Policy.EnableUserPreferenceAccess)) {
|
||||
page.querySelector('.passwordSection').classList.remove('hide');
|
||||
} else {
|
||||
page.querySelector('.passwordSection').classList.add('hide');
|
||||
}
|
||||
|
||||
if (showLocalAccessSection && (loggedInUser.Policy.IsAdministrator || user.Policy.EnableUserPreferenceAccess)) {
|
||||
page.querySelector('.localAccessSection').classList.remove('hide');
|
||||
} else {
|
||||
page.querySelector('.localAccessSection').classList.add('hide');
|
||||
}
|
||||
|
||||
var txtEasyPassword = page.querySelector('#txtEasyPassword');
|
||||
txtEasyPassword.value = '';
|
||||
|
||||
if (user.HasConfiguredEasyPassword) {
|
||||
txtEasyPassword.placeholder = '******';
|
||||
page.querySelector('#btnResetEasyPassword').classList.remove('hide');
|
||||
} else {
|
||||
txtEasyPassword.removeAttribute('placeholder');
|
||||
txtEasyPassword.placeholder = '';
|
||||
page.querySelector('#btnResetEasyPassword').classList.add('hide');
|
||||
}
|
||||
|
||||
page.querySelector('.chkEnableLocalEasyPassword').checked = user.Configuration.EnableLocalPassword;
|
||||
});
|
||||
});
|
||||
|
||||
page.querySelector('#txtCurrentPassword').value = '';
|
||||
page.querySelector('#txtNewPassword').value = '';
|
||||
page.querySelector('#txtNewPasswordConfirm').value = '';
|
||||
}
|
||||
|
||||
return function (view, params) {
|
||||
|
||||
function saveEasyPassword() {
|
||||
|
||||
var userId = params.userId;
|
||||
|
||||
var easyPassword = view.querySelector('#txtEasyPassword').value;
|
||||
|
||||
if (easyPassword) {
|
||||
|
||||
ApiClient.updateEasyPassword(userId, easyPassword).then(function () {
|
||||
|
||||
onEasyPasswordSaved(userId);
|
||||
|
||||
});
|
||||
|
||||
} else {
|
||||
onEasyPasswordSaved(userId);
|
||||
}
|
||||
}
|
||||
|
||||
function onEasyPasswordSaved(userId) {
|
||||
|
||||
ApiClient.getUser(userId).then(function (user) {
|
||||
|
||||
user.Configuration.EnableLocalPassword = view.querySelector('.chkEnableLocalEasyPassword').checked;
|
||||
|
||||
ApiClient.updateUserConfiguration(user.Id, user.Configuration).then(function () {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
require(['toast'], function (toast) {
|
||||
toast(Globalize.translate('MessageSettingsSaved'));
|
||||
});
|
||||
loadUser(view, params);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function savePassword() {
|
||||
|
||||
var userId = getParameterByName("userId");
|
||||
|
||||
var currentPassword = view.querySelector('#txtCurrentPassword').value;
|
||||
var newPassword = view.querySelector('#txtNewPassword').value;
|
||||
|
||||
ApiClient.updateUserPassword(userId, currentPassword, newPassword).then(function () {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
require(['toast'], function (toast) {
|
||||
toast(Globalize.translate('PasswordSaved'));
|
||||
});
|
||||
loadUser(view, params);
|
||||
|
||||
}, function () {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
Dashboard.alert({
|
||||
title: Globalize.translate('HeaderLoginFailure'),
|
||||
message: Globalize.translate('MessageInvalidUser')
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function onSubmit(e) {
|
||||
|
||||
var form = this;
|
||||
|
||||
if (form.querySelector('#txtNewPassword').value != form.querySelector('#txtNewPasswordConfirm').value) {
|
||||
|
||||
require(['toast'], function (toast) {
|
||||
toast(Globalize.translate('PasswordMatchError'));
|
||||
});
|
||||
} else {
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
savePassword();
|
||||
}
|
||||
|
||||
// Disable default form submission
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
function onLocalAccessSubmit(e) {
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
saveEasyPassword();
|
||||
|
||||
// Disable default form submission
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
||||
function resetPassword() {
|
||||
|
||||
var msg = Globalize.translate('PasswordResetConfirmation');
|
||||
|
||||
require(['confirm'], function (confirm) {
|
||||
|
||||
confirm(msg, Globalize.translate('PasswordResetHeader')).then(function () {
|
||||
|
||||
var userId = getParameterByName("userId");
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
ApiClient.resetUserPassword(userId).then(function () {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
Dashboard.alert({
|
||||
message: Globalize.translate('PasswordResetComplete'),
|
||||
title: Globalize.translate('PasswordResetHeader')
|
||||
});
|
||||
|
||||
loadUser(view, params);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function resetEasyPassword() {
|
||||
|
||||
var msg = Globalize.translate('PinCodeResetConfirmation');
|
||||
|
||||
require(['confirm'], function (confirm) {
|
||||
|
||||
confirm(msg, Globalize.translate('HeaderPinCodeReset')).then(function () {
|
||||
|
||||
var userId = getParameterByName("userId");
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
ApiClient.resetEasyPassword(userId).then(function () {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
|
||||
Dashboard.alert({
|
||||
message: Globalize.translate('PinCodeResetComplete'),
|
||||
title: Globalize.translate('HeaderPinCodeReset')
|
||||
});
|
||||
|
||||
loadUser(view, params);
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
view.querySelector('.updatePasswordForm').addEventListener('submit', onSubmit);
|
||||
view.querySelector('.localAccessForm').addEventListener('submit', onLocalAccessSubmit);
|
||||
|
||||
view.querySelector('#btnResetEasyPassword').addEventListener('click', resetEasyPassword);
|
||||
view.querySelector('#btnResetPassword').addEventListener('click', resetPassword);
|
||||
|
||||
view.addEventListener('viewshow', function () {
|
||||
loadUser(view, params);
|
||||
});
|
||||
};
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue