interface interactive

This commit is contained in:
nBiqoz
2025-09-07 12:30:23 +02:00
parent 74e56c956c
commit ef0819ae90
27 changed files with 1827 additions and 515 deletions

View File

@@ -0,0 +1,83 @@
export interface ColorOption {
name: string;
value: string;
bgClass: string;
textClass: string;
}
// Palette de couleurs harmonisée (équivalent Tailwind 200)
export const COLOR_PALETTE: ColorOption[] = [
{
name: 'Rouge',
value: '#fecaca', // red-200
bgClass: 'bg-red-200',
textClass: 'text-red-800'
},
{
name: 'Orange',
value: '#fed7aa', // orange-200
bgClass: 'bg-orange-200',
textClass: 'text-orange-800'
},
{
name: 'Jaune',
value: '#fef3c7', // yellow-200
bgClass: 'bg-yellow-200',
textClass: 'text-yellow-800'
},
{
name: 'Vert',
value: '#bbf7d0', // green-200
bgClass: 'bg-green-200',
textClass: 'text-green-800'
},
{
name: 'Bleu',
value: '#bfdbfe', // blue-200
bgClass: 'bg-blue-200',
textClass: 'text-blue-800'
},
{
name: 'Indigo',
value: '#c7d2fe', // indigo-200
bgClass: 'bg-indigo-200',
textClass: 'text-indigo-800'
},
{
name: 'Violet',
value: '#ddd6fe', // violet-200
bgClass: 'bg-violet-200',
textClass: 'text-violet-800'
},
{
name: 'Rose',
value: '#fbcfe8', // pink-200
bgClass: 'bg-pink-200',
textClass: 'text-pink-800'
}
];
// Fonction pour obtenir une couleur par hash
export function generateColorFromName(name: string): ColorOption {
// Vérification de sécurité
if (!name || typeof name !== 'string' || name.length === 0) {
return COLOR_PALETTE[0]; // Retourner la première couleur par défaut
}
let hash = 0;
for (let i = 0; i < name.length; i++) {
const char = name.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
hash = hash & hash;
}
const index = Math.abs(hash) % COLOR_PALETTE.length;
return COLOR_PALETTE[index];
}
// Fonction pour obtenir la couleur hex
export function getHexColorFromName(name: string): string {
return generateColorFromName(name).value;
}
// Export des valeurs hex pour compatibilité
export const COLOR_VALUES = COLOR_PALETTE.map(color => color.value);

View File

@@ -0,0 +1,65 @@
// Configuration des entités basée sur replacements.yaml
// Système 100% dynamique
// Tout est récupéré depuis Presidio
export interface EntityPattern {
regex: RegExp;
className: string;
label: string;
presidioType: string;
}
export interface PresidioConfig {
replacements: Record<string, string>;
default_anonymizers: Record<string, string>;
}
// Interface pour les résultats Presidio
/**
* Interfaces pour les données de Presidio et le mapping.
* Simplifié pour ne contenir que les définitions nécessaires.
*/
// Interface pour un résultat d'analyse de Presidio
export interface PresidioAnalyzerResult {
entity_type: string;
start: number;
end: number;
score: number;
}
// Interface pour une ligne du tableau de mapping
import { generateColorFromName, getHexColorFromName } from "./colorPalette";
export interface EntityMapping {
entity_type: string;
start: number;
end: number;
text: string;
replacementValue?: string;
displayName?: string; // Ajouter cette propriété
customColor?: string;
}
// Utiliser la palette centralisée
export { generateColorFromName, getHexColorFromName };
/**
* Récupère la configuration Presidio depuis l'API
*/
export const fetchPresidioConfig = async (): Promise<PresidioConfig | null> => {
try {
const response = await fetch("/api/presidio/config");
if (!response.ok) {
console.warn("Impossible de récupérer la config Presidio");
return null;
}
return await response.json();
} catch (error) {
console.warn(
"Erreur lors de la récupération de la config Presidio:",
error
);
return null;
}
};