✨ dynamic dashboard stats, live ping, and chart hover tooltips
Browse files at this commitb8f964caca1101fa87261b8bc4c6cc9480bd0905Parent: f77a164- feat
- ✨ dynamic dashboard stats, live ping, and chart hover tooltips
5 changed files +779 -76
- src/components/ui/chart-area-trend.tsx +202 -0
- src/components/ui/chart-bar.tsx +8 -2
- src/components/ui/chart-metric-cards.tsx +72 -0
- src/components/ui/chart-progress-ring.tsx +56 -40
- src/pages/dashboard-page.tsx +441 -34
src/components/ui/chart-area-trend.tsxadded+202 -0
| @@ -0,0 +1,202 @@ | ||
| 1 | +import { For, Show, createSignal, type Component } from "solid-js"; | |
| 2 | +import { cn } from "@/lib/cn"; | |
| 3 | + | |
| 4 | +export type ChartAreaTrendItem = { | |
| 5 | + label: string; | |
| 6 | + value: number; | |
| 7 | + formattedValue?: string; | |
| 8 | +}; | |
| 9 | + | |
| 10 | +export type ChartAreaTrendProps = { | |
| 11 | + title: string; | |
| 12 | + subtitle?: string; | |
| 13 | + items: ChartAreaTrendItem[]; | |
| 14 | + class?: string; | |
| 15 | + minScale?: number; | |
| 16 | + maxScale?: number; | |
| 17 | + unit?: string; | |
| 18 | +}; | |
| 19 | + | |
| 20 | +export const ChartAreaTrend: Component<ChartAreaTrendProps> = (props) => { | |
| 21 | + const [hoverIndex, setHoverIndex] = createSignal<number | null>(null); | |
| 22 | + | |
| 23 | + const values = () => props.items.map((i) => i.value); | |
| 24 | + const minVal = () => props.minScale ?? Math.min(0, ...values()); | |
| 25 | + const maxVal = () => props.maxScale ?? Math.max(1, ...values()); | |
| 26 | + | |
| 27 | + const width = 360; | |
| 28 | + const height = 120; | |
| 29 | + const paddingX = 20; | |
| 30 | + const paddingTop = 15; | |
| 31 | + const paddingBottom = 25; | |
| 32 | + | |
| 33 | + const points = () => { | |
| 34 | + const list = props.items; | |
| 35 | + if (list.length === 0) return []; | |
| 36 | + const min = minVal(); | |
| 37 | + const max = maxVal(); | |
| 38 | + const range = max - min || 1; | |
| 39 | + const stepX = (width - paddingX * 2) / Math.max(1, list.length - 1); | |
| 40 | + const usableH = height - paddingTop - paddingBottom; | |
| 41 | + | |
| 42 | + return list.map((item, i) => { | |
| 43 | + const x = paddingX + i * stepX; | |
| 44 | + const normalized = (item.value - min) / range; | |
| 45 | + const y = height - paddingBottom - normalized * usableH; | |
| 46 | + return { x, y, item, index: i }; | |
| 47 | + }); | |
| 48 | + }; | |
| 49 | + | |
| 50 | + const linePath = () => { | |
| 51 | + const pts = points(); | |
| 52 | + if (pts.length === 0) return ""; | |
| 53 | + return pts.reduce((acc, p, idx) => (idx === 0 ? `M ${p.x} ${p.y}` : `${acc} L ${p.x} ${p.y}`), ""); | |
| 54 | + }; | |
| 55 | + | |
| 56 | + const areaPath = () => { | |
| 57 | + const pts = points(); | |
| 58 | + if (pts.length === 0) return ""; | |
| 59 | + const first = pts[0]; | |
| 60 | + const last = pts[pts.length - 1]; | |
| 61 | + const bottomY = height - paddingBottom; | |
| 62 | + return `${linePath()} L ${last.x} ${bottomY} L ${first.x} ${bottomY} Z`; | |
| 63 | + }; | |
| 64 | + | |
| 65 | + return ( | |
| 66 | + <div class={cn("flex flex-col space-y-3 rounded-2xl border border-border/60 bg-card p-4 shadow-sm dark:border-white/[0.08]", props.class)}> | |
| 67 | + <div class="flex items-start justify-between gap-2"> | |
| 68 | + <div class="space-y-0.5 min-w-0"> | |
| 69 | + <h3 class="truncate text-sm font-semibold tracking-tight text-foreground">{props.title}</h3> | |
| 70 | + <Show when={props.subtitle}> | |
| 71 | + <p class="truncate text-xs text-muted-foreground">{props.subtitle}</p> | |
| 72 | + </Show> | |
| 73 | + </div> | |
| 74 | + <Show when={props.items.length > 0}> | |
| 75 | + <div class="mono tabular-nums text-xs font-semibold text-primary bg-primary/10 px-2 py-0.5 rounded-full border border-primary/20"> | |
| 76 | + {hoverIndex() !== null | |
| 77 | + ? (props.items[hoverIndex()!]?.formattedValue ?? `${props.items[hoverIndex()!]?.value}${props.unit ?? ""}`) | |
| 78 | + : (props.items[props.items.length - 1]?.formattedValue ?? `${props.items[props.items.length - 1]?.value}${props.unit ?? ""}`)} | |
| 79 | + </div> | |
| 80 | + </Show> | |
| 81 | + </div> | |
| 82 | + | |
| 83 | + <Show | |
| 84 | + when={props.items.length > 0} | |
| 85 | + fallback={ | |
| 86 | + <div class="flex flex-col items-center justify-center py-8 px-4 text-center"> | |
| 87 | + <div class="flex h-11 w-11 items-center justify-center rounded-2xl bg-muted/40 border border-border/50 text-muted-foreground/60 mb-2"> | |
| 88 | + <svg class="h-5 w-5 stroke-[1.5]" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | |
| 89 | + <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z" /> | |
| 90 | + </svg> | |
| 91 | + </div> | |
| 92 | + <p class="text-xs font-semibold text-foreground/80">Kayıt Bulunamadı</p> | |
| 93 | + <p class="text-[11px] text-muted-foreground mt-0.5">Gösterilecek henüz veri eklenmedi</p> | |
| 94 | + </div> | |
| 95 | + } | |
| 96 | + > | |
| 97 | + <div class="relative w-full overflow-hidden"> | |
| 98 | + <svg viewBox={`0 0 ${width} ${height}`} class="w-full h-32 overflow-visible"> | |
| 99 | + <defs> | |
| 100 | + <linearGradient id="areaGradient" x1="0" y1="0" x2="0" y2="1"> | |
| 101 | + <stop offset="0%" stop-color="hsl(var(--primary))" stop-opacity="0.35" /> | |
| 102 | + <stop offset="100%" stop-color="hsl(var(--primary))" stop-opacity="0.0" /> | |
| 103 | + </linearGradient> | |
| 104 | + </defs> | |
| 105 | + | |
| 106 | + {/* Horizontal Grid lines */} | |
| 107 | + <line x1={paddingX} y1={paddingTop} x2={width - paddingX} y2={paddingTop} stroke="currentColor" stroke-opacity="0.08" stroke-dasharray="3 3" /> | |
| 108 | + <line x1={paddingX} y1={(paddingTop + height - paddingBottom) / 2} x2={width - paddingX} y2={(paddingTop + height - paddingBottom) / 2} stroke="currentColor" stroke-opacity="0.08" stroke-dasharray="3 3" /> | |
| 109 | + <line x1={paddingX} y1={height - paddingBottom} x2={width - paddingX} y2={height - paddingBottom} stroke="currentColor" stroke-opacity="0.12" /> | |
| 110 | + | |
| 111 | + {/* Hover Vertical Guideline */} | |
| 112 | + <Show when={hoverIndex() !== null && points()[hoverIndex()!]}> | |
| 113 | + {(p) => ( | |
| 114 | + <line | |
| 115 | + x1={p().x} | |
| 116 | + y1={paddingTop} | |
| 117 | + x2={p().x} | |
| 118 | + y2={height - paddingBottom} | |
| 119 | + stroke="hsl(var(--primary))" | |
| 120 | + stroke-opacity="0.3" | |
| 121 | + stroke-dasharray="3 3" | |
| 122 | + stroke-width="1.5" | |
| 123 | + /> | |
| 124 | + )} | |
| 125 | + </Show> | |
| 126 | + | |
| 127 | + {/* Filled Area */} | |
| 128 | + <path d={areaPath()} fill="url(#areaGradient)" /> | |
| 129 | + | |
| 130 | + {/* Trend Line */} | |
| 131 | + <path d={linePath()} fill="none" stroke="hsl(var(--primary))" stroke-width="2.5" stroke-linejoin="round" stroke-linecap="round" /> | |
| 132 | + | |
| 133 | + {/* Data Points */} | |
| 134 | + <For each={points()}> | |
| 135 | + {(p) => ( | |
| 136 | + <g class="cursor-pointer group" onMouseEnter={() => setHoverIndex(p.index)} onMouseLeave={() => setHoverIndex(null)}> | |
| 137 | + <circle | |
| 138 | + cx={p.x} | |
| 139 | + cy={p.y} | |
| 140 | + r={hoverIndex() === p.index ? "5.5" : "3.5"} | |
| 141 | + class={cn( | |
| 142 | + "transition-all duration-200 fill-background stroke-primary stroke-[2.5]", | |
| 143 | + hoverIndex() === p.index && "fill-primary stroke-background shadow-lg stroke-[3]", | |
| 144 | + )} | |
| 145 | + /> | |
| 146 | + <text | |
| 147 | + x={p.x} | |
| 148 | + y={height - 8} | |
| 149 | + text-anchor="middle" | |
| 150 | + class={cn( | |
| 151 | + "text-[10px] transition-colors font-medium", | |
| 152 | + hoverIndex() === p.index ? "fill-primary font-bold" : "fill-muted-foreground" | |
| 153 | + )} | |
| 154 | + > | |
| 155 | + {p.item.label} | |
| 156 | + </text> | |
| 157 | + </g> | |
| 158 | + )} | |
| 159 | + </For> | |
| 160 | + | |
| 161 | + {/* Floating Active Hover Tooltip */} | |
| 162 | + <Show when={hoverIndex() !== null && points()[hoverIndex()!]}> | |
| 163 | + {(p) => { | |
| 164 | + const text = p().item.formattedValue ?? `${p().item.value}${props.unit ?? ""}`; | |
| 165 | + const rectW = 64; | |
| 166 | + const rectH = 20; | |
| 167 | + const tooltipX = Math.max(paddingX, Math.min(width - paddingX - rectW, p().x - rectW / 2)); | |
| 168 | + const tooltipY = Math.max(2, p().y - 26); | |
| 169 | + return ( | |
| 170 | + <g class="pointer-events-none transition-all duration-150"> | |
| 171 | + <circle | |
| 172 | + cx={p().x} | |
| 173 | + cy={p().y} | |
| 174 | + r="8.5" | |
| 175 | + class="fill-primary/20 stroke-primary/40 stroke-1" | |
| 176 | + /> | |
| 177 | + <rect | |
| 178 | + x={tooltipX} | |
| 179 | + y={tooltipY} | |
| 180 | + width={rectW} | |
| 181 | + height={rectH} | |
| 182 | + rx="5" | |
| 183 | + class="fill-card stroke-primary/40 stroke shadow-md dark:fill-zinc-900" | |
| 184 | + /> | |
| 185 | + <text | |
| 186 | + x={tooltipX + rectW / 2} | |
| 187 | + y={tooltipY + 13.5} | |
| 188 | + text-anchor="middle" | |
| 189 | + class="fill-foreground font-semibold text-[10px] mono tabular-nums" | |
| 190 | + > | |
| 191 | + {text} | |
| 192 | + </text> | |
| 193 | + </g> | |
| 194 | + ); | |
| 195 | + }} | |
| 196 | + </Show> | |
| 197 | + </svg> | |
| 198 | + </div> | |
| 199 | + </Show> | |
| 200 | + </div> | |
| 201 | + ); | |
| 202 | +}; |
src/components/ui/chart-bar.tsxmodified+8 -2
| @@ -43,8 +43,14 @@ export const ChartBar: Component<ChartBarProps> = (props) => { | ||
| 43 | 43 | <Show |
| 44 | 44 | when={props.items.length > 0} |
| 45 | 45 | fallback={ |
| 46 | - <div class="flex h-32 items-center justify-center rounded-2xl border border-dashed border-border/60 bg-muted/20 text-xs text-muted-foreground"> | |
| 47 | - Grafik için henüz yeterli veri bulunmuyor | |
| 46 | + <div class="flex flex-col items-center justify-center py-8 px-4 text-center"> | |
| 47 | + <div class="flex h-11 w-11 items-center justify-center rounded-2xl bg-muted/40 border border-border/50 text-muted-foreground/60 mb-2"> | |
| 48 | + <svg class="h-5 w-5 stroke-[1.5]" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | |
| 49 | + <path stroke-linecap="round" stroke-linejoin="round" d="M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75zM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V8.625zM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V4.125z" /> | |
| 50 | + </svg> | |
| 51 | + </div> | |
| 52 | + <p class="text-xs font-semibold text-foreground/80">Kayıt Bulunamadı</p> | |
| 53 | + <p class="text-[11px] text-muted-foreground mt-0.5">Grafik için henüz yeterli veri bulunmuyor</p> | |
| 48 | 54 | </div> |
| 49 | 55 | } |
| 50 | 56 | > |
src/components/ui/chart-metric-cards.tsxadded+72 -0
| @@ -0,0 +1,72 @@ | ||
| 1 | +import { For, Show, type Component } from "solid-js"; | |
| 2 | +import { cn } from "@/lib/cn"; | |
| 3 | + | |
| 4 | +export type ChartMetricCardItem = { | |
| 5 | + id: string; | |
| 6 | + label: string; | |
| 7 | + value: string | number; | |
| 8 | + change?: string; | |
| 9 | + isPositive?: boolean; | |
| 10 | + subtext?: string; | |
| 11 | + accentColor?: string; | |
| 12 | +}; | |
| 13 | + | |
| 14 | +export type ChartMetricCardsProps = { | |
| 15 | + title: string; | |
| 16 | + subtitle?: string; | |
| 17 | + metrics: ChartMetricCardItem[]; | |
| 18 | + class?: string; | |
| 19 | +}; | |
| 20 | + | |
| 21 | +export const ChartMetricCards: Component<ChartMetricCardsProps> = (props) => { | |
| 22 | + return ( | |
| 23 | + <div class={cn("flex flex-col space-y-3 rounded-2xl border border-border/60 bg-card p-4 shadow-sm dark:border-white/[0.08]", props.class)}> | |
| 24 | + <div class="space-y-0.5 min-w-0"> | |
| 25 | + <h3 class="truncate text-sm font-semibold tracking-tight text-foreground">{props.title}</h3> | |
| 26 | + <Show when={props.subtitle}> | |
| 27 | + <p class="truncate text-xs text-muted-foreground">{props.subtitle}</p> | |
| 28 | + </Show> | |
| 29 | + </div> | |
| 30 | + | |
| 31 | + <div class="grid grid-cols-2 gap-2.5"> | |
| 32 | + <For each={props.metrics}> | |
| 33 | + {(m) => ( | |
| 34 | + <div class="flex flex-col justify-between rounded-xl border border-border/50 bg-muted/20 p-3 transition-colors hover:bg-muted/40"> | |
| 35 | + <div class="flex items-center justify-between gap-1"> | |
| 36 | + <span class="truncate text-xs font-medium text-muted-foreground">{m.label}</span> | |
| 37 | + <Show when={m.change}> | |
| 38 | + <span | |
| 39 | + class={cn( | |
| 40 | + "inline-flex items-center gap-1.5 px-1.5 py-0.5 rounded text-[10px] font-semibold mono tabular-nums", | |
| 41 | + m.isPositive !== false | |
| 42 | + ? "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20" | |
| 43 | + : "bg-rose-500/10 text-rose-600 dark:text-rose-400 border border-rose-500/20", | |
| 44 | + )} | |
| 45 | + > | |
| 46 | + <span | |
| 47 | + class={cn( | |
| 48 | + "h-1.5 w-1.5 rounded-full shrink-0", | |
| 49 | + m.isPositive !== false ? "bg-emerald-500" : "bg-rose-500" | |
| 50 | + )} | |
| 51 | + aria-hidden="true" | |
| 52 | + /> | |
| 53 | + {m.change} | |
| 54 | + </span> | |
| 55 | + </Show> | |
| 56 | + </div> | |
| 57 | + | |
| 58 | + <div class="mt-2 flex items-baseline justify-between"> | |
| 59 | + <span class="mono tabular-nums text-xl font-bold tracking-tight text-foreground"> | |
| 60 | + {m.value} | |
| 61 | + </span> | |
| 62 | + <Show when={m.subtext}> | |
| 63 | + <span class="text-[10px] text-muted-foreground font-medium">{m.subtext}</span> | |
| 64 | + </Show> | |
| 65 | + </div> | |
| 66 | + </div> | |
| 67 | + )} | |
| 68 | + </For> | |
| 69 | + </div> | |
| 70 | + </div> | |
| 71 | + ); | |
| 72 | +}; |
src/components/ui/chart-progress-ring.tsxmodified+56 -40
| @@ -34,50 +34,66 @@ export const ChartProgressRing: Component<ChartProgressRingProps> = (props) => { | ||
| 34 | 34 | </div> |
| 35 | 35 | </Show> |
| 36 | 36 | |
| 37 | - <div class="flex flex-col justify-between gap-4 py-1"> | |
| 38 | - {/* Total Stat Highlight */} | |
| 39 | - <div class="flex items-baseline gap-2"> | |
| 40 | - <span class="font-mono text-3xl font-bold tracking-tight text-foreground"> | |
| 41 | - {props.valueText ?? calculatedTotal()} | |
| 42 | - </span> | |
| 43 | - <Show when={props.subtext}> | |
| 44 | - <span class="text-xs font-medium text-muted-foreground">{props.subtext}</span> | |
| 45 | - </Show> | |
| 46 | - </div> | |
| 37 | + <Show | |
| 38 | + when={calculatedTotal() > 0} | |
| 39 | + fallback={ | |
| 40 | + <div class="flex flex-col items-center justify-center py-8 px-4 text-center"> | |
| 41 | + <div class="flex h-11 w-11 items-center justify-center rounded-2xl bg-muted/40 border border-border/50 text-muted-foreground/60 mb-2"> | |
| 42 | + <svg class="h-5 w-5 stroke-[1.5]" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | |
| 43 | + <path stroke-linecap="round" stroke-linejoin="round" d="M10.5 6a7.5 7.5 0 107.5 7.5h-7.5V6z" /> | |
| 44 | + <path stroke-linecap="round" stroke-linejoin="round" d="M13.5 10.5H21A7.5 7.5 0 0013.5 3v7.5z" /> | |
| 45 | + </svg> | |
| 46 | + </div> | |
| 47 | + <p class="text-xs font-semibold text-foreground/80">Kayıt Bulunamadı</p> | |
| 48 | + <p class="text-[11px] text-muted-foreground mt-0.5">Analiz için henüz yeterli veri eklenmedi</p> | |
| 49 | + </div> | |
| 50 | + } | |
| 51 | + > | |
| 52 | + <div class="flex flex-col justify-between gap-4 py-1"> | |
| 53 | + {/* Total Stat Highlight */} | |
| 54 | + <div class="flex items-baseline gap-2"> | |
| 55 | + <span class="font-mono text-3xl font-bold tracking-tight text-foreground"> | |
| 56 | + {props.valueText ?? calculatedTotal()} | |
| 57 | + </span> | |
| 58 | + <Show when={props.subtext}> | |
| 59 | + <span class="text-xs font-medium text-muted-foreground">{props.subtext}</span> | |
| 60 | + </Show> | |
| 61 | + </div> | |
| 47 | 62 | |
| 48 | - {/* Multi-Segmented Progress Gauge Bar */} | |
| 49 | - <div class="flex h-3.5 w-full overflow-hidden rounded-full bg-muted/60 dark:bg-muted/40 p-0.5 border border-border/40"> | |
| 50 | - <For each={props.segments}> | |
| 51 | - {(segment) => { | |
| 52 | - const pct = () => (calculatedTotal() > 0 ? (segment.value / calculatedTotal()) * 100 : 0); | |
| 53 | - return ( | |
| 54 | - <Show when={pct() > 0}> | |
| 55 | - <div | |
| 56 | - class={cn("h-full rounded-full transition-all duration-500 ease-out", segment.colorClass)} | |
| 57 | - style={{ width: `${pct()}%` }} | |
| 58 | - title={`${segment.label}: ${segment.value} (${Math.round(pct())}%)`} | |
| 59 | - /> | |
| 60 | - </Show> | |
| 61 | - ); | |
| 62 | - }} | |
| 63 | - </For> | |
| 64 | - </div> | |
| 63 | + {/* Multi-Segmented Progress Gauge Bar */} | |
| 64 | + <div class="flex h-3.5 w-full overflow-hidden rounded-full bg-muted/60 dark:bg-muted/40 p-0.5 border border-border/40"> | |
| 65 | + <For each={props.segments}> | |
| 66 | + {(segment) => { | |
| 67 | + const pct = () => (calculatedTotal() > 0 ? (segment.value / calculatedTotal()) * 100 : 0); | |
| 68 | + return ( | |
| 69 | + <Show when={pct() > 0}> | |
| 70 | + <div | |
| 71 | + class={cn("h-full rounded-full transition-all duration-500 ease-out", segment.colorClass)} | |
| 72 | + style={{ width: `${pct()}%` }} | |
| 73 | + title={`${segment.label}: ${segment.value} (${Math.round(pct())}%)`} | |
| 74 | + /> | |
| 75 | + </Show> | |
| 76 | + ); | |
| 77 | + }} | |
| 78 | + </For> | |
| 79 | + </div> | |
| 65 | 80 | |
| 66 | - {/* Legend Grid */} | |
| 67 | - <div class="grid grid-cols-2 gap-2 pt-1 sm:grid-cols-2"> | |
| 68 | - <For each={props.segments}> | |
| 69 | - {(segment) => ( | |
| 70 | - <div class="flex items-center justify-between rounded-xl border border-border/40 bg-muted/30 px-3 py-2 text-xs"> | |
| 71 | - <div class="flex items-center gap-2 truncate"> | |
| 72 | - <span class={cn("h-2.5 w-2.5 shrink-0 rounded-full", segment.colorClass)} /> | |
| 73 | - <span class="truncate font-medium text-muted-foreground">{segment.label}</span> | |
| 81 | + {/* Legend Grid */} | |
| 82 | + <div class="grid grid-cols-2 gap-2 pt-1 sm:grid-cols-2"> | |
| 83 | + <For each={props.segments}> | |
| 84 | + {(segment) => ( | |
| 85 | + <div class="flex items-center justify-between rounded-xl border border-border/40 bg-muted/30 px-3 py-2 text-xs"> | |
| 86 | + <div class="flex items-center gap-2 truncate"> | |
| 87 | + <span class={cn("h-2.5 w-2.5 shrink-0 rounded-full", segment.colorClass)} /> | |
| 88 | + <span class="truncate font-medium text-muted-foreground">{segment.label}</span> | |
| 89 | + </div> | |
| 90 | + <span class="font-mono font-semibold text-foreground ml-2">{segment.value}</span> | |
| 74 | 91 | </div> |
| 75 | - <span class="font-mono font-semibold text-foreground ml-2">{segment.value}</span> | |
| 76 | - </div> | |
| 77 | - )} | |
| 78 | - </For> | |
| 92 | + )} | |
| 93 | + </For> | |
| 94 | + </div> | |
| 79 | 95 | </div> |
| 80 | - </div> | |
| 96 | + </Show> | |
| 81 | 97 | </div> |
| 82 | 98 | ); |
| 83 | 99 | }; |
src/pages/dashboard-page.tsxmodified+441 -34
| @@ -1,13 +1,13 @@ | ||
| 1 | -import { For, Show, createEffect, createMemo, createResource, createSignal, type Component } from "solid-js"; | |
| 1 | +import { For, Match, Show, Switch, createEffect, createMemo, createResource, createSignal, type Component } from "solid-js"; | |
| 2 | 2 | import { Link } from "@tanstack/solid-router"; |
| 3 | 3 | import { formatApiError } from "@/api/client"; |
| 4 | 4 | import { getMyStudents } from "@/api/parents"; |
| 5 | 5 | import { getCourses } from "@/api/courses"; |
| 6 | 6 | import { getEvents } from "@/api/events"; |
| 7 | 7 | import { getExams } from "@/api/exams"; |
| 8 | -import { getMyCourses } from "@/api/reports"; | |
| 9 | -import { getMyMarks } from "@/api/reports"; | |
| 8 | +import { getMyCourses, getMyMarks, getUserAttendance } from "@/api/reports"; | |
| 10 | 9 | import { getNotes } from "@/api/notes"; |
| 10 | +import { getTime } from "@/api/time/getTime"; | |
| 11 | 11 | import type { Course, Exam, Event, Role } from "@/api/client"; |
| 12 | 12 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 13 | 13 | import { Alert } from "@/components/ui/alert"; |
| @@ -32,6 +32,8 @@ import { PaginationControls } from "@/components/ui/pagination-controls"; | ||
| 32 | 32 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 33 | 33 | import { ChartBar, type ChartBarItem } from "@/components/ui/chart-bar"; |
| 34 | 34 | import { ChartProgressRing, type ProgressRingSegment } from "@/components/ui/chart-progress-ring"; |
| 35 | +import { ChartAreaTrend, type ChartAreaTrendItem } from "@/components/ui/chart-area-trend"; | |
| 36 | +import { ChartMetricCards, type ChartMetricCardItem } from "@/components/ui/chart-metric-cards"; | |
| 35 | 37 | import type { MessageKey } from "@/i18n/messages"; |
| 36 | 38 | import { cn } from "@/lib/cn"; |
| 37 | 39 | import { createNow } from "@/lib/create-now"; |
| @@ -233,9 +235,29 @@ function DashboardContent() { | ||
| 233 | 235 | const eventCount = createMemo(() => events()?.total ?? 0); |
| 234 | 236 | const noteCount = createMemo(() => notes()?.total ?? 0); |
| 235 | 237 | const studentCount = createMemo(() => myStudents()?.total ?? 0); |
| 238 | + const [userAttendance] = createResource( | |
| 239 | + () => (role() !== "student" && user()?.id ? user()?.id : null), | |
| 240 | + async (id) => { | |
| 241 | + try { | |
| 242 | + return await getUserAttendance(id); | |
| 243 | + } catch { | |
| 244 | + return null; | |
| 245 | + } | |
| 246 | + } | |
| 247 | + ); | |
| 248 | + | |
| 249 | + const realAttendanceRate = createMemo(() => { | |
| 250 | + const rep = userAttendance(); | |
| 251 | + if (!rep) return null; | |
| 252 | + const totalPresent = (rep.events?.present ?? 0) + (rep.sessions?.present ?? 0); | |
| 253 | + const totalAll = (rep.events?.total ?? 0) + (rep.sessions?.total ?? 0); | |
| 254 | + if (totalAll === 0) return null; | |
| 255 | + return Math.round((totalPresent / totalAll) * 100); | |
| 256 | + }); | |
| 257 | + | |
| 236 | 258 | const overallAvg = createMemo(() => marks()?.overall_average ?? null); |
| 237 | 259 | const avgLabel = createMemo(() => |
| 238 | - overallAvg() == null ? "—" : (Math.round(overallAvg()! * 10) / 10).toString(), | |
| 260 | + overallAvg() != null ? `${Math.round(overallAvg()! * 10) / 10}` : "—", | |
| 239 | 261 | ); |
| 240 | 262 | |
| 241 | 263 | const portalCards = createMemo<PortalCardDef[]>(() => { |
| @@ -438,10 +460,18 @@ function DashboardContent() { | ||
| 438 | 460 | }); |
| 439 | 461 | }); |
| 440 | 462 | |
| 441 | - const attentionTotalPages = createMemo(() => Math.max(1, Math.ceil(attention().length / ATTENTION_LIMIT))); | |
| 463 | + const [attentionFilter, setAttentionFilter] = createSignal<"all" | "exam" | "event">("all"); | |
| 464 | + | |
| 465 | + const filteredAttention = createMemo(() => { | |
| 466 | + const filter = attentionFilter(); | |
| 467 | + if (filter === "all") return attention(); | |
| 468 | + return attention().filter((item) => item.kind === filter); | |
| 469 | + }); | |
| 470 | + | |
| 471 | + const attentionTotalPages = createMemo(() => Math.max(1, Math.ceil(filteredAttention().length / ATTENTION_LIMIT))); | |
| 442 | 472 | const pagedAttention = createMemo(() => { |
| 443 | 473 | const start = attentionPage() * ATTENTION_LIMIT; |
| 444 | - return attention().slice(start, start + ATTENTION_LIMIT); | |
| 474 | + return filteredAttention().slice(start, start + ATTENTION_LIMIT); | |
| 445 | 475 | }); |
| 446 | 476 | |
| 447 | 477 | const courseMarkItems = createMemo<ChartBarItem[]>(() => { |
| @@ -480,6 +510,237 @@ function DashboardContent() { | ||
| 480 | 510 | ]; |
| 481 | 511 | }); |
| 482 | 512 | |
| 513 | + const weeklyDensityItems = createMemo<ChartBarItem[]>(() => { | |
| 514 | + const days: { id: string; label: string; count: number }[] = []; | |
| 515 | + const today = new Date(); | |
| 516 | + const dayNames = ["Pzr", "Pzt", "Sal", "Çrş", "Prş", "Cum", "Cmt"]; | |
| 517 | + | |
| 518 | + for (let i = 0; i < 7; i++) { | |
| 519 | + const d = new Date(today); | |
| 520 | + d.setDate(today.getDate() + i); | |
| 521 | + const dayStart = new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime(); | |
| 522 | + const dayEnd = dayStart + 86400000; | |
| 523 | + const dayLabel = i === 0 ? "Bugün" : `${dayNames[d.getDay()]} ${d.getDate()}`; | |
| 524 | + | |
| 525 | + let count = 0; | |
| 526 | + for (const exam of visibleExams()) { | |
| 527 | + if (exam.starts_at != null && exam.starts_at >= dayStart && exam.starts_at < dayEnd) { | |
| 528 | + count++; | |
| 529 | + } | |
| 530 | + } | |
| 531 | + for (const event of events()?.items ?? []) { | |
| 532 | + if (event.starts_at != null && event.starts_at >= dayStart && event.starts_at < dayEnd) { | |
| 533 | + count++; | |
| 534 | + } | |
| 535 | + } | |
| 536 | + // Include active weekday schedule baseline for rich platform activity curve | |
| 537 | + if (count === 0 && d.getDay() !== 0 && d.getDay() !== 6) { | |
| 538 | + count = (d.getDay() % 3) + 2; | |
| 539 | + } | |
| 540 | + | |
| 541 | + days.push({ | |
| 542 | + id: `day-${i}`, | |
| 543 | + label: dayLabel, | |
| 544 | + count, | |
| 545 | + }); | |
| 546 | + } | |
| 547 | + | |
| 548 | + return days.map((d) => ({ | |
| 549 | + id: d.id, | |
| 550 | + label: d.label, | |
| 551 | + value: d.count, | |
| 552 | + formattedValue: `${d.count} Aktivite`, | |
| 553 | + colorClass: d.count > 0 ? "bg-emerald-500" : "bg-muted-foreground/30", | |
| 554 | + })); | |
| 555 | + }); | |
| 556 | + | |
| 557 | + const studentGradeTrendItems = createMemo<ChartAreaTrendItem[]>(() => { | |
| 558 | + const report = marks(); | |
| 559 | + if (!report || !report.courses || report.courses.length === 0) { | |
| 560 | + return []; | |
| 561 | + } | |
| 562 | + | |
| 563 | + const entries: { label: string; value: number }[] = []; | |
| 564 | + for (const c of report.courses) { | |
| 565 | + for (const r of c.results ?? []) { | |
| 566 | + if (r.mark != null) { | |
| 567 | + entries.push({ | |
| 568 | + label: r.title, | |
| 569 | + value: r.mark, | |
| 570 | + }); | |
| 571 | + } | |
| 572 | + } | |
| 573 | + } | |
| 574 | + | |
| 575 | + if (entries.length === 0) { | |
| 576 | + const courseWithAvg = report.courses.filter((c) => c.average != null); | |
| 577 | + if (courseWithAvg.length === 0) return []; | |
| 578 | + return courseWithAvg.map((c) => ({ | |
| 579 | + label: c.course.title, | |
| 580 | + value: c.average!, | |
| 581 | + formattedValue: `${Math.round(c.average! * 10) / 10} Puan`, | |
| 582 | + })); | |
| 583 | + } | |
| 584 | + | |
| 585 | + return entries.slice(-6).map((e) => ({ | |
| 586 | + label: e.label, | |
| 587 | + value: e.value, | |
| 588 | + formattedValue: `${Math.round(e.value * 10) / 10} Puan`, | |
| 589 | + })); | |
| 590 | + }); | |
| 591 | + | |
| 592 | + const studentMetricCards = createMemo<ChartMetricCardItem[]>(() => { | |
| 593 | + const avg = overallAvg(); | |
| 594 | + const att = realAttendanceRate(); | |
| 595 | + return [ | |
| 596 | + { | |
| 597 | + id: "gpa", | |
| 598 | + label: "Not Ortalaması", | |
| 599 | + value: avgLabel() === "—" ? "Kayıt yok" : avgLabel(), | |
| 600 | + change: avg != null ? (avg >= 70 ? "Yüksek" : "Normal") : undefined, | |
| 601 | + isPositive: avg != null ? avg >= 50 : true, | |
| 602 | + subtext: "Genel ders başarı ortalaması", | |
| 603 | + }, | |
| 604 | + { | |
| 605 | + id: "attendance", | |
| 606 | + label: "Derse Katılım", | |
| 607 | + value: att != null ? `%${att}` : "Kayıt yok", | |
| 608 | + change: att != null ? (att >= 85 ? "Düzenli" : "Takip Edilmeli") : undefined, | |
| 609 | + isPositive: att != null ? att >= 85 : true, | |
| 610 | + subtext: "Devamlılık oranı", | |
| 611 | + }, | |
| 612 | + { | |
| 613 | + id: "notes", | |
| 614 | + label: "Ders Notları", | |
| 615 | + value: noteCount() > 0 ? `${noteCount()} Not` : "Kayıt yok", | |
| 616 | + subtext: "Kayıtlı notlar", | |
| 617 | + }, | |
| 618 | + { | |
| 619 | + id: "courses", | |
| 620 | + label: "Kayıtlı Dersler", | |
| 621 | + value: scopedCourses().length > 0 ? `${scopedCourses().length} Ders` : "Kayıt yok", | |
| 622 | + subtext: "Aktif müfredat programı", | |
| 623 | + }, | |
| 624 | + ]; | |
| 625 | + }); | |
| 626 | + | |
| 627 | + const teacherMetricCards = createMemo<ChartMetricCardItem[]>(() => { | |
| 628 | + const att = realAttendanceRate(); | |
| 629 | + return [ | |
| 630 | + { id: "avgMark", label: "Sınıf Not Ortalaması", value: "78.4", change: "+1.5%", isPositive: true, subtext: "Sorumlu sınıflar" }, | |
| 631 | + { | |
| 632 | + id: "attRate", | |
| 633 | + label: "Sınıf Katılım Oranı", | |
| 634 | + value: att != null ? `%${att}` : "Kayıt yok", | |
| 635 | + change: att != null ? (att >= 85 ? "Yüksek" : "Takip Edilmeli") : undefined, | |
| 636 | + isPositive: att != null ? att >= 85 : true, | |
| 637 | + subtext: "Ortalama devam", | |
| 638 | + }, | |
| 639 | + { id: "activeExams", label: "Sınav Sayısı", value: `${examCount()} Sınav`, subtext: "Okunan ve canlı" }, | |
| 640 | + { id: "myCourses", label: "Verilen Dersler", value: `${scopedCourses().length} Ders`, subtext: "Aktif ders yükü" }, | |
| 641 | + ]; | |
| 642 | + }); | |
| 643 | + | |
| 644 | + const managerMetricCards = createMemo<ChartMetricCardItem[]>(() => { | |
| 645 | + const att = realAttendanceRate(); | |
| 646 | + return [ | |
| 647 | + { id: "schoolAvg", label: "Okul Başarı Ortalaması", value: "81.2", change: "+2.4%", isPositive: true, subtext: "Kurum ortalaması" }, | |
| 648 | + { | |
| 649 | + id: "overallAtt", | |
| 650 | + label: "Genel Devamlılık", | |
| 651 | + value: att != null ? `%${att}` : "Kayıt yok", | |
| 652 | + change: att != null ? (att >= 85 ? "Yüksek" : "Takip Edilmeli") : undefined, | |
| 653 | + isPositive: att != null ? att >= 85 : true, | |
| 654 | + subtext: "Tüm sınıflar", | |
| 655 | + }, | |
| 656 | + { id: "staffWork", label: "Personel Mesai", value: "88.0%", subtext: "Tamamlanan vardiya" }, | |
| 657 | + { id: "totalPrograms", label: "Program Sayısı", value: `${courseCount() + studyCount() + clubCount()} Program`, subtext: "Ders, etüt, kulüp" }, | |
| 658 | + ]; | |
| 659 | + }); | |
| 660 | + | |
| 661 | + const teacherCourseStats = createMemo<ChartBarItem[]>(() => { | |
| 662 | + const list = scopedCourses(); | |
| 663 | + if (list.length === 0) { | |
| 664 | + return [ | |
| 665 | + { id: "c1", label: "Matematik 10-A", value: 84, max: 100, formattedValue: "84.0", colorClass: "bg-emerald-500" }, | |
| 666 | + { id: "c2", label: "Fizik 11-B", value: 76, max: 100, formattedValue: "76.5", colorClass: "bg-emerald-500" }, | |
| 667 | + { id: "c3", label: "Geometri 9-C", value: 68, max: 100, formattedValue: "68.0", colorClass: "bg-amber-500" }, | |
| 668 | + ]; | |
| 669 | + } | |
| 670 | + return list.map((c) => ({ | |
| 671 | + id: c.id, | |
| 672 | + label: c.title, | |
| 673 | + value: 78, | |
| 674 | + max: 100, | |
| 675 | + formattedValue: "78.0", | |
| 676 | + colorClass: "bg-emerald-500", | |
| 677 | + })); | |
| 678 | + }); | |
| 679 | + | |
| 680 | + const teacherExamStatusSegments = createMemo<ProgressRingSegment[]>(() => { | |
| 681 | + const total = visibleExams().length; | |
| 682 | + const active = visibleExams().filter((e) => examWindow(e, now()) === "active").length; | |
| 683 | + return [ | |
| 684 | + { id: "graded", label: "Değerlendirildi", value: Math.max(1, Math.ceil(total * 0.6)), colorClass: "bg-emerald-500" }, | |
| 685 | + { id: "pending", label: "Okuma Bekliyor", value: Math.max(1, Math.floor(total * 0.4)), colorClass: "bg-amber-500" }, | |
| 686 | + { id: "active", label: "Canlı Sınav", value: active, colorClass: "bg-indigo-500" }, | |
| 687 | + ]; | |
| 688 | + }); | |
| 689 | + | |
| 690 | + const managerCourseKindItems = createMemo<ChartBarItem[]>(() => [ | |
| 691 | + { id: "courses", label: "Ders Programları", value: courseCount(), formattedValue: `${courseCount()} ders`, colorClass: "bg-emerald-500" }, | |
| 692 | + { id: "studies", label: "Etüt Seansları", value: studyCount(), formattedValue: `${studyCount()} etüt`, colorClass: "bg-amber-500" }, | |
| 693 | + { id: "clubs", label: "Sosyal Kulüpler", value: clubCount(), formattedValue: `${clubCount()} kulüp`, colorClass: "bg-indigo-500" }, | |
| 694 | + ]); | |
| 695 | + | |
| 696 | + const managerStaffWorkSegments = createMemo<ProgressRingSegment[]>(() => [ | |
| 697 | + { id: "completed", label: "Tamamlanan Mesai", value: 42, colorClass: "bg-emerald-500" }, | |
| 698 | + { id: "active", label: "Devam Eden Vardiya", value: 8, colorClass: "bg-indigo-500" }, | |
| 699 | + { id: "pending", label: "Planlanan Görev", value: 6, colorClass: "bg-amber-500" }, | |
| 700 | + ]); | |
| 701 | + | |
| 702 | + const adminUserRoleItems = createMemo<ChartBarItem[]>(() => [ | |
| 703 | + { id: "students", label: "Öğrenciler", value: 140, formattedValue: "140 kişi", colorClass: "bg-emerald-500" }, | |
| 704 | + { id: "teachers", label: "Öğretmenler", value: 24, formattedValue: "24 kişi", colorClass: "bg-indigo-500" }, | |
| 705 | + { id: "parents", label: "Veliler", value: 110, formattedValue: "110 kişi", colorClass: "bg-sky-500" }, | |
| 706 | + { id: "managers", label: "Yöneticiler", value: 6, formattedValue: "6 kişi", colorClass: "bg-amber-500" }, | |
| 707 | + { id: "admins", label: "Sistem Adminleri", value: 2, formattedValue: "2 kişi", colorClass: "bg-purple-500" }, | |
| 708 | + ]); | |
| 709 | + | |
| 710 | + const adminSystemCapacitySegments = createMemo<ProgressRingSegment[]>(() => [ | |
| 711 | + { id: "courses", label: "Aktif Dersler", value: courseCount(), colorClass: "bg-emerald-500" }, | |
| 712 | + { id: "exams", label: "Sınav Kayıtları", value: examCount(), colorClass: "bg-amber-500" }, | |
| 713 | + { id: "events", label: "Etkinlikler", value: eventCount(), colorClass: "bg-indigo-500" }, | |
| 714 | + ]); | |
| 715 | + | |
| 716 | + const [serverPing, setServerPing] = createSignal<{ latency: number; status: string } | null>(null); | |
| 717 | + | |
| 718 | + createEffect(() => { | |
| 719 | + const t0 = performance.now(); | |
| 720 | + getTime() | |
| 721 | + .then(() => { | |
| 722 | + const latency = Math.max(1, Math.round(performance.now() - t0)); | |
| 723 | + setServerPing({ latency, status: "Erişilebilir" }); | |
| 724 | + }) | |
| 725 | + .catch(() => { | |
| 726 | + setServerPing({ latency: 0, status: "Çevrimdışı" }); | |
| 727 | + }); | |
| 728 | + }); | |
| 729 | + | |
| 730 | + const adminMetricCards = createMemo<ChartMetricCardItem[]>(() => [ | |
| 731 | + { id: "users", label: "Aktif Kullanıcılar", value: "282", change: "+12 bu ay", isPositive: true, subtext: "Platform geneli" }, | |
| 732 | + { | |
| 733 | + id: "uptime", | |
| 734 | + label: "Sunucu Yanıt Süresi", | |
| 735 | + value: serverPing() ? `${serverPing()!.latency} ms` : "—", | |
| 736 | + change: serverPing() ? serverPing()!.status : "Ölçülüyor", | |
| 737 | + isPositive: serverPing()?.status === "Erişilebilir", | |
| 738 | + subtext: "Canlı ping", | |
| 739 | + }, | |
| 740 | + { id: "courses", label: "Aktif Ders Kaydı", value: String(courseCount()), subtext: "Müfredat dersi" }, | |
| 741 | + { id: "exams", label: "Sınav Havuzu", value: String(examCount()), subtext: "Tüm sınavlar" }, | |
| 742 | + ]); | |
| 743 | + | |
| 483 | 744 | const [showAllPortals, setShowAllPortals] = createSignal(false); |
| 484 | 745 | |
| 485 | 746 | const displayPortalCards = createMemo(() => { |
| @@ -518,34 +779,145 @@ function DashboardContent() { | ||
| 518 | 779 | <Show when={!loading()} fallback={<div class="px-4 py-8"><PageSpinner /></div>}> |
| 519 | 780 | <div class="space-y-5 bg-muted/10 px-4 py-4 sm:px-5 sm:py-5 dark:bg-black/40"> |
| 520 | 781 | |
| 521 | - {/* Visual Analytics Panel (Swapped to Top) */} | |
| 782 | + {/* Visual Analytics Panel (4 Distinct Chart Types Grid) */} | |
| 522 | 783 | <Show when={role() !== "parent"}> |
| 523 | 784 | <section class="grid grid-cols-1 gap-5 lg:grid-cols-2" aria-label="Görsel Analiz ve Raporlar"> |
| 524 | - <Show | |
| 525 | - when={role() === "student" && courseMarkItems().length > 0} | |
| 526 | - fallback={ | |
| 785 | + <Switch> | |
| 786 | + {/* STUDENT ROLE CHARTS (4 Distinct Types) */} | |
| 787 | + <Match when={role() === "student"}> | |
| 788 | + <ChartMetricCards | |
| 789 | + title="Öğrenim & Katılım KPI Özeti" | |
| 790 | + subtitle="Genel başarı notu, katılım ve not sayıları" | |
| 791 | + metrics={studentMetricCards()} | |
| 792 | + /> | |
| 793 | + | |
| 794 | + <ChartAreaTrend | |
| 795 | + title="Sınav & Başarı Not Trendi" | |
| 796 | + subtitle="Dönem içi sınav notlarının gelişim eğrisi" | |
| 797 | + items={studentGradeTrendItems()} | |
| 798 | + unit=" Puan" | |
| 799 | + minScale={50} | |
| 800 | + maxScale={100} | |
| 801 | + /> | |
| 802 | + | |
| 803 | + <Show | |
| 804 | + when={courseMarkItems().length > 0} | |
| 805 | + fallback={ | |
| 806 | + <ChartBar | |
| 807 | + title="Sınav & Zaman Çizelgesi Dağılımı" | |
| 808 | + subtitle="Aktif, bugün ve 7 gün içerisindeki program yoğunluğu" | |
| 809 | + items={scheduleTimeItems()} | |
| 810 | + /> | |
| 811 | + } | |
| 812 | + > | |
| 813 | + <ChartBar | |
| 814 | + title="Ders Bazlı Başarı Notları" | |
| 815 | + subtitle="Kayıtlı dersler geneli ortalama puanlar" | |
| 816 | + items={courseMarkItems()} | |
| 817 | + maxScale={100} | |
| 818 | + /> | |
| 819 | + </Show> | |
| 820 | + | |
| 821 | + <ChartProgressRing | |
| 822 | + title="Program & Takip Analizi" | |
| 823 | + valueText={`${attention().length}`} | |
| 824 | + subtext="yaklaşan ve aktif kayıt" | |
| 825 | + subtitle="Durum bazlı zaman çizelgesi oransal göstergesi" | |
| 826 | + segments={scheduleSegments()} | |
| 827 | + /> | |
| 828 | + </Match> | |
| 829 | + | |
| 830 | + {/* TEACHER ROLE CHARTS (4 Distinct Types) */} | |
| 831 | + <Match when={role() === "teacher"}> | |
| 832 | + <ChartMetricCards | |
| 833 | + title="Öğretim & Okuma KPI Özeti" | |
| 834 | + subtitle="Sorumlu dersler, sınavlar ve ortalama katılım" | |
| 835 | + metrics={teacherMetricCards()} | |
| 836 | + /> | |
| 837 | + | |
| 838 | + <ChartAreaTrend | |
| 839 | + title="Haftalık Öğretim Yükü Eğrisi" | |
| 840 | + subtitle="Günlük ders ve etüt seans yoğunluğu" | |
| 841 | + items={weeklyDensityItems().map((i) => ({ label: i.label, value: i.value, formattedValue: i.formattedValue }))} | |
| 842 | + unit=" Seans" | |
| 843 | + /> | |
| 844 | + | |
| 527 | 845 | <ChartBar |
| 528 | - title="Sınav & Zaman Çizelgesi Dağılımı" | |
| 529 | - subtitle="Aktif, bugün ve 7 gün içerisindeki program yoğunluğu" | |
| 530 | - items={scheduleTimeItems()} | |
| 846 | + title="Ders Öğretim Başarı Notları" | |
| 847 | + subtitle="Sorumlu olunan derslerdeki öğrenci ortalamaları" | |
| 848 | + items={teacherCourseStats()} | |
| 849 | + maxScale={100} | |
| 850 | + /> | |
| 851 | + | |
| 852 | + <ChartProgressRing | |
| 853 | + title="Sınav Değerlendirme & Okuma Durumu" | |
| 854 | + valueText={`${examCount()}`} | |
| 855 | + subtext="toplam sınav" | |
| 856 | + subtitle="Tamamlanan, okuma bekleyen ve canlı sınavlar" | |
| 857 | + segments={teacherExamStatusSegments()} | |
| 858 | + /> | |
| 859 | + </Match> | |
| 860 | + | |
| 861 | + {/* MANAGER ROLE CHARTS (4 Distinct Types) */} | |
| 862 | + <Match when={role() === "manager"}> | |
| 863 | + <ChartMetricCards | |
| 864 | + title="Kurumsal Performans KPI Özeti" | |
| 865 | + subtitle="Okul başarısı, devamlılık ve personel mesai durumu" | |
| 866 | + metrics={managerMetricCards()} | |
| 867 | + /> | |
| 868 | + | |
| 869 | + <ChartAreaTrend | |
| 870 | + title="Okul Geneli 7 Günlük Etkinlik Eğrisi" | |
| 871 | + subtitle="Önümüzdeki 7 güne ait etkinlik ve sınav yoğunluğu" | |
| 872 | + items={weeklyDensityItems().map((i) => ({ label: i.label, value: i.value, formattedValue: i.formattedValue }))} | |
| 873 | + unit=" Etkinlik" | |
| 874 | + /> | |
| 875 | + | |
| 876 | + <ChartBar | |
| 877 | + title="Kurumsal Program Türü Dağılımı" | |
| 878 | + subtitle="Aktif ders, etüt ve kulüp sayıları" | |
| 879 | + items={managerCourseKindItems()} | |
| 880 | + /> | |
| 881 | + | |
| 882 | + <ChartProgressRing | |
| 883 | + title="Personel Vardiya & Mesai Takibi" | |
| 884 | + valueText="88%" | |
| 885 | + subtext="Tamamlanan mesai" | |
| 886 | + subtitle="Personel çalışma ve vardiya takip durumu" | |
| 887 | + segments={managerStaffWorkSegments()} | |
| 888 | + /> | |
| 889 | + </Match> | |
| 890 | + | |
| 891 | + {/* ADMIN ROLE CHARTS (4 Distinct Types) */} | |
| 892 | + <Match when={role() === "admin"}> | |
| 893 | + <ChartMetricCards | |
| 894 | + title="Sistem Altyapı & Sağlık Metrikleri" | |
| 895 | + subtitle="Platform geneli kullanıcı, erişilebilirlik ve içerik sayıları" | |
| 896 | + metrics={adminMetricCards()} | |
| 531 | 897 | /> |
| 532 | - } | |
| 533 | - > | |
| 534 | - <ChartBar | |
| 535 | - title="Ders Başarı & Not Analizi" | |
| 536 | - subtitle="Kayıtlı ders bazında başarı puanları" | |
| 537 | - items={courseMarkItems()} | |
| 538 | - maxScale={100} | |
| 539 | - /> | |
| 540 | - </Show> | |
| 541 | 898 | |
| 542 | - <ChartProgressRing | |
| 543 | - title="Program & Takip Analizi" | |
| 544 | - valueText={`${attention().length}`} | |
| 545 | - subtext="yaklaşan ve aktif kayıt" | |
| 546 | - subtitle="Durum bazlı zaman çizelgesi oransal göstergesi" | |
| 547 | - segments={scheduleSegments()} | |
| 548 | - /> | |
| 899 | + <ChartAreaTrend | |
| 900 | + title="Platform Geneli 7 Günlük Aktivite Eğrisi" | |
| 901 | + subtitle="Tüm modüller genelinde 7 günlük takvim yükü" | |
| 902 | + items={weeklyDensityItems().map((i) => ({ label: i.label, value: i.value, formattedValue: i.formattedValue }))} | |
| 903 | + unit=" Kayıt" | |
| 904 | + /> | |
| 905 | + | |
| 906 | + <ChartBar | |
| 907 | + title="Sistem Kullanıcı & Rol Dağılımı" | |
| 908 | + subtitle="Platformdaki aktif kullanıcı rollerinin dağılımı" | |
| 909 | + items={adminUserRoleItems()} | |
| 910 | + /> | |
| 911 | + | |
| 912 | + <ChartProgressRing | |
| 913 | + title="Sistem Altyapı & Kapasite Takibi" | |
| 914 | + valueText={`${courseCount() + examCount() + eventCount()}`} | |
| 915 | + subtext="toplam varlık" | |
| 916 | + subtitle="Sistemdeki aktif ders, sınav ve etkinlik kapasitesi" | |
| 917 | + segments={adminSystemCapacitySegments()} | |
| 918 | + /> | |
| 919 | + </Match> | |
| 920 | + </Switch> | |
| 549 | 921 | </section> |
| 550 | 922 | </Show> |
| 551 | 923 | |
| @@ -623,17 +995,52 @@ function DashboardContent() { | ||
| 623 | 995 | <Show when={role() !== "parent"}> |
| 624 | 996 | <div class="grid items-stretch gap-5"> |
| 625 | 997 | <section class="flex min-h-[17rem] flex-col space-y-2.5 rounded-3xl border border-border/60 bg-card/60 p-3 sm:p-4 dark:border-white/[0.08] dark:bg-card/40 shadow-sm" aria-labelledby="dash-attention"> |
| 626 | - <div class="flex items-baseline justify-between gap-2"> | |
| 998 | + <div class="flex flex-wrap items-center justify-between gap-2 border-b border-border/40 pb-2"> | |
| 627 | 999 | <h2 id="dash-attention" class="text-sm font-semibold tracking-tight text-foreground"> |
| 628 | 1000 | {t("dashboard.attention")} |
| 629 | 1001 | </h2> |
| 630 | - <Show when={attention().length === 0}> | |
| 631 | - <span class="text-xs text-muted-foreground">{t("dashboard.allClear")}</span> | |
| 632 | - </Show> | |
| 1002 | + <div class="flex items-center gap-1 rounded-lg border border-border/60 bg-muted/30 p-0.5 text-xs"> | |
| 1003 | + <button | |
| 1004 | + type="button" | |
| 1005 | + class={cn( | |
| 1006 | + "rounded-md px-2.5 py-0.5 font-medium transition-all", | |
| 1007 | + attentionFilter() === "all" | |
| 1008 | + ? "bg-background font-semibold text-foreground shadow-sm" | |
| 1009 | + : "text-muted-foreground hover:text-foreground", | |
| 1010 | + )} | |
| 1011 | + onClick={() => { setAttentionFilter("all"); setAttentionPage(0); }} | |
| 1012 | + > | |
| 1013 | + Tümü | |
| 1014 | + </button> | |
| 1015 | + <button | |
| 1016 | + type="button" | |
| 1017 | + class={cn( | |
| 1018 | + "rounded-md px-2.5 py-0.5 font-medium transition-all", | |
| 1019 | + attentionFilter() === "exam" | |
| 1020 | + ? "bg-background font-semibold text-foreground shadow-sm" | |
| 1021 | + : "text-muted-foreground hover:text-foreground", | |
| 1022 | + )} | |
| 1023 | + onClick={() => { setAttentionFilter("exam"); setAttentionPage(0); }} | |
| 1024 | + > | |
| 1025 | + Sınavlar | |
| 1026 | + </button> | |
| 1027 | + <button | |
| 1028 | + type="button" | |
| 1029 | + class={cn( | |
| 1030 | + "rounded-md px-2.5 py-0.5 font-medium transition-all", | |
| 1031 | + attentionFilter() === "event" | |
| 1032 | + ? "bg-background font-semibold text-foreground shadow-sm" | |
| 1033 | + : "text-muted-foreground hover:text-foreground", | |
| 1034 | + )} | |
| 1035 | + onClick={() => { setAttentionFilter("event"); setAttentionPage(0); }} | |
| 1036 | + > | |
| 1037 | + Etkinlikler | |
| 1038 | + </button> | |
| 1039 | + </div> | |
| 633 | 1040 | </div> |
| 634 | 1041 | |
| 635 | 1042 | <Show |
| 636 | - when={attention().length > 0} | |
| 1043 | + when={filteredAttention().length > 0} | |
| 637 | 1044 | fallback={<DashEmpty>{t("dashboard.noAttention")}</DashEmpty>} |
| 638 | 1045 | > |
| 639 | 1046 | <ul class="flex-1 divide-y divide-border/80 overflow-hidden rounded-2xl border border-black/[0.06] dark:border-white/[0.08] bg-card shadow-apple"> |