Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
page navigation fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
drunkleen committed Mar 10, 2024
1 parent fd9b31d commit 4f92dd1
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 241 deletions.
1 change: 0 additions & 1 deletion core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ def panel_admin(request) -> HttpResponse:
context["cpu_percent"] = psutil.cpu_percent(interval=1)
context["ram_percent"] = psutil.virtual_memory().percent

print(context)
return render(request, 'panel/pages/overview.html', context)
return redirect('panel-user', username=request.user.username)

Expand Down
150 changes: 29 additions & 121 deletions static/panel/js/custom/apps/user-management/roles/list/add.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,52 @@
"use strict";

// Class definition
var KTUsersAddRole = function () {
var KTUsersAddUser = function () {
// Shared variables
const element = document.getElementById('kt_modal_add_role');
const form = element.querySelector('#kt_modal_add_role_form');
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 initAddRole = () => {
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: {
'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 => {
// 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 close?",
text: "Are you sure you would like to cancel?",
icon: "warning",
showCancelButton: true,
buttonsStyling: false,
confirmButtonText: "Yes, close it!",
confirmButtonText: "Yes, cancel it!",
cancelButtonText: "No, return",
customClass: {
confirmButton: "btn btn-primary",
cancelButton: "btn btn-active-light"
}
}).then(function (result) {
if (result.value) {
modal.hide(); // Hide modal
}
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",
}
});
}
});
});

// Cancel button handler
const cancelButton = element.querySelector('[data-kt-roles-modal-action="cancel"]');
cancelButton.addEventListener('click', e => {
// Close button handler
const closeButton = element.querySelector('[data-kt-users-modal-action="close"]');
closeButton.addEventListener('click', e => {
e.preventDefault();

Swal.fire({
Expand All @@ -76,8 +62,8 @@ var KTUsersAddRole = function () {
}
}).then(function (result) {
if (result.value) {
form.reset(); // Reset form
modal.hide(); // Hide modal
form.reset(); // Reset form
modal.hide();
} else if (result.dismiss === 'cancel') {
Swal.fire({
text: "Your form has not been cancelled!.",
Expand All @@ -91,95 +77,17 @@ var KTUsersAddRole = function () {
}
});
});

// 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();
initAddUser();
}
};
}();

// On document ready
KTUtil.onDOMContentLoaded(function () {
KTUsersAddRole.init();
KTUsersAddUser.init();
});
2 changes: 1 addition & 1 deletion static/panel/js/custom/pages/user-profile/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ var KTProfileGeneral = function () {

if ( localStorage.getItem('nav-initialized') === "1") {
window.scroll({
top: parseInt(profileNav.getAttribute("data-kt-pages-scroll-position")),
top: parseInt(profileNav.getAttribute("data-kt-page-scroll-position")),
behavior: 'smooth'
});
}
Expand Down
18 changes: 9 additions & 9 deletions static/panel/js/scripts.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (document.readyState === "loading") {
KTComponents.init();
}

// Init pages loader
// Init page loader
window.addEventListener("load", function() {
KTApp.hidePageLoading();
});
Expand Down Expand Up @@ -649,14 +649,14 @@ var KTApp = function () {
}

var showPageLoading = function() {
document.body.classList.add('pages-loading');
document.body.setAttribute('data-kt-app-pages-loading', "on");
document.body.classList.add('page-loading');
document.body.setAttribute('data-kt-app-page-loading', "on");
}

var hidePageLoading = function() {
// CSS3 Transitions only after pages load(.pages-loading or .app-pages-loading class added to body tag and remove with JS on pages load)
document.body.classList.remove('pages-loading');
document.body.removeAttribute('data-kt-app-pages-loading');
// CSS3 Transitions only after page load(.page-loading or .app-page-loading class added to body tag and remove with JS on page load)
document.body.classList.remove('page-loading');
document.body.removeAttribute('data-kt-app-page-loading');
}

return {
Expand Down Expand Up @@ -7443,7 +7443,7 @@ var KTAppLayoutBuilder = function() {
);

setTimeout(function() {
location.reload(); // reload pages
location.reload(); // reload page
}, 1500);
},
error: function(response) {
Expand Down Expand Up @@ -7537,13 +7537,13 @@ var KTAppLayoutBuilder = function() {
return;

toastr.success(
"Preview has been successfully reset and the pages will be reloaded.",
"Preview has been successfully reset and the page will be reloaded.",
"Reset Preview!",
{timeOut: 0, extendedTimeOut: 0, closeButton: true, closeDuration: 0}
);

setTimeout(function() {
location.reload(); // reload pages
location.reload(); // reload page
}, 1500);
},
error: function(response) {
Expand Down
4 changes: 2 additions & 2 deletions static/panel/js/widgets.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -17976,7 +17976,7 @@ var KTTimelineWidget1 = function () {
group: 'ui',
start: moment(now).add(30, 'minutes'),
end: moment(now).add(2.5, 'hours'),
content: 'Landing pages',
content: 'Landing page',
progress: "55%",
color: 'danger',
users: [
Expand Down Expand Up @@ -18637,7 +18637,7 @@ var KTTimelineWidget4 = function () {
group: 'ui',
start: moment(now).add(30, 'minutes'),
end: moment(now).add(2.5, 'hours'),
content: 'Landing pages',
content: 'Landing page',
progress: "55%",
color: 'danger',
users: [
Expand Down
Loading

0 comments on commit 4f92dd1

Please sign in to comment.