From 6621f7a8fe336eac21ad731d9d8f30160d34e572 Mon Sep 17 00:00:00 2001 From: Lucas Lara Date: Tue, 22 Apr 2025 12:59:49 +0200 Subject: [PATCH] refs #1884 Enhance command execution logic to handle 'disconnected' state and update UI for multiple clients --- .../execute-command.component.ts | 17 +++++++++++++---- .../app/components/groups/groups.component.html | 1 - .../app/components/groups/groups.component.ts | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.ts b/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.ts index 721a97f..6ebe109 100644 --- a/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.ts +++ b/ogWebconsole/src/app/components/commands/main-commands/execute-command/execute-command.component.ts @@ -62,20 +62,29 @@ export class ExecuteCommandComponent implements OnInit { states = [this.clientState]; } - const allOff = states.every(state => state === 'off'); + const allOffOrDisconnected = states.every(state => state === 'off' || state === 'disconnected'); const allSameState = states.every(state => state === states[0]); + const multipleClients = this.clientData.length > 1; this.arrayCommands = this.arrayCommands.map(command => { - if (allOff) { + if (allOffOrDisconnected) { command.disabled = command.slug !== 'power-on'; } else if (allSameState) { - if (states[0] === 'off') { + if (states[0] === 'off' || states[0] === 'disconnected') { command.disabled = command.slug !== 'power-on'; } else { command.disabled = command.slug === 'power-on'; } } else { - command.disabled = true; + if (command.slug === 'create-image') { + command.disabled = multipleClients; + } else if ( + ['power-on', 'power-off', 'reboot', 'login', 'deploy-image', 'partition', 'run-script'].includes(command.slug) + ) { + command.disabled = false; + } else { + command.disabled = true; + } } return command; }); diff --git a/ogWebconsole/src/app/components/groups/groups.component.html b/ogWebconsole/src/app/components/groups/groups.component.html index 95db6c5..b15de2e 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.html +++ b/ogWebconsole/src/app/components/groups/groups.component.html @@ -202,7 +202,6 @@ [buttonText]="'Ejecutar comandos'" [icon]="'terminal'" [disabled]="!((selectedNode?.clients ?? []).length > 0)"> - diff --git a/ogWebconsole/src/app/components/groups/groups.component.ts b/ogWebconsole/src/app/components/groups/groups.component.ts index 0235ab9..b1a85ec 100644 --- a/ogWebconsole/src/app/components/groups/groups.component.ts +++ b/ogWebconsole/src/app/components/groups/groups.component.ts @@ -85,6 +85,7 @@ export class GroupsComponent implements OnInit, OnDestroy { { value: 'windows-session', name: 'Windows Session' }, { value: 'busy', name: 'Ocupado' }, { value: 'mac', name: 'Mac' }, + { value: 'disconnected', name: 'Desconectado'} ]; displayedColumns: string[] = ['select', 'status', 'ip', 'firmwareType', 'name', 'oglive', 'subnet', 'pxeTemplate', 'actions'];