Merge match-video: sports match sheet, in-player point capture, HEVC transcode fix

This commit is contained in:
ghassan 2026-08-08 05:33:36 +03:00
commit 057ce87564
10 changed files with 1424 additions and 492 deletions

View File

@ -99,31 +99,10 @@ class MatchEventController extends Controller
return response()->json(['success' => false, 'message' => 'Unauthorized'], 403); return response()->json(['success' => false, 'message' => 'Unauthorized'], 403);
} }
// Get ALL previous points in this round (ordered by timestamp) // Create the row first with placeholder scores, then recompute the whole
$previousPoints = MatchPoint::where('match_round_id', $request->round_id) // round's running scores. This is the only correct approach when two
->where('timestamp_seconds', '<', $request->timestamp_seconds) // points can share a timestamp (Blue + Red at the same moment) or when
->orderBy('timestamp_seconds', 'asc') // a point is inserted between existing ones.
->pluck('points', 'competitor')
->toArray();
// Calculate cumulative scores by summing each point value
$scoreBlue = 0;
$scoreRed = 0;
if (isset($previousPoints['blue'])) {
$scoreBlue += $previousPoints['blue'];
}
if (isset($previousPoints['red'])) {
$scoreRed += $previousPoints['red'];
}
// Add current point
if ($request->competitor === 'blue') {
$scoreBlue += $request->points;
} else {
$scoreRed += $request->points;
}
$point = MatchPoint::create([ $point = MatchPoint::create([
'video_id' => $video->id, 'video_id' => $video->id,
'match_round_id' => $request->round_id, 'match_round_id' => $request->round_id,
@ -132,17 +111,42 @@ class MatchEventController extends Controller
'points' => $request->points, 'points' => $request->points,
'competitor' => $request->competitor, 'competitor' => $request->competitor,
'notes' => $request->notes, 'notes' => $request->notes,
'score_blue' => $scoreBlue, 'score_blue' => 0,
'score_red' => $scoreRed, 'score_red' => 0,
]); ]);
$this->recomputeRoundScores($request->round_id);
return response()->json([ return response()->json([
'success' => true, 'success' => true,
'point' => $point, 'point' => $point->fresh(),
'message' => 'Point added successfully!', 'message' => 'Point added successfully!',
]); ]);
} }
/**
* Recompute cumulative score_blue/score_red for every point in a round,
* ordered by (timestamp_seconds, id). Handles same-timestamp ties by
* insertion order, so Blue and Red saved at the same moment both end up
* reflecting the running score after that moment.
*/
private function recomputeRoundScores(int $roundId): void
{
$blue = 0;
$red = 0;
MatchPoint::where('match_round_id', $roundId)
->orderBy('timestamp_seconds', 'asc')
->orderBy('id', 'asc')
->get()
->each(function (MatchPoint $p) use (&$blue, &$red) {
if ($p->competitor === 'blue') $blue += (int) $p->points;
else $red += (int) $p->points;
if ((int) $p->score_blue !== $blue || (int) $p->score_red !== $red) {
$p->update(['score_blue' => $blue, 'score_red' => $red]);
}
});
}
public function updatePoint(Request $request, MatchPoint $point) public function updatePoint(Request $request, MatchPoint $point)
{ {
$request->validate([ $request->validate([
@ -158,6 +162,7 @@ class MatchEventController extends Controller
return response()->json(['success' => false, 'message' => 'Unauthorized'], 403); return response()->json(['success' => false, 'message' => 'Unauthorized'], 403);
} }
$roundId = $point->match_round_id;
$point->update([ $point->update([
'timestamp_seconds' => $request->timestamp_seconds, 'timestamp_seconds' => $request->timestamp_seconds,
'action' => $request->action, 'action' => $request->action,
@ -166,9 +171,11 @@ class MatchEventController extends Controller
'notes' => $request->notes, 'notes' => $request->notes,
]); ]);
$this->recomputeRoundScores($roundId);
return response()->json([ return response()->json([
'success' => true, 'success' => true,
'point' => $point, 'point' => $point->fresh(),
'message' => 'Point updated successfully!', 'message' => 'Point updated successfully!',
]); ]);
} }
@ -180,7 +187,9 @@ class MatchEventController extends Controller
return response()->json(['success' => false, 'message' => 'Unauthorized'], 403); return response()->json(['success' => false, 'message' => 'Unauthorized'], 403);
} }
$roundId = $point->match_round_id;
$point->delete(); $point->delete();
$this->recomputeRoundScores($roundId);
return response()->json([ return response()->json([
'success' => true, 'success' => true,

View File

@ -479,8 +479,29 @@ class VideoController extends Controller
} }
if ($nasUploadSucceeded) { if ($nasUploadSucceeded) {
// For non-audio: HLS generation still runs (downloads from NAS, keeps HLS local) // For non-audio: HLS generation still runs (downloads from NAS, keeps HLS local).
// GenerateHlsJob no-ops unless status === 'ready', and on the NAS branch the
// upload IS the "done" state (there's no local CompressVideoJob to flip it).
if (! $isAudioUpload) { if (! $isAudioUpload) {
$duration = 0;
try {
$ffprobeBin = config('ffmpeg.ffprobe.binaries', '/usr/bin/ffprobe');
$localCopy = app(\App\Services\NasSyncService::class)->ensureLocalCopy($video->fresh());
if ($localCopy && file_exists($localCopy)) {
$out = [];
exec("{$ffprobeBin} -v error -show_entries format=duration -of csv=p=0 " . escapeshellarg($localCopy), $out);
$duration = (int) round((float) ($out[0] ?? 0));
}
} catch (\Throwable $e) {
\Log::warning('store: ffprobe duration failed: ' . $e->getMessage());
}
$video->update([
'status' => 'ready',
'duration' => $duration ?: $video->duration,
'is_shorts' => ($duration ?: $video->duration) <= 60 && $orientation === 'portrait',
]);
\App\Jobs\GenerateHlsJob::dispatch($video->fresh()) \App\Jobs\GenerateHlsJob::dispatch($video->fresh())
->onQueue('video-processing') ->onQueue('video-processing')
->onConnection('database'); ->onConnection('database');
@ -831,7 +852,7 @@ class VideoController extends Controller
'key' => $video->getRouteKey(), 'key' => $video->getRouteKey(),
'type' => $video->type, 'type' => $video->type,
'has_hls' => (bool) $video->has_hls, 'has_hls' => (bool) $video->has_hls,
'hls_url' => $video->has_hls ? route('videos.hls', ['video' => $video, 'file' => 'master.m3u8']) : null, 'hls_url' => $video->has_hls ? route('videos.hls', ['video' => $video, 'file' => 'playlist.m3u8']) : null,
'stream_url' => route('videos.stream', $video) . '?v=' . $video->updated_at->timestamp, 'stream_url' => route('videos.stream', $video) . '?v=' . $video->updated_at->timestamp,
// When a specific language track is requested (playlist row pin, // When a specific language track is requested (playlist row pin,
// shared link with ?track=), expose it separately. The player uses // shared link with ?track=), expose it separately. The player uses
@ -1112,6 +1133,9 @@ class VideoController extends Controller
'slides' => $slides, 'slides' => $slides,
'language' => $video->language, 'language' => $video->language,
'audio_tracks' => $audioTracks, 'audio_tracks' => $audioTracks,
'sports_match_id'=> $video->type === 'match'
? \App\Models\SportsMatch::where('video_id', $video->id)->value('id')
: null,
], ],
]); ]);
} }

