refs #1883 Move 'Execute commands' to tree node actions
testing/ogGui-multibranch/pipeline/head This commit looks good Details

pull/20/head
Lucas Lara García 2025-04-15 15:17:03 +02:00
parent e9a00119aa
commit 436267cfb9
4 changed files with 21 additions and 9 deletions

View File

@ -8,12 +8,17 @@
[matMenuTriggerFor]="commandMenu">
{{ buttonText }}
</button>
<button mat-menu-item *ngSwitchCase="'menu-item'" [matMenuTriggerFor]="commandMenu" [disabled]="disabled">
<mat-icon>{{ icon }}</mat-icon>
<span>{{ buttonText }}</span>
</button>
</ng-container>
<mat-menu #commandMenu="matMenu">
<button mat-menu-item [disabled]="command.disabled
|| (command.slug === 'create-image' && clientData.length > 1)"
*ngFor="let command of arrayCommands" (click)="onCommandSelect(command.slug)">
|| (command.slug === 'create-image' && clientData.length > 1)" *ngFor="let command of arrayCommands"
(click)="onCommandSelect(command.slug)">
{{ command.name }}
</button>
</mat-menu>

View File

@ -11,7 +11,7 @@ import { ConfigService } from '@services/config.service';
})
export class ExecuteCommandComponent implements OnInit {
@Input() clientData: any[] = [];
@Input() buttonType: 'icon' | 'text' = 'icon';
@Input() buttonType: 'icon' | 'text' | 'menu-item' = 'icon';
@Input() buttonText: string = 'Ejecutar Comandos';
@Input() icon: string = 'terminal';
@Input() disabled: boolean = false;

View File

@ -198,6 +198,9 @@
<mat-icon>delete</mat-icon>
<span>{{ 'delete' | translate }}</span>
</button>
<app-execute-command [clientData]="selection.selected" [buttonType]="'menu-item'"
[buttonText]="'Ejecutar comandos'" [icon]="'terminal'" [disabled]="selection.selected.length === 0">
</app-execute-command>
</mat-menu>
</div>
@ -245,7 +248,8 @@
<div *ngFor="let client of arrayClients" class="client-item">
<div class="client-card">
<mat-checkbox (click)="$event.stopPropagation()" (change)="toggleRow(client)"
[checked]="selection.isSelected(client)" [disabled]="client.status === 'busy' || client.status === 'off' || client.status === 'disconnected'">
[checked]="selection.isSelected(client)"
[disabled]="client.status === 'busy' || client.status === 'off' || client.status === 'disconnected'">
</mat-checkbox>
<img style="margin-top: 0.5em;" [src]="'assets/images/computer_' + client.status + '.svg'"
alt="Client Icon" class="client-image" />
@ -314,7 +318,8 @@
</th>
<td mat-cell *matCellDef="let row">
<mat-checkbox (click)="$event.stopPropagation()" (change)="toggleRow(row)"
[checked]="selection.isSelected(row)" [disabled]="row.status === 'busy' || row.status === 'off' || row.status === 'disconnected'">
[checked]="selection.isSelected(row)"
[disabled]="row.status === 'busy' || row.status === 'off' || row.status === 'disconnected'">
</mat-checkbox>
</td>
</ng-container>

View File

@ -369,13 +369,15 @@ export class GroupsComponent implements OnInit, OnDestroy {
onNodeClick(event: MouseEvent, node: TreeNode): void {
event.stopPropagation();
this.selectedNode = node;
this.fetchClientsForNode(node);
const selectedClientsBeforeEdit = this.selection.selected.map(client => client.uuid);
this.fetchClientsForNode(node, selectedClientsBeforeEdit);
}
onMenuClick(event: Event, node: any): void {
event.stopPropagation();
this.selectedNode = node;
this.fetchClientsForNode(node);
const selectedClientsBeforeEdit = this.selection.selected.map(client => client.uuid);
this.fetchClientsForNode(node, selectedClientsBeforeEdit);
}