Initial Commit

The initial public commit of MVGL website code.
This commit is contained in:
Jimmy B. 2024-01-14 13:51:43 -06:00
commit b39ecf1638
2043 changed files with 215154 additions and 0 deletions

View file

@ -0,0 +1,178 @@
"use strict";
// Class definition
var KTAccountSettingsProfileDetails = function () {
// Private variables
var form;
var submitButton;
var validation;
// Private functions
var initValidation = function () {
// Init form validation rules. For more info check the FormValidation plugin's official documentation: https://formvalidation.io/
validation = FormValidation.formValidation(
form,
{
fields: {
first_name: {
validators: {
notEmpty: {
message: 'First name is required'
}
}
},
last_name: {
validators: {
notEmpty: {
message: 'Last name is required'
}
}
},
phone: {
validators: {
notEmpty: {
message: 'Contact phone number is required'
}
}
},
country: {
validators: {
notEmpty: {
message: 'Please select a country'
}
}
},
timezone: {
validators: {
notEmpty: {
message: 'Please select a timezone'
}
}
},
language: {
validators: {
notEmpty: {
message: 'Please select a language'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Select2 validation integration
$(form.querySelector('[name="country"]')).on('change', function () {
// Revalidate the color field when an option is chosen
validation.revalidateField('country');
});
$(form.querySelector('[name="language"]')).on('change', function () {
// Revalidate the color field when an option is chosen
validation.revalidateField('language');
});
$(form.querySelector('[name="timezone"]')).on('change', function () {
// Revalidate the color field when an option is chosen
validation.revalidateField('timezone');
});
}
var handleForm = function () {
submitButton.addEventListener('click', function (e) {
e.preventDefault();
// Validate form
validation.validate().then(function (status) {
if (status === 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Send ajax request
axios.post(submitButton.closest('form').getAttribute('action'), new FormData(form))
.then(function (response) {
// Show message popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Thank you! You've updated your basic info",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
}
});
})
.catch(function (error) {
let dataMessage = error.response.data.message;
let dataErrors = error.response.data.errors;
for (const errorsKey in dataErrors) {
if (!dataErrors.hasOwnProperty(errorsKey)) continue;
dataMessage += "\r\n" + dataErrors[errorsKey];
}
if (error.response) {
Swal.fire({
text: dataMessage,
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
})
.then(function () {
// always executed
// Hide loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
});
} else {
// Show error popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
});
}
// Public methods
return {
init: function () {
form = document.getElementById('kt_account_profile_details_form');
submitButton = form.querySelector('#kt_account_profile_details_submit');
initValidation();
handleForm();
}
}
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTAccountSettingsProfileDetails.init();
});

View file

@ -0,0 +1,296 @@
"use strict";
// Class definition
var KTAccountSettingsSigninMethods = function () {
// Private functions
var initSettings = function () {
// UI elements
var signInMainEl = document.getElementById('kt_signin_email');
var signInEditEl = document.getElementById('kt_signin_email_edit');
var passwordMainEl = document.getElementById('kt_signin_password');
var passwordEditEl = document.getElementById('kt_signin_password_edit');
// button elements
var signInChangeEmail = document.getElementById('kt_signin_email_button');
var signInCancelEmail = document.getElementById('kt_signin_cancel');
var passwordChange = document.getElementById('kt_signin_password_button');
var passwordCancel = document.getElementById('kt_password_cancel');
// toggle UI
signInChangeEmail.querySelector('button').addEventListener('click', function () {
toggleChangeEmail();
});
signInCancelEmail.addEventListener('click', function () {
toggleChangeEmail();
});
passwordChange.querySelector('button').addEventListener('click', function () {
toggleChangePassword();
});
passwordCancel.addEventListener('click', function () {
toggleChangePassword();
});
var toggleChangeEmail = function () {
signInMainEl.classList.toggle('d-none');
signInChangeEmail.classList.toggle('d-none');
signInEditEl.classList.toggle('d-none');
}
var toggleChangePassword = function () {
passwordMainEl.classList.toggle('d-none');
passwordChange.classList.toggle('d-none');
passwordEditEl.classList.toggle('d-none');
}
}
var handleChangeEmail = function (e) {
var validation;
// form elements
var form = document.getElementById('kt_signin_change_email');
var submitButton = form.querySelector('#kt_signin_submit');
validation = FormValidation.formValidation(
form,
{
fields: {
email: {
validators: {
notEmpty: {
message: 'Email is required'
},
emailAddress: {
message: 'The value is not a valid email address'
}
}
},
password: {
validators: {
notEmpty: {
message: 'Password is required'
}
}
}
},
plugins: { //Learn more: https://formvalidation.io/guide/plugins
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row'
})
}
}
);
submitButton.addEventListener('click', function (e) {
e.preventDefault();
validation.validate().then(function (status) {
if (status === 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Send ajax request
axios.post(form.getAttribute('action'), new FormData(form))
.then(function (response) {
// Show message popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Your email has been successfully changed.",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn font-weight-bold btn-light-primary"
}
});
})
.catch(function (error) {
let dataMessage = error.response.data.message;
let dataErrors = error.response.data.errors;
for (const errorsKey in dataErrors) {
if (!dataErrors.hasOwnProperty(errorsKey)) continue;
dataMessage += "\r\n" + dataErrors[errorsKey];
}
if (error.response) {
Swal.fire({
text: dataMessage,
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
})
.then(function () {
// always executed
// Hide loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
});
} else {
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn font-weight-bold btn-light-primary"
}
});
}
});
});
}
var handleChangePassword = function (e) {
var validation;
// form elements
var form = document.getElementById('kt_signin_change_password');
var submitButton = form.querySelector('#kt_password_submit');
validation = FormValidation.formValidation(
form,
{
fields: {
current_password: {
validators: {
notEmpty: {
message: 'Current Password is required'
}
}
},
password: {
validators: {
notEmpty: {
message: 'New Password is required'
}
}
},
password_confirmation: {
validators: {
notEmpty: {
message: 'Confirm Password is required'
},
identical: {
compare: function () {
return form.querySelector('[name="password"]').value;
},
message: 'The password and its confirm are not the same'
}
}
},
},
plugins: { //Learn more: https://formvalidation.io/guide/plugins
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row'
})
}
}
);
submitButton.addEventListener('click', function (e) {
e.preventDefault();
validation.validate().then(function (status) {
if (status == 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Send ajax request
axios.post(form.getAttribute('action'), new FormData(form))
.then(function (response) {
// Show message popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Your password has been successfully reset.",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn font-weight-bold btn-light-primary"
}
});
})
.catch(function (error) {
let dataMessage = error.response.data.message;
let dataErrors = error.response.data.errors;
for (const errorsKey in dataErrors) {
if (!dataErrors.hasOwnProperty(errorsKey)) continue;
dataMessage += "\r\n" + dataErrors[errorsKey];
}
if (error.response) {
Swal.fire({
text: dataMessage,
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
})
.then(function () {
// always executed
// Hide loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
});
} else {
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn font-weight-bold btn-light-primary"
}
});
}
});
});
}
// Public methods
return {
init: function () {
initSettings();
handleChangeEmail();
handleChangePassword();
}
}
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTAccountSettingsSigninMethods.init();
});

View file