View File

@ -4,8 +4,6 @@ namespace App\Jobs;
use App\Models\Setting; use App\Models\Setting;
use App\Models\Video; use App\Models\Video;
use FFMpeg\FFMpeg;
use FFMpeg\Format\Video\X264;
use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Config;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
@ -13,7 +11,6 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
class CompressVideoJob implements ShouldQueue class CompressVideoJob implements ShouldQueue
{ {
@ -30,7 +27,6 @@ class CompressVideoJob implements ShouldQueue
{ {
$video = $this->video; $video = $this->video;
// Get original file path
$originalPath = storage_path('app/' . $video->path); $originalPath = storage_path('app/' . $video->path);
if (!file_exists($originalPath)) { if (!file_exists($originalPath)) {
@ -38,98 +34,114 @@ class CompressVideoJob implements ShouldQueue
return; return;
} }
// Create compressed file alongside the original
$compressedFilename = 'compressed_' . $video->filename; $compressedFilename = 'compressed_' . $video->filename;
$compressedPath = dirname($originalPath) . '/' . $compressedFilename; $compressedPath = dirname($originalPath) . '/' . $compressedFilename;
try { try {
$ffmpegConfig = Config::get('ffmpeg'); $ffmpegConfig = Config::get('ffmpeg');
$ffmpeg = FFMpeg::create([ $ffmpegBin = $ffmpegConfig['ffmpeg'] ?? '/usr/bin/ffmpeg';
'ffmpeg.binaries' => $ffmpegConfig['ffmpeg'] ?? '/usr/bin/ffmpeg', $ffprobeBin = $ffmpegConfig['ffprobe'] ?? '/usr/bin/ffprobe';
'ffprobe.binaries' => $ffmpegConfig['ffprobe'] ?? '/usr/bin/ffprobe',
'timeout' => $ffmpegConfig['timeout'] ?? 3600, // Detect the source video codec. Browsers on Chrome/Firefox/Android can't
]); // decode HEVC (H.265/hev1/hvc1) — those sources must be replaced with H.264
$ffmpegVideo = $ffmpeg->open($originalPath); // even if the transcode is larger, so downloads and MP4 fallback stay playable.
$srcCodec = '';
try {
$probeOut = [];
exec(escapeshellcmd($ffprobeBin) . ' -v error -select_streams v:0 -show_entries stream=codec_name -of csv=p=0 ' . escapeshellarg($originalPath), $probeOut);
$srcCodec = strtolower(trim($probeOut[0] ?? ''));
} catch (\Throwable $e) {}
$forceReplace = in_array($srcCodec, ['hevc', 'h265', 'hev1', 'hvc1'], true);
// Verify the GPU is actually reachable and able to encode before sending
// the file to it; otherwise fall back to CPU so the job never hangs.
$gpuEnabled = Setting::gpuUsable(); $gpuEnabled = Setting::gpuUsable();
$encoder = Setting::gpuEncoder(); $encoder = Setting::gpuEncoder(); // h264_nvenc / libx264
$preset = Setting::gpuPreset(); $preset = Setting::gpuPreset(); // p1p7 for NVENC, fast/medium/slow for x264
$device = Setting::gpuDevice(); $device = Setting::gpuDevice();
$hwaccel = Setting::gpuHwaccel();
if ($gpuEnabled) { // Build ffmpeg command directly — php-ffmpeg's X264 format validator
$videoPasses = [ // only accepts 'libx264' and throws on 'h264_nvenc'.
"-c:v {$encoder}", $cmd = [escapeshellcmd($ffmpegBin), '-y'];
"-preset {$preset}",
'-rc vbr', if ($gpuEnabled && $hwaccel !== 'none') {
'-cq 23', $cmd[] = "-hwaccel {$hwaccel}";
'-profile:v high', $cmd[] = "-hwaccel_device {$device}";
'-pix_fmt yuv420p', }
"-gpu {$device}",
]; $cmd[] = '-i ' . escapeshellarg($originalPath);
$cmd[] = "-c:v {$encoder}";
if ($gpuEnabled && str_contains($encoder, 'nvenc')) {
$cmd[] = "-preset {$preset}";
$cmd[] = '-rc vbr';
$cmd[] = '-cq 23';
$cmd[] = "-gpu {$device}";
} else { } else {
$videoPasses = [ $cmd[] = "-preset {$preset}";
'-c:v libx264', $cmd[] = '-crf 23';
'-preset fast',
'-crf 23',
'-profile:v high',
'-pix_fmt yuv420p',
];
} }
$audioPasses = ['-c:a aac', '-b:a 192k'];
$format = new X264('aac', $encoder); $cmd[] = '-profile:v high';
foreach ($videoPasses as $pass) { $cmd[] = '-pix_fmt yuv420p';
$format->addLegacyOption($pass); $cmd[] = '-c:a aac';
} $cmd[] = '-b:a 192k';
foreach ($audioPasses as $pass) { $cmd[] = '-movflags +faststart';
$format->addLegacyOption($pass); $cmd[] = escapeshellarg($compressedPath);
}
$ffmpegVideo->save($format, $compressedPath); $fullCmd = implode(' ', $cmd) . ' 2>&1';
Log::info('CompressVideoJob: Starting', [
'video_id' => $video->id,
'src_codec' => $srcCodec,
'encoder' => $encoder,
'gpu' => $gpuEnabled,
]);
$output = [];
exec($fullCmd, $output, $exitCode);
if ($exitCode !== 0) {
$tail = implode("\n", array_slice($output, -30));
throw new \RuntimeException("FFmpeg exited {$exitCode}:\n{$tail}");
}
// Check if compressed file was created and is smaller
if (file_exists($compressedPath)) { if (file_exists($compressedPath)) {
$originalSize = filesize($originalPath); $originalSize = filesize($originalPath);
$compressedSize = filesize($compressedPath); $compressedSize = filesize($compressedPath);
// Only use compressed file if it's smaller if ($compressedSize < $originalSize || $forceReplace) {
if ($compressedSize < $originalSize) {
// Delete original and rename compressed
unlink($originalPath); unlink($originalPath);
rename($compressedPath, $originalPath); rename($compressedPath, $originalPath);
// Update video record
$video->update([ $video->update([
'size' => $compressedSize, 'size' => $compressedSize,
'filename' => $video->filename, // Keep same filename
'mime_type' => 'video/mp4', 'mime_type' => 'video/mp4',
]); ]);
Log::info('CompressVideoJob: Video compressed', [ Log::info('CompressVideoJob: Video compressed', [
'video_id' => $video->id, 'video_id' => $video->id,
'original_size' => $originalSize, 'original_size' => $originalSize,
'compressed_size' => $compressedSize, 'compressed_size' => $compressedSize,
'saved' => round(($originalSize - $compressedSize) / $originalSize * 100) . '%', 'saved' => round(($originalSize - $compressedSize) / max(1, $originalSize) * 100) . '%',
'encoder' => $encoder, 'encoder' => $encoder,
'gpu' => $gpuEnabled, 'gpu' => $gpuEnabled,
'src_codec' => $srcCodec,
'forced' => $forceReplace && $compressedSize >= $originalSize,
]); ]);
} else { } else {
// Compressed file is larger, delete it
unlink($compressedPath); unlink($compressedPath);
Log::info('CompressVideoJob: Compression made file larger, keeping original'); Log::info('CompressVideoJob: Compression made file larger, keeping original', ['src_codec' => $srcCodec]);
} }
} }
$video->update(['status' => 'ready']); $video->update(['status' => 'ready']);
// Chain to HLS generation for GPU-accelerated adaptive playback
\App\Jobs\GenerateHlsJob::dispatch($video); \App\Jobs\GenerateHlsJob::dispatch($video);
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error('CompressVideoJob failed: ' . $e->getMessage()); Log::error('CompressVideoJob failed: ' . $e->getMessage());
$video->update(['status' => 'ready']); // Mark as ready anyway if (file_exists($compressedPath)) @unlink($compressedPath);
$video->update(['status' => 'ready']);
} }
} }
} }

