This commit is contained in:
Juergen Kunz
2025-07-04 18:50:15 +00:00
parent 5d4bf4eff8
commit aed9151998
3 changed files with 9 additions and 25 deletions

View File

@@ -321,7 +321,6 @@ export const toggleAutoRefreshAction = uiStatePart.createAction(async (statePart
// Set Active View Action // Set Active View Action
export const setActiveViewAction = uiStatePart.createAction<string>(async (statePartArg, viewName) => { export const setActiveViewAction = uiStatePart.createAction<string>(async (statePartArg, viewName) => {
const currentState = statePartArg.getState(); const currentState = statePartArg.getState();
console.log('[SetActiveView]', currentState.activeView, '->', viewName);
// If switching to network view, ensure we fetch network data // If switching to network view, ensure we fetch network data
if (viewName === 'network' && currentState.activeView !== 'network') { if (viewName === 'network' && currentState.activeView !== 'network') {
@@ -402,7 +401,6 @@ export const fetchNetworkStatsAction = networkStatePart.createAction(async (stat
async function dispatchCombinedRefreshAction() { async function dispatchCombinedRefreshAction() {
const context = getActionContext(); const context = getActionContext();
const currentView = uiStatePart.getState().activeView; const currentView = uiStatePart.getState().activeView;
console.log('[CombinedRefresh] activeView:', currentView, 'will fetch network:', currentView === 'network');
try { try {
// Always fetch basic stats for dashboard widgets // Always fetch basic stats for dashboard widgets

View File

@@ -27,10 +27,10 @@ export class OpsDashboard extends DeesElement {
}; };
@state() private uiState: appstate.IUiState = { @state() private uiState: appstate.IUiState = {
activeView: 'dashboard', activeView: 'overview',
sidebarCollapsed: false, sidebarCollapsed: false,
autoRefresh: true, autoRefresh: true,
refreshInterval: 30000, refreshInterval: 1000,
theme: 'light', theme: 'light',
}; };
@@ -87,9 +87,6 @@ export class OpsDashboard extends DeesElement {
{ {
name: 'Network', name: 'Network',
element: OpsViewNetwork, element: OpsViewNetwork,
action: () => {
appstate.uiStatePart.dispatchAction(appstate.setActiveViewAction, 'network');
},
}, },
{ {
name: 'Emails', name: 'Emails',
@@ -108,14 +105,6 @@ export class OpsDashboard extends DeesElement {
element: OpsViewSecurity, element: OpsViewSecurity,
}, },
]} ]}
.userMenuItems=${[
{
name: 'Logout',
action: async () => {
await appstate.loginStatePart.dispatchAction(appstate.logoutAction, null);
},
},
]}
> >
</dees-simple-appdash> </dees-simple-appdash>
</dees-simple-login> </dees-simple-login>
@@ -133,10 +122,15 @@ export class OpsDashboard extends DeesElement {
// Handle view changes // Handle view changes
const appDash = this.shadowRoot.querySelector('dees-simple-appdash'); const appDash = this.shadowRoot.querySelector('dees-simple-appdash');
if (appDash) { if (appDash) {
appDash.addEventListener('viewSwitch', (e: CustomEvent) => { appDash.addEventListener('view-select', (e: CustomEvent) => {
const viewName = e.detail.tabName; const viewName = e.detail.view.name;
appstate.uiStatePart.dispatchAction(appstate.setActiveViewAction, viewName.toLowerCase()); appstate.uiStatePart.dispatchAction(appstate.setActiveViewAction, viewName.toLowerCase());
}); });
// Handle logout event
appDash.addEventListener('logout', async () => {
await appstate.loginStatePart.dispatchAction(appstate.logoutAction, null);
});
} }
// Handle initial state // Handle initial state
@@ -175,8 +169,4 @@ export class OpsDashboard extends DeesElement {
form.reset(); form.reset();
} }
} }
private async logout() {
await appstate.loginStatePart.dispatchAction(appstate.logoutAction, null);
}
} }

View File

@@ -65,10 +65,6 @@ export class OpsViewNetwork extends DeesElement {
async connectedCallback() { async connectedCallback() {
await super.connectedCallback(); await super.connectedCallback();
console.log('[NetworkView] Connected - setting activeView to network');
// Force the activeView to be 'network' when this component connects
await appstate.uiStatePart.dispatchAction(appstate.setActiveViewAction, 'network');
// When network view becomes visible, ensure we fetch network data // When network view becomes visible, ensure we fetch network data
await appstate.networkStatePart.dispatchAction(appstate.fetchNetworkStatsAction, null); await appstate.networkStatePart.dispatchAction(appstate.fetchNetworkStatsAction, null);