diff --git a/ogWebconsole/src/app/components/groups/groups.component.ts b/ogWebconsole/src/app/components/groups/groups.component.ts index 4ecac3a..088cc9f 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.ts +++ b/ogWebconsole/src/app/components/groups/groups.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; +import { Component, OnInit, OnDestroy, ViewChild, QueryList, ViewChildren } from '@angular/core'; import { HttpClient, HttpParams } from '@angular/common/http'; import { Router } from '@angular/router'; import { MatDialog } from '@angular/material/dialog'; @@ -24,8 +24,8 @@ import { ManageClientComponent } from "./shared/clients/manage-client/manage-cli import { debounceTime } from 'rxjs/operators'; import { Subject } from 'rxjs'; import { ConfigService } from '@services/config.service'; -import { GlobalStatusComponent } from '../global-status/global-status.component'; import { BreakpointObserver } from '@angular/cdk/layout'; +import { MatMenuTrigger } from '@angular/material/menu'; enum NodeType { OrganizationalUnit = 'organizational-unit', @@ -41,6 +41,7 @@ enum NodeType { styleUrls: ['./groups.component.css'], }) export class GroupsComponent implements OnInit, OnDestroy { + @ViewChildren(MatMenuTrigger) menuTriggers!: QueryList; isSmallScreen: boolean = false; baseUrl: string; mercureUrl: string; @@ -481,10 +482,11 @@ export class GroupsComponent implements OnInit, OnDestroy { ? this.dialog.open(ManageOrganizationalUnitComponent, { data: { uuid }, width: '900px' }) : this.dialog.open(ManageClientComponent, { data: { uuid }, width: '900px' }); - dialogRef.afterClosed().subscribe(() => { - if (node) { - this.refreshData(node.id); + dialogRef.afterClosed().subscribe((result) => { + if (result?.success) { + this.refreshData(node?.id); } + this.menuTriggers.forEach(trigger => trigger.closeMenu()); }); } @@ -548,8 +550,11 @@ export class GroupsComponent implements OnInit, OnDestroy { ? this.dialog.open(ManageOrganizationalUnitComponent, { data: { uuid }, width: '900px' }) : this.dialog.open(ManageClientComponent, { data: { uuid }, width: '900px' }); - dialogRef.afterClosed().subscribe(() => { - this.refreshData(this.selectedNode?.id, selectedClientsBeforeEdit); + dialogRef.afterClosed().subscribe((result) => { + if (result?.success) { + this.refreshData(this.selectedNode?.id, selectedClientsBeforeEdit); + } + this.menuTriggers.forEach(trigger => trigger.closeMenu()); }); } diff --git a/ogWebconsole/src/app/components/groups/shared/clients/manage-client/manage-client.component.ts b/ogWebconsole/src/app/components/groups/shared/clients/manage-client/manage-client.component.ts index 270a03d..3f6a793 100644 --- a/ogWebconsole/src/app/components/groups/shared/clients/manage-client/manage-client.component.ts +++ b/ogWebconsole/src/app/components/groups/shared/clients/manage-client/manage-client.component.ts @@ -272,7 +272,7 @@ export class ManageClientComponent implements OnInit { this.http.patch(putUrl, formData, { headers }).subscribe( response => { - this.dialogRef.close(); + this.dialogRef.close({ success: true }); this.toastService.success('Cliente actualizado exitosamente', 'Éxito'); }, error => { @@ -285,6 +285,7 @@ export class ManageClientComponent implements OnInit { (response) => { this.toastService.success('Cliente creado exitosamente', 'Éxito'); this.dialogRef.close({ + success: true, client: response, organizationalUnit: formData.organizationalUnit, }); @@ -300,6 +301,6 @@ export class ManageClientComponent implements OnInit { } onNoClick(): void { - this.dialogRef.close(); + this.dialogRef.close({ success: false }); } } diff --git a/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.ts b/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.ts index 8dd9b72..87c49df 100644 --- a/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.ts +++ b/ogWebconsole/src/app/components/groups/shared/organizational-units/manage-organizational-unit/manage-organizational-unit.component.ts @@ -75,7 +75,7 @@ export class ManageOrganizationalUnitComponent implements OnInit { }); this.networkSettingsFormGroup = this._formBuilder.group({ - ogLive: [ null], + ogLive: [null], repository: [null], proxy: [null], dns: [null], @@ -394,7 +394,7 @@ export class ManageOrganizationalUnitComponent implements OnInit { this.http.put(putUrl, formData, { headers }).subscribe( response => { this.unitAdded.emit(); - this.dialogRef.close(); + this.dialogRef.close({ success: true }); this.toastService.success('Editado exitosamente', 'Éxito'); }, error => { @@ -413,7 +413,7 @@ export class ManageOrganizationalUnitComponent implements OnInit { this.http.post(postUrl, formData, { headers }).subscribe( response => { this.unitAdded.emit(response); - this.dialogRef.close(response); + this.dialogRef.close({ success: true }); this.toastService.success('Creado exitosamente', 'Éxito'); }, error => { @@ -430,6 +430,6 @@ export class ManageOrganizationalUnitComponent implements OnInit { } onNoClick(): void { - this.dialogRef.close(); + this.dialogRef.close({ success: false }); } }