INIT
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
// Configuration loader
|
||||
let appConfig = null;
|
||||
|
||||
/**
|
||||
* Load configuration from config.json
|
||||
*/
|
||||
async function loadConfig() {
|
||||
if (appConfig) {
|
||||
return appConfig;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/config.json');
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to load config: ${response.statusText}`);
|
||||
}
|
||||
appConfig = await response.json();
|
||||
return appConfig;
|
||||
} catch (error) {
|
||||
console.error('Error loading config:', error);
|
||||
// Return default config if file can't be loaded
|
||||
return {
|
||||
pocketbase: {
|
||||
collections: {
|
||||
jobs: "Job_Info",
|
||||
notes: "notes",
|
||||
users: "users"
|
||||
}
|
||||
},
|
||||
pagination: {
|
||||
itemsPerPage: 20
|
||||
},
|
||||
filters: {
|
||||
defaultFilter: "all"
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the jobs collection name
|
||||
*/
|
||||
async function getJobsCollection() {
|
||||
const config = await loadConfig();
|
||||
return config.pocketbase.collections.jobs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notes collection name
|
||||
*/
|
||||
async function getNotesCollection() {
|
||||
const config = await loadConfig();
|
||||
return config.pocketbase.collections.notes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get items per page setting
|
||||
*/
|
||||
async function getItemsPerPage() {
|
||||
const config = await loadConfig();
|
||||
return config.pagination.itemsPerPage || 20;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user