@ -0,0 +1,174 @@
"use strict";
// Class Definition
var KTPasswordResetNewPassword = function () {
// Elements
var form;
var submitButton;
var validator;
var passwordMeter;
var handleForm = function (e) {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
validator = FormValidation.formValidation(
form,
{
fields: {
'password': {
validators: {
notEmpty: {
message: 'The password is required'
},
callback: {
message: 'Please enter valid password',
callback: function (input) {
if (input.value.length > 0) {
return validatePassword();
}
}
}
}
},
'confirm-password': {
validators: {
notEmpty: {
message: 'The password confirmation is required'
},
identical: {
compare: function () {
return form.querySelector('[name="password"]').value;
},
message: 'The password and its confirm are not the same'
}
}
},
'toc': {
validators: {
notEmpty: {
message: 'You must accept the terms and conditions'
}
}
}
},
plugins: {
trigger: new FormValidation.plugins.Trigger({
event: {
password: false
}
}),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
submitButton.addEventListener('click', function (e) {
e.preventDefault();
validator.revalidateField('password');
validator.validate().then(function (status) {
if (status == 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate ajax request
axios.post(submitButton.closest('form').getAttribute('action'), new FormData(form))
.then(function (response) {
// Show message popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "You have successfully reset your password!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
window.location.href = '/login';
form.querySelector('[name="email"]').value = "";
form.querySelector('[name="password"]').value = "";
form.querySelector('[name="confirm-password"]').value = "";
passwordMeter.reset(); // reset password meter
}
});
})
.catch(function (error) {
let dataMessage = error.response.data.message;
let dataErrors = error.response.data.errors;
for (const errorsKey in dataErrors) {
if (!dataErrors.hasOwnProperty(errorsKey)) continue;
dataMessage += "\r\n" + dataErrors[errorsKey];
}
if (error.response) {
Swal.fire({
text: dataMessage,
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
})
.then(function () {
// always executed
// Hide loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
});
} else {
// Show error popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
});
form.querySelector('input[name="password"]').addEventListener('input', function () {
if (this.value.length > 0) {
validator.updateFieldStatus('password', 'NotValidated');
}
});
}
var validatePassword = function () {
return (passwordMeter.getScore() > 50);
}
// Public Functions
return {
// public functions
init: function () {
form = document.querySelector('#kt_new_password_form');
submitButton = document.querySelector('#kt_new_password_submit');
passwordMeter = KTPasswordMeter.getInstance(form.querySelector('[data-kt-password-meter="true"]'));
handleForm();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTPasswordResetNewPassword.init();
});

View file

@ -0,0 +1,131 @@
"use strict";
// Class Definition
var KTPasswordResetGeneral = function () {
// Elements
var form;
var submitButton;
var validator;
// Handle form
var handleForm = function (e) {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
validator = FormValidation.formValidation(
form,
{
fields: {
'email': {
validators: {
notEmpty: {
message: 'Email address is required'
},
emailAddress: {
message: 'The value is not a valid email address'
}
}
}
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Handle form submit
submitButton.addEventListener('click', function (e) {
// Prevent button default action
e.preventDefault();
// Validate form
validator.validate().then(function (status) {
if (status === 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate ajax request
axios.post(submitButton.closest('form').getAttribute('action'), new FormData(form))
.then(function (response) {
// Show message popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Please check your email to proceed with the password reset.",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
form.querySelector('[name="email"]').value = "";
}
});
})
.catch(function (error) {
let dataMessage = error.response.data.message;
let dataErrors = error.response.data.errors;
for (const errorsKey in dataErrors) {
if (!dataErrors.hasOwnProperty(errorsKey)) continue;
dataMessage += "\r\n" + dataErrors[errorsKey];
}
if (error.response) {
Swal.fire({
text: dataMessage,
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
})
.then(function () {
// always executed
// Hide loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
});
} else {
// Show error popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
});
}
// Public functions
return {
// Initialization
init: function () {
form = document.querySelector('#kt_password_reset_form');
submitButton = document.querySelector('#kt_password_reset_submit');
handleForm();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTPasswordResetGeneral.init();
});

View file

@ -0,0 +1,143 @@
"use strict";
// Class definition
var KTSigninGeneral = function () {
// Elements
var form;
var submitButton;
var validator;
// Handle form
var handleForm = function (e) {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
validator = FormValidation.formValidation(
form,
{
fields: {
'email': {
validators: {
notEmpty: {
message: 'Email address is required'
},
emailAddress: {
message: 'The value is not a valid email address'
}
}
},
'password': {
validators: {
notEmpty: {
message: 'The password is required'
},
callback: {
message: 'Please enter valid password',
}
}
}
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Handle form submit
submitButton.addEventListener('click', function (e) {
// Prevent button default action
e.preventDefault();
// Validate form
validator.validate().then(function (status) {
if (status === 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate ajax request
axios.post(submitButton.closest('form').getAttribute('action'), new FormData(form))
.then(function (response) {
// Show message popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "You have successfully logged in!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
form.querySelector('[name="email"]').value = "";
form.querySelector('[name="password"]').value = "";
window.location.reload();
}
});
})
.catch(function (error) {
let dataMessage = error.response.data.message;
let dataErrors = error.response.data.errors;
for (const errorsKey in dataErrors) {
if (!dataErrors.hasOwnProperty(errorsKey)) continue;
dataMessage += "\r\n" + dataErrors[errorsKey];
}
if (error.response) {
Swal.fire({
text: dataMessage,
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
})
.then(function () {
// always executed
// Hide loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
});
} else {
// Show error popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
});
}
// Public functions
return {
// Initialization
init: function () {
form = document.querySelector('#kt_sign_in_form');
submitButton = document.querySelector('#kt_sign_in_submit');
handleForm();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTSigninGeneral.init();
});

View file

@ -0,0 +1,205 @@
"use strict";
// Class definition
var KTSignupGeneral = function () {
// Elements
var form;
var submitButton;
var validator;
var passwordMeter;
// Handle form
var handleForm = function (e) {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
validator = FormValidation.formValidation(
form,
{
fields: {
'username': {
validators: {
notEmpty: {
message: 'A username is required.'
},
stringLength: {
max: 16,
message: 'The username must not be more than 16 characters.',
},
regexp: {
regexp: /^[a-zA-Z0-9-_]+$/,
message: 'Usernames can only contain alphanumeric characters, hyphens and underscores.'
}
}
},
'email': {
validators: {
notEmpty: {
message: 'An email address is required.'
},
emailAddress: {
message: 'The value is not a valid email address.'
}
}
},
'password': {
validators: {
stringLength: {
min: 16,
message: 'The password must be at least 16 characters long.',
},
notEmpty: {
message: 'A password is required.'
},
callback: {
message: 'Please enter valid password.',
callback: function (input) {
if (input.value.length > 0) {
return validatePassword();
}
}
}
}
},
'password_confirmation': {
validators: {
notEmpty: {
message: 'The password confirmation field is required.'
},
identical: {
compare: function () {
return form.querySelector('[name="password"]').value;
},
message: 'The passwords are not the same.'
}
}
},
'toc': {
validators: {
notEmpty: {
message: 'You must accept the terms and conditions'
}
}
}
},
plugins: {
trigger: new FormValidation.plugins.Trigger({
event: {
password: false
}
}),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Handle form submit
submitButton.addEventListener('click', function (e) {
// Prevent button default action
e.preventDefault();
// Validate form
validator.validate().then(function (status) {
if (status === 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate ajax request
axios.post(submitButton.closest('form').getAttribute('action'), new FormData(form))
.then(function (response) {
// Show message popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "You have successfully registered! Please check your email for verification.",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
form.querySelector('[name="email"]').value = "";
form.querySelector('[name="password"]').value = "";
window.location.reload();
}
});
})
.catch(function (error) {
let dataMessage = error.response.data.message;
let dataErrors = error.response.data.errors;
for (const errorsKey in dataErrors) {
if (!dataErrors.hasOwnProperty(errorsKey)) continue;
dataMessage += "\r\n" + dataErrors[errorsKey];
}
if (error.response) {
Swal.fire({
text: dataMessage,
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
})
.then(function () {
// always executed
// Hide loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
});
} else {
// Show error popup. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
});
// Handle password input
form.querySelector('input[name="password"]').addEventListener('input', function () {
if (this.value.length > 0) {
validator.updateFieldStatus('password', 'NotValidated');
}
});
}
// Password input validation
var validatePassword = function () {
return (passwordMeter.getScore() > 50);
}
// Public functions
return {
// Initialization
init: function () {
form = document.querySelector('#kt_sign_up_form');
submitButton = document.querySelector('#kt_sign_up_submit');
passwordMeter = KTPasswordMeter.getInstance(form.querySelector('[data-kt-password-meter="true"]'));
handleForm();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTSignupGeneral.init();
});

View file

@ -0,0 +1,266 @@
"use strict";
// Class definition
var KTModalTwoFactorAuthentication = function () {
// Private variables
var modal;
var modalObject;
var optionsWrapper;
var optionsSelectButton;
var smsWrapper;
var smsForm;
var smsSubmitButton;
var smsCancelButton;
var smsValidator;
var appsWrapper;
var appsForm;
var appsSubmitButton;
var appsCancelButton;
var appsValidator;
// Private functions
var handleOptionsForm = function() {
// Handle options selection
optionsSelectButton.addEventListener('click', function (e) {
e.preventDefault();
var option = optionsWrapper.querySelector('[name="auth_option"]:checked');
optionsWrapper.classList.add('d-none');
if (option.value == 'sms') {
smsWrapper.classList.remove('d-none');
} else {
appsWrapper.classList.remove('d-none');
}
});
}
var showOptionsForm = function() {
optionsWrapper.classList.remove('d-none');
smsWrapper.classList.add('d-none');
appsWrapper.classList.add('d-none');
}
var handleSMSForm = function() {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
smsValidator = FormValidation.formValidation(
smsForm,
{
fields: {
'mobile': {
validators: {
notEmpty: {
message: 'Mobile no is required'
}
}
}
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Handle apps submition
smsSubmitButton.addEventListener('click', function (e) {
e.preventDefault();
// Validate form before submit
if (smsValidator) {
smsValidator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
// Show loading indication
smsSubmitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
smsSubmitButton.disabled = true;
// Simulate ajax process
setTimeout(function() {
// Remove loading indication
smsSubmitButton.removeAttribute('data-kt-indicator');
// Enable button
smsSubmitButton.disabled = false;
// Show success message. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Mobile number has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modalObject.hide();
showOptionsForm();
}
});
//smsForm.submit(); // Submit form
}, 2000);
} else {
// Show error message.
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
}
});
// Handle sms cancelation
smsCancelButton.addEventListener('click', function (e) {
e.preventDefault();
var option = optionsWrapper.querySelector('[name="auth_option"]:checked');
optionsWrapper.classList.remove('d-none');
smsWrapper.classList.add('d-none');
});
}
var handleAppsForm = function() {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
appsValidator = FormValidation.formValidation(
appsForm,
{
fields: {
'code': {
validators: {
notEmpty: {
message: 'Code is required'
}
}
}
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Handle apps submition
appsSubmitButton.addEventListener('click', function (e) {
e.preventDefault();
// Validate form before submit
if (appsValidator) {
appsValidator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
appsSubmitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
appsSubmitButton.disabled = true;
setTimeout(function() {
appsSubmitButton.removeAttribute('data-kt-indicator');
// Enable button
appsSubmitButton.disabled = false;
// Show success message.
Swal.fire({
text: "Code has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modalObject.hide();
showOptionsForm();
}
});
//appsForm.submit(); // Submit form
}, 2000);
} else {
// Show error message.
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
}
});
// Handle apps cancelation
appsCancelButton.addEventListener('click', function (e) {
e.preventDefault();
var option = optionsWrapper.querySelector('[name="auth_option"]:checked');
optionsWrapper.classList.remove('d-none');
appsWrapper.classList.add('d-none');
});
}
// Public methods
return {
init: function () {
// Elements
modal = document.querySelector('#kt_modal_two_factor_authentication');
if (!modal) {
return;
}
modalObject = new bootstrap.Modal(modal);
optionsWrapper = modal.querySelector('[data-kt-element="options"]');
optionsSelectButton = modal.querySelector('[data-kt-element="options-select"]');
smsWrapper = modal.querySelector('[data-kt-element="sms"]');
smsForm = modal.querySelector('[data-kt-element="sms-form"]');
smsSubmitButton = modal.querySelector('[data-kt-element="sms-submit"]');
smsCancelButton = modal.querySelector('[data-kt-element="sms-cancel"]');
appsWrapper = modal.querySelector('[data-kt-element="apps"]');
appsForm = modal.querySelector('[data-kt-element="apps-form"]');
appsSubmitButton = modal.querySelector('[data-kt-element="apps-submit"]');
appsCancelButton = modal.querySelector('[data-kt-element="apps-cancel"]');
// Handle forms
handleOptionsForm();
handleSMSForm();
handleAppsForm();
}
}
}();
// On document ready
KTUtil.onDOMContentLoaded(function() {
KTModalTwoFactorAuthentication.init();
});

View file

@ -0,0 +1,166 @@
"use strict";
// Class definition
var KTUsersAddPermission = function () {
// Shared variables
const element = document.getElementById('kt_modal_add_permission');
const form = element.querySelector('#kt_modal_add_permission_form');
const modal = new bootstrap.Modal(element);
// Init add schedule modal
var initAddPermission = () => {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
var validator = FormValidation.formValidation(
form,
{
fields: {
'permission_name': {
validators: {
notEmpty: {
message: 'Permission name is required'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Close button handler
const closeButton = element.querySelector('[data-kt-permissions-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to close?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, close it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
modal.hide(); // Hide modal
}
});
});
// Cancel button handler
const cancelButton = element.querySelector('[data-kt-permissions-modal-action="cancel"]');
cancelButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Submit button handler
const submitButton = element.querySelector('[data-kt-permissions-modal-action="submit"]');
submitButton.addEventListener('click', function (e) {
// Prevent default button action
e.preventDefault();
// Validate form before submit
if (validator) {
validator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function () {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modal.hide();
}
});
//form.submit(); // Submit form
}, 2000);
} else {
// Show popup warning. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
}
});
}
return {
// Public functions
init: function () {
initAddPermission();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersAddPermission.init();
});

View file

@ -0,0 +1,117 @@
"use strict";
// Class definition
var KTUsersPermissionsList = function () {
// Shared variables
var datatable;
var table;
// Init add schedule modal
var initPermissionsList = () => {
// Set date data order
const tableRows = table.querySelectorAll('tbody tr');
tableRows.forEach(row => {
const dateRow = row.querySelectorAll('td');
const realDate = moment(dateRow[2].innerHTML, "DD MMM YYYY, LT").format(); // select date from 2nd column in table
dateRow[2].setAttribute('data-order', realDate);
});
// Init datatable --- more info on datatables: https://datatables.net/manual/
datatable = $(table).DataTable({
"info": false,
'order': [],
'columnDefs': [
{ orderable: false, targets: 1 }, // Disable ordering on column 1 (assigned)
{ orderable: false, targets: 3 }, // Disable ordering on column 3 (actions)
]
});
}
// Search Datatable --- official docs reference: https://datatables.net/reference/api/search()
var handleSearchDatatable = () => {
const filterSearch = document.querySelector('[data-kt-permissions-table-filter="search"]');
filterSearch.addEventListener('keyup', function (e) {
datatable.search(e.target.value).draw();
});
}
// Delete user
var handleDeleteRows = () => {
// Select all delete buttons
const deleteButtons = table.querySelectorAll('[data-kt-permissions-table-filter="delete_row"]');
deleteButtons.forEach(d => {
// Delete button on click
d.addEventListener('click', function (e) {
e.preventDefault();
// Select parent row
const parent = e.target.closest('tr');
// Get permission name
const permissionName = parent.querySelectorAll('td')[0].innerText;
// SweetAlert2 pop up --- official docs reference: https://sweetalert2.github.io/
Swal.fire({
text: "Are you sure you want to delete " + permissionName + "?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, delete!",
cancelButtonText: "No, cancel",
customClass: {
confirmButton: "btn fw-bold btn-danger",
cancelButton: "btn fw-bold btn-active-light-primary"
}
}).then(function (result) {
if (result.value) {
Swal.fire({
text: "You have deleted " + permissionName + "!.",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn fw-bold btn-primary",
}
}).then(function () {
// Remove current row
datatable.row($(parent)).remove().draw();
});
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: customerName + " was not deleted.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn fw-bold btn-primary",
}
});
}
});
})
});
}
return {
// Public functions
init: function () {
table = document.querySelector('#kt_permissions_table');
if (!table) {
return;
}
initPermissionsList();
handleSearchDatatable();
handleDeleteRows();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersPermissionsList.init();
});

View file

@ -0,0 +1,166 @@
"use strict";
// Class definition
var KTUsersUpdatePermission = function () {
// Shared variables
const element = document.getElementById('kt_modal_update_permission');
const form = element.querySelector('#kt_modal_update_permission_form');
const modal = new bootstrap.Modal(element);
// Init add schedule modal
var initUpdatePermission = () => {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
var validator = FormValidation.formValidation(
form,
{
fields: {
'permission_name': {
validators: {
notEmpty: {
message: 'Permission name is required'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Close button handler
const closeButton = element.querySelector('[data-kt-permissions-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to close?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, close it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
modal.hide(); // Hide modal
}
});
});
// Cancel button handler
const cancelButton = element.querySelector('[data-kt-permissions-modal-action="cancel"]');
cancelButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Submit button handler
const submitButton = element.querySelector('[data-kt-permissions-modal-action="submit"]');
submitButton.addEventListener('click', function (e) {
// Prevent default button action
e.preventDefault();
// Validate form before submit
if (validator) {
validator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function () {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modal.hide();
}
});
//form.submit(); // Submit form
}, 2000);
} else {
// Show popup warning. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
}
});
}
return {
// Public functions
init: function () {
initUpdatePermission();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersUpdatePermission.init();
});

View file

@ -0,0 +1,185 @@
"use strict";
// Class definition
var KTUsersAddRole = function () {
// Shared variables
const element = document.getElementById('kt_modal_add_role');
const form = element.querySelector('#kt_modal_add_role_form');
const modal = new bootstrap.Modal(element);
// Init add schedule modal
var initAddRole = () => {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
var validator = FormValidation.formValidation(
form,
{
fields: {
'role_name': {
validators: {
notEmpty: {
message: 'Role name is required'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Close button handler
const closeButton = element.querySelector('[data-kt-roles-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to close?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, close it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
modal.hide(); // Hide modal
}
});
});
// Cancel button handler
const cancelButton = element.querySelector('[data-kt-roles-modal-action="cancel"]');
cancelButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Submit button handler
const submitButton = element.querySelector('[data-kt-roles-modal-action="submit"]');
submitButton.addEventListener('click', function (e) {
// Prevent default button action
e.preventDefault();
// Validate form before submit
if (validator) {
validator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function () {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modal.hide();
}
});
//form.submit(); // Submit form
}, 2000);
} else {
// Show popup warning. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
}
});
}
// Select all handler
const handleSelectAll = () =>{
// Define variables
const selectAll = form.querySelector('#kt_roles_select_all');
const allCheckboxes = form.querySelectorAll('[type="checkbox"]');
// Handle check state
selectAll.addEventListener('change', e => {
// Apply check state to all checkboxes
allCheckboxes.forEach(c => {
c.checked = e.target.checked;
});
});
}
return {
// Public functions
init: function () {
initAddRole();
handleSelectAll();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersAddRole.init();
});

View file

@ -0,0 +1,183 @@
"use strict";
// Class definition
var KTUsersUpdatePermissions = function () {
// Shared variables
const element = document.getElementById('kt_modal_update_role');
const form = element.querySelector('#kt_modal_update_role_form');
const modal = new bootstrap.Modal(element);
// Init add schedule modal
var initUpdatePermissions = () => {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
var validator = FormValidation.formValidation(
form,
{
fields: {
'role_name': {
validators: {
notEmpty: {
message: 'Role name is required'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Close button handler
const closeButton = element.querySelector('[data-kt-roles-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to close?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, close it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
modal.hide(); // Hide modal
}
});
});
// Cancel button handler
const cancelButton = element.querySelector('[data-kt-roles-modal-action="cancel"]');
cancelButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Submit button handler
const submitButton = element.querySelector('[data-kt-roles-modal-action="submit"]');
submitButton.addEventListener('click', function (e) {
// Prevent default button action
e.preventDefault();
// Validate form before submit
if (validator) {
validator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function () {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modal.hide();
}
});
//form.submit(); // Submit form
}, 2000);
} else {
// Show popup warning. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
}
});
}
// Select all handler
const handleSelectAll = () => {
// Define variables
const selectAll = form.querySelector('#kt_roles_select_all');
const allCheckboxes = form.querySelectorAll('[type="checkbox"]');
// Handle check state
selectAll.addEventListener('change', e => {
// Apply check state to all checkboxes
allCheckboxes.forEach(c => {
c.checked = e.target.checked;
});
});
}
return {
// Public functions
init: function () {
initUpdatePermissions();
handleSelectAll();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersUpdatePermissions.init();
});

View file

@ -0,0 +1,183 @@
"use strict";
// Class definition
var KTUsersUpdatePermissions = function () {
// Shared variables
const element = document.getElementById('kt_modal_update_role');
const form = element.querySelector('#kt_modal_update_role_form');
const modal = new bootstrap.Modal(element);
// Init add schedule modal
var initUpdatePermissions = () => {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
var validator = FormValidation.formValidation(
form,
{
fields: {
'role_name': {
validators: {
notEmpty: {
message: 'Role name is required'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Close button handler
const closeButton = element.querySelector('[data-kt-roles-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to close?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, close it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
modal.hide(); // Hide modal
}
});
});
// Cancel button handler
const cancelButton = element.querySelector('[data-kt-roles-modal-action="cancel"]');
cancelButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Submit button handler
const submitButton = element.querySelector('[data-kt-roles-modal-action="submit"]');
submitButton.addEventListener('click', function (e) {
// Prevent default button action
e.preventDefault();
// Validate form before submit
if (validator) {
validator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function () {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modal.hide();
}
});
//form.submit(); // Submit form
}, 2000);
} else {
// Show popup warning. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
}
});
}
// Select all handler
const handleSelectAll = () => {
// Define variables
const selectAll = form.querySelector('#kt_roles_select_all');
const allCheckboxes = form.querySelectorAll('[type="checkbox"]');
// Handle check state
selectAll.addEventListener('change', e => {
// Apply check state to all checkboxes
allCheckboxes.forEach(c => {
c.checked = e.target.checked;
});
});
}
return {
// Public functions
init: function () {
initUpdatePermissions();
handleSelectAll();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersUpdatePermissions.init();
});

View file

@ -0,0 +1,225 @@
"use strict";
// Class definition
var KTUsersViewRole = function () {
// Shared variables
var datatable;
var table;
// Init add schedule modal
var initViewRole = () => {
// Set date data order
const tableRows = table.querySelectorAll('tbody tr');
tableRows.forEach(row => {
const dateRow = row.querySelectorAll('td');
const realDate = moment(dateRow[3].innerHTML, "DD MMM YYYY, LT").format(); // select date from 5th column in table
dateRow[3].setAttribute('data-order', realDate);
});
// Init datatable --- more info on datatables: https://datatables.net/manual/
datatable = $(table).DataTable({
"info": false,
'order': [],
"pageLength": 5,
"lengthChange": false,
'columnDefs': [
{ orderable: false, targets: 0 }, // Disable ordering on column 0 (checkbox)
{ orderable: false, targets: 4 }, // Disable ordering on column 4 (actions)
]
});
}
// Search Datatable --- official docs reference: https://datatables.net/reference/api/search()
var handleSearchDatatable = () => {
const filterSearch = document.querySelector('[data-kt-roles-table-filter="search"]');
filterSearch.addEventListener('keyup', function (e) {
datatable.search(e.target.value).draw();
});
}
// Delete user
var handleDeleteRows = () => {
// Select all delete buttons
const deleteButtons = table.querySelectorAll('[data-kt-roles-table-filter="delete_row"]');
deleteButtons.forEach(d => {
// Delete button on click
d.addEventListener('click', function (e) {
e.preventDefault();
// Select parent row
const parent = e.target.closest('tr');
// Get customer name
const userName = parent.querySelectorAll('td')[1].innerText;
// SweetAlert2 pop up --- official docs reference: https://sweetalert2.github.io/
Swal.fire({
text: "Are you sure you want to delete " + userName + "?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, delete!",
cancelButtonText: "No, cancel",
customClass: {
confirmButton: "btn fw-bold btn-danger",
cancelButton: "btn fw-bold btn-active-light-primary"
}
}).then(function (result) {
if (result.value) {
Swal.fire({
text: "You have deleted " + userName + "!.",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn fw-bold btn-primary",
}
}).then(function () {
// Remove current row
datatable.row($(parent)).remove().draw();
});
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: customerName + " was not deleted.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn fw-bold btn-primary",
}
});
}
});
})
});
}
// Init toggle toolbar
var initToggleToolbar = () => {
// Toggle selected action toolbar
// Select all checkboxes
const checkboxes = table.querySelectorAll('[type="checkbox"]');
// Select elements
const deleteSelected = document.querySelector('[data-kt-view-roles-table-select="delete_selected"]');
// Toggle delete selected toolbar
checkboxes.forEach(c => {
// Checkbox on click event
c.addEventListener('click', function () {
setTimeout(function () {
toggleToolbars();
}, 50);
});
});
// Deleted selected rows
deleteSelected.addEventListener('click', function () {
// SweetAlert2 pop up --- official docs reference: https://sweetalert2.github.io/
Swal.fire({
text: "Are you sure you want to delete selected customers?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, delete!",
cancelButtonText: "No, cancel",
customClass: {
confirmButton: "btn fw-bold btn-danger",
cancelButton: "btn fw-bold btn-active-light-primary"
}
}).then(function (result) {
if (result.value) {
Swal.fire({
text: "You have deleted all selected customers!.",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn fw-bold btn-primary",
}
}).then(function () {
// Remove all selected customers
checkboxes.forEach(c => {
if (c.checked) {
datatable.row($(c.closest('tbody tr'))).remove().draw();
}
});
// Remove header checked box
const headerCheckbox = table.querySelectorAll('[type="checkbox"]')[0];
headerCheckbox.checked = false;
}).then(function(){
toggleToolbars(); // Detect checked checkboxes
initToggleToolbar(); // Re-init toolbar to recalculate checkboxes
});
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Selected customers was not deleted.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn fw-bold btn-primary",
}
});
}
});
});
}
// Toggle toolbars
const toggleToolbars = () => {
// Define variables
const toolbarBase = document.querySelector('[data-kt-view-roles-table-toolbar="base"]');
const toolbarSelected = document.querySelector('[data-kt-view-roles-table-toolbar="selected"]');
const selectedCount = document.querySelector('[data-kt-view-roles-table-select="selected_count"]');
// Select refreshed checkbox DOM elements
const allCheckboxes = table.querySelectorAll('tbody [type="checkbox"]');
// Detect checkboxes state & count
let checkedState = false;
let count = 0;
// Count checked boxes
allCheckboxes.forEach(c => {
if (c.checked) {
checkedState = true;
count++;
}
});
// Toggle toolbars
if (checkedState) {
selectedCount.innerHTML = count;
toolbarBase.classList.add('d-none');
toolbarSelected.classList.remove('d-none');
} else {
toolbarBase.classList.remove('d-none');
toolbarSelected.classList.add('d-none');
}
}
return {
// Public functions
init: function () {
table = document.querySelector('#kt_roles_view_table');
if (!table) {
return;
}
initViewRole();
handleSearchDatatable();
handleDeleteRows();
initToggleToolbar();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersViewRole.init();
});

View file

@ -0,0 +1,183 @@
"use strict";
// Class definition
var KTUsersAddUser = function () {
// Shared variables
const element = document.getElementById('kt_modal_add_user');
const form = element.querySelector('#kt_modal_add_user_form');
const modal = new bootstrap.Modal(element);
// Init add schedule modal
var initAddUser = () => {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
var validator = FormValidation.formValidation(
form,
{
fields: {
'user_name': {
validators: {
notEmpty: {
message: 'Full name is required'
}
}
},
'user_email': {
validators: {
notEmpty: {
message: 'Valid email address is required'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Submit button handler
const submitButton = element.querySelector('[data-kt-users-modal-action="submit"]');
submitButton.addEventListener('click', e => {
e.preventDefault();
// Validate form before submit
if (validator) {
validator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function () {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modal.hide();
}
});
//form.submit(); // Submit form
}, 2000);
} else {
// Show popup warning. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
}
});
// Cancel button handler
const cancelButton = element.querySelector('[data-kt-users-modal-action="cancel"]');
cancelButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide();
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Close button handler
const closeButton = element.querySelector('[data-kt-users-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide();
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
}
return {
// Public functions
init: function () {
initAddUser();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersAddUser.init();
});

View file

@ -0,0 +1,170 @@
"use strict";
// Class definition
var KTModalExportUsers = function () {
// Shared variables
const element = document.getElementById('kt_modal_export_users');
const form = element.querySelector('#kt_modal_export_users_form');
const modal = new bootstrap.Modal(element);
// Init form inputs
var initForm = function () {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
var validator = FormValidation.formValidation(
form,
{
fields: {
'format': {
validators: {
notEmpty: {
message: 'File format is required'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Submit button handler
const submitButton = element.querySelector('[data-kt-users-modal-action="submit"]');
submitButton.addEventListener('click', function (e) {
e.preventDefault();
// Validate form before submit
if (validator) {
validator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable submit button whilst loading
submitButton.disabled = true;
setTimeout(function () {
submitButton.removeAttribute('data-kt-indicator');
Swal.fire({
text: "User list has been successfully exported!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modal.hide();
// Enable submit button after loading
submitButton.disabled = false;
}
});
//form.submit(); // Submit form
}, 2000);
} else {
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
}
});
// Cancel button handler
const cancelButton = element.querySelector('[data-kt-users-modal-action="cancel"]');
cancelButton.addEventListener('click', function (e) {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Close button handler
const closeButton = element.querySelector('[data-kt-users-modal-action="close"]');
closeButton.addEventListener('click', function (e) {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
}
return {
// Public functions
init: function () {
initForm();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTModalExportUsers.init();
});

View file

@ -0,0 +1,317 @@
"use strict";
window.$ = window.jQuery = require( 'jquery' );
require( 'datatables.net' );
var KTUsersList = function () {
// Define shared variables
var table = document.getElementById('kt_table_users');
var datatable;
var toolbarBase;
var toolbarSelected;
var selectedCount;
// Private functions
var initUserTable = function () {
// Set date data order
const tableRows = table.querySelectorAll('tbody tr');
tableRows.forEach(row => {
const dateRow = row.querySelectorAll('td');
const lastLogin = dateRow[3].innerText.toLowerCase(); // Get last login time
let timeCount = 0;
let timeFormat = 'minutes';
// Determine date & time format -- add more formats when necessary
if (lastLogin.includes('yesterday')) {
timeCount = 1;
timeFormat = 'days';
} else if (lastLogin.includes('mins')) {
timeCount = parseInt(lastLogin.replace(/\D/g, ''));
timeFormat = 'minutes';
} else if (lastLogin.includes('hours')) {
timeCount = parseInt(lastLogin.replace(/\D/g, ''));
timeFormat = 'hours';
} else if (lastLogin.includes('days')) {
timeCount = parseInt(lastLogin.replace(/\D/g, ''));
timeFormat = 'days';
} else if (lastLogin.includes('weeks')) {
timeCount = parseInt(lastLogin.replace(/\D/g, ''));
timeFormat = 'weeks';
}
// Subtract date/time from today -- more info on moment datetime subtraction: https://momentjs.com/docs/#/durations/subtract/
const realDate = moment().subtract(timeCount, timeFormat).format();
// Insert real date to last login attribute
dateRow[3].setAttribute('data-order', realDate);
// Set real date for joined column
const joinedDate = moment(dateRow[5].innerHTML, "DD MMM YYYY, LT").format(); // select date from 5th column in table
dateRow[5].setAttribute('data-order', joinedDate);
});
// Init datatable --- more info on datatables: https://datatables.net/manual/
datatable = $(table).DataTable({
"info": false,
'order': [],
"pageLength": 10,
"lengthChange": false,
'columnDefs': [
{ orderable: false, targets: 0 }, // Disable ordering on column 0 (checkbox)
{ orderable: false, targets: 6 }, // Disable ordering on column 6 (actions)
]
});
// Re-init functions on every table re-draw -- more info: https://datatables.net/reference/event/draw
datatable.on('draw', function () {
initToggleToolbar();
handleDeleteRows();
toggleToolbars();
});
}
// Search Datatable --- official docs reference: https://datatables.net/reference/api/search()
var handleSearchDatatable = () => {
const filterSearch = document.querySelector('[data-kt-user-table-filter="search"]');
filterSearch.addEventListener('keyup', function (e) {
datatable.search(e.target.value).draw();
});
}
// Filter Datatable
var handleFilterDatatable = () => {
// Select filter options
const filterForm = document.querySelector('[data-kt-user-table-filter="form"]');
const filterButton = filterForm.querySelector('[data-kt-user-table-filter="filter"]');
const selectOptions = filterForm.querySelectorAll('select');
// Filter datatable on submit
filterButton.addEventListener('click', function () {
var filterString = '';
// Get filter values
selectOptions.forEach((item, index) => {
if (item.value && item.value !== '') {
if (index !== 0) {
filterString += ' ';
}
// Build filter value options
filterString += item.value;
}
});
// Filter datatable --- official docs reference: https://datatables.net/reference/api/search()
datatable.search(filterString).draw();
});
}
// Reset Filter
var handleResetForm = () => {
// Select reset button
const resetButton = document.querySelector('[data-kt-user-table-filter="reset"]');
// Reset datatable
resetButton.addEventListener('click', function () {
// Select filter options
const filterForm = document.querySelector('[data-kt-user-table-filter="form"]');
const selectOptions = filterForm.querySelectorAll('select');
// Reset select2 values -- more info: https://select2.org/programmatic-control/add-select-clear-items
selectOptions.forEach(select => {
$(select).val('').trigger('change');
});
// Reset datatable --- official docs reference: https://datatables.net/reference/api/search()
datatable.search('').draw();
});
}
// Delete subscirption
var handleDeleteRows = () => {
// Select all delete buttons
const deleteButtons = table.querySelectorAll('[data-kt-users-table-filter="delete_row"]');
deleteButtons.forEach(d => {
// Delete button on click
d.addEventListener('click', function (e) {
e.preventDefault();
// Select parent row
const parent = e.target.closest('tr');
// Get user name
const userName = parent.querySelectorAll('td')[1].querySelectorAll('a')[1].innerText;
// SweetAlert2 pop up --- official docs reference: https://sweetalert2.github.io/
Swal.fire({
text: "Are you sure you want to delete " + userName + "?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, delete!",
cancelButtonText: "No, cancel",
customClass: {
confirmButton: "btn fw-bold btn-danger",
cancelButton: "btn fw-bold btn-active-light-primary"
}
}).then(function (result) {
if (result.value) {
Swal.fire({
text: "You have deleted " + userName + "!.",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn fw-bold btn-primary",
}
}).then(function () {
// Remove current row
datatable.row($(parent)).remove().draw();
}).then(function () {
// Detect checked checkboxes
toggleToolbars();
});
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: customerName + " was not deleted.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn fw-bold btn-primary",
}
});
}
});
})
});
}
// Init toggle toolbar
var initToggleToolbar = () => {
// Toggle selected action toolbar
// Select all checkboxes
const checkboxes = table.querySelectorAll('[type="checkbox"]');
// Select elements
toolbarBase = document.querySelector('[data-kt-user-table-toolbar="base"]');
toolbarSelected = document.querySelector('[data-kt-user-table-toolbar="selected"]');
selectedCount = document.querySelector('[data-kt-user-table-select="selected_count"]');
const deleteSelected = document.querySelector('[data-kt-user-table-select="delete_selected"]');
// Toggle delete selected toolbar
checkboxes.forEach(c => {
// Checkbox on click event
c.addEventListener('click', function () {
setTimeout(function () {
toggleToolbars();
}, 50);
});
});
// Deleted selected rows
deleteSelected.addEventListener('click', function () {
// SweetAlert2 pop up --- official docs reference: https://sweetalert2.github.io/
Swal.fire({
text: "Are you sure you want to delete selected customers?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, delete!",
cancelButtonText: "No, cancel",
customClass: {
confirmButton: "btn fw-bold btn-danger",
cancelButton: "btn fw-bold btn-active-light-primary"
}
}).then(function (result) {
if (result.value) {
Swal.fire({
text: "You have deleted all selected customers!.",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn fw-bold btn-primary",
}
}).then(function () {
// Remove all selected customers
checkboxes.forEach(c => {
if (c.checked) {
datatable.row($(c.closest('tbody tr'))).remove().draw();
}
});
// Remove header checked box
const headerCheckbox = table.querySelectorAll('[type="checkbox"]')[0];
headerCheckbox.checked = false;
}).then(function () {
toggleToolbars(); // Detect checked checkboxes
initToggleToolbar(); // Re-init toolbar to recalculate checkboxes
});
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Selected customers was not deleted.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn fw-bold btn-primary",
}
});
}
});
});
}
// Toggle toolbars
const toggleToolbars = () => {
// Select refreshed checkbox DOM elements
const allCheckboxes = table.querySelectorAll('tbody [type="checkbox"]');
// Detect checkboxes state & count
let checkedState = false;
let count = 0;
// Count checked boxes
allCheckboxes.forEach(c => {
if (c.checked) {
checkedState = true;
count++;
}
});
// Toggle toolbars
if (checkedState) {
selectedCount.innerHTML = count;
toolbarBase.classList.add('d-none');
toolbarSelected.classList.remove('d-none');
} else {
toolbarBase.classList.remove('d-none');
toolbarSelected.classList.add('d-none');
}
}
return {
// Public functions
init: function () {
if (!table) {
return;
}
initUserTable();
initToggleToolbar();
handleSearchDatatable();
handleResetForm();
handleDeleteRows();
handleFilterDatatable();
}
}
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersList.init();
});

View file

@ -0,0 +1,81 @@
"use strict";
// Class definition
var KTUsersAddAuthApp = function () {
// Shared variables
const element = document.getElementById('kt_modal_add_auth_app');
const modal = new bootstrap.Modal(element);
// Init add schedule modal
var initAddAuthApp = () => {
// Close button handler
const closeButton = element.querySelector('[data-kt-users-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to close?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, close it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
modal.hide(); // Hide modal
}
});
});
}
// QR code to text code swapper
var initCodeSwap = () => {
const qrCode = element.querySelector('[ data-kt-add-auth-action="qr-code"]');
const textCode = element.querySelector('[ data-kt-add-auth-action="text-code"]');
const qrCodeButton = element.querySelector('[ data-kt-add-auth-action="qr-code-button"]');
const textCodeButton = element.querySelector('[ data-kt-add-auth-action="text-code-button"]');
const qrCodeLabel = element.querySelector('[ data-kt-add-auth-action="qr-code-label"]');
const textCodeLabel = element.querySelector('[ data-kt-add-auth-action="text-code-label"]');
const toggleClass = () =>{
qrCode.classList.toggle('d-none');
qrCodeButton.classList.toggle('d-none');
qrCodeLabel.classList.toggle('d-none');
textCode.classList.toggle('d-none');
textCodeButton.classList.toggle('d-none');
textCodeLabel.classList.toggle('d-none');
}
// Swap to text code handler
textCodeButton.addEventListener('click', e =>{
e.preventDefault();
toggleClass();
});
qrCodeButton.addEventListener('click', e =>{
e.preventDefault();
toggleClass();
});
}
return {
// Public functions
init: function () {
initAddAuthApp();
initCodeSwap();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersAddAuthApp.init();
});

View file

@ -0,0 +1,173 @@
"use strict";
// Class definition
var KTUsersAddOneTimePassword = function () {
// Shared variables
const element = document.getElementById('kt_modal_add_one_time_password');
const form = element.querySelector('#kt_modal_add_one_time_password_form');
const modal = new bootstrap.Modal(element);
// Init one time password modal
var initAddOneTimePassword = () => {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
var validator = FormValidation.formValidation(
form,
{
fields: {
'otp_mobile_number': {
validators: {
notEmpty: {
message: 'Valid mobile number is required'
}
}
},
'otp_confirm_password': {
validators: {
notEmpty: {
message: 'Password confirmation is required'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Close button handler
const closeButton = element.querySelector('[data-kt-users-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to close?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, close it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
modal.hide(); // Hide modal
}
});
});
// Cancel button handler
const cancelButton = element.querySelector('[data-kt-users-modal-action="cancel"]');
cancelButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Submit button handler
const submitButton = element.querySelector('[data-kt-users-modal-action="submit"]');
submitButton.addEventListener('click', function (e) {
// Prevent default button action
e.preventDefault();
// Validate form before submit
if (validator) {
validator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function () {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modal.hide();
}
});
//form.submit(); // Submit form
}, 2000);
} else {
// Show popup warning. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
}
});
}
return {
// Public functions
init: function () {
initAddOneTimePassword();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersAddOneTimePassword.init();
});

View file

@ -0,0 +1,223 @@
"use strict";
// Class definition
var KTUsersAddSchedule = function () {
// Shared variables
const element = document.getElementById('kt_modal_add_schedule');
const form = element.querySelector('#kt_modal_add_schedule_form');
const modal = new bootstrap.Modal(element);
// Init add schedule modal
var initAddSchedule = () => {
// Init flatpickr -- for more info: https://flatpickr.js.org/
$("#kt_modal_add_schedule_datepicker").flatpickr({
enableTime: true,
dateFormat: "Y-m-d H:i",
});
// Init tagify -- for more info: https://yaireo.github.io/tagify/
const tagifyInput = form.querySelector('#kt_modal_add_schedule_tagify');
new Tagify(tagifyInput, {
whitelist: ["sean@dellito.com", "brian@exchange.com", "mikaela@pexcom.com", "f.mitcham@kpmg.com.au", "olivia@corpmail.com", "owen.neil@gmail.com", "dam@consilting.com", "emma@intenso.com", "ana.cf@limtel.com", "robert@benko.com", "lucy.m@fentech.com", "ethan@loop.com.au"],
maxTags: 10,
dropdown: {
maxItems: 20, // <- mixumum allowed rendered suggestions
classname: "tagify__inline__suggestions", // <- custom classname for this dropdown, so it could be targeted
enabled: 0, // <- show suggestions on focus
closeOnSelect: false // <- do not hide the suggestions dropdown once an item has been selected
}
});
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
var validator = FormValidation.formValidation(
form,
{
fields: {
'event_datetime': {
validators: {
notEmpty: {
message: 'Event date & time is required'
}
}
},
'event_name': {
validators: {
notEmpty: {
message: 'Event name is required'
}
}
},
'event_org': {
validators: {
notEmpty: {
message: 'Event organiser is required'
}
}
},
'event_invitees': {
validators: {
notEmpty: {
message: 'Event invitees is required'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Revalidate country field. For more info, plase visit the official plugin site: https://select2.org/
$(form.querySelector('[name="event_invitees"]')).on('change', function () {
// Revalidate the field when an option is chosen
validator.revalidateField('event_invitees');
});
// Close button handler
const closeButton = element.querySelector('[data-kt-users-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Cancel button handler
const cancelButton = element.querySelector('[data-kt-users-modal-action="cancel"]');
cancelButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Submit button handler
const submitButton = element.querySelector('[data-kt-users-modal-action="submit"]');
submitButton.addEventListener('click', function (e) {
// Prevent default button action
e.preventDefault();
// Validate form before submit
if (validator) {
validator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function() {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modal.hide();
}
});
//form.submit(); // Submit form
}, 2000);
} else {
// Show popup warning. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
}
});
}
return {
// Public functions
init: function () {
initAddSchedule();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersAddSchedule.init();
});

View file

@ -0,0 +1,324 @@
"use strict";
// Class definition
var KTUsersAddTask = function () {
// Shared variables
const element = document.getElementById('kt_modal_add_task');
const form = element.querySelector('#kt_modal_add_task_form');
const modal = new bootstrap.Modal(element);
// Init add task modal
var initAddTask = () => {
// Init flatpickr -- for more info: https://flatpickr.js.org/
$("#kt_modal_add_task_datepicker").flatpickr({
dateFormat: "Y-m-d",
});
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
var validator = FormValidation.formValidation(
form,
{
fields: {
'task_duedate': {
validators: {
notEmpty: {
message: 'Task due date is required'
}
}
},
'task_name': {
validators: {
notEmpty: {
message: 'Task name is required'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Close button handler
const closeButton = element.querySelector('[data-kt-users-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Cancel button handler
const cancelButton = element.querySelector('[data-kt-users-modal-action="cancel"]');
cancelButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Submit button handler
const submitButton = element.querySelector('[data-kt-users-modal-action="submit"]');
submitButton.addEventListener('click', function (e) {
// Prevent default button action
e.preventDefault();
// Validate form before submit
if (validator) {
validator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function () {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modal.hide();
}
});
//form.submit(); // Submit form
}, 2000);
} else {
// Show popup warning. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});
}
});
}
// Init update task status
var initUpdateTaskStatus = () => {
const allTaskMenus = document.querySelectorAll('[data-kt-menu-id="kt-users-tasks"]');
allTaskMenus.forEach(el => {
const resetButton = el.querySelector('[data-kt-users-update-task-status="reset"]');
const submitButton = el.querySelector('[data-kt-users-update-task-status="submit"]');
const taskForm = el.querySelector('[data-kt-menu-id="kt-users-tasks-form"]');
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
var validator = FormValidation.formValidation(
taskForm,
{
fields: {
'task_status': {
validators: {
notEmpty: {
message: 'Task due date is required'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Revalidate country field. For more info, plase visit the official plugin site: https://select2.org/
$(taskForm.querySelector('[name="task_status"]')).on('change', function () {
// Revalidate the field when an option is chosen
validator.revalidateField('task_status');
});
// Reset action handler
resetButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to reset?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, reset it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
taskForm.reset(); // Reset form
el.hide();
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form was not reset!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Submit action handler
submitButton.addEventListener('click', e => {
e.preventDefault();
// Validate form before submit
if (validator) {
validator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function () {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
el.hide();
}
});
//taskForm.submit(); // Submit form
}, 2000);
} else {
// Show popup warning. For more info check the plugin's official documentation: https://sweetalert2.github.io/
Swal.fire({
text: "Sorry, looks like there are some errors detected, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function(){
//el.show();
});
}
});
}
});
});
}
return {
// Public functions
init: function () {
initAddTask();
initUpdateTaskStatus();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersAddTask.init();
});

View file

@ -0,0 +1,132 @@
"use strict";
// Class definition
var KTUsersUpdateDetails = function () {
// Shared variables
const element = document.getElementById('kt_modal_update_details');
const form = element.querySelector('#kt_modal_update_user_form');
const modal = new bootstrap.Modal(element);
// Init add schedule modal
var initUpdateDetails = () => {
// Close button handler
const closeButton = element.querySelector('[data-kt-users-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Cancel button handler
const cancelButton = element.querySelector('[data-kt-users-modal-action="cancel"]');
cancelButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Submit button handler
const submitButton = element.querySelector('[data-kt-users-modal-action="submit"]');
submitButton.addEventListener('click', function (e) {
// Prevent default button action
e.preventDefault();
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function () {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modal.hide();
}
});
//form.submit(); // Submit form
}, 2000);
});
}
return {
// Public functions
init: function () {
initUpdateDetails();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersUpdateDetails.init();
});

View file

@ -0,0 +1,166 @@
"use strict";
// Class definition
var KTUsersUpdateEmail = function () {
// Shared variables
const element = document.getElementById('kt_modal_update_email');
const form = element.querySelector('#kt_modal_update_email_form');
const modal = new bootstrap.Modal(element);
// Init add schedule modal
var initUpdateEmail = () => {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
var validator = FormValidation.formValidation(
form,
{
fields: {
'profile_email': {
validators: {
notEmpty: {
message: 'Email address is required'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Close button handler
const closeButton = element.querySelector('[data-kt-users-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Cancel button handler
const cancelButton = element.querySelector('[data-kt-users-modal-action="cancel"]');
cancelButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Submit button handler
const submitButton = element.querySelector('[data-kt-users-modal-action="submit"]');
submitButton.addEventListener('click', function (e) {
// Prevent default button action
e.preventDefault();
// Validate form before submit
if (validator) {
validator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function () {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modal.hide();
}
});
//form.submit(); // Submit form
}, 2000);
}
});
}
});
}
return {
// Public functions
init: function () {
initUpdateEmail();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersUpdateEmail.init();
});

View file

@ -0,0 +1,194 @@
"use strict";
// Class definition
var KTUsersUpdatePassword = function () {
// Shared variables
const element = document.getElementById('kt_modal_update_password');
const form = element.querySelector('#kt_modal_update_password_form');
const modal = new bootstrap.Modal(element);
// Init add schedule modal
var initUpdatePassword = () => {
// Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/
var validator = FormValidation.formValidation(
form,
{
fields: {
'current_password': {
validators: {
notEmpty: {
message: 'Current password is required'
}
}
},
'new_password': {
validators: {
notEmpty: {
message: 'The password is required'
},
callback: {
message: 'Please enter valid password',
callback: function (input) {
if (input.value.length > 0) {
return validatePassword();
}
}
}
}
},
'confirm_password': {
validators: {
notEmpty: {
message: 'The password confirmation is required'
},
identical: {
compare: function () {
return form.querySelector('[name="new_password"]').value;
},
message: 'The password and its confirm are not the same'
}
}
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap5({
rowSelector: '.fv-row',
eleInvalidClass: '',
eleValidClass: ''
})
}
}
);
// Close button handler
const closeButton = element.querySelector('[data-kt-users-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Cancel button handler
const cancelButton = element.querySelector('[data-kt-users-modal-action="cancel"]');
cancelButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Submit button handler
const submitButton = element.querySelector('[data-kt-users-modal-action="submit"]');
submitButton.addEventListener('click', function (e) {
// Prevent default button action
e.preventDefault();
// Validate form before submit
if (validator) {
validator.validate().then(function (status) {
console.log('validated!');
if (status == 'Valid') {
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function () {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modal.hide();
}
});
//form.submit(); // Submit form
}, 2000);
}
});
}
});
}
return {
// Public functions
init: function () {
initUpdatePassword();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersUpdatePassword.init();
});

View file

@ -0,0 +1,132 @@
"use strict";
// Class definition
var KTUsersUpdateRole = function () {
// Shared variables
const element = document.getElementById('kt_modal_update_role');
const form = element.querySelector('#kt_modal_update_role_form');
const modal = new bootstrap.Modal(element);
// Init add schedule modal
var initUpdateRole = () => {
// Close button handler
const closeButton = element.querySelector('[data-kt-users-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Cancel button handler
const cancelButton = element.querySelector('[data-kt-users-modal-action="cancel"]');
cancelButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
// Submit button handler
const submitButton = element.querySelector('[data-kt-users-modal-action="submit"]');
submitButton.addEventListener('click', function (e) {
// Prevent default button action
e.preventDefault();
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function () {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
}).then(function (result) {
if (result.isConfirmed) {
modal.hide();
}
});
//form.submit(); // Submit form
}, 2000);
});
}
return {
// Public functions
init: function () {
initUpdateRole();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersUpdateRole.init();
});

View file

@ -0,0 +1,234 @@
"use strict";
// Class definition
var KTUsersViewMain = function () {
// Init login session button
var initLoginSession = () => {
const button = document.getElementById('kt_modal_sign_out_sesions');
button.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like sign out all sessions?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, sign out!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
Swal.fire({
text: "You have signed out all sessions!.",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your sessions are still preserved!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
}
// Init sign out single user
var initSignOutUser = () => {
const signOutButtons = document.querySelectorAll('[data-kt-users-sign-out="single_user"]');
signOutButtons.forEach(button => {
button.addEventListener('click', e => {
e.preventDefault();
const deviceName = button.closest('tr').querySelectorAll('td')[1].innerText;
Swal.fire({
text: "Are you sure you would like sign out " + deviceName + "?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, sign out!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
Swal.fire({
text: "You have signed out " + deviceName + "!.",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
}).then(function(){
button.closest('tr').remove();
});
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: deviceName + "'s session is still preserved!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
});
}
// Delete two step authentication handler
const initDeleteTwoStep = () => {
const deleteButton = document.getElementById('kt_users_delete_two_step');
deleteButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like remove this two-step authentication?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, remove it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
Swal.fire({
text: "You have removed this two-step authentication!.",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your two-step authentication is still valid!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
})
}
// Email preference form handler
const initEmailPreferenceForm = () => {
// Define variables
const form = document.getElementById('kt_users_email_notification_form');
const submitButton = form.querySelector('#kt_users_email_notification_submit');
const cancelButton = form.querySelector('#kt_users_email_notification_cancel');
// Submit action handler
submitButton.addEventListener('click', e => {
e.preventDefault();
// Show loading indication
submitButton.setAttribute('data-kt-indicator', 'on');
// Disable button to avoid multiple click
submitButton.disabled = true;
// Simulate form submission. For more info check the plugin's official documentation: https://sweetalert2.github.io/
setTimeout(function () {
// Remove loading indication
submitButton.removeAttribute('data-kt-indicator');
// Enable button
submitButton.disabled = false;
// Show popup confirmation
Swal.fire({
text: "Form has been successfully submitted!",
icon: "success",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
//form.submit(); // Submit form
}, 2000);
});
cancelButton.addEventListener('click', e => {
e.preventDefault();
Swal.fire({
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary",
}
});
}
});
});
}
return {
// Public functions
init: function () {
initLoginSession();
initSignOutUser();
initDeleteTwoStep();
initEmailPreferenceForm();
}
};
}();
// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersViewMain.init();
});

File diff suppressed because it is too large Load diff