// Plugin management functionality
async function loadPlugins() {
try {
const response = await fetch('/panel/api/plugins');
const plugins = await response.json();
const pluginsList = document.getElementById('pluginsList');
pluginsList.innerHTML = plugins.map(plugin => `
| ${plugin.name} |
${plugin.description || 'No description available.'} |
${plugin.enabled ? 'Enabled' : 'Disabled'}
|
|
`).join('');
/*
Suggested CSS for the new classes (add to your panel's CSS file):
.plugin-row.plugin-disabled { opacity: 0.7; }
.plugin-name { font-weight: bold; }
.badge { padding: 0.4em 0.6em; font-size: 0.9em; }
.bg-success { background-color: #28a745; color: white; }
.bg-secondary { background-color: #6c757d; color: white; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: .875rem; }
.btn-outline-warning { border-color: #ffc107; color: #ffc107; }
.btn-outline-warning:hover { background-color: #ffc107; color: #212529; }
.btn-outline-success { border-color: #28a745; color: #28a745; }
.btn-outline-success:hover { background-color: #28a745; color: white; }
*/
} catch (error) {
showToast(error.message, 'error');
}
}
async function togglePlugin(pluginName) {
try {
const response = await fetch('/panel/api/plugins/toggle', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ pluginName })
});
const result = await response.json();
showToast(result.message);
loadPlugins(); // Refresh the plugins list
} catch (error) {
showToast(error.message, 'error');
}
}
// Load plugins when the plugins section is shown
document.querySelector('[onclick="showSection(\'plugins\')"]')
.addEventListener('click', loadPlugins);