View File

@ -9,7 +9,7 @@
@php @php
// Force 16:9 for every video — orientation classes intentionally disabled // Force 16:9 for every video — orientation classes intentionally disabled
$orientationClass = ''; $orientationClass = '';
$hlsUrl = $video->has_hls ? route('videos.hls', ['video' => $video, 'file' => 'master.m3u8']) : null; $hlsUrl = $video->has_hls ? route('videos.hls', ['video' => $video, 'file' => 'playlist.m3u8']) : null;
$mp4Url = route('videos.stream', $video) . '?v=' . $video->updated_at->timestamp; $mp4Url = route('videos.stream', $video) . '?v=' . $video->updated_at->timestamp;
$nextUrl = $nextVideo && $playlist ? route('videos.show', $nextVideo) .'?playlist='.$playlist->share_token : null; $nextUrl = $nextVideo && $playlist ? route('videos.show', $nextVideo) .'?playlist='.$playlist->share_token : null;
$prevUrl = $previousVideo && $playlist ? route('videos.show', $previousVideo).'?playlist='.$playlist->share_token : null; $prevUrl = $previousVideo && $playlist ? route('videos.show', $previousVideo).'?playlist='.$playlist->share_token : null;

View File

@ -1362,10 +1362,18 @@
<i class="bi bi-fire"></i> <i class="bi bi-fire"></i>
<span>Trending</span> <span>Trending</span>
</a> </a>
<a href="{{ auth()->check() ? route('videos.create') : route('login') }}" class="yt-bottom-nav-item {{ request()->routeIs('videos.create') ? 'active' : '' }}"> @auth
<i class="bi bi-plus-circle-fill"></i> <a href="#" class="yt-bottom-nav-item {{ request()->routeIs('videos.create') ? 'active' : '' }}"
<span>Upload</span> onclick="event.preventDefault(); openUploadChooser();">
</a> <i class="bi bi-plus-circle-fill"></i>
<span>Upload</span>
</a>
@else
<a href="{{ route('login') }}" class="yt-bottom-nav-item">
<i class="bi bi-plus-circle-fill"></i>
<span>Upload</span>
</a>
@endauth
<a href="{{ route('history') }}" class="yt-bottom-nav-item {{ request()->routeIs('history') ? 'active' : '' }}"> <a href="{{ route('history') }}" class="yt-bottom-nav-item {{ request()->routeIs('history') ? 'active' : '' }}">
<i class="bi bi-collection-play-fill"></i> <i class="bi bi-collection-play-fill"></i>
<span>History</span> <span>History</span>

View File

@ -233,12 +233,8 @@ window._editCurrentVideoId = null;
// ── Modal open / close ──────────────────────────────────────────────────────── // ── Modal open / close ────────────────────────────────────────────────────────
function openEditVideoModal(videoId) { function openEditVideoModal(videoId) {
if (window.innerWidth < 992) { // Always resolve type first so a match video opens the sports-match sheet
window.location.href = `/videos/${videoId}/edit`; // instead of the generic video-edit modal — same for mobile.
return;
}
window._editCurrentVideoId = videoId;
fetch(`/videos/${videoId}/edit`, { fetch(`/videos/${videoId}/edit`, {
headers: { headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}', 'X-CSRF-TOKEN': '{{ csrf_token() }}',
@ -251,6 +247,25 @@ function openEditVideoModal(videoId) {
if (!data.success) { showToast('Failed to load video data', 'error'); return; } if (!data.success) { showToast('Failed to load video data', 'error'); return; }
const v = data.video; const v = data.video;
// Match videos always route to the sports-match sheet — edit the existing
// match if one is linked, otherwise open create-mode with the video already
// attached so the user can add the match details.
if (v.type === 'match' && typeof window.openSportsMatchModal === 'function') {
if (v.sports_match_id) {
window.openSportsMatchModal(v.sports_match_id);
} else {
window.openSportsMatchModal({ videoId: v.id, videoTitle: v.title });
}
return;
}
// Mobile fallback for non-match videos: full-page edit view
if (window.innerWidth < 992) {
window.location.href = `/videos/${videoId}/edit`;
return;
}
window._editCurrentVideoId = videoId;
document.getElementById('edit-form').action = `/videos/${videoId}`; document.getElementById('edit-form').action = `/videos/${videoId}`;
// Header // Header

View File

@ -524,6 +524,72 @@
.sm-img-avatar .sm-img-ph { min-height: 74px; gap: 2px; font-size: 10px; } .sm-img-avatar .sm-img-ph { min-height: 74px; gap: 2px; font-size: 10px; }
.sm-img-avatar .sm-img-ph i { font-size: 16px; } .sm-img-avatar .sm-img-ph i { font-size: 16px; }
.sm-img-avatar .sm-img-preview { width: 74px; height: 74px; max-height: 74px; } .sm-img-avatar .sm-img-preview { width: 74px; height: 74px; max-height: 74px; }
/* ── Mobile: render as a bottom sheet ─────────────────────────── */
@media (max-width: 768px) {
#sportsMatchModal .modal-dialog {
margin: 0;
max-width: 100%;
width: 100%;
min-height: 100%;
display: flex;
align-items: flex-end;
}
#sportsMatchModal .sm-content {
border-radius: 20px 20px 0 0;
border-left: none;
border-right: none;
border-bottom: none;
width: 100%;
max-height: 92vh;
display: flex;
flex-direction: column;
box-shadow: 0 -12px 40px rgba(0,0,0,.6);
transform: translateY(100%);
transition: transform .3s cubic-bezier(.22,1,.36,1);
}
#sportsMatchModal.show .sm-content { transform: translateY(0); }
/* Grabber handle at the top */
#sportsMatchModal .sm-header {
position: relative;
padding-top: 18px;
}
#sportsMatchModal .sm-header::before {
content: '';
position: absolute;
top: 6px; left: 50%;
transform: translateX(-50%);
width: 40px; height: 4px;
background: #333; border-radius: 2px;
}
#sportsMatchModal .modal-body {
overflow-y: auto;
-webkit-overflow-scrolling: touch;
flex: 1 1 auto;
padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
#sportsMatchModal .sm-footer {
padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
gap: 6px;
flex-wrap: wrap;
}
#sportsMatchModal .sm-footer .btn {
flex: 1 1 auto;
font-size: 13px;
padding: 10px 12px;
}
/* Slide-up animation on the modal fade class as well */
#sportsMatchModal.fade .modal-dialog { transform: none; }
}
@media (max-width: 480px) {
#sportsMatchModal .sm-header h5 { font-size: 15px; }
#sportsMatchModal .sm-header-icon { width: 34px; height: 34px; font-size: 16px; }
}
</style> </style>
<script> <script>
@ -555,12 +621,28 @@
function token() { return form.querySelector('[name="_token"]').value; } function token() { return form.querySelector('[name="_token"]').value; }
// ── Public entry point ─────────────────────────────────────────────── // ── Public entry point ───────────────────────────────────────────────
window.openSportsMatchModal = function (matchId) { // - openSportsMatchModal(matchId) → edit existing match
// - openSportsMatchModal({videoId, videoTitle}) → create against an existing video
// - openSportsMatchModal() → fresh create (upload a new video)
window.openSportsMatchModal = function (arg) {
resetForm(); resetForm();
if (matchId) loadMatch(matchId); if (typeof arg === 'number' || typeof arg === 'string') {
loadMatch(arg);
} else if (arg && typeof arg === 'object' && arg.videoId) {
attachExistingVideo(arg.videoId, arg.videoTitle || '');
}
getModal().show(); getModal().show();
}; };
function attachExistingVideo(videoId, videoTitle) {
videoIdInp.value = videoId;
document.getElementById('sm-video-create').classList.add('d-none');
document.getElementById('sm-video-attached').classList.remove('d-none');
document.getElementById('sm-video-attached-title').textContent = videoTitle || ('Video #' + videoId);
// Advanced fields are also useful when the video already exists.
document.getElementById('sm-advanced').classList.remove('d-none');
}
function resetForm() { function resetForm() {
form.reset(); form.reset();
idInput.value = ''; idInput.value = '';

View File

@ -711,6 +711,55 @@
} }
.utc-card:hover .utc-card-arr { opacity: 1; transform: translateX(0); } .utc-card:hover .utc-card-arr { opacity: 1; transform: translateX(0); }
/* ── Mobile: render the chooser as a bottom sheet ───────────── */
@media (max-width: 768px) {
.utc-overlay {
align-items: flex-end; justify-content: stretch;
padding: 0; background: rgba(0,0,0,.55);
backdrop-filter: blur(4px);
}
.utc-box {
max-width: none; width: 100%;
border-radius: 20px 20px 0 0;
border-left: none; border-right: none; border-bottom: none;
padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
transform: translateY(100%); transition: transform .28s cubic-bezier(.22,1,.36,1);
box-shadow: 0 -12px 40px rgba(0,0,0,.6);
max-height: 88vh; overflow-y: auto;
}
.utc-overlay.show .utc-box { transform: translateY(0); }
/* Grabber handle at the top */
.utc-box::before {
content: ''; display: block; width: 40px; height: 4px;
background: #333; border-radius: 2px; margin: 4px auto 14px;
}
.utc-close { top: 12px; right: 12px; }
.utc-head { margin-bottom: 16px; }
.utc-head-icon { width: 44px; height: 44px; font-size: 20px; margin-bottom: 10px; }
.utc-title { font-size: 17px; }
.utc-sub { font-size: 12px; }
/* Row of compact tiles instead of full stacked cards */
.utc-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
.utc-card {
padding: 16px 8px 14px; border-radius: 14px; border-width: 1px;
}
.utc-card-ico {
width: 44px; height: 44px; margin-bottom: 8px;
font-size: 20px; border-radius: 12px;
}
.utc-card-title { font-size: 13px; }
.utc-card-desc { display: none; }
.utc-card-arr { display: none; }
.utc-card:active {
transform: scale(.96);
background: color-mix(in srgb, var(--accent) 10%, #111);
border-color: var(--accent);
}
}
/* ════════════════════════════════════════════════════════════════ /* ════════════════════════════════════════════════════════════════
Unified control system one consistent look for every field, Unified control system one consistent look for every field,
dropdown and picker in the upload modal. Scoped to #uploadModal dropdown and picker in the upload modal. Scoped to #uploadModal
@ -829,19 +878,28 @@ const _UTC_META = {
}; };
function openUploadChooser() { function openUploadChooser() {
// Mobile keeps the existing full-page create flow (with its own type picker) // Chooser is shown on every viewport — on mobile chooseUploadType() routes
if (window.innerWidth < 992) { // straight to the standalone create page with the picked ?type= preserved.
window.location.href = '{{ route("videos.create") }}';
return;
}
document.getElementById('upload-type-chooser').classList.add('show'); document.getElementById('upload-type-chooser').classList.add('show');
} }
// Called from the desktop chooser cards on mobile — carries the picked type
// through to the standalone create page via ?type=.
function chooseUploadTypeMobile(type) {
const t = ['generic', 'music', 'match'].includes(type) ? type : 'generic';
window.location.href = '{{ route("videos.create") }}?type=' + encodeURIComponent(t);
}
function closeUploadChooser() { function closeUploadChooser() {
document.getElementById('upload-type-chooser').classList.remove('show'); document.getElementById('upload-type-chooser').classList.remove('show');
} }
function chooseUploadType(type) { function chooseUploadType(type) {
// Mobile has no modal — route straight to the create page with the type preserved.
if (window.innerWidth < 992) {
chooseUploadTypeMobile(type);
return;
}
const meta = _UTC_META[type] || _UTC_META.generic; const meta = _UTC_META[type] || _UTC_META.generic;
closeUploadChooser(); closeUploadChooser();
openUploadModal(); openUploadModal();

View File

@ -784,6 +784,17 @@
setAudioMode(this.dataset.type === 'music'); setAudioMode(this.dataset.type === 'music');
}); });
}); });
// Honor ?type=generic|music|match forwarded from the desktop chooser
// when routed here on mobile — pre-select the corresponding option.
(function preselectTypeFromQuery() {
try {
const t = new URLSearchParams(window.location.search).get('type');
if (!t) return;
const opt = document.querySelector('#type-options .option-item[data-type="' + t + '"]');
if (opt) opt.click();
} catch (_) {}
}());
document.querySelectorAll('#visibility-options .option-item').forEach(item => { document.querySelectorAll('#visibility-options .option-item').forEach(item => {
item.querySelector('input').addEventListener('change', () => { item.querySelector('input').addEventListener('change', () => {
document.querySelectorAll('#visibility-options .option-item').forEach(o => o.classList.remove('active')); document.querySelectorAll('#visibility-options .option-item').forEach(o => o.classList.remove('active'));

File diff suppressed because it is too large Load Diff