mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 21:03:01 +00:00
fix(web): use runtime default tab and add Alpine.initTree to fetch fallback
- Replace hard-coded 'overview' comparison with runtime defaultTab (isAPMode ? 'wifi' : 'overview') in both enhancement paths, so activeTab is preserved correctly in AP mode - Add Alpine.initTree(el) call in the plugin config fetch() fallback so Alpine directives in the injected HTML are initialized, matching the pattern used by loadOverviewDirect and loadWifiDirect Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -546,13 +546,14 @@
|
|||||||
// Preserve runtime state that should not be reset
|
// Preserve runtime state that should not be reset
|
||||||
const preservedPlugins = this.installedPlugins;
|
const preservedPlugins = this.installedPlugins;
|
||||||
const preservedTab = this.activeTab;
|
const preservedTab = this.activeTab;
|
||||||
|
const defaultTab = isAPMode ? 'wifi' : 'overview';
|
||||||
const wasInitialized = this._initialized;
|
const wasInitialized = this._initialized;
|
||||||
Object.assign(this, fullApp);
|
Object.assign(this, fullApp);
|
||||||
// Restore runtime state if non-default
|
// Restore runtime state if non-default
|
||||||
if (preservedPlugins && preservedPlugins.length > 0) {
|
if (preservedPlugins && preservedPlugins.length > 0) {
|
||||||
this.installedPlugins = preservedPlugins;
|
this.installedPlugins = preservedPlugins;
|
||||||
}
|
}
|
||||||
if (preservedTab && preservedTab !== 'overview') {
|
if (preservedTab && preservedTab !== defaultTab) {
|
||||||
this.activeTab = preservedTab;
|
this.activeTab = preservedTab;
|
||||||
}
|
}
|
||||||
if (wasInitialized) {
|
if (wasInitialized) {
|
||||||
@@ -1276,7 +1277,12 @@
|
|||||||
} else if (!window.htmx) {
|
} else if (!window.htmx) {
|
||||||
fetch('/v3/partials/plugin-config/' + pid)
|
fetch('/v3/partials/plugin-config/' + pid)
|
||||||
.then(r => r.text())
|
.then(r => r.text())
|
||||||
.then(html => { el.innerHTML = html; });
|
.then(html => {
|
||||||
|
el.innerHTML = html;
|
||||||
|
if (window.Alpine) {
|
||||||
|
window.Alpine.initTree(el);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
loadContent(0);
|
loadContent(0);
|
||||||
@@ -3091,6 +3097,9 @@
|
|||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
if (window._appEnhanced) return;
|
if (window._appEnhanced) return;
|
||||||
window._appEnhanced = true;
|
window._appEnhanced = true;
|
||||||
|
const isAPMode = window.location.hostname === '192.168.4.1' ||
|
||||||
|
window.location.hostname.startsWith('192.168.4.');
|
||||||
|
const defaultTab = isAPMode ? 'wifi' : 'overview';
|
||||||
const appElement = document.querySelector('[x-data]');
|
const appElement = document.querySelector('[x-data]');
|
||||||
if (appElement && appElement._x_dataStack && appElement._x_dataStack[0]) {
|
if (appElement && appElement._x_dataStack && appElement._x_dataStack[0]) {
|
||||||
const existingComponent = appElement._x_dataStack[0];
|
const existingComponent = appElement._x_dataStack[0];
|
||||||
@@ -3105,7 +3114,7 @@
|
|||||||
if (preservedPlugins && preservedPlugins.length > 0) {
|
if (preservedPlugins && preservedPlugins.length > 0) {
|
||||||
existingComponent.installedPlugins = preservedPlugins;
|
existingComponent.installedPlugins = preservedPlugins;
|
||||||
}
|
}
|
||||||
if (preservedTab && preservedTab !== 'overview') {
|
if (preservedTab && preservedTab !== defaultTab) {
|
||||||
existingComponent.activeTab = preservedTab;
|
existingComponent.activeTab = preservedTab;
|
||||||
}
|
}
|
||||||
// Call init to load plugins and set up watchers (only if not already initialized)
|
// Call init to load plugins and set up watchers (only if not already initialized)
|
||||||
|
|||||||
Reference in New Issue
Block a user