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']
|
||||
})
|
||||
export class ExecuteCommandComponent implements OnInit {
|
||||
@Input() runScriptContext: any = null;
|
||||
@Input() clientState: string = 'off';
|
||||
@Input() clientData: any[] = [];
|
||||
@Input() buttonType: 'icon' | 'text' | 'menu-item' = 'icon';
|
||||
@Input() buttonText: string = 'Ejecutar Comandos';
|
||||
@Input() icon: string = 'terminal';
|
||||
@Input() disabled: boolean = false;
|
||||
@Input() runScriptContext: string = '';
|
||||
baseUrl: string;
|
||||
loading: boolean = true;
|
||||
|
||||
|
@ -231,10 +231,8 @@ export class ExecuteCommandComponent implements OnInit {
|
|||
this.router.navigate(['/clients/run-script'], {
|
||||
queryParams: {
|
||||
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-title">
|
||||
<h2>
|
||||
{{ 'runScript' | translate }} {{this.runScriptContext}}
|
||||
{{ 'runScript' | translate }} {{runScriptTitle}}
|
||||
</h2>
|
||||
</div>
|
||||
<div class="button-row">
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import {Component, EventEmitter, Output} from '@angular/core';
|
||||
import {SelectionModel} from "@angular/cdk/collections";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {ToastrService} from "ngx-toastr";
|
||||
import {ConfigService} from "@services/config.service";
|
||||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {SaveScriptComponent} from "./save-script/save-script.component";
|
||||
import {MatDialog} from "@angular/material/dialog";
|
||||
import { Component, EventEmitter, Output } from '@angular/core';
|
||||
import { SelectionModel } from "@angular/cdk/collections";
|
||||
import { HttpClient } from "@angular/common/http";
|
||||
import { ToastrService } from "ngx-toastr";
|
||||
import { ConfigService } from "@services/config.service";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { SaveScriptComponent } from "./save-script/save-script.component";
|
||||
import { MatDialog } from "@angular/material/dialog";
|
||||
|
||||
@Component({
|
||||
selector: 'app-run-script-assistant',
|
||||
|
@ -32,7 +32,7 @@ export class RunScriptAssistantComponent {
|
|||
newScript: string = '';
|
||||
selection = new SelectionModel(true, []);
|
||||
parameterNames: string[] = Object.keys(this.parameters);
|
||||
runScriptContext: string = '';
|
||||
runScriptContext: any = null;
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
|
@ -52,7 +52,7 @@ export class RunScriptAssistantComponent {
|
|||
}
|
||||
});
|
||||
this.clientId = this.clientData?.length ? this.clientData[0]['@id'] : null;
|
||||
this.clientData.forEach((client: { selected: boolean; status: string}) => {
|
||||
this.clientData.forEach((client: { selected: boolean; status: string }) => {
|
||||
if (client.status === 'og-live') {
|
||||
client.selected = true;
|
||||
}
|
||||
|
@ -63,6 +63,31 @@ export class RunScriptAssistantComponent {
|
|||
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 {
|
||||
this.loading = true;
|
||||
|
||||
|
@ -118,7 +143,7 @@ export class RunScriptAssistantComponent {
|
|||
}
|
||||
|
||||
return client.partitions
|
||||
.map((p: { partitionNumber: any; size: any; filesystem: any }) => `#${p.partitionNumber} ${p.filesystem} - ${p.size / 1024 }GB`)
|
||||
.map((p: { partitionNumber: any; size: any; filesystem: any }) => `#${p.partitionNumber} ${p.filesystem} - ${p.size / 1024}GB`)
|
||||
.join('\n');
|
||||
}
|
||||
|
||||
|
@ -164,7 +189,7 @@ export class RunScriptAssistantComponent {
|
|||
|
||||
this.http.post(`${this.baseUrl}/commands/run-script`, {
|
||||
clients: this.selectedClients.map((client: any) => client.uuid),
|
||||
script: this.commandType === 'existing' ? this.scriptContent : this.newScript,
|
||||
script: this.commandType === 'existing' ? this.scriptContent : this.newScript,
|
||||
}).subscribe(
|
||||
response => {
|
||||
this.toastService.success('Script ejecutado correctamente');
|
||||
|
|
|
@ -830,24 +830,24 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
|||
this.fetchClientsForNode(this.selectedNode);
|
||||
}
|
||||
|
||||
getRunScriptContext(clientData: any[]): string {
|
||||
getRunScriptContext(clientData: any[]): any {
|
||||
const selectedClientNames = clientData.map(client => client.name);
|
||||
|
||||
|
||||
if (clientData.length === 1) {
|
||||
return selectedClientNames[0];
|
||||
return clientData[0]; // devuelve el objeto cliente completo
|
||||
} else if (
|
||||
clientData.length === this.selectedClients.data.length &&
|
||||
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) {
|
||||
return selectedClientNames.join(', ');
|
||||
} else if (this.selectedNode?.name && clientData.length === 0) {
|
||||
return this.selectedNode.name;
|
||||
return clientData; // devuelve array de objetos cliente
|
||||
} else if (this.selectedNode && clientData.length === 0) {
|
||||
return this.selectedNode;
|
||||
}
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
openPartitionTypeModal(event: MouseEvent, node: TreeNode | null = null): void {
|
||||
event.stopPropagation();
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@ export class PartitionTypeOrganizatorComponent implements OnInit {
|
|||
displayedColumns: string[] = ['diskNumber', 'partitionNumber', 'partitionCode', 'size', 'filesystem', 'memoryUsage'];
|
||||
|
||||
ngOnInit(): void {
|
||||
console.log('Data recibida en modal:', this.data);
|
||||
|
||||
this.simplifiedData = this.data.map((client: any) => ({
|
||||
name: client.name,
|
||||
partitions: client.partitions.map((p: any) => ({
|
||||
|
@ -27,6 +25,4 @@ export class PartitionTypeOrganizatorComponent implements OnInit {
|
|||
}))
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue