generalbots/botui/ui/suite/monitoring/resources.js
Rodrigo Rodriguez (Pragmatismo) 037db5c381 feat: Major workspace reorganization and documentation update
- Add comprehensive documentation in botbook/ with 12 chapters
- Add botapp/ Tauri desktop application
- Add botdevice/ IoT device support
- Add botlib/ shared library crate
- Add botmodels/ Python ML models service
- Add botplugin/ browser extension
- Add botserver/ reorganized server code
- Add bottemplates/ bot templates
- Add bottest/ integration tests
- Add botui/ web UI server
- Add CI/CD workflows in .forgejo/workflows/
- Add AGENTS.md and PROD.md documentation
- Add dependency management scripts (DEPENDENCIES.sh/ps1)
- Remove legacy src/ structure and migrations
- Clean up temporary and backup files
2026-04-19 08:14:25 -03:00

54 lines
1.5 KiB
JavaScript

/* Resources page JavaScript */
function refreshDiskInfo() {
htmx.trigger('#disk-partitions', 'refresh');
}
function sortProcesses(sortBy) {
const sortParam = `?sort=${sortBy}`;
htmx.ajax('GET', `/api/monitoring/resources/processes${sortParam}`, {
target: '#process-list',
swap: 'innerHTML'
});
}
// Color-code usage based on percentage
function updateUsageColors() {
document.querySelectorAll('.card-value').forEach(el => {
const value = parseInt(el.textContent);
if (value >= 90) {
el.classList.add('error');
el.classList.remove('warning');
} else if (value >= 75) {
el.classList.add('warning');
el.classList.remove('error');
} else {
el.classList.remove('warning', 'error');
}
});
document.querySelectorAll('.usage-fill, .progress-fill').forEach(el => {
const width = parseInt(el.style.width);
if (width >= 90) {
el.classList.add('error');
el.classList.remove('warning');
} else if (width >= 75) {
el.classList.add('warning');
el.classList.remove('error');
} else {
el.classList.remove('warning', 'error');
}
});
}
// Run on HTMX swap for resources
document.body.addEventListener('htmx:afterSwap', function(evt) {
if (evt.target.closest('.resources-container')) {
updateUsageColors();
}
});
// Initialize on page load
document.addEventListener('DOMContentLoaded', function() {
updateUsageColors();
});