Skip to content

Commit

Permalink
dublicate code weg
Browse files Browse the repository at this point in the history
  • Loading branch information
VeraWise committed Feb 27, 2025
1 parent f4c6409 commit 2367b93
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import {Component, Input} from '@angular/core';
import {TranslatePipe} from "@ngx-translate/core";
import {ConfigMap} from "../../domain/Kubernetes";
import {hideTooltip, showTooltip} from "../search-table-util";

@Component({
selector: 'app-config-map-table',
Expand All @@ -22,25 +23,11 @@ export class ConfigMapTableComponent {

protected readonly Object = Object;

showTooltip(event: MouseEvent, data: Record<string, any>) {
const tooltip = document.getElementById('tooltip');
if (tooltip) {
tooltip.textContent = data && typeof data === 'object'
? Object.entries(data)
.map(([key, value]) => `${key}: ${value}`)
.join('\n')
: 'No data available';

tooltip.style.display = 'block';
tooltip.style.left = `${event.pageX + 10}px`;
tooltip.style.top = `${event.pageY + 10}px`;
}
showTooltip(event: MouseEvent, data: Record<string, any> | undefined) {
showTooltip(event, data);
}

hideTooltip() {
const tooltip = document.getElementById('tooltip');
if (tooltip) {
tooltip.style.display = 'none';
}
hideTooltip();
}
}
22 changes: 22 additions & 0 deletions App/Frontend/src/app/search-table/search-table-util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

export function showTooltip(event: MouseEvent, data: Record<string, any> | undefined, tooltipId = 'tooltip') {
const tooltip = document.getElementById(tooltipId);
if (tooltip) {
tooltip.textContent = data && typeof data === 'object'
? Object.entries(data)
.map(([key, value]) => `${key}: ${value}`)
.join('\n')
: 'No data available';

tooltip.style.display = 'block';
tooltip.style.left = `${event.pageX + 10}px`;
tooltip.style.top = `${event.pageY + 10}px`;
}
}

export function hideTooltip(tooltipId = 'tooltip') {
const tooltip = document.getElementById(tooltipId);
if (tooltip) {
tooltip.style.display = 'none';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { Component, Input } from '@angular/core';
import { TranslatePipe } from "@ngx-translate/core";
import { Secret } from "../../domain/Kubernetes";
import {hideTooltip, showTooltip} from "../search-table-util";

@Component({
selector: 'app-secret-table',
Expand All @@ -22,23 +23,11 @@ export class SecretTableComponent {

protected readonly Object = Object;

showTooltip(event: MouseEvent, data: Record<string, any>) {
const tooltip = document.getElementById('tooltip');
if (tooltip) {
tooltip.textContent = Object.entries(data)
.map(([key, value]) => `${key}: ${value}`)
.join('\n');

tooltip.style.display = 'block';
tooltip.style.left = `${event.pageX + 10}px`;
tooltip.style.top = `${event.pageY + 10}px`;
}
showTooltip(event: MouseEvent, data: Record<string, any> | undefined) {
showTooltip(event, data);
}

hideTooltip() {
const tooltip = document.getElementById('tooltip');
if (tooltip) {
tooltip.style.display = 'none';
}
hideTooltip();
}
}

0 comments on commit 2367b93

Please sign in to comment.