Rev 29209 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(function() {$(document).on('click', ".add-auth-user", function() {console.log("Add Auth User clicked......");loadAddAuthUser("main-content");});$(document).on('click', ".change-auth-user-password", function() {console.log("change auth user password clicked......");loadChangeAuthUserPassword("main-content");});$(document).on('click', ".mk_gmail_edit",function() {var $that = $(this);bootbox.prompt("New Gmail Id",function(result) {if (result&& result.indexOf('@gmail.com') > 0) {doGetAjaxRequestHandler(context+ "/authuser/edit?emailId="+ $that.data("id")+ "&gmailId="+ result,function(response) {if (response == "true") {bootbox.alert("Gmail Id updated successfully");$that.closest('td').find('span').html(result);$that.closest('td').find('button').html('Edit');return;}});} else {bootbox.alert("Gmail id is required");}});});$(document).on('click', ".img_edit",function() {var $that = $(this);bootbox.prompt("New Image Url",function(result) {if (result) {doGetAjaxRequestHandler(context+ "/authuser/editImageUrl?emailId="+ $that.data("id")+ "&imageUrl="+ result,function(response) {if (response == "true") {bootbox.alert("Image Url updated successfully");$that.closest('td').find('span').html(result);$that.closest('td').find('button').html('Edit');return;}});} else {bootbox.alert("Image url is required");}});});$(document).on('click', ".reset-password",function() {console.log("reset-password clicked......");var emailId = $(this).data('id');console.log(emailId);if (confirm("Are you sure you want to reset password of Auth userEmail=!"+ emailId) == true) {resetAuthUserPassword("main-content", emailId);}});$(document).on('click', ".remove-user",function() {console.log("heelo");var $that = $(this);if (confirm("Are you sure you want to remove the user")) {doPostAjaxRequestHandler(context + "/authuser/remove?id="+ $that.data("id"), function(response) {if (response == "true") {alert("Remove User Successfully");loadAddAuthUser("main-content");}});}});$(document).on('click', ".change-password",function() {console.log("change-password button clicked......");var oldPassword = $("#currentPassword").val();var newPassword = $("#newPassword").val();var confirmPassword = $("#confirmPassword").val();if (oldPassword == "" || oldPassword == null|| oldPassword == undefined) {alert("oldPassword cann't be blank");return;}if (newPassword == "" || newPassword == null|| newPassword == undefined) {alert("lastName cann't be blank");return;}if (confirmPassword == "" || confirmPassword == null|| confirmPassword == undefined) {alert("confirmPassword cann't be blank");return;}if (confirmPassword == newPassword) {if (confirm("Are you sure you want to change user password!") == true) {changeAuthUserPassword(oldPassword, newPassword);}} else {alert("new Password and confirm Password must be match");}});$(document).on('click', ".create-auth-user",function() {console.log("Create Auth User button clicked......");var emailId = $("#authUserEmail").val();var firstName = $("#authUserFirstName").val();var lastName = $("#authUserLastName").val();var mobileNumber = $("#authUserMobileNumber").val();var gmailId = $("#authUserGmailId").val();var employeeCode = $("#authUserEmployeeCode").val();var imageUrl=$("#authUserImage").val();if (emailId == "" || emailId == null|| emailId == undefined) {alert("emailId cann't be blank");return;}if (gmailId == "" || gmailId == null|| gmailId == undefined) {gmailId = null;}validateEmail(emailId);if (firstName == "" || firstName == null|| firstName == undefined) {alert("firstName can't be blank");return;}if (lastName == "" || lastName == null|| lastName == undefined) {alert("lastName can't be blank");return;}if (employeeCode == "" || employeeCode == null|| employeeCode == undefined) {alert("Employee Code can't be blank");return;}if (mobileNumber == "" || mobileNumber == null|| mobileNumber == undefined) {alert("mobileNumber can't be blank");return;}if (mobileNumber.length != 10) {alert("required 10 digits, match requested format!");return;}if (confirm("Are you sure you want to create Auth user!") == true) {addAuthUser(emailId, firstName, lastName,mobileNumber, gmailId, employeeCode,imageUrl);}});$(document).on('click', "#authUsers-paginated .next",function() {loadPaginatedNextItems('/getPaginatedAuthUser', null,'authUsers-paginated', 'auth-user-table','auth-user-details-container');$(this).blur();});$(document).on('click', ".add-manager",function() {var row = $(this).closest("tr");var authId = $(this).data("id");console.log("authId"+authId);var managerId = $(row).find("#auth-users option:selected").val();console.log("managerId"+managerId);doPostAjaxRequestHandler(context + "/addManagerId?authId="+ authId + "&managerId=" + managerId, function(response) {if (response == "true") {alert("Add Manager Successfully");loadAddAuthUser("main-content");}});});$(document).on('click', "#authUsers-paginated .previous",function() {loadPaginatedPreviousItems('/getPaginatedAuthUser', null,'authUsers-paginated', 'auth-user-table','auth-user-details-container');$(this).blur();});});function loadChangeAuthUserPassword(domId) {doGetAjaxRequestHandler(context + "/changePassword", function(response) {$('#' + domId).html(response);});}function changeAuthUserPassword(oldPassword, newPassword) {var params = {"oldPassword": oldPassword,"newPassword": newPassword}doPostAjaxRequestWithParamsHandler(context + "/changePassword", params,function(response) {alert("Password changed successfully");loadChangeAuthUserPassword("main-content");});}function addAuthUser(emailId, firstName, lastName, mobileNumber, gmailId, employeeCode, imageUrl) {var params = {"emailId": emailId,"firstName": firstName,"lastName": lastName,"mobileNumber": mobileNumber,"gmailId": gmailId,"employeeCode": employeeCode,"imageUrl":imageUrl}doPostAjaxRequestWithParamsHandler(context + "/createAuthUser",params,function(response) {alert("User successfully added! Password sent to registered email="+ emailId);$('#' + "main-content").html(response);});}function loadAddAuthUser(domId) {doGetAjaxRequestHandler(context + "/createAuthUser", function(response) {$('#' + domId).html(response);});}function resetAuthUserPassword(domId, emailId) {var params = {"emailId": emailId}doAjaxRequestWithParamsHandler(context + "/forgetPassword", "POST", params,function(response) {if (response == "true") {alert("Password send to " + emailId + " Successfully ");loadAddAuthUser(domId);}});}function validateEmail(emailField) {var reg = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;if (reg.test(emailField) == false) {alert('Invalid Email Address');return false;}return true;}