mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 13:02:59 +00:00
fix(web): wire up "Check & Update All" plugins button (#249)
window.updateAllPlugins was never assigned, so the button always showed "Bulk update handler unavailable." Wire it to PluginInstallManager.updateAll(), add per-plugin progress feedback in the button text, show a summary notification on completion, and skip redundant plugin list reloads. Co-authored-by: Chuck <chuck@example.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -80,26 +80,34 @@ const PluginInstallManager = {
|
||||
|
||||
/**
|
||||
* Update all plugins.
|
||||
*
|
||||
*
|
||||
* @param {Function} onProgress - Optional callback(index, total, pluginId) for progress updates
|
||||
* @returns {Promise<Array>} Update results
|
||||
*/
|
||||
async updateAll() {
|
||||
async updateAll(onProgress) {
|
||||
if (!window.PluginStateManager || !window.PluginStateManager.installedPlugins) {
|
||||
throw new Error('Installed plugins not loaded');
|
||||
}
|
||||
|
||||
|
||||
const plugins = window.PluginStateManager.installedPlugins;
|
||||
const results = [];
|
||||
|
||||
for (const plugin of plugins) {
|
||||
|
||||
for (let i = 0; i < plugins.length; i++) {
|
||||
const plugin = plugins[i];
|
||||
if (onProgress) onProgress(i + 1, plugins.length, plugin.id);
|
||||
try {
|
||||
const result = await this.update(plugin.id);
|
||||
const result = await window.PluginAPI.updatePlugin(plugin.id);
|
||||
results.push({ pluginId: plugin.id, success: true, result });
|
||||
} catch (error) {
|
||||
results.push({ pluginId: plugin.id, success: false, error });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Reload plugin list once at the end
|
||||
if (window.PluginStateManager) {
|
||||
await window.PluginStateManager.loadInstalledPlugins();
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
};
|
||||
@@ -109,5 +117,6 @@ if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = PluginInstallManager;
|
||||
} else {
|
||||
window.PluginInstallManager = PluginInstallManager;
|
||||
window.updateAllPlugins = (onProgress) => PluginInstallManager.updateAll(onProgress);
|
||||
}
|
||||
|
||||
|
||||
@@ -1712,9 +1712,35 @@ function runUpdateAllPlugins() {
|
||||
button.dataset.running = 'true';
|
||||
button.disabled = true;
|
||||
button.classList.add('opacity-60', 'cursor-wait');
|
||||
button.innerHTML = '<i class="fas fa-sync fa-spin mr-2"></i>Updating...';
|
||||
button.innerHTML = '<i class="fas fa-sync fa-spin mr-2"></i>Checking...';
|
||||
|
||||
Promise.resolve(window.updateAllPlugins())
|
||||
const onProgress = (current, total, pluginId) => {
|
||||
button.innerHTML = `<i class="fas fa-sync fa-spin mr-2"></i>Updating ${current}/${total}...`;
|
||||
};
|
||||
|
||||
Promise.resolve(window.updateAllPlugins(onProgress))
|
||||
.then(results => {
|
||||
if (!results || !results.length) {
|
||||
showNotification('No plugins to update.', 'info');
|
||||
return;
|
||||
}
|
||||
let updated = 0, upToDate = 0, failed = 0;
|
||||
for (const r of results) {
|
||||
if (!r.success) {
|
||||
failed++;
|
||||
} else if (r.result && r.result.message && r.result.message.includes('already up to date')) {
|
||||
upToDate++;
|
||||
} else {
|
||||
updated++;
|
||||
}
|
||||
}
|
||||
const parts = [];
|
||||
if (updated > 0) parts.push(`${updated} updated`);
|
||||
if (upToDate > 0) parts.push(`${upToDate} already up to date`);
|
||||
if (failed > 0) parts.push(`${failed} failed`);
|
||||
const type = failed > 0 ? (updated > 0 ? 'warning' : 'error') : 'success';
|
||||
showNotification(parts.join(', '), type);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error updating all plugins:', error);
|
||||
if (typeof showNotification === 'function') {
|
||||
|
||||
Reference in New Issue
Block a user