feat: add shared utilities and table macros

- Add shared table macros for consistent table styling
- Add shared JavaScript utilities (date formatting, etc.)
- Add admin settings API enhancements
- Add admin schema updates

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-21 14:12:43 +01:00
parent a118edced5
commit 9cf0a568c0
4 changed files with 346 additions and 0 deletions

View File

@@ -184,7 +184,86 @@ const Utils = {
}
};
// ============================================================================
// Platform Settings
// ============================================================================
/**
* Platform settings cache and loader
*/
const PlatformSettings = {
_settings: null,
_loading: false,
_loadPromise: null,
/**
* Load platform display settings from API
* @returns {Promise<Object>} Platform settings
*/
async load() {
// Return cached settings if available
if (this._settings) {
return this._settings;
}
// Return existing promise if already loading
if (this._loadPromise) {
return this._loadPromise;
}
this._loading = true;
this._loadPromise = (async () => {
try {
const response = await fetch('/api/v1/admin/settings/display/public');
if (response.ok) {
this._settings = await response.json();
} else {
// Default settings
this._settings = { rows_per_page: 20 };
}
} catch (error) {
console.warn('Failed to load platform settings, using defaults:', error);
this._settings = { rows_per_page: 20 };
}
this._loading = false;
return this._settings;
})();
return this._loadPromise;
},
/**
* Get rows per page setting
* @returns {number} Rows per page (default: 20)
*/
getRowsPerPage() {
return this._settings?.rows_per_page || 20;
},
/**
* Get rows per page synchronously (returns cached or default)
* @returns {number} Rows per page
*/
get rowsPerPage() {
return this._settings?.rows_per_page || 20;
},
/**
* Reset cached settings (call after updating settings)
*/
reset() {
this._settings = null;
this._loadPromise = null;
}
};
// Load settings on page load
document.addEventListener('DOMContentLoaded', () => {
PlatformSettings.load();
});
// Make available globally
window.PlatformSettings = PlatformSettings;
window.Utils = Utils;
// Export for modules