Merge branch 'develop' of ssh://ognproject.evlt.uma.es:21987/opengnsys/oggui into develop
commit
1df6578efd
|
@ -10,13 +10,13 @@ import { ConfigService } from '@services/config.service';
|
||||||
styleUrls: ['./execute-command.component.css']
|
styleUrls: ['./execute-command.component.css']
|
||||||
})
|
})
|
||||||
export class ExecuteCommandComponent implements OnInit {
|
export class ExecuteCommandComponent implements OnInit {
|
||||||
|
@Input() runScriptContext: any = null;
|
||||||
@Input() clientState: string = 'off';
|
@Input() clientState: string = 'off';
|
||||||
@Input() clientData: any[] = [];
|
@Input() clientData: any[] = [];
|
||||||
@Input() buttonType: 'icon' | 'text' | 'menu-item' = 'icon';
|
@Input() buttonType: 'icon' | 'text' | 'menu-item' = 'icon';
|
||||||
@Input() buttonText: string = 'Ejecutar Comandos';
|
@Input() buttonText: string = 'Ejecutar Comandos';
|
||||||
@Input() icon: string = 'terminal';
|
@Input() icon: string = 'terminal';
|
||||||
@Input() disabled: boolean = false;
|
@Input() disabled: boolean = false;
|
||||||
@Input() runScriptContext: string = '';
|
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
loading: boolean = true;
|
loading: boolean = true;
|
||||||
|
|
||||||
|
@ -231,10 +231,8 @@ export class ExecuteCommandComponent implements OnInit {
|
||||||
this.router.navigate(['/clients/run-script'], {
|
this.router.navigate(['/clients/run-script'], {
|
||||||
queryParams: {
|
queryParams: {
|
||||||
clientData: JSON.stringify(clientDataToSend) ,
|
clientData: JSON.stringify(clientDataToSend) ,
|
||||||
runScriptContext: this.runScriptContext
|
runScriptContext: JSON.stringify(this.runScriptContext)
|
||||||
}
|
}
|
||||||
}).then(() => {
|
})
|
||||||
console.log('Navigated to run script with data:', clientDataToSend, 'runScriptContext:', this.runScriptContext);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<div class="header-container">
|
<div class="header-container">
|
||||||
<div class="header-container-title">
|
<div class="header-container-title">
|
||||||
<h2>
|
<h2>
|
||||||
{{ 'runScript' | translate }} {{this.runScriptContext}}
|
{{ 'runScript' | translate }} {{runScriptTitle}}
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="button-row">
|
<div class="button-row">
|
||||||
|
|
|
@ -32,7 +32,7 @@ export class RunScriptAssistantComponent {
|
||||||
newScript: string = '';
|
newScript: string = '';
|
||||||
selection = new SelectionModel(true, []);
|
selection = new SelectionModel(true, []);
|
||||||
parameterNames: string[] = Object.keys(this.parameters);
|
parameterNames: string[] = Object.keys(this.parameters);
|
||||||
runScriptContext: string = '';
|
runScriptContext: any = null;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private http: HttpClient,
|
private http: HttpClient,
|
||||||
|
@ -63,6 +63,31 @@ export class RunScriptAssistantComponent {
|
||||||
this.loadScripts()
|
this.loadScripts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.route.queryParams.subscribe(params => {
|
||||||
|
this.runScriptContext = params['runScriptContext'] ? JSON.parse(params['runScriptContext']) : null;
|
||||||
|
this.clientData = params['clientData'] ? JSON.parse(params['clientData']) : [];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get runScriptTitle(): string {
|
||||||
|
const ctx = this.runScriptContext;
|
||||||
|
if (!ctx) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
// Si es un array de clientes
|
||||||
|
if (Array.isArray(ctx)) {
|
||||||
|
return ctx.map(c => c.name).join(', ');
|
||||||
|
}
|
||||||
|
// Si es un objeto con propiedad name
|
||||||
|
if (typeof ctx === 'object' && 'name' in ctx) {
|
||||||
|
return ctx.name;
|
||||||
|
}
|
||||||
|
// Si es un string plano
|
||||||
|
return String(ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
loadScripts(): void {
|
loadScripts(): void {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
|
||||||
|
|
|
@ -830,22 +830,22 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
||||||
this.fetchClientsForNode(this.selectedNode);
|
this.fetchClientsForNode(this.selectedNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
getRunScriptContext(clientData: any[]): string {
|
getRunScriptContext(clientData: any[]): any {
|
||||||
const selectedClientNames = clientData.map(client => client.name);
|
const selectedClientNames = clientData.map(client => client.name);
|
||||||
|
|
||||||
if (clientData.length === 1) {
|
if (clientData.length === 1) {
|
||||||
return selectedClientNames[0];
|
return clientData[0]; // devuelve el objeto cliente completo
|
||||||
} else if (
|
} else if (
|
||||||
clientData.length === this.selectedClients.data.length &&
|
clientData.length === this.selectedClients.data.length &&
|
||||||
selectedClientNames.every(name => this.selectedClients.data.some(c => c.name === name))
|
selectedClientNames.every(name => this.selectedClients.data.some(c => c.name === name))
|
||||||
) {
|
) {
|
||||||
return this.selectedNode?.name || '';
|
return this.selectedNode || null; // devuelve el nodo completo
|
||||||
} else if (clientData.length > 1) {
|
} else if (clientData.length > 1) {
|
||||||
return selectedClientNames.join(', ');
|
return clientData; // devuelve array de objetos cliente
|
||||||
} else if (this.selectedNode?.name && clientData.length === 0) {
|
} else if (this.selectedNode && clientData.length === 0) {
|
||||||
return this.selectedNode.name;
|
return this.selectedNode;
|
||||||
}
|
}
|
||||||
return '';
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
openPartitionTypeModal(event: MouseEvent, node: TreeNode | null = null): void {
|
openPartitionTypeModal(event: MouseEvent, node: TreeNode | null = null): void {
|
||||||
|
|
|
@ -13,8 +13,6 @@ export class PartitionTypeOrganizatorComponent implements OnInit {
|
||||||
displayedColumns: string[] = ['diskNumber', 'partitionNumber', 'partitionCode', 'size', 'filesystem', 'memoryUsage'];
|
displayedColumns: string[] = ['diskNumber', 'partitionNumber', 'partitionCode', 'size', 'filesystem', 'memoryUsage'];
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
console.log('Data recibida en modal:', this.data);
|
|
||||||
|
|
||||||
this.simplifiedData = this.data.map((client: any) => ({
|
this.simplifiedData = this.data.map((client: any) => ({
|
||||||
name: client.name,
|
name: client.name,
|
||||||
partitions: client.partitions.map((p: any) => ({
|
partitions: client.partitions.map((p: any) => ({
|
||||||
|
@ -27,6 +25,4 @@ export class PartitionTypeOrganizatorComponent implements OnInit {
|
||||||
}))
|
}))
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue