v1.0.0-alpha4: Add Redis/Valkey caching and search with principal agent auth for global settings
This commit is contained in:
+33
-4
@@ -339,7 +339,7 @@
|
||||
}, 200);
|
||||
}
|
||||
|
||||
// Load app settings from PocketBase
|
||||
// Load app settings from PocketBase (global settings)
|
||||
async function loadAppSettings() {
|
||||
try {
|
||||
const records = await pb.collection('app_preferences_settings').getFullList({
|
||||
@@ -777,7 +777,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Load table data from PocketBase respecting current column order/visibility
|
||||
// Load table data from Redis cache (via API endpoint)
|
||||
async function loadTableData() {
|
||||
try {
|
||||
if (isLoadingTableData) {
|
||||
@@ -787,10 +787,25 @@
|
||||
isLoadingTableData = true;
|
||||
loadingIndicator.classList.remove('hidden');
|
||||
|
||||
const records = await pb.collection('Job_Info_TestEnv').getFullList({
|
||||
sort: 'Job_Number',
|
||||
// Fetch from cached API endpoint
|
||||
const response = await fetch('/api/jobs', {
|
||||
headers: {
|
||||
'X-PocketBase-Token': pb.authStore.token
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch jobs from API');
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
if (!result.success) {
|
||||
throw new Error(result.message || 'Failed to fetch jobs');
|
||||
}
|
||||
|
||||
const records = result.data;
|
||||
console.log(`Loaded ${records.length} jobs ${result.cached ? 'from cache' : 'from PocketBase'}`);
|
||||
|
||||
tableBody.innerHTML = '';
|
||||
const visibleColumns = getVisibleColumns();
|
||||
|
||||
@@ -863,6 +878,20 @@
|
||||
[fieldName]: newValue
|
||||
});
|
||||
console.log(`Updated ${fieldName} to ${newValue} for record ${recordId}`);
|
||||
|
||||
// Clear cache to force fresh data on next load
|
||||
try {
|
||||
await fetch('/api/cache/clear', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-PocketBase-Token': pb.authStore.token
|
||||
}
|
||||
});
|
||||
console.log('Cache cleared after update');
|
||||
} catch (cacheError) {
|
||||
console.warn('Failed to clear cache:', cacheError);
|
||||
// Non-fatal - data is still updated in PocketBase
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error updating field:', error);
|
||||
// Revert checkbox on error
|
||||
|
||||
Reference in New Issue
Block a user