From 80734085609c524cecd97da0e707dc3bbcc10afa Mon Sep 17 00:00:00 2001 From: jmbardallo Date: Fri, 30 Oct 2026 20:34:12 +0100 Subject: [PATCH] feat(plugins): soporte de tooltipFields y desacoplamiento total en PluginService (v1.24.5) --- CHANGELOG.md | 9 +++++-- .../src/app/services/plugin.service.ts | 25 ++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6566fe..0db3410 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,14 @@ ## [1.24.5] - 2026-10-30 +### Added +- **Soporte Genérico de Tooltips Dinámicos (`PluginBadgeRule.tooltipFields`)**: + - Incorporada la especificación declarativa `tooltipFields` en `PluginBadgeRule`, permitiendo a cualquier plugin declarar en su propio manifiesto qué campos de metadatos deben anexarse al tooltip (con `prefix` y `suffix` opcionales). + ### Removed -- **Eliminación Total de Sondeo Periódico (`GroupsComponent`)**: - - Retirado el temporizador `interval(30000)` en `GroupsComponent`. La arquitectura se mantiene 100% reactiva exclusivamente mediante los eventos push de Mercure (SSE), evitando cualquier sobrecarga innecesaria en el servidor. +- **Desacoplamiento Total de Plugins en `PluginService`**: + - Eliminado todo código ad-hoc y variables específicas de dominio (`dni`, `remaining_minutes`, `student`, `user`, etc.) del motor genérico de `PluginService`. `oggui` pasa a ser 100% agnóstico e independiente de los plugins instalados. + - Retirado el temporizador `interval(30000)` en `GroupsComponent`. La arquitectura se mantiene 100% reactiva exclusivamente mediante los eventos push de Mercure (SSE). ## [1.24.4] - 2026-10-30 diff --git a/ogWebconsole/src/app/services/plugin.service.ts b/ogWebconsole/src/app/services/plugin.service.ts index f676873..07a9f4b 100644 --- a/ogWebconsole/src/app/services/plugin.service.ts +++ b/ogWebconsole/src/app/services/plugin.service.ts @@ -37,6 +37,12 @@ export interface RoleDefinition { shortCode?: string;// Código corto usado en frontend (ej: 'super-admin') } +export interface PluginBadgeField { + key: string; + prefix?: string; + suffix?: string; +} + export interface PluginBadgeRule { status: string; type: string; @@ -45,6 +51,7 @@ export interface PluginBadgeRule { labelKey?: string; tooltip: string; tooltipKey?: string; + tooltipFields?: PluginBadgeField[]; } export interface PluginBadge { @@ -716,19 +723,19 @@ export class PluginService { } } - // Enriquecer tooltip con metadatos contextuales si están disponibles (p. ej. DNI del alumno, tiempo restante) + // Enriquecer tooltip con metadatos contextuales si el badge declara tooltipFields const meta = (idKey ? this.getPluginMetadata(plugin.name, idKey) : null) || (uuidKey ? this.getPluginMetadata(plugin.name, uuidKey) : null); - if (meta) { - const dni = meta.dni || meta.user || meta.student; - const mins = meta.remaining_minutes ?? meta.remainingMinutes; + if (matchingBadge.tooltipFields && matchingBadge.tooltipFields.length > 0 && meta) { const infoParts: string[] = []; - if (dni) { - infoParts.push(`DNI: ${dni}`); - } - if (mins !== undefined && mins !== null && mins !== '') { - infoParts.push(`${mins} min`); + for (const field of matchingBadge.tooltipFields) { + const val = meta[field.key]; + if (val !== undefined && val !== null && val !== '') { + const prefix = field.prefix || ''; + const suffix = field.suffix || ''; + infoParts.push(`${prefix}${val}${suffix}`); + } } if (infoParts.length > 0) { const detailStr = infoParts.join(' · ');