refs #1884 Refactor command state handling to improve client status management and enable/disable commands based on client states
testing/ogGui-multibranch/pipeline/head This commit looks good
Details
testing/ogGui-multibranch/pipeline/head This commit looks good
Details
parent
6621f7a8fe
commit
a418d26615
|
@ -56,6 +56,7 @@ export class ExecuteCommandComponent implements OnInit {
|
|||
private updateCommandStates(): void {
|
||||
let states: string[] = [];
|
||||
|
||||
// Obtener los estados de los clientes
|
||||
if (this.clientData.length > 0) {
|
||||
states = this.clientData.map(client => client.status);
|
||||
} else if (this.clientState) {
|
||||
|
@ -68,21 +69,28 @@ export class ExecuteCommandComponent implements OnInit {
|
|||
|
||||
this.arrayCommands = this.arrayCommands.map(command => {
|
||||
if (allOffOrDisconnected) {
|
||||
// Si todos los clientes están apagados o desconectados, solo habilitar "Encender"
|
||||
command.disabled = command.slug !== 'power-on';
|
||||
} else if (allSameState) {
|
||||
// Si todos los clientes tienen el mismo estado
|
||||
if (states[0] === 'off' || states[0] === 'disconnected') {
|
||||
command.disabled = command.slug !== 'power-on';
|
||||
} else {
|
||||
command.disabled = command.slug === 'power-on';
|
||||
// Habilitar comandos específicos para un cliente que no está apagado ni desconectado
|
||||
command.disabled = !['reboot', 'login', 'deploy-image', 'partition', 'run-script'].includes(command.slug);
|
||||
}
|
||||
} else {
|
||||
// Si los estados son distintos
|
||||
if (command.slug === 'create-image') {
|
||||
// "Crear imagen" solo está habilitado para un único cliente
|
||||
command.disabled = multipleClients;
|
||||
} else if (
|
||||
['power-on', 'power-off', 'reboot', 'login', 'deploy-image', 'partition', 'run-script'].includes(command.slug)
|
||||
) {
|
||||
// Habilitar los comandos permitidos cuando los estados son distintos
|
||||
command.disabled = false;
|
||||
} else {
|
||||
// Deshabilitar otros comandos
|
||||
command.disabled = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue