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">
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import {Component, EventEmitter, Output} from '@angular/core';
|
import { Component, EventEmitter, Output } from '@angular/core';
|
||||||
import {SelectionModel} from "@angular/cdk/collections";
|
import { SelectionModel } from "@angular/cdk/collections";
|
||||||
import {HttpClient} from "@angular/common/http";
|
import { HttpClient } from "@angular/common/http";
|
||||||
import {ToastrService} from "ngx-toastr";
|
import { ToastrService } from "ngx-toastr";
|
||||||
import {ConfigService} from "@services/config.service";
|
import { ConfigService } from "@services/config.service";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
import {SaveScriptComponent} from "./save-script/save-script.component";
|
import { SaveScriptComponent } from "./save-script/save-script.component";
|
||||||
import {MatDialog} from "@angular/material/dialog";
|
import { MatDialog } from "@angular/material/dialog";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-run-script-assistant',
|
selector: 'app-run-script-assistant',
|
||||||
|
@ -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,
|
||||||
|
@ -52,7 +52,7 @@ export class RunScriptAssistantComponent {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.clientId = this.clientData?.length ? this.clientData[0]['@id'] : null;
|
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') {
|
if (client.status === 'og-live') {
|
||||||
client.selected = true;
|
client.selected = true;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -118,7 +143,7 @@ export class RunScriptAssistantComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
return client.partitions
|
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');
|
.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +189,7 @@ export class RunScriptAssistantComponent {
|
||||||
|
|
||||||
this.http.post(`${this.baseUrl}/commands/run-script`, {
|
this.http.post(`${this.baseUrl}/commands/run-script`, {
|
||||||
clients: this.selectedClients.map((client: any) => client.uuid),
|
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(
|
}).subscribe(
|
||||||
response => {
|
response => {
|
||||||
this.toastService.success('Script ejecutado correctamente');
|
this.toastService.success('Script ejecutado correctamente');
|
||||||
|
|
|
@ -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