Le modèle front portait un alert_id texte, des value/threshold non nullables et ignorait metric et prediction_id, alors que l'API sérialise un entier, des flottants nullables et ces deux champs. Toute comparaison avec l'alert_id d'une recommandation échouait silencieusement. - alert.model.ts : alert_id number, value/threshold/metric/prediction_id nullables - alerts.service.ts : getAlerts(filters) pose site_id et severity en HttpParams, les deux filtres que l'API accepte - alerts.fixture.ts : réaligné sur le contrat (ids entiers, horodatages UTC, champs nuls sur outage/sensor, un cas spike) - alert-presentation.ts : tons, libellés et unités partagés ; low passe en neutre, le vert se lisait comme un état sain
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { BadgeTone } from '../components/ui/badge/badge';
|
|
import { AlertMetric, AlertSeverity, AlertType } from './alert.model';
|
|
|
|
// Pourquoi : `low` en neutre plutôt qu'en vert, une alerte faible reste une alerte ; le vert se
|
|
// lisait comme « tout va bien » à côté des rouges.
|
|
export const TON_PAR_SEVERITE: Record<AlertSeverity, BadgeTone> = {
|
|
low: 'neutral',
|
|
medium: 'warning',
|
|
high: 'danger',
|
|
critical: 'critical',
|
|
};
|
|
|
|
export const LIBELLE_PAR_SEVERITE: Record<AlertSeverity, string> = {
|
|
low: 'Faible',
|
|
medium: 'Moyenne',
|
|
high: 'Élevée',
|
|
critical: 'Critique',
|
|
};
|
|
|
|
export const LIBELLE_PAR_TYPE: Record<AlertType, string> = {
|
|
spike: 'Pic de consommation',
|
|
threshold: 'Seuil dépassé',
|
|
anomaly: 'Anomalie',
|
|
outage: 'Coupure',
|
|
sensor: 'Capteur',
|
|
};
|
|
|
|
export const UNITE_PAR_METRIQUE: Record<AlertMetric, string> = {
|
|
consumption_kw: 'kW',
|
|
consumption_kwh: 'kWh',
|
|
};
|
|
|
|
export const SEVERITES: readonly AlertSeverity[] = ['low', 'medium', 'high', 'critical'];
|
|
|
|
export const TYPES_ALERTE: readonly AlertType[] = [
|
|
'spike',
|
|
'threshold',
|
|
'anomaly',
|
|
'outage',
|
|
'sensor',
|
|
];
|