import React, { useEffect } from 'react'; import { useAppStore } from '../store/useAppStore'; import { HardDrive, RefreshCw, Layers } from 'lucide-react'; export const TreemapView: React.FC = () => { const { partitions, treemapItems, isLoadingTreemap, loadTreemap, startLeftoverScan, apps } = useAppStore(); useEffect(() => { loadTreemap(); }, []); const formatBytes = (bytes: number) => { const gb = bytes / (1024 * 1024 * 1024); return `${gb.toFixed(1)} GB`; }; const handleBlockClick = (name: string) => { const matchedApp = apps.find((a) => a.display_name === name); if (matchedApp) { startLeftoverScan(matchedApp); } }; return (
{/* Üst Başlık & Disk Bölümleri */}

Disk Alanı & Squarified Treemap Görselleştirmesi

Uygulamaların diskte kapladığı alanı görsel olarak inceleyin.

{/* Sürücü Kartları */}
{partitions.map((part) => { const usedPct = part.total_bytes > 0 ? (part.used_bytes / part.total_bytes) * 100 : 0; return (
Sürücü {part.mount_point} ({part.file_system || 'NTFS'})
{usedPct.toFixed(0)}%
{/* İlerleme Çubuğu */}
90 ? 'bg-rose-500' : usedPct > 75 ? 'bg-amber-400' : 'bg-sky-500' }`} style={{ width: `${usedPct}%` }} />
Kullanılan: {formatBytes(part.used_bytes)} Boş: {formatBytes(part.free_bytes)} Toplam: {formatBytes(part.total_bytes)}
); })}
{/* Squarified Treemap Alanı */}
Uygulama Boyut Dağılımı Tıklayarak doğrudan kalıntı taramasını başlatın
{isLoadingTreemap ? (

Harita oluşturuluyor...

) : treemapItems.length === 0 ? (
Boyut bilgisi olan uygulama bulunamadı.
) : (
{treemapItems.slice(0, 36).map((item) => { const totalValue = treemapItems.reduce((acc, i) => acc + i.value, 0); const pct = totalValue > 0 ? (item.value / totalValue) * 100 : 2; const flexGrow = Math.max(1, Math.round(pct * 2)); return (
handleBlockClick(item.name)} style={{ flexGrow, backgroundColor: item.color, minWidth: '80px', minHeight: '60px', }} title={`${item.name} (${item.formatted_size}) - Kalıntı taramak için tıklayın`} className="rounded-md p-2 flex flex-col justify-between cursor-pointer transition-transform hover:scale-[1.02] hover:shadow-lg shadow-black/40 text-slate-950 font-semibold select-none overflow-hidden" > {item.name} {item.formatted_size}
); })}
)}
); };