From 647fa5079e5e26645fa2397bfca4e73911b72573 Mon Sep 17 00:00:00 2001 From: Nicolas Arenas Date: Thu, 14 May 2026 21:38:35 +0200 Subject: [PATCH] =?UTF-8?q?feat(oggui):=20soporte=20de=20m=C3=BAltiples=20?= =?UTF-8?q?SYSLOG=5FIDENTIFIER=20en=20visor=20de=20logs=20de=20disco?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - StatusLogsComponent: @Input identifiers[] en lugar de identifier string, parseo de entries JSON estructurado con formato [timestamp] ID: mensaje - Templates ogboot, ogdhcp, ogrepository, ogcore-status: identifiers correctos por componente y host basado en IP en lugar de nombre del servidor - Añadidos métodos getSelectedXxxIp() en ogboot, ogdhcp y ogrepository status --- .../ogboot-status.component.html | 4 +- .../ogboot-status/ogboot-status.component.ts | 5 +++ .../ogcore-status.component.html | 2 +- .../ogdhcp-status.component.html | 4 +- .../ogdhcp-status/ogdhcp-status.component.ts | 5 +++ .../ogrepository-status.component.html | 4 +- .../ogrepository-status.component.ts | 5 +++ .../status-logs/status-logs.component.ts | 38 ++++++++++++++----- 8 files changed, 51 insertions(+), 16 deletions(-) diff --git a/ogWebconsole/src/app/components/global-status/ogboot-status/ogboot-status.component.html b/ogWebconsole/src/app/components/global-status/ogboot-status/ogboot-status.component.html index ad0c987..b44e5f0 100644 --- a/ogWebconsole/src/app/components/global-status/ogboot-status/ogboot-status.component.html +++ b/ogWebconsole/src/app/components/global-status/ogboot-status/ogboot-status.component.html @@ -45,8 +45,8 @@
diff --git a/ogWebconsole/src/app/components/global-status/ogboot-status/ogboot-status.component.ts b/ogWebconsole/src/app/components/global-status/ogboot-status/ogboot-status.component.ts index 6a1082b..8abd633 100644 --- a/ogWebconsole/src/app/components/global-status/ogboot-status/ogboot-status.component.ts +++ b/ogWebconsole/src/app/components/global-status/ogboot-status/ogboot-status.component.ts @@ -101,6 +101,11 @@ export class GlobalOgbootStatusComponent implements OnInit { } } + getSelectedBootServerIp(): string { + const s = this.bootServers.find(s => s.uuid === this.selectedBootServerUuid); + return s ? s.ip : ''; + } + getSelectedBootServerName(): string { const selectedBootServer = this.bootServers.find(server => server.uuid === this.selectedBootServerUuid); return selectedBootServer ? selectedBootServer.name : ''; diff --git a/ogWebconsole/src/app/components/global-status/ogcore-status/ogcore-status.component.html b/ogWebconsole/src/app/components/global-status/ogcore-status/ogcore-status.component.html index ae17fdb..f7358c6 100644 --- a/ogWebconsole/src/app/components/global-status/ogcore-status/ogcore-status.component.html +++ b/ogWebconsole/src/app/components/global-status/ogcore-status/ogcore-status.component.html @@ -3,7 +3,7 @@
diff --git a/ogWebconsole/src/app/components/global-status/ogdhcp-status/ogdhcp-status.component.html b/ogWebconsole/src/app/components/global-status/ogdhcp-status/ogdhcp-status.component.html index 099bf15..d344c9b 100644 --- a/ogWebconsole/src/app/components/global-status/ogdhcp-status/ogdhcp-status.component.html +++ b/ogWebconsole/src/app/components/global-status/ogdhcp-status/ogdhcp-status.component.html @@ -45,8 +45,8 @@
diff --git a/ogWebconsole/src/app/components/global-status/ogdhcp-status/ogdhcp-status.component.ts b/ogWebconsole/src/app/components/global-status/ogdhcp-status/ogdhcp-status.component.ts index c15f1a5..9ab253f 100644 --- a/ogWebconsole/src/app/components/global-status/ogdhcp-status/ogdhcp-status.component.ts +++ b/ogWebconsole/src/app/components/global-status/ogdhcp-status/ogdhcp-status.component.ts @@ -104,6 +104,11 @@ export class OgdhcpStatusComponent implements OnInit { } } + getSelectedDhcpIp(): string { + const d = this.dhcps.find(d => d.uuid === this.selectedDhcpUuid); + return d ? d.ip : ''; + } + getSelectedDhcpName(): string { const selectedDhcp = this.dhcps.find(dhcp => dhcp.uuid === this.selectedDhcpUuid); return selectedDhcp ? selectedDhcp.name : ''; diff --git a/ogWebconsole/src/app/components/global-status/ogrepository-status/ogrepository-status.component.html b/ogWebconsole/src/app/components/global-status/ogrepository-status/ogrepository-status.component.html index cb4f294..a0fae1e 100644 --- a/ogWebconsole/src/app/components/global-status/ogrepository-status/ogrepository-status.component.html +++ b/ogWebconsole/src/app/components/global-status/ogrepository-status/ogrepository-status.component.html @@ -52,8 +52,8 @@
diff --git a/ogWebconsole/src/app/components/global-status/ogrepository-status/ogrepository-status.component.ts b/ogWebconsole/src/app/components/global-status/ogrepository-status/ogrepository-status.component.ts index 32b9bfb..6f06dce 100644 --- a/ogWebconsole/src/app/components/global-status/ogrepository-status/ogrepository-status.component.ts +++ b/ogWebconsole/src/app/components/global-status/ogrepository-status/ogrepository-status.component.ts @@ -103,6 +103,11 @@ export class OgrepositoryStatusComponent implements OnInit { } } + getSelectedRepositoryIp(): string { + const r = this.repositories.find(r => r.uuid === this.selectedRepositoryUuid); + return r ? r.ip : ''; + } + getSelectedRepositoryName(): string { const selectedRepo = this.repositories.find(repo => repo.uuid === this.selectedRepositoryUuid); return selectedRepo ? selectedRepo.name : ''; diff --git a/ogWebconsole/src/app/components/global-status/status-logs/status-logs.component.ts b/ogWebconsole/src/app/components/global-status/status-logs/status-logs.component.ts index cdb5d9a..9053dd4 100644 --- a/ogWebconsole/src/app/components/global-status/status-logs/status-logs.component.ts +++ b/ogWebconsole/src/app/components/global-status/status-logs/status-logs.component.ts @@ -5,6 +5,14 @@ import { ConfigService } from '@services/config.service'; import { TranslateService } from '@ngx-translate/core'; import { MatTabChangeEvent } from '@angular/material/tabs'; +interface JournalEntry { + MESSAGE: string; + SYSLOG_IDENTIFIER?: string; + _HOSTNAME?: string; + __REALTIME_TIMESTAMP?: string; + PRIORITY?: string; +} + @Component({ selector: 'app-status-logs', templateUrl: './status-logs.component.html', @@ -12,7 +20,7 @@ import { MatTabChangeEvent } from '@angular/material/tabs'; }) export class StatusLogsComponent implements OnInit, OnDestroy, AfterViewChecked { @ViewChild('logContent') private logContainer!: ElementRef; - @Input() identifier: string = ''; + @Input() identifiers: string[] = []; @Input() host: string = ''; @Input() oglogUrl: SafeResourceUrl | null = null; @Input() title: string = ''; @@ -53,12 +61,12 @@ export class StatusLogsComponent implements OnInit, OnDestroy, AfterViewChecked } onTabChange(event: MatTabChangeEvent): void { - if (event.index === 0) { // Disk Logs tab + if (event.index === 0) { if (this.isLive) { this.loadDiskLogs(); this.startPolling(); } - } else { // oglog Logs tab or others + } else { this.stopPolling(); } } @@ -68,27 +76,39 @@ export class StatusLogsComponent implements OnInit, OnDestroy, AfterViewChecked } loadDiskLogs(): void { - if (!this.identifier) return; + if (!this.identifiers.length) return; if (!this.isLive) { this.loadingDiskLogs = true; } - - const url = `${this.configService.apiUrl}/opengnsys/system/disk-logs?SYSLOG_IDENTIFIER=${this.identifier}&host=${this.host}&lines=200`; - this.http.get<{ content: string }>(url).subscribe({ + const idParam = this.identifiers.join(','); + const hostParam = this.host ? `&host=${encodeURIComponent(this.host)}` : ''; + const url = `${this.configService.apiUrl}/opengnsys/system/disk-logs?SYSLOG_IDENTIFIER=${encodeURIComponent(idParam)}${hostParam}&lines=200`; + + this.http.get<{ entries: JournalEntry[] }>(url).subscribe({ next: (response) => { - this.diskLogsContent = response.content || ''; + this.diskLogsContent = this.formatEntries(response.entries || []); this.loadingDiskLogs = false; this.errorDiskLogs = null; }, - error: (err) => { + error: () => { this.errorDiskLogs = 'Error al cargar logs de disco'; this.loadingDiskLogs = false; } }); } + private formatEntries(entries: JournalEntry[]): string { + return entries.map(entry => { + const ts = entry.__REALTIME_TIMESTAMP + ? new Date(parseInt(entry.__REALTIME_TIMESTAMP, 10) / 1000).toISOString().replace('T', ' ').substring(0, 23) + : ' '; + const id = entry.SYSLOG_IDENTIFIER ?? ''; + return `[${ts}] ${id}: ${entry.MESSAGE ?? ''}`; + }).join('\n'); + } + private startPolling(): void { this.stopPolling(); this.pollInterval = setInterval(() => {