diff --git a/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.html b/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.html index b671896..552618d 100644 --- a/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.html +++ b/ogWebconsole/src/app/components/commands/commands-groups/create-command-group/create-command-group.component.html @@ -1,5 +1,5 @@
-

Crear Grupo de Comandos

+

Grupo de Comandos

@@ -54,7 +54,7 @@
- +
diff --git a/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.html b/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.html index d77f900..ccee5f3 100644 --- a/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.html +++ b/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.html @@ -1,65 +1,91 @@
-

Trazas de ejecuciones

+

Trazas de ejecuciones

- - Buscar por comando - - - - - Buscar por cliente - - - - - Buscar por estado - - - - - Buscar por usuario - - - - - Buscar por fecha - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Comando {{ trace.command.name }} Cliente {{ trace.client.name }} Estado {{ trace.status }} Ejecutado En {{ trace.executedAt | date:'short' }} Creado Por {{ trace.createdBy }}
- - - + + Buscar por comando + + + + + Buscar por cliente + + + + + Buscar por estado + + + + + Buscar por usuario + + + + + Buscar por fecha + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Ejecución {{ group.commandId }} Comando + +
{{ trace.command.name }}
+
+
Cliente + +
{{ trace.client.name }}
+
+
Estado + +
{{ trace.status }}
+
+
Ejecutado En + +
{{ trace.executedAt | date:'short' }}
+
+
Creado Por + +
{{ trace.createdBy }}
+
+
+ + + + \ No newline at end of file diff --git a/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.ts b/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.ts index a9a41ab..44a3992 100644 --- a/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.ts +++ b/ogWebconsole/src/app/components/commands/commands-task/task-logs/task-logs.component.ts @@ -8,16 +8,15 @@ import { HttpClient } from '@angular/common/http'; }) export class TaskLogsComponent implements OnInit { - baseUrl: string = import.meta.env.NG_APP_BASE_API_URL; // Utilizando baseUrl desde el env + baseUrl: string = import.meta.env.NG_APP_BASE_API_URL; traces: any[] = []; - filteredTraces: any[] = []; // Nueva variable para las trazas filtradas + groupedTraces: any[] = []; length: number = 0; itemsPerPage: number = 20; page: number = 1; pageSizeOptions: number[] = [10, 20, 30, 50]; - displayedColumns: string[] = ['commandName', 'clientName', 'status', 'executedAt', 'createdBy']; + displayedColumns: string[] = ['commandId','commandName', 'clientName', 'status', 'executedAt', 'createdBy']; - // Variables para los términos de búsqueda searchCommand: string = ''; searchClient: string = ''; searchStatus: string = ''; @@ -30,7 +29,6 @@ export class TaskLogsComponent implements OnInit { this.loadTraces(); } - // Método para cargar las trazas con paginación loadTraces(): void { const url = `${this.baseUrl}/traces?page=${this.page}&itemsPerPage=${this.itemsPerPage}`; @@ -38,8 +36,7 @@ export class TaskLogsComponent implements OnInit { (data) => { this.traces = data['hydra:member']; this.length = data['hydra:totalItems']; - this.filteredTraces = this.traces; // Inicializa con todas las trazas - console.log('Traces:', this.traces); + this.groupedTraces = this.groupByCommandId(this.traces); }, (error) => { console.error('Error fetching traces', error); @@ -47,16 +44,31 @@ export class TaskLogsComponent implements OnInit { ); } - // Método que se llama cuando cambia la paginación - onPageChange(event: any): void { - this.page = event.pageIndex + 1; // Actualiza el número de página - this.itemsPerPage = event.pageSize; // Actualiza los ítems por página - this.loadTraces(); // Recarga las trazas con los nuevos parámetros de paginación + groupByCommandId(traces: any[]): any[] { + const grouped: { [key: string]: any[] } = {}; + + traces.forEach(trace => { + const commandId = trace.command.id; + if (!grouped[commandId]) { + grouped[commandId] = []; + } + grouped[commandId].push(trace); + }); + + return Object.keys(grouped).map(key => ({ + commandId: key, + traces: grouped[key] + })); + } + + onPageChange(event: any): void { + this.page = event.pageIndex + 1; + this.itemsPerPage = event.pageSize; + this.loadTraces(); } - // Método para filtrar las trazas filterTraces(): void { - this.filteredTraces = this.traces.filter(trace => { + const filtered = this.traces.filter(trace => { const commandMatch = trace.command.name.toLowerCase().includes(this.searchCommand.toLowerCase()); const clientMatch = trace.client.name.toLowerCase().includes(this.searchClient.toLowerCase()); const statusMatch = trace.status.toLowerCase().includes(this.searchStatus.toLowerCase()); @@ -66,6 +78,7 @@ export class TaskLogsComponent implements OnInit { return commandMatch && clientMatch && statusMatch && createdByMatch && executedAtMatch; }); - this.length = this.filteredTraces.length; // Actualiza la longitud para el paginador + this.length = filtered.length; + this.groupedTraces = this.groupByCommandId(filtered); } } diff --git a/ogWebconsole/src/app/components/commands/main-commands/create-command/create-command.component.ts b/ogWebconsole/src/app/components/commands/main-commands/create-command/create-command.component.ts index 4733069..2f63786 100644 --- a/ogWebconsole/src/app/components/commands/main-commands/create-command/create-command.component.ts +++ b/ogWebconsole/src/app/components/commands/main-commands/create-command/create-command.component.ts @@ -2,6 +2,7 @@ import { Component, Inject } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { HttpClient } from '@angular/common/http'; +import { ToastrService } from 'ngx-toastr'; @Component({ selector: 'app-create-command', @@ -18,9 +19,10 @@ export class CreateCommandComponent { private fb: FormBuilder, private http: HttpClient, public dialogRef: MatDialogRef, + private toastService: ToastrService, @Inject(MAT_DIALOG_DATA) public data: any ) { - this.isEditMode = data && data.command; // Verifica si `data` y `data.command` existen + this.isEditMode = data && data.command; } ngOnInit(): void { @@ -44,6 +46,7 @@ export class CreateCommandComponent { if (this.isEditMode) { this.http.patch(`${this.apiUrl}/${this.data.command.uuid}`, commandData).subscribe( response => { + this.toastService.success('Comando creado con éxito'); this.dialogRef.close(commandData); }, error => {