Added settings menu
This commit is contained in:
@@ -2604,3 +2604,313 @@ body.dark-mode select option {
|
||||
color: var(--terminal-cyan);
|
||||
text-shadow: 0 0 5px var(--terminal-cyan);
|
||||
}
|
||||
|
||||
/* ========================================
|
||||
SETTINGS MODAL STYLES
|
||||
======================================== */
|
||||
|
||||
/* Settings Icon */
|
||||
.settings-icon {
|
||||
background: transparent;
|
||||
border: 2px solid var(--terminal-green);
|
||||
color: var(--terminal-green);
|
||||
font-size: 1.2rem;
|
||||
padding: 0.25rem 0.5rem;
|
||||
cursor: pointer;
|
||||
font-family: var(--font-mono);
|
||||
transition: all 0.3s ease;
|
||||
border-radius: 0;
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
.settings-icon:hover {
|
||||
background: var(--terminal-green);
|
||||
color: var(--bg-primary);
|
||||
box-shadow: var(--glow-green);
|
||||
}
|
||||
|
||||
/* Settings Modal Container */
|
||||
.settings-modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 10000;
|
||||
}
|
||||
|
||||
.settings-backdrop {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
backdrop-filter: blur(5px);
|
||||
}
|
||||
|
||||
.settings-content {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
background: var(--bg-secondary);
|
||||
border: 2px solid var(--terminal-green);
|
||||
box-shadow: 0 0 30px rgba(0, 255, 65, 0.5);
|
||||
max-width: 800px;
|
||||
max-height: 90vh;
|
||||
overflow-y: auto;
|
||||
font-family: var(--font-mono);
|
||||
padding: 2rem;
|
||||
animation: settingsSlideIn 0.3s ease;
|
||||
}
|
||||
|
||||
@keyframes settingsSlideIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translate(-50%, -60%);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
}
|
||||
|
||||
/* Settings Header */
|
||||
.settings-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 2rem;
|
||||
padding-bottom: 1rem;
|
||||
border-bottom: 2px solid var(--terminal-green);
|
||||
}
|
||||
|
||||
.settings-header h3 {
|
||||
color: var(--terminal-amber);
|
||||
text-shadow: var(--glow-amber);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 1.5rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.close-settings {
|
||||
background: transparent;
|
||||
border: 2px solid var(--terminal-green);
|
||||
color: var(--terminal-green);
|
||||
font-size: 1.5rem;
|
||||
padding: 0.25rem 0.75rem;
|
||||
cursor: pointer;
|
||||
font-family: var(--font-mono);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.close-settings:hover {
|
||||
background: var(--status-closed);
|
||||
border-color: var(--status-closed);
|
||||
color: var(--bg-primary);
|
||||
box-shadow: 0 0 10px var(--status-closed);
|
||||
}
|
||||
|
||||
/* Settings Body */
|
||||
.settings-body {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
/* Settings Sections */
|
||||
.settings-section {
|
||||
margin-bottom: 2rem;
|
||||
border: 2px solid var(--terminal-green);
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.settings-section h4 {
|
||||
color: var(--terminal-amber);
|
||||
text-shadow: var(--glow-amber);
|
||||
font-family: var(--font-mono);
|
||||
margin-bottom: 1rem;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
/* Setting Rows */
|
||||
.setting-row {
|
||||
margin-bottom: 1rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.setting-row:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.setting-row label {
|
||||
color: var(--terminal-green);
|
||||
font-family: var(--font-mono);
|
||||
min-width: 180px;
|
||||
}
|
||||
|
||||
.setting-select {
|
||||
flex: 1;
|
||||
max-width: 200px;
|
||||
font-family: var(--font-mono);
|
||||
background: var(--bg-primary);
|
||||
color: var(--terminal-green);
|
||||
border: 2px solid var(--terminal-green);
|
||||
padding: 0.5rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.setting-select:focus {
|
||||
outline: none;
|
||||
border-color: var(--terminal-amber);
|
||||
box-shadow: 0 0 10px rgba(255, 193, 7, 0.3);
|
||||
}
|
||||
|
||||
/* Checkbox Group */
|
||||
.checkbox-group {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
flex-wrap: wrap;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.checkbox-group label {
|
||||
min-width: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.checkbox-group input[type="checkbox"] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Keyboard Shortcuts Display */
|
||||
.shortcuts-list {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.shortcut-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 0.5rem 0;
|
||||
border-bottom: 1px solid var(--terminal-green);
|
||||
}
|
||||
|
||||
.shortcut-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.shortcut-item kbd {
|
||||
background: var(--bg-primary);
|
||||
border: 2px solid var(--terminal-green);
|
||||
padding: 0.25rem 0.5rem;
|
||||
color: var(--terminal-amber);
|
||||
text-shadow: var(--glow-amber);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.shortcut-item span {
|
||||
color: var(--terminal-green);
|
||||
}
|
||||
|
||||
/* User Info Grid */
|
||||
.user-info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 150px 1fr;
|
||||
gap: 0.5rem 1rem;
|
||||
font-family: var(--font-mono);
|
||||
color: var(--terminal-green);
|
||||
}
|
||||
|
||||
.user-info-grid div {
|
||||
padding: 0.25rem 0;
|
||||
}
|
||||
|
||||
/* Settings Footer */
|
||||
.settings-footer {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
justify-content: flex-end;
|
||||
padding-top: 1rem;
|
||||
border-top: 2px solid var(--terminal-green);
|
||||
}
|
||||
|
||||
.settings-footer .btn {
|
||||
font-family: var(--font-mono);
|
||||
padding: 0.75rem 1.5rem;
|
||||
border: 2px solid;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.settings-footer .btn-primary {
|
||||
color: var(--status-open);
|
||||
border-color: var(--status-open);
|
||||
}
|
||||
|
||||
.settings-footer .btn-primary:hover {
|
||||
background: var(--status-open);
|
||||
color: var(--bg-primary);
|
||||
box-shadow: 0 0 15px var(--status-open);
|
||||
}
|
||||
|
||||
.settings-footer .btn-secondary {
|
||||
color: var(--terminal-green);
|
||||
border-color: var(--terminal-green);
|
||||
}
|
||||
|
||||
.settings-footer .btn-secondary:hover {
|
||||
background: var(--terminal-green);
|
||||
color: var(--bg-primary);
|
||||
box-shadow: var(--glow-green);
|
||||
}
|
||||
|
||||
/* Table Density Classes */
|
||||
.table-compact table {
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.table-compact th,
|
||||
.table-compact td {
|
||||
padding: 6px 10px;
|
||||
}
|
||||
|
||||
.table-comfortable table {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.table-comfortable th,
|
||||
.table-comfortable td {
|
||||
padding: 16px 20px;
|
||||
}
|
||||
|
||||
/* Responsive Settings Modal */
|
||||
@media (max-width: 768px) {
|
||||
.settings-content {
|
||||
max-width: 95%;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.setting-row {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.setting-row label {
|
||||
min-width: auto;
|
||||
}
|
||||
|
||||
.setting-select {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.user-info-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
142
assets/js/settings.js
Normal file
142
assets/js/settings.js
Normal file
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* Settings Management System
|
||||
* Handles loading, saving, and applying user preferences
|
||||
*/
|
||||
|
||||
let userPreferences = {};
|
||||
|
||||
// Load preferences on page load
|
||||
async function loadUserPreferences() {
|
||||
try {
|
||||
const response = await fetch('/api/user_preferences.php');
|
||||
const data = await response.json();
|
||||
if (data.success) {
|
||||
userPreferences = data.preferences;
|
||||
applyPreferences();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading preferences:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply preferences to UI
|
||||
function applyPreferences() {
|
||||
// Rows per page
|
||||
const rowsPerPage = userPreferences.rows_per_page || '15';
|
||||
const rowsSelect = document.getElementById('rowsPerPage');
|
||||
if (rowsSelect) {
|
||||
rowsSelect.value = rowsPerPage;
|
||||
}
|
||||
|
||||
// Default filters
|
||||
const defaultFilters = (userPreferences.default_status_filters || 'Open,Pending,In Progress').split(',');
|
||||
document.querySelectorAll('[name="defaultFilters"]').forEach(cb => {
|
||||
cb.checked = defaultFilters.includes(cb.value);
|
||||
});
|
||||
|
||||
// Table density
|
||||
const density = userPreferences.table_density || 'normal';
|
||||
const densitySelect = document.getElementById('tableDensity');
|
||||
if (densitySelect) {
|
||||
densitySelect.value = density;
|
||||
}
|
||||
document.body.classList.remove('table-compact', 'table-comfortable');
|
||||
if (density !== 'normal') {
|
||||
document.body.classList.add(`table-${density}`);
|
||||
}
|
||||
|
||||
// Notifications
|
||||
const notificationsCheckbox = document.getElementById('notificationsEnabled');
|
||||
if (notificationsCheckbox) {
|
||||
notificationsCheckbox.checked = userPreferences.notifications_enabled !== '0';
|
||||
}
|
||||
|
||||
const soundCheckbox = document.getElementById('soundEffects');
|
||||
if (soundCheckbox) {
|
||||
soundCheckbox.checked = userPreferences.sound_effects !== '0';
|
||||
}
|
||||
|
||||
// Toast duration
|
||||
const toastDuration = userPreferences.toast_duration || '3000';
|
||||
const toastSelect = document.getElementById('toastDuration');
|
||||
if (toastSelect) {
|
||||
toastSelect.value = toastDuration;
|
||||
}
|
||||
}
|
||||
|
||||
// Save preferences
|
||||
async function saveSettings() {
|
||||
const prefs = {
|
||||
rows_per_page: document.getElementById('rowsPerPage').value,
|
||||
default_status_filters: Array.from(document.querySelectorAll('[name="defaultFilters"]:checked'))
|
||||
.map(cb => cb.value).join(','),
|
||||
table_density: document.getElementById('tableDensity').value,
|
||||
notifications_enabled: document.getElementById('notificationsEnabled').checked ? '1' : '0',
|
||||
sound_effects: document.getElementById('soundEffects').checked ? '1' : '0',
|
||||
toast_duration: document.getElementById('toastDuration').value
|
||||
};
|
||||
|
||||
try {
|
||||
// Save each preference
|
||||
for (const [key, value] of Object.entries(prefs)) {
|
||||
const response = await fetch('/api/user_preferences.php', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ key, value })
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
if (!result.success) {
|
||||
throw new Error(`Failed to save ${key}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof toast !== 'undefined') {
|
||||
toast.success('Preferences saved successfully!');
|
||||
}
|
||||
closeSettingsModal();
|
||||
|
||||
// Reload page to apply new preferences
|
||||
setTimeout(() => window.location.reload(), 1000);
|
||||
} catch (error) {
|
||||
if (typeof toast !== 'undefined') {
|
||||
toast.error('Error saving preferences');
|
||||
}
|
||||
console.error('Error saving preferences:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Modal controls
|
||||
function openSettingsModal() {
|
||||
const modal = document.getElementById('settingsModal');
|
||||
if (modal) {
|
||||
modal.style.display = 'block';
|
||||
loadUserPreferences();
|
||||
}
|
||||
}
|
||||
|
||||
function closeSettingsModal() {
|
||||
const modal = document.getElementById('settingsModal');
|
||||
if (modal) {
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// Keyboard shortcut to open settings (Alt+S)
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.altKey && e.key === 's') {
|
||||
e.preventDefault();
|
||||
openSettingsModal();
|
||||
}
|
||||
|
||||
// ESC to close modal
|
||||
if (e.key === 'Escape') {
|
||||
const modal = document.getElementById('settingsModal');
|
||||
if (modal && modal.style.display === 'block') {
|
||||
closeSettingsModal();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Initialize on page load
|
||||
document.addEventListener('DOMContentLoaded', loadUserPreferences);
|
||||
Reference in New Issue
Block a user