From d739c6b81c61f5b272d4de520508cf8b856a6f4e Mon Sep 17 00:00:00 2001 From: Manuel Aranda Date: Tue, 14 Jul 2026 10:45:01 +0200 Subject: [PATCH] ref 3008. Last selected OU --- .../app/components/groups/groups.component.ts | 22 +++++++++++++------ ogWebconsole/src/app/services/auth.service.ts | 1 + 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ogWebconsole/src/app/components/groups/groups.component.ts b/ogWebconsole/src/app/components/groups/groups.component.ts index 15e6fe5..984718d 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.ts +++ b/ogWebconsole/src/app/components/groups/groups.component.ts @@ -168,7 +168,7 @@ export class GroupsComponent implements OnInit, OnDestroy { ngOnInit(): void { this.updateGridCols(); - this.refreshData(); + this.refreshData(localStorage.getItem('lastSelectedOU') ?? undefined); window.addEventListener('resize', this.updateGridCols); this.selectedClients.filterPredicate = (client: Client, filter: string): boolean => { @@ -340,12 +340,12 @@ export class GroupsComponent implements OnInit, OnDestroy { this.treeDataSource.data = [...this.originalTreeData]; if (selectedNodeIdOrUuid) { this.selectedNode = this.findNodeByIdOrUuid(this.treeDataSource.data, selectedNodeIdOrUuid); + } - if (this.selectedNode) { - this.treeControl.collapseAll(); - this.expandPathToNode(this.selectedNode); - this.fetchClientsForNode(this.selectedNode, selectedClientsBeforeEdit); - } + if (selectedNodeIdOrUuid && this.selectedNode) { + this.treeControl.collapseAll(); + this.expandPathToNode(this.selectedNode); + this.fetchClientsForNode(this.selectedNode, selectedClientsBeforeEdit); } else { this.treeControl.collapseAll(); if (this.treeDataSource.data.length > 0) { @@ -419,8 +419,9 @@ export class GroupsComponent implements OnInit, OnDestroy { onNodeClick(event: MouseEvent, node: TreeNode): void { event.stopPropagation(); this.selectedNode = node; + this.persistSelectedNode(node); const selectedClientsBeforeEdit = this.selection.selected.map(client => client.uuid); - + const checkStatusAfterLoad = node.type === NodeType.Classroom || node.type === NodeType.ClientsGroup; this.fetchClientsForNode(node, selectedClientsBeforeEdit, checkStatusAfterLoad); } @@ -428,10 +429,17 @@ export class GroupsComponent implements OnInit, OnDestroy { onMenuClick(event: Event, node: any): void { event.stopPropagation(); this.selectedNode = node; + this.persistSelectedNode(node); const selectedClientsBeforeEdit = this.selection.selected.map(client => client.uuid); this.fetchClientsForNode(node, selectedClientsBeforeEdit); } + private persistSelectedNode(node: TreeNode): void { + if (node.uuid) { + localStorage.setItem('lastSelectedOU', node.uuid); + } + } + diff --git a/ogWebconsole/src/app/services/auth.service.ts b/ogWebconsole/src/app/services/auth.service.ts index c88d1b0..d3b0104 100644 --- a/ogWebconsole/src/app/services/auth.service.ts +++ b/ogWebconsole/src/app/services/auth.service.ts @@ -128,6 +128,7 @@ export class AuthService { localStorage.removeItem('username'); localStorage.removeItem('groupsView'); localStorage.removeItem('language'); + localStorage.removeItem('lastSelectedOU'); this.tokenPayload = null; if (options.redirect && this.router.url !== '/auth/login') { this.router.navigate(['/auth/login']);