refs #2940. Status - classromm
testing/ogGui-multibranch/pipeline/head There was a failure building this commit
Details
testing/ogGui-multibranch/pipeline/head There was a failure building this commit
Details
parent
af8f793dec
commit
b2b3dc47af
|
|
@ -402,7 +402,7 @@
|
|||
<mat-icon>more_vert</mat-icon>
|
||||
</button>
|
||||
|
||||
<span class="sync-spinner" *ngIf="syncStatus && syncingClientId === client.uuid">
|
||||
<span class="sync-spinner" *ngIf="syncingClientIds.has(client.uuid)">
|
||||
<mat-spinner diameter="24"></mat-spinner>
|
||||
</span>
|
||||
|
||||
|
|
@ -415,7 +415,7 @@
|
|||
<mat-icon>visibility</mat-icon>
|
||||
<span>{{ 'viewDetails' | translate }}</span>
|
||||
</button>
|
||||
<button mat-menu-item *ngIf="(!syncStatus || syncingClientId !== client.uuid)"
|
||||
<button mat-menu-item *ngIf="!syncingClientIds.has(client.uuid)"
|
||||
(click)="getStatus(client, selectedNode)">
|
||||
<mat-icon>sync</mat-icon>
|
||||
<span>{{ 'sync' | translate }}</span>
|
||||
|
|
@ -499,7 +499,7 @@
|
|||
<div class="client-status-container">
|
||||
<img [src]="'assets/images/computer_' + client.status + '.svg'" alt="Client Icon"
|
||||
class="client-image" />
|
||||
<span *ngIf="syncStatus && syncingClientId === client.uuid">
|
||||
<span *ngIf="syncingClientIds.has(client.uuid)">
|
||||
<mat-spinner diameter="24"></mat-spinner>
|
||||
</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -75,8 +75,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
currentView: string = 'list';
|
||||
savedFilterNames: [string, string][] = [];
|
||||
selectedTreeFilter = '';
|
||||
syncStatus = false;
|
||||
syncingClientId: string | null = null;
|
||||
syncingClientIds = new Set<string>();
|
||||
private originalTreeData: TreeNode[] = [];
|
||||
arrayClients: any[] = [];
|
||||
filters: { [key: string]: string } = {};
|
||||
|
|
@ -406,6 +405,10 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
this.selectedNode = node;
|
||||
const selectedClientsBeforeEdit = this.selection.selected.map(client => client.uuid);
|
||||
this.fetchClientsForNode(node, selectedClientsBeforeEdit);
|
||||
|
||||
if (node.type === NodeType.Classroom || node.type === NodeType.ClassroomsGroup) {
|
||||
this.getStatusForAllClientsInNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
onMenuClick(event: Event, node: any): void {
|
||||
|
|
@ -796,24 +799,20 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
getStatus(client: Client, node: any): void {
|
||||
if (!client.uuid || !client['@id']) return;
|
||||
|
||||
this.syncingClientId = client.uuid;
|
||||
this.syncStatus = true;
|
||||
this.syncingClientIds.add(client.uuid);
|
||||
|
||||
const parentNodeId = client.organizationalUnit?.id || node.id;
|
||||
console.log('Parent node id:', parentNodeId);
|
||||
|
||||
this.subscriptions.add(
|
||||
this.http.post(`${this.baseUrl}${client['@id']}/agent/status`, {}).subscribe(
|
||||
() => {
|
||||
this.toastr.success('Cliente actualizado correctamente');
|
||||
this.syncStatus = false;
|
||||
this.syncingClientId = null;
|
||||
this.syncingClientIds.delete(client.uuid);
|
||||
this.refreshData(parentNodeId)
|
||||
},
|
||||
(error) => {
|
||||
this.toastr.error(error.error['hydra:description'] || 'Error al actualizar el cliente');
|
||||
this.syncStatus = false;
|
||||
this.syncingClientId = null;
|
||||
this.syncingClientIds.delete(client.uuid);
|
||||
this.refreshData(parentNodeId)
|
||||
}
|
||||
)
|
||||
|
|
@ -821,6 +820,27 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
|
||||
getStatusForAllClientsInNode(node: any): void {
|
||||
this.http.get<any>(`${this.baseUrl}/clients?organizationalUnit.id=${node.id}&itemsPerPage=1000`).subscribe({
|
||||
next: (response: any) => {
|
||||
const clients: Client[] = response['hydra:member'];
|
||||
const validClients = clients.filter(client => client.uuid && client['@id']);
|
||||
if (validClients.length === 0) return;
|
||||
|
||||
validClients.forEach(client => {
|
||||
this.syncingClientIds.add(client.uuid);
|
||||
this.subscriptions.add(
|
||||
this.http.post(`${this.baseUrl}${client['@id']}/agent/status`, {}).subscribe({
|
||||
next: () => this.syncingClientIds.delete(client.uuid),
|
||||
error: () => this.syncingClientIds.delete(client.uuid),
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
isAllSelected() {
|
||||
const numSelected = this.selection.selected.length;
|
||||
const numRows = this.selectedClients.data.length;
|
||||
|
|
|
|||
Loading…
Reference in New Issue