Remove executeCommand function and console logs

oggui/commands
Alvaro Puente Mella 2024-09-24 20:22:39 +02:00
parent 16a07f5139
commit e5d1b30386
5 changed files with 19 additions and 24 deletions

View File

@ -32,10 +32,6 @@
<mat-icon>more_vert</mat-icon>
</button>
<mat-menu #menu="matMenu">
<button mat-menu-item (click)="executeCommand(command)">
<mat-icon>play_arrow</mat-icon>
<span>Ejecutar</span>
</button>
<button mat-menu-item (click)="viewDetails(command)">
<mat-icon>info</mat-icon>
<span>Detalles</span>

View File

@ -44,10 +44,6 @@ export class CommandsComponent implements OnInit {
});
}
executeCommand(command: any): void {
console.log('Ejecutar comando:', command);
}
editCommand(command: any): void {
const dialogRef = this.dialog.open(CreateCommandComponent, {
width: '600px',
@ -74,7 +70,6 @@ export class CommandsComponent implements OnInit {
}
deleteCommand(command: any): void {
console.log('Eliminar comando:', command);
const dialogRef = this.dialog.open(DeleteModalComponent,
{
width: '300px',

View File

@ -43,6 +43,7 @@ export class CommandDetailComponent implements OnInit {
} else {
if (this.form.get('selectedClients')?.value.length > 0) {
console.log('Ejecutar comando con los siguientes clientes:', this.form.value.selectedClients);
console.log('Comando ejecutado', this.data.command);
this.dialogRef.close();
} else {
this.form.get('selectedClients')?.markAsTouched();

View File

@ -11,6 +11,7 @@ import { CommandDetailComponent } from '../../commands/detail-command/command-de
styleUrls: ['./acctions-modal.component.css']
})
export class AcctionsModalComponent {
baseUrl: string = import.meta.env.NG_APP_BASE_API_URL;
selectedElements: any;
commands: any[] = [];
displayedColumns: string[] = ['name', 'createdBy', 'createdAt'];
@ -52,19 +53,22 @@ export class AcctionsModalComponent {
}
onCommandClick(command: any): void {
const dialogRef = this.dialog.open(CommandDetailComponent, {
width: '600px',
data: {
command: command,
importedClients: this.selectedElements
}
});
const payload = {
clients: this.selectedElements.map((uuid: any) => `/clients/${uuid}`)
};
dialogRef.afterClosed().subscribe(result => {
if (result) {
console.log('Modal cerrado. Resultado:', result);
}
});
const apiUrl = `${this.baseUrl}/commands/${command.uuid}/execute`;
this.http.post(apiUrl, payload).subscribe({
next: () => {
console.log('Command executed successfully');
this.loadCommands();
this.toastService.success('Command executed successfully');
},
error: (error) => {
console.error('Error executing command:', error);
}
});
}
chunkArray(arr: any[], chunkSize: number): any[] {

View File

@ -378,7 +378,7 @@ export class GroupsComponent implements OnInit {
onCheckboxChange(event: any, name: string, uuid: string) {
if (event.checked) {
this.selectedElements.push({ name, uuid });
this.selectedElements.push(uuid);
} else {
const index = this.selectedElements.indexOf(name);
if (index > -1) {
@ -387,14 +387,13 @@ export class GroupsComponent implements OnInit {
}
this.isAllSelected = this.selectedElements.length === this.filteredResults.length;
console.log(this.selectedElements);
}
toggleSelectAll() {
this.isAllSelected = !this.isAllSelected;
if (this.isAllSelected) {
this.selectedElements = this.filteredResults.map(result => result.name);
this.selectedElements = this.filteredResults.map(result => result.uuid);
} else {
this.selectedElements = [];
}