Initial commit

This commit is contained in:
2025-12-08 12:12:07 +07:00
commit 0b2e8c4c16
1238 changed files with 160253 additions and 0 deletions

45
js/real_api.js Normal file
View File

@@ -0,0 +1,45 @@
export class RealApi {
static getBaseUrl() {
// Adjust if serving from a different machine
return window.location.hostname === 'localhost'
? 'http://localhost:3001/api'
: `http://${window.location.hostname}:3001/api`;
}
static async fetchData(endpoint) {
try {
const response = await fetch(`${this.getBaseUrl()}${endpoint}`);
if (!response.ok) throw new Error(`API Error: ${response.status}`);
return await response.json();
} catch (error) {
console.error(error);
return null; // Handle gracefully in UI
}
}
static async getDashboardStats() {
const data = await this.fetchData('/dashboard');
return data || {
totalJobs: 0,
successRate: 0,
totalBytes: 0,
activeClients: 0,
storageUsage: 0
};
}
static async getRecentJobs() {
const data = await this.fetchData('/jobs');
return data || [];
}
static async getClients() {
const data = await this.fetchData('/clients');
return data || [];
}
static async getStorage() {
const data = await this.fetchData('/storage');
return data || [];
}
}