import { Panel } from './Panel'; import { joinSafeHtml, safeHtml } from '@/utils/sanitize'; import { type ClimateAnomaly, getSeverityIcon, formatDelta } from '@/services/climate'; import { t } from '@/services/i18n'; export class ClimateAnomalyPanel extends Panel { private anomalies: ClimateAnomaly[] = []; private hasLoadedAnomalies = false; private onZoneClick?: (lat: number, lon: number) => void; constructor() { super({ id: 'climate', title: t('panels.climate'), showCount: true, trackActivity: true, infoTooltip: t('components.climate.infoTooltip'), }); this.showLoading(t('common.loadingClimateData')); } public setZoneClickHandler(handler: (lat: number, lon: number) => void): void { this.onZoneClick = handler; } public setAnomalies(anomalies: ClimateAnomaly[]): void { this.anomalies = anomalies; this.hasLoadedAnomalies = true; this.setCount(anomalies.length); this.renderContent(); } public hasData(): boolean { return this.hasLoadedAnomalies; } private renderContent(): void { if (this.anomalies.length === 0) { this.setSafeContent(safeHtml`
| ${t('components.climate.zone')} | ${t('components.climate.temp')} | ${t('components.climate.precip')} | ${t('components.climate.severityLabel')} |
|---|