diff --git a/ogWebconsole/src/app/components/groups/data.service.ts b/ogWebconsole/src/app/components/groups/data.service.ts index 795ebec..6e8ae9d 100644 --- a/ogWebconsole/src/app/components/groups/data.service.ts +++ b/ogWebconsole/src/app/components/groups/data.service.ts @@ -39,11 +39,10 @@ export class DataService { } getChildren(uuid: string): Observable { - console.log('uuid', uuid); return this.http.get(`${this.apiUrl}&parent=${uuid}`).pipe( map(response => { if (response['hydra:member'] && Array.isArray(response['hydra:member'])) { - return response['hydra:member'].filter((element: any) => element.parent === `/organizational-units/${uuid}`); + return response['hydra:member'].filter((element: any) => element.parent && element.parent['@id'] === `/organizational-units/${uuid}`); } else { throw new Error('Unexpected response format'); } @@ -55,12 +54,12 @@ export class DataService { ); } - getClients(unidadId: string): Observable { - console.log('unidadId', unidadId); + getClients(uuid: string): Observable { + console.log('unidadId', uuid); return this.http.get(this.clientsUrl).pipe( map(response => { if (response['hydra:member'] && Array.isArray(response['hydra:member'])) { - return response['hydra:member'].filter((client: any) => client.organizationalUnit === `/organizational-units/${unidadId}`); + return response['hydra:member'].filter((client: any) => client.organizationalUnit && client.organizationalUnit['@id'] === `/organizational-units/${uuid}`); } else { throw new Error('Unexpected response format'); } @@ -71,4 +70,6 @@ export class DataService { }) ); } + + } diff --git a/ogWebconsole/src/app/components/groups/groups.component.html b/ogWebconsole/src/app/components/groups/groups.component.html index 51b2cc0..b61ca4a 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.html +++ b/ogWebconsole/src/app/components/groups/groups.component.html @@ -15,15 +15,12 @@ apartment {{ unidad.nombre }} - - edit - delete - + - + {{ breadcrumb.join(' > ') }} @@ -31,7 +28,7 @@
- + apartment @@ -65,4 +62,5 @@ +
\ No newline at end of file diff --git a/ogWebconsole/src/app/components/groups/groups.component.ts b/ogWebconsole/src/app/components/groups/groups.component.ts index 19c3970..c379d78 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.ts +++ b/ogWebconsole/src/app/components/groups/groups.component.ts @@ -27,21 +27,23 @@ export class GroupsComponent implements OnInit { onSelectUnidad(unidad: UnidadOrganizativa): void { this.selectedUnidad = unidad; this.breadcrumb = [unidad.nombre]; - this.loadChildrenAndClients(unidad.uuid, unidad.id); + this.loadChildrenAndClients(unidad.uuid); } onSelectChild(child: any): void { if (child.uuid && child.id) { this.breadcrumb.push(child.name || child.nombre); - this.loadChildrenAndClients(child.uuid, child.id); + this.loadChildrenAndClients(child.uuid); } } - loadChildrenAndClients(uuid: string, id: number): void { + loadChildrenAndClients(uuid: string): void { this.dataService.getChildren(uuid).subscribe( childrenData => { + console.log('Children data:', childrenData); // Depuración this.dataService.getClients(uuid).subscribe( clientsData => { + console.log('Clients data:', clientsData); // Depuración const newChildren = [...childrenData, ...clientsData]; if (newChildren.length > 0) { this.children = newChildren; @@ -57,6 +59,7 @@ export class GroupsComponent implements OnInit { ); } + addOU(): void { this.dialog.open(CreateOrganizationalUnitComponent); }