Modificado comportamiento al hacer click en un aula, la petición de mostrar ordenadores y la de actualizar el estado de cada uno, se hacen secuencialmente y no en paralelo, asi evitamos el loader general mientras se resuelven los estados de los equipos
parent
bc3190380e
commit
3bbca40dbb
|
|
@ -418,11 +418,9 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
event.stopPropagation();
|
||||
this.selectedNode = node;
|
||||
const selectedClientsBeforeEdit = this.selection.selected.map(client => client.uuid);
|
||||
this.fetchClientsForNode(node, selectedClientsBeforeEdit);
|
||||
|
||||
if (node.type === NodeType.Classroom || node.type === NodeType.ClientsGroup) {
|
||||
this.getStatusForAllClientsInNode(node);
|
||||
}
|
||||
|
||||
const checkStatusAfterLoad = node.type === NodeType.Classroom || node.type === NodeType.ClientsGroup;
|
||||
this.fetchClientsForNode(node, selectedClientsBeforeEdit, checkStatusAfterLoad);
|
||||
}
|
||||
|
||||
onMenuClick(event: Event, node: any): void {
|
||||
|
|
@ -433,7 +431,9 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
|
||||
public fetchClientsForNode(node: any, selectedClientsBeforeEdit: string[] = []): void {
|
||||
private fetchClientsSubscription?: Subscription;
|
||||
|
||||
public fetchClientsForNode(node: any, selectedClientsBeforeEdit: string[] = [], checkStatusAfterLoad: boolean = false): void {
|
||||
const params = new HttpParams({ fromObject: this.filters });
|
||||
|
||||
// Agregar parámetros de ordenamiento al backend
|
||||
|
|
@ -442,8 +442,12 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
backendParams['order[' + this.sortBy + ']'] = this.sortDirection;
|
||||
}
|
||||
|
||||
if (this.fetchClientsSubscription) {
|
||||
this.fetchClientsSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
this.isLoadingClients = true;
|
||||
this.http.get<any>(`${this.baseUrl}/clients?organizationalUnit.id=${node.id}&page=${this.page + 1}&itemsPerPage=${this.itemsPerPage}`, { params: backendParams }).subscribe({
|
||||
this.fetchClientsSubscription = this.http.get<any>(`${this.baseUrl}/clients?organizationalUnit.id=${node.id}&page=${this.page + 1}&itemsPerPage=${this.itemsPerPage}`, { params: backendParams }).subscribe({
|
||||
next: (response: any) => {
|
||||
let members = response['hydra:member'];
|
||||
let total = response['hydra:totalItems'];
|
||||
|
|
@ -476,6 +480,10 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
members.forEach((c: Client) => c.uuid && this.syncingClientIds.add(c.uuid));
|
||||
}
|
||||
|
||||
if (checkStatusAfterLoad) {
|
||||
this.getStatusForAllClientsInNode(node);
|
||||
}
|
||||
|
||||
// Calcular estadísticas después de cargar los clientes
|
||||
this.calculateLocalStats();
|
||||
},
|
||||
|
|
@ -855,14 +863,19 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
|
||||
private checkStatusSubscription?: Subscription;
|
||||
|
||||
getStatusForAllClientsInNode(node: any): void {
|
||||
if (!node.uuid) return;
|
||||
|
||||
if (this.checkStatusSubscription) {
|
||||
this.checkStatusSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
this.isCheckingNodeStatus = true;
|
||||
this.selectedClients.data.forEach(c => c.uuid && this.syncingClientIds.add(c.uuid));
|
||||
|
||||
this.subscriptions.add(
|
||||
this.http.post<{ results: Array<{ uuid: string; ip: string; status: string; success: boolean }> }>(
|
||||
this.checkStatusSubscription = this.http.post<{ results: Array<{ uuid: string; ip: string; status: string; success: boolean }> }>(
|
||||
`${this.baseUrl}/organizational-units/${node.uuid}/agent/status`,
|
||||
{}
|
||||
).subscribe({
|
||||
|
|
@ -883,8 +896,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
this.selectedClients.data.forEach(c => c.uuid && this.syncingClientIds.delete(c.uuid));
|
||||
this.toastr.error(this.translate.instant('errorCheckingStatus'));
|
||||
},
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue