sls/resources/views/interview/candidate_room.blade.php
kushal.saha 71b5c30113 fix: add candidate joining status, reverse video,
refactor the candiate_room to have js bundled
2026-08-12 10:56:49 +00:00

431 lines
24 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>Live Assessment Room - {{ $interview->candidate_name }} | SingleLogin</title>
@vite(['resources/css/app.css', 'resources/js/app.js'])
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Instrument+Sans:wght@400;500;600;700&family=Outfit:wght@500;600;700&display=swap" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css">
<!-- PeerJS, Metered SDK, SweetAlert2 & html2canvas -->
<script src="https://unpkg.com/peerjs@1.5.2/dist/peerjs.min.js"></script>
<script src="//cdn.metered.ca/sdk/video/1.4.6/sdk.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
<!-- Monaco Code Editor Loader (loaded after UMD libraries to prevent define.amd conflicts) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.45.0/min/vs/loader.min.js"></script>
<style>
:root {
--bg-color: #080c14;
--card-bg: #0f172a;
--card-border: rgba(255, 255, 255, 0.15);
--accent-primary: #6366f1;
}
/* Modern Custom Scrollbars */
html, body, *, ::-webkit-scrollbar {
scrollbar-width: thin;
scrollbar-color: rgba(255, 255, 255, 0.4) rgba(15, 23, 42, 0.35);
}
::-webkit-scrollbar {
width: 5px;
height: 5px;
}
::-webkit-scrollbar-track {
background: rgba(15, 23, 42, 0.35);
}
::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.4);
border-radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Instrument Sans', sans-serif;
background-color: var(--bg-color);
color: white;
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
}
.ide-header {
height: 60px;
background: #0d1322;
border-bottom: 1px solid var(--card-border);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
}
.ide-layout {
display: grid;
grid-template-columns: 1fr 340px;
height: calc(100vh - 60px);
width: 100%;
}
.editor-section {
display: flex;
flex-direction: column;
border-right: 1px solid var(--card-border);
height: 100%;
}
#monaco-editor-container {
flex: 1;
width: 100%;
height: 100%;
}
.terminal-section {
height: 220px;
background: #050811;
border-top: 1px solid var(--card-border);
display: flex;
flex-direction: column;
}
.terminal-header {
height: 36px;
background: #090e1a;
border-bottom: 1px solid rgba(255,255,255,0.08);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 16px;
font-size: 0.75rem;
color: #94a3b8;
font-weight: 600;
}
#terminal-output {
flex: 1;
padding: 12px 16px;
font-family: 'Fira Code', monospace;
font-size: 0.8rem;
color: #34d399;
overflow-y: auto;
white-space: pre-wrap;
}
.proctor-sidebar {
background: #0d1322;
padding: 16px;
display: flex;
flex-direction: column;
gap: 16px;
overflow-y: auto;
}
.webcam-box {
width: 100%;
height: 180px;
min-height: 180px;
flex-shrink: 0;
background: #000;
border-radius: 12px;
border: 2px solid var(--card-border);
overflow: hidden;
position: relative;
}
#webcam {
width: 100%;
height: 100%;
object-fit: cover;
}
.btn-ide {
padding: 8px 16px;
border-radius: 8px;
font-weight: 600;
font-size: 0.8rem;
cursor: pointer;
border: 1px solid var(--card-border);
background: rgba(255,255,255,0.05);
color: white;
transition: all 0.2s ease;
}
.btn-ide-primary {
background: #10b981;
border-color: #10b981;
color: white;
}
.btn-ide-run {
background: #6366f1;
border-color: #6366f1;
color: white;
}
/* Warning Popup Overlay */
#warning-banner {
position: fixed;
top: 70px;
left: 50%;
transform: translateX(-50%);
background: rgba(239, 68, 68, 0.95);
color: white;
padding: 12px 24px;
border-radius: 12px;
font-weight: 700;
font-size: 0.9rem;
box-shadow: 0 10px 30px rgba(239, 68, 68, 0.5);
z-index: 9999;
display: none;
backdrop-filter: blur(10px);
}
</style>
</head>
<body data-interview-id="{{ $interview->id }}" data-candidate-name="{{ addslashes($interview->candidate_name) }}" data-candidate-email="{{ $interview->candidate_email }}" data-submission-id="{{ $interview->submission_unique_id }}" data-language="{{ strtolower($interview->language) }}" data-call-status="{{ $interview->call_status ?? 'idle' }}" data-login-url="{{ route('interview.candidate.login') }}">
<script id="candidate-submitted-code" type="application/json">@json($interview->submitted_code)</script>
<script id="candidate-drawing-data" type="application/json">@json($interview->candidate_drawing)</script>
<!-- IDE Header Bar -->
<header class="ide-header">
<div style="display: flex; align-items: center; gap: 12px;">
<div style="font-weight: 700; font-family: 'Outfit', sans-serif; font-size: 1.05rem; color: white;">
Candidate Assessment Room
</div>
<code style="background: rgba(255,255,255,0.06); padding: 4px 10px; border-radius: 6px; color: #38bdf8; font-size: 0.75rem;">
ID: {{ $interview->submission_unique_id }}
</code>
</div>
<div style="display: flex; align-items: center; gap: 14px;">
<button onclick="toggleNotepadModal()" class="btn-ide" style="background: rgba(99,102,241,0.2); border-color: #6366f1;">
📝 Open Notepad
</button>
<button onclick="toggleDrawingModal()" class="btn-ide" style="background: rgba(6,182,212,0.2); border-color: #06b6d4;">
🎨 Open Drawing
</button>
<div style="display: flex; align-items: center; gap: 8px;">
<label style="font-size: 0.75rem; color: #94a3b8; font-weight: 500;">Language:</label>
<select id="language-select" class="btn-ide" style="background: #151b2c;">
<option value="python" {{ strtolower($interview->language) === 'python' ? 'selected' : '' }}>Python 3</option>
<option value="cpp" {{ strtolower($interview->language) === 'cpp' ? 'selected' : '' }}>C++ (GCC)</option>
<option value="c" {{ strtolower($interview->language) === 'c' ? 'selected' : '' }}>C (GCC)</option>
<option value="java" {{ strtolower($interview->language) === 'java' ? 'selected' : '' }}>Java 15</option>
<option value="php" {{ strtolower($interview->language) === 'php' ? 'selected' : '' }}>PHP 8.2 / Laravel</option>
<option value="javascript" {{ strtolower($interview->language) === 'javascript' ? 'selected' : '' }}>JavaScript (Node.js)</option>
</select>
</div>
<button onclick="runCode()" class="btn-ide btn-ide-run">
Run Code
</button>
<button onclick="submitSolution()" class="btn-ide btn-ide-primary">
Submit Final Solution
</button>
<button onclick="candidateLogoutAction()" class="btn-ide" style="background: rgba(239,68,68,0.2); border-color: #ef4444; color: #fca5a5; font-weight: 700;">
🚪 Logout
</button>
</div>
</header>
<!-- Candidate Notepad Modal -->
<div id="notepad-modal" style="position: fixed; top: 70px; right: 360px; width: 420px; height: 350px; background: #0f172a; border: 1.5px solid #6366f1; border-radius: 16px; box-shadow: 0 20px 40px rgba(0,0,0,0.6); display: none; flex-direction: column; z-index: 1000; overflow: hidden;">
<div style="background: #1e293b; padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.1);">
<div style="font-weight: 700; font-size: 0.85rem; color: white;">📝 Candidate Notepad (Synced)</div>
<button onclick="toggleNotepadModal()" style="background: none; border: none; color: #94a3b8; font-size: 1.2rem; cursor: pointer;">&times;</button>
</div>
<textarea id="notepad-textarea" oninput="saveNotepadContent()" placeholder="Type rough notes, pseudo-code, or thoughts here..." style="flex: 1; width: 100%; padding: 14px; background: #0b0f19; color: #e2e8f0; border: none; outline: none; font-family: 'Fira Code', monospace; font-size: 0.85rem; resize: none;">{{ $interview->candidate_notes }}</textarea>
<div style="padding: 6px 12px; background: #0d1322; font-size: 0.65rem; color: #34d399; text-align: right;">
Auto-saved to interviewer portal
</div>
</div>
<!-- Candidate Canvas Drawing Modal -->
<div id="drawing-modal" style="position: fixed; top: 70px; right: 360px; width: 550px; height: 420px; background: #0f172a; border: 1.5px solid #06b6d4; border-radius: 16px; box-shadow: 0 20px 40px rgba(0,0,0,0.6); display: none; flex-direction: column; z-index: 1000; overflow: hidden;">
<div style="background: #1e293b; padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.1);">
<div style="font-weight: 700; font-size: 0.85rem; color: white;">🎨 Candidate Live Drawing Board</div>
<div style="display: flex; gap: 8px; align-items: center;">
<input type="color" id="draw-color" value="#38bdf8" style="width: 26px; height: 26px; border: none; border-radius: 50%; cursor: pointer;">
<button onclick="clearCanvasDraw()" class="btn-ide" style="padding: 2px 8px; font-size: 0.7rem;">Clear</button>
<button onclick="toggleDrawingModal()" style="background: none; border: none; color: #94a3b8; font-size: 1.2rem; cursor: pointer;">&times;</button>
</div>
</div>
<div style="flex: 1; background: #050811; position: relative;">
<canvas id="drawing-canvas" width="550" height="340" style="cursor: crosshair; display: block; width: 100%; height: 100%;"></canvas>
</div>
<div style="padding: 6px 12px; background: #0d1322; font-size: 0.65rem; color: #38bdf8; text-align: right;">
🎨 Draw architecture / logic diagrams (Auto-synced to Interviewer)
</div>
</div>
<!-- IDE Room Layout -->
<div class="ide-layout">
<!-- Main Editor & Terminal Area -->
<div class="editor-section">
<div id="monaco-editor-container"></div>
<div class="terminal-section">
<div class="terminal-header">
<span>EXECUTION OUTPUT TERMINAL (STDOUT / STDERR)</span>
<span id="run-status" style="color: #94a3b8;">Ready</span>
</div>
<div id="terminal-output">// Press 'Run Code' to execute candidate solution live...</div>
</div>
</div>
@php
$words = preg_split('/\s+/', trim($interview->candidate_name));
if (count($words) >= 2) {
$candInitials = strtoupper(substr($words[0], 0, 1) . substr(end($words), 0, 1));
} else {
$nameStr = trim($interview->candidate_name);
$candInitials = strtoupper(substr($nameStr, 0, 1) . (strlen($nameStr) > 1 ? substr($nameStr, -1) : ''));
}
@endphp
<!-- Sidebar: Real-Time 2-Way Interview Call & Screen Share -->
<div class="proctor-sidebar">
<!-- Candidate Camera Feed -->
<div class="webcam-box" style="position: relative;">
<video id="webcam" autoplay muted playsinline style="width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1);"></video>
<div id="webcam-avatar-placeholder" style="position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; background: #0f172a; color: white; z-index: 5;">
<div style="width: 60px; height: 60px; border-radius: 50%; background: linear-gradient(135deg, #6366f1 0%, #0078d4 100%); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 800; font-family: 'Outfit', sans-serif; box-shadow: 0 0 15px rgba(99,102,241,0.4);">
{{ $candInitials }}
</div>
<div style="font-size: 0.7rem; color: #94a3b8; margin-top: 6px;">Camera Disabled</div>
</div>
<div style="position: absolute; bottom: 8px; left: 8px; background: rgba(0,0,0,0.6); padding: 2px 8px; border-radius: 4px; font-size: 0.65rem; color: #34d399; font-weight: 600; z-index: 10; display: flex; align-items: center; gap: 6px;">
<span>Candidate (You)</span>
<span style="opacity: 0.4;">|</span>
<i id="cand-self-mic-icon" class="fa-solid fa-microphone" style="color: #34d399; font-size: 10px;" title="Mic On"></i>
<i id="cand-self-cam-icon" class="fa-solid fa-video" style="color: #34d399; font-size: 10px;" title="Camera On"></i>
</div>
</div>
<!-- Remote Interviewer Panelist Video Grid (Multi-Party WebRTC Mesh) -->
<div id="interviewer-mesh-grid" style="display: flex; flex-direction: column; gap: 10px; width: 100%;">
<div id="interviewer-placeholder-box" class="webcam-box" style="position: relative; border-color: #6366f1;">
<video id="interviewer-video-default" autoplay playsinline style="width: 100%; height: 100%; object-fit: cover; background: #050811; display: none; transform: scaleX(-1);"></video>
<div id="interviewer-video-placeholder" style="position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(15,23,42,0.95); color: #94a3b8; font-size: 0.75rem; text-align: center; padding: 10px; z-index: 5;">
<div id="interviewer-avatar-circle" style="width: 60px; height: 60px; border-radius: 50%; background: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 800; font-family: 'Outfit', sans-serif; color: white; margin-bottom: 6px; box-shadow: 0 0 15px rgba(56,189,248,0.4);">
IV
</div>
<div id="call-status-sub" style="font-size: 0.7rem; color: #e2e8f0; font-weight: 600;">Interviewer Panel</div>
<div style="font-size: 0.65rem; color: #38bdf8; margin-top: 2px;">Waiting for interviewer panelist to join call...</div>
</div>
<div style="position: absolute; bottom: 8px; left: 8px; background: rgba(99,102,241,0.8); padding: 2px 8px; border-radius: 4px; font-size: 0.65rem; color: white; font-weight: 600; z-index: 10;">
🎙️ Interviewer / Panelist
</div>
</div>
</div>
<canvas id="proctor-canvas" style="display: none;" width="320" height="240"></canvas>
<!-- Candidate Profile Info -->
<div style="background: rgba(255,255,255,0.03); border: 1px solid var(--card-border); border-radius: 12px; padding: 14px; font-size: 0.8rem;">
<div style="font-weight: 700; color: white; margin-bottom: 6px;">Candidate Profile</div>
<div style="color: #94a3b8;">Name: <strong style="color: white;">{{ $interview->candidate_name }}</strong></div>
<div style="color: #94a3b8;">Email: <span style="color: white;">{{ $interview->candidate_email }}</span></div>
<div style="color: #94a3b8; margin-top: 6px;">Access Expires: <span style="color: #fca5a5;">{{ $interview->expires_at->format('H:i:s T') }}</span></div>
</div>
<!-- Real-Time Call Controls (Mic, Camera, Screen Sharing) -->
<div style="background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.3); border-radius: 14px; padding: 14px;">
<div style="font-size: 0.8rem; font-weight: 700; color: white; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between;">
<span>📞 Real-Time Interview Call</span>
<span id="call-status-badge" style="font-size: 0.65rem; background: rgba(16,185,129,0.2); color: #34d399; padding: 2px 8px; border-radius: 999px;">READY</span>
</div>
<button id="candidate-join-active-call-btn" onclick="acceptCandidateCall()" class="btn-ide" style="display: none; width: 100%; padding: 10px; margin-bottom: 10px; font-size: 0.8rem; font-weight: 700; background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; border: none; box-shadow: 0 0 15px rgba(16,185,129,0.4); cursor: pointer; animation: acceptGlow 1.5s infinite alternate;">
🟢 📞 Call in Progress &bull; Join Call Now
</button>
<div style="display: flex; gap: 8px; margin-bottom: 10px;">
<button id="toggle-mic-btn" onclick="toggleMic()" class="btn-ide" style="flex: 1; padding: 8px; font-size: 0.75rem; background: rgba(16,185,129,0.2); border-color: #10b981;">
🎤 Mic On
</button>
<button id="toggle-cam-btn" onclick="toggleCam()" class="btn-ide" style="flex: 1; padding: 8px; font-size: 0.75rem; background: rgba(16,185,129,0.2); border-color: #10b981;">
📷 Cam On
</button>
<button id="leave-call-btn" onclick="candidateLeaveCall()" class="btn-ide" style="padding: 8px; font-size: 0.75rem; background: rgba(239,68,68,0.2); border-color: #ef4444; color: #fca5a5;" title="Leave 2-Way Call">
🚪 Leave Call
</button>
</div>
<button id="share-screen-btn" onclick="startScreenShare()" class="btn-ide btn-ide-run" style="width: 100%; padding: 10px; font-size: 0.8rem; background: linear-gradient(135deg, #6366f1 0%, #0078d4 100%);">
🖥️ Share Screen with Interviewer
</button>
</div>
<!-- 2-Way Real-Time Chat Container with Interviewer/Panelist -->
<div style="background: rgba(15,23,42,0.8); border: 1px solid var(--card-border); border-radius: 14px; padding: 12px; margin-top: 10px;">
<div style="font-size: 0.8rem; font-weight: 700; color: white; margin-bottom: 8px; display: flex; align-items: center; gap: 6px;">
💬 Live Chat with Interviewer
</div>
<div id="candidate-chat-history" style="background: #050811; border: 1px solid var(--card-border); border-radius: 10px; padding: 8px; height: 130px; overflow-y: auto; font-size: 0.72rem; margin-bottom: 8px;">
<div style="color: #94a3b8; font-style: italic; text-align: center; padding-top: 40px;">No messages yet. Send a message below.</div>
</div>
<div style="display: flex; gap: 6px;">
<input type="text" id="candidate-chat-input" placeholder="Type message to panelist..." onkeydown="if(event.key==='Enter') sendCandidateMessage()" class="form-input" style="font-size: 0.75rem; background: #0b0f19; color: #ffffff !important; border: 1px solid var(--card-border); padding: 6px 10px; flex: 1;">
<button onclick="sendCandidateMessage()" class="btn-ide" style="padding: 6px 10px; font-size: 0.75rem; background: #6366f1; border: none; font-weight: 600;">
Send
</button>
</div>
</div>
</div>
</div>
<!-- CANDIDATE INCOMING CALL MODAL / RINGING OVERLAY (DISABLED: Auto-connect enabled) -->
<div id="candidate-incoming-modal" style="display: none !important; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(5, 8, 17, 0.85); backdrop-filter: blur(16px); align-items: center; justify-content: center; z-index: 10000; opacity: 0; pointer-events: none; transition: opacity 0.3s ease;">
<div style="max-width: 440px; width: 90%; background: linear-gradient(145deg, #0f172a 0%, #1e1b4b 100%); border: 2px solid #10b981; border-radius: 24px; padding: 32px; text-align: center; color: white; box-shadow: 0 0 50px rgba(16, 185, 129, 0.6);">
<div style="position: relative; width: 90px; height: 90px; margin: 0 auto 20px auto; display: flex; align-items: center; justify-content: center;">
<div style="position: absolute; inset: -15px; border-radius: 50%; border: 2px solid rgba(16, 185, 129, 0.6); animation: ringPulse 1.4s infinite ease-out;"></div>
<div style="position: absolute; inset: -30px; border-radius: 50%; border: 2px solid rgba(99, 102, 241, 0.4); animation: ringPulse 1.4s infinite ease-out 0.4s;"></div>
<div style="width: 80px; height: 80px; border-radius: 50%; background: linear-gradient(135deg, #10b981 0%, #0078d4 100%); display: flex; align-items: center; justify-content: center; font-size: 2.4rem; font-weight: 800; color: white; box-shadow: 0 10px 25px rgba(16, 185, 129, 0.5); z-index: 5;">
📞
</div>
</div>
<div style="font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1.5px; color: #34d399; font-weight: 800; margin-bottom: 6px;">
INCOMING INTERVIEW CALL
</div>
<h3 style="font-family: 'Outfit', sans-serif; font-size: 1.4rem; font-weight: 800; color: white; margin-bottom: 4px;">
Interviewer Panel Calling...
</h3>
<div style="font-size: 0.8rem; color: #a5b4fc; margin-bottom: 20px;">
The interviewer panel has initiated a live 2-way call.
</div>
<div style="display: flex; gap: 12px; margin-top: 10px;">
<button onclick="declineCandidateCall()" style="flex: 1; padding: 14px; background: rgba(239, 68, 68, 0.2); border: 1.5px solid #ef4444; color: #fca5a5; font-weight: 700; font-size: 0.9rem; border-radius: 14px; cursor: pointer;">
🛑 Decline / Busy
</button>
<button onclick="acceptCandidateCall()" style="flex: 1.4; padding: 14px; background: linear-gradient(135deg, #10b981 0%, #059669 100%); border: none; color: white; font-weight: 800; font-size: 0.95rem; border-radius: 14px; box-shadow: 0 0 25px rgba(16, 185, 129, 0.6); cursor: pointer; animation: acceptGlow 1.5s infinite alternate;">
📞 Accept Call
</button>
</div>
</div>
</div>
</body>
</html>