Files
eveAI/eveai_client/platform/static/assets/js/processing-status.js
Josako 5c982fcc2c - Added EveAI Client to project
- Improvements to EntitlementsDomain & Services
- Prechecks in Document domain
- Add audit information to LicenseUsage
2025-05-17 15:56:14 +02:00

64 lines
2.2 KiB
JavaScript

/**
* Processing Status Manager for EveAI Client
* Manages the processing status indicator in a consistent way
*/
class ProcessingStatusManager {
constructor(elementId = 'processingStatus') {
console.log('ProcessingStatusManager constructor: ', elementId);
this.statusElement = document.getElementById(elementId);
if (!this.statusElement) {
console.error(`Status element with ID "${elementId}" not found`);
// Create a temporary element to avoid errors
this.statusElement = document.createElement('span');
this.statusElement.id = elementId;
document.body.appendChild(this.statusElement);
}
// Initialize with ready state
this.ready('Ready');
console.log(`ProcessingStatusManager initialized with element ${elementId}`);
}
/**
* Update the processing status
* @param {string} message - The status message
* @param {string} stateType - State type (ready, processing, error)
*/
updateStatus(message, stateType) {
if (!this.statusElement) return this;
console.log(`ProcessingStatusManager: Updating status (${stateType}): ${message}`);
// Update text content
this.statusElement.textContent = message;
// Update class based on state type
this.statusElement.className = `badge bg-${stateType}`;
return this;
}
/**
* Convenience methods for different status types
*/
ready(message) { return this.updateStatus(message, 'ready'); }
processing(message) { return this.updateStatus(message, 'processing'); }
error(message) { return this.updateStatus(message, 'error'); }
}
// Initialize when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
console.log('ProcessingStatus.js DOMContentLoaded fired');
// Create global ProcessingStatusManager instance
window.processingStatus = new ProcessingStatusManager('processingStatus');
console.log('ProcessingStatusManager created:', {
instance: window.processingStatus,
constructor: window.processingStatus.constructor.name,
hasUpdateMethod: typeof window.processingStatus.updateStatus === 'function',
methods: Object.getOwnPropertyNames(window.processingStatus).filter(name =>
typeof window.processingStatus[name] === 'function')
});
});