Refactor updateCommandStates method in ExecuteCommandComponent: restore and optimize command state management logic for improved functionality
testing/ogGui-multibranch/pipeline/head There was a failure building this commit
Details
testing/ogGui-multibranch/pipeline/head There was a failure building this commit
Details
parent
9582ce338c
commit
2bc17e8b56
|
@ -55,40 +55,40 @@ export class ExecuteCommandComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateCommandStates(): void {
|
private updateCommandStates(): void {
|
||||||
// let states: string[] = [];
|
let states: string[] = [];
|
||||||
|
|
||||||
// if (this.clientData.length > 0) {
|
if (this.clientData.length > 0) {
|
||||||
// states = this.clientData.map(client => client.status);
|
states = this.clientData.map(client => client.status);
|
||||||
// } else if (this.clientState) {
|
} else if (this.clientState) {
|
||||||
// states = [this.clientState];
|
states = [this.clientState];
|
||||||
// }
|
}
|
||||||
|
|
||||||
// const allOffOrDisconnected = states.every(state => state === 'off' || state === 'disconnected');
|
const allOffOrDisconnected = states.every(state => state === 'off' || state === 'disconnected');
|
||||||
// const allSameState = states.every(state => state === states[0]);
|
const allSameState = states.every(state => state === states[0]);
|
||||||
// const multipleClients = this.clientData.length > 1;
|
const multipleClients = this.clientData.length > 1;
|
||||||
|
|
||||||
// this.arrayCommands = this.arrayCommands.map(command => {
|
this.arrayCommands = this.arrayCommands.map(command => {
|
||||||
// if (allOffOrDisconnected) {
|
if (allOffOrDisconnected) {
|
||||||
// command.disabled = command.slug !== 'power-on';
|
command.disabled = command.slug !== 'power-on';
|
||||||
// } else if (allSameState) {
|
} else if (allSameState) {
|
||||||
// if (states[0] === 'off' || states[0] === 'disconnected') {
|
if (states[0] === 'off' || states[0] === 'disconnected') {
|
||||||
// command.disabled = command.slug !== 'power-on';
|
command.disabled = command.slug !== 'power-on';
|
||||||
// } else {
|
} else {
|
||||||
// command.disabled = !['power-off', 'reboot', 'login', 'create-image', 'deploy-image', 'partition', 'run-script'].includes(command.slug);
|
command.disabled = !['power-off', 'reboot', 'login', 'create-image', 'deploy-image', 'partition', 'run-script'].includes(command.slug);
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// if (command.slug === 'create-image') {
|
if (command.slug === 'create-image') {
|
||||||
// command.disabled = multipleClients;
|
command.disabled = multipleClients;
|
||||||
// } else if (
|
} else if (
|
||||||
// ['power-on', 'power-off', 'reboot', 'login', 'deploy-image', 'partition', 'run-script'].includes(command.slug)
|
['power-on', 'power-off', 'reboot', 'login', 'deploy-image', 'partition', 'run-script'].includes(command.slug)
|
||||||
// ) {
|
) {
|
||||||
// command.disabled = false;
|
command.disabled = false;
|
||||||
// } else {
|
} else {
|
||||||
// command.disabled = true;
|
command.disabled = true;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// return command;
|
return command;
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onCommandSelect(action: any): void {
|
onCommandSelect(action: any): void {
|
||||||
|
|
Loading…
Reference in New Issue