sls/resources/views/components/audit-log-item.blade.php

56 lines
2.8 KiB
PHP

@props([
'type' => 'violation',
'details' => '',
'timestamp' => null,
'screenshotUrl' => null,
'aiVerdict' => null,
])
@php
$icoClass = 'amber';
$faIcon = 'fa-solid fa-window-restore';
$isFlag = false;
if ($type === 'focus_lost') {
$icoClass = 'amber'; $faIcon = 'fa-solid fa-window-restore';
} elseif (in_array($type, ['gaze_anomaly', 'gaze_fixed_staring'])) {
$icoClass = 'amber'; $faIcon = 'fa-solid fa-eye';
} elseif (in_array($type, ['gaze_lower_device', 'reading_external_device'])) {
$icoClass = 'red'; $faIcon = 'fa-solid fa-mobile-screen'; $isFlag = true;
} elseif (in_array($type, ['question_repeat_lower', 'question_repetition'])) {
$icoClass = 'red'; $faIcon = 'fa-solid fa-comments'; $isFlag = true;
} elseif ($type === 'talking_on_phone') {
$icoClass = 'red'; $faIcon = 'fa-solid fa-phone'; $isFlag = true;
} elseif ($type === 'external_ai_detected') {
$icoClass = 'red'; $faIcon = 'fa-solid fa-robot'; $isFlag = true;
} elseif ($type === 'tab_switch') {
$icoClass = 'amber'; $faIcon = 'fa-solid fa-window-restore';
}
$titleCap = ucfirst(str_replace('_', ' ', $type));
$timeStr = $timestamp ? \Carbon\Carbon::parse($timestamp)->format('H:i:s') : now()->format('H:i:s');
@endphp
<div {{ $attributes->merge(['class' => 'log-item flex gap-2.5 p-3 border-b border-[#1b2233] last:border-b-0 ' . ($isFlag ? 'bg-[rgba(239,74,95,0.1)] flag' : '')]) }}>
<div class="log-ico w-6 h-6 rounded-md flex-shrink-0 flex items-center justify-center text-[11px] mt-0.5 {{ $icoClass === 'amber' ? 'bg-[rgba(240,169,57,0.12)] text-[#f0a939]' : 'bg-[rgba(239,74,95,0.1)] text-[#ef4a5f]' }}">
<i class="{{ $faIcon }}"></i>
</div>
<div>
<div class="log-text text-xs leading-relaxed text-slate-300">
<b class="text-white {{ $isFlag ? '!text-[#ef4a5f]' : '' }}">{{ $titleCap }}</b> &mdash; {{ $details }}
@if($screenshotUrl)
<a href="{{ $screenshotUrl }}" target="_blank" class="text-sky-400 underline ml-1 font-medium">[<i class="fa-solid fa-camera mr-0.5"></i> Screenshot]</a>
@endif
@if($aiVerdict)
@php
$confPct = round(($aiVerdict['confidence'] ?? 0.85) * 100);
$engineName = $aiVerdict['engine'] ?? 'AI Engine';
$toolName = !empty($aiVerdict['ai_tool_detected']) ? ' &bull; Detected: <strong>' . e($aiVerdict['ai_tool_detected']) . '</strong>' : '';
@endphp
<div class="mt-1 text-[11px] text-red-300"><b>AI inspector &middot; {{ $confPct }}% cheating confidence</b> ({!! $engineName . $toolName !!})</div>
@endif
</div>
<div class="log-time text-[10.5px] text-slate-500 mt-0.5">{{ $timeStr }}</div>
</div>
</div>