import { Component, Inject } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { ConfigService } from '@services/config.service'; import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; @Component({ selector: 'app-client-logs-modal', templateUrl: './client-logs-modal.component.html', styleUrls: ['./client-logs-modal.component.css'] }) export class ClientLogsModalComponent { iframeUrl: SafeResourceUrl; grafanaUrl: string; constructor( public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: { client: any }, private configService: ConfigService, private sanitizer: DomSanitizer ) { const mac = this.data.client.mac || ''; const iframeUrlString = `${this.configService.logUrl}/d-solo/opengnsys-clients/filebeat-clients?orgId=1&timezone=browser&var-hostname=$__all&var-mac=${mac}&refresh=5s&panelId=1&__feature.dashboardSceneSolo`; this.iframeUrl = this.sanitizer.bypassSecurityTrustResourceUrl(iframeUrlString); this.grafanaUrl = `${this.configService.logUrl}/d/opengnsys-clients/filebeat-clients?orgId=1&from=now-5m&to=now&timezone=browser&var-hostname=$__all&var-mac=${mac}&refresh=5s&viewPanel=panel-1`; } closeModal(): void { this.dialogRef.close(); } openGrafanaInNewTab(): void { window.open(this.grafanaUrl, '_blank'); } }