2021-12-24 17:55:56 +00:00
|
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
use App\Entities\Clip\VideoClip;
|
|
|
|
|
use CodeIgniter\I18n\Time;
|
|
|
|
|
|
|
|
|
|
?>
|
2021-12-07 16:58:12 +00:00
|
|
|
|
<?= $this->extend('_layout') ?>
|
|
|
|
|
|
|
|
|
|
<?= $this->section('pageTitle') ?>
|
2021-12-24 17:55:56 +00:00
|
|
|
|
<?= lang('VideoClip.list.title') ?>
|
2021-12-07 16:58:12 +00:00
|
|
|
|
<?= $this->endSection() ?>
|
|
|
|
|
|
2021-12-27 11:22:39 +00:00
|
|
|
|
<?= $this->section('headerRight') ?>
|
2024-12-17 15:06:08 +00:00
|
|
|
|
<?php // @icon("add-fill")?>
|
2024-05-09 17:55:41 +00:00
|
|
|
|
<x-Button uri="<?= route_to('video-clips-create', $podcast->id, $episode->id) ?>" variant="primary" iconLeft="add-fill"><?= lang('VideoClip.create') ?></x-Button>
|
2021-12-27 11:22:39 +00:00
|
|
|
|
<?= $this->endSection() ?>
|
|
|
|
|
|
2021-12-07 16:58:12 +00:00
|
|
|
|
<?= $this->section('content') ?>
|
2021-12-21 16:25:03 +00:00
|
|
|
|
<?= data_table(
|
|
|
|
|
[
|
|
|
|
|
[
|
2021-12-24 17:55:56 +00:00
|
|
|
|
'header' => lang('VideoClip.list.status.label'),
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'cell' => function ($videoClip): string {
|
2021-12-24 09:49:34 +00:00
|
|
|
|
$pillVariantMap = [
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'queued' => 'default',
|
|
|
|
|
'pending' => 'warning',
|
|
|
|
|
'running' => 'primary',
|
2021-12-24 09:49:34 +00:00
|
|
|
|
'canceled' => 'default',
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'failed' => 'danger',
|
|
|
|
|
'passed' => 'success',
|
2021-12-24 09:49:34 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$pillIconMap = [
|
2024-12-17 15:06:08 +00:00
|
|
|
|
'queued' => 'timer-fill', // @icon("timer-fill")
|
|
|
|
|
'pending' => 'pause-fill', // @icon("pause-fill")
|
|
|
|
|
'running' => 'loader-fill', // @icon("loader-fill")
|
|
|
|
|
'canceled' => 'forbid-fill', // @icon("forbid-fill")
|
|
|
|
|
'failed' => 'close-fill', // @icon("close-fill")
|
|
|
|
|
'passed' => 'check-fill', // @icon("check-fill")
|
2021-12-24 09:49:34 +00:00
|
|
|
|
];
|
|
|
|
|
|
2021-12-24 17:55:56 +00:00
|
|
|
|
$pillIconClassMap = [
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'queued' => '',
|
|
|
|
|
'pending' => '',
|
|
|
|
|
'running' => 'animate-spin',
|
2021-12-24 17:55:56 +00:00
|
|
|
|
'canceled' => '',
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'failed' => '',
|
|
|
|
|
'passed' => '',
|
2021-12-24 17:55:56 +00:00
|
|
|
|
];
|
|
|
|
|
|
2024-05-09 17:55:41 +00:00
|
|
|
|
return '<x-Pill variant="' . $pillVariantMap[$videoClip->status] . '" icon="' . $pillIconMap[$videoClip->status] . '" iconClass="' . $pillIconClassMap[$videoClip->status] . '" hint="' . lang('VideoClip.list.status.' . $videoClip->status . '_hint') . '">' . lang('VideoClip.list.status.' . $videoClip->status) . '</x-Pill>';
|
2021-12-24 09:49:34 +00:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
[
|
2021-12-24 17:55:56 +00:00
|
|
|
|
'header' => lang('VideoClip.list.clip'),
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'cell' => function ($videoClip): string {
|
2021-12-24 09:49:34 +00:00
|
|
|
|
$formatClass = [
|
2021-12-23 16:56:06 +00:00
|
|
|
|
'landscape' => 'aspect-video',
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'portrait' => 'aspect-[9/16]',
|
|
|
|
|
'squared' => 'aspect-square',
|
2021-12-24 09:49:34 +00:00
|
|
|
|
];
|
2024-05-09 17:55:41 +00:00
|
|
|
|
return '<a href="' . route_to('video-clip', $videoClip->podcast_id, $videoClip->episode_id, $videoClip->id) . '" class="inline-flex items-center w-full group gap-x-2"><div class="relative"><span class="absolute block w-3 h-3 rounded-full ring-2 ring-white -bottom-1 -left-1" data-tooltip="bottom" title="' . lang('Settings.theme.' . $videoClip->theme['name']) . '" style="background-color:hsl(' . $videoClip->theme['preview'] . ')"></span><div class="flex items-center justify-center h-6 overflow-hidden bg-black rounded-sm aspect-video" data-tooltip="bottom" title="' . lang('VideoClip.format.' . $videoClip->format) . '"><span class="flex items-center justify-center h-full text-white bg-gray-400 ' . $formatClass[$videoClip->format] . '">' . icon('play-fill') . '</span></div></div><div class="flex flex-col"><div class="text-sm">#' . $videoClip->id . ' – <span class="font-semibold group-hover:underline">' . esc($videoClip->title) . '</span><span class="ml-1 text-sm">by ' . esc($videoClip->user->username) . '</span></div><span class="text-xs">' . format_duration((int) $videoClip->duration) . '</span></div></a>';
|
2021-12-24 09:49:34 +00:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
[
|
2021-12-24 17:55:56 +00:00
|
|
|
|
'header' => lang('VideoClip.list.duration'),
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'cell' => function (VideoClip $videoClip): string {
|
2021-12-24 17:55:56 +00:00
|
|
|
|
$duration = '';
|
|
|
|
|
if ($videoClip->job_started_at !== null) {
|
|
|
|
|
if ($videoClip->job_ended_at !== null) {
|
|
|
|
|
$duration = '<div class="flex flex-col text-xs gap-y-1">' .
|
2024-04-26 17:57:25 +00:00
|
|
|
|
'<div class="inline-flex items-center font-mono gap-x-1">' . icon('timer-fill', [
|
|
|
|
|
'class' => 'text-sm text-gray-400',
|
|
|
|
|
]) . format_duration((int) $videoClip->job_duration, true) . '</div>' .
|
|
|
|
|
'<div class="inline-flex items-center gap-x-1">' . icon('calendar-fill', [
|
|
|
|
|
'class' => 'text-sm text-gray-400',
|
|
|
|
|
]) . relative_time($videoClip->job_ended_at) . '</div>' .
|
2021-12-24 17:55:56 +00:00
|
|
|
|
'</div>';
|
|
|
|
|
} else {
|
2024-04-26 17:57:25 +00:00
|
|
|
|
$duration = '<div class="inline-flex items-center font-mono text-xs gap-x-1">' . icon('timer-fill', [
|
|
|
|
|
'class' => 'text-sm text-gray-400',
|
|
|
|
|
]) . format_duration(($videoClip->job_started_at->difference(Time::now()))->getSeconds(), true) . '</div>';
|
2021-12-24 17:55:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $duration;
|
2021-12-21 16:25:03 +00:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
[
|
2021-12-24 09:49:34 +00:00
|
|
|
|
'header' => lang('Common.actions'),
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'cell' => function ($videoClip): string {
|
2021-12-24 17:55:56 +00:00
|
|
|
|
$downloadButton = '';
|
|
|
|
|
if ($videoClip->media) {
|
|
|
|
|
helper('misc');
|
2022-01-03 13:52:07 +00:00
|
|
|
|
$filename = 'clip-' . slugify($videoClip->title) . "-{$videoClip->start_time}-{$videoClip->end_time}";
|
2024-12-17 15:06:08 +00:00
|
|
|
|
// @icon("import-fill")
|
2024-05-09 17:55:41 +00:00
|
|
|
|
$downloadButton = '<x-IconButton glyph="import-fill" uri="' . $videoClip->media->file_url . '" download="' . $filename . '">' . lang('VideoClip.download_clip') . '</x-IconButton>';
|
2021-12-24 17:55:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return '<div class="inline-flex items-center gap-x-2">' . $downloadButton .
|
2024-05-09 17:55:41 +00:00
|
|
|
|
'<button id="more-dropdown-' . $videoClip->id . '" type="button" class="inline-flex items-center p-1 rounded-full" data-dropdown="button" data-dropdown-target="more-dropdown-' . $videoClip->id . '-menu" aria-haspopup="true" aria-expanded="false">' .
|
2024-04-26 17:57:25 +00:00
|
|
|
|
icon('more-2-fill') .
|
2021-12-24 17:55:56 +00:00
|
|
|
|
'</button>' .
|
2024-05-09 17:55:41 +00:00
|
|
|
|
'<x-DropdownMenu id="more-dropdown-' . $videoClip->id . '-menu" labelledby="more-dropdown-' . $videoClip->id . '" offsetY="-24" items="' . esc(json_encode([
|
2021-12-24 17:55:56 +00:00
|
|
|
|
[
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'type' => 'link',
|
2021-12-24 17:55:56 +00:00
|
|
|
|
'title' => lang('VideoClip.go_to_page'),
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'uri' => route_to('video-clip', $videoClip->podcast_id, $videoClip->episode_id, $videoClip->id),
|
2021-12-24 17:55:56 +00:00
|
|
|
|
],
|
2022-01-02 14:11:05 +00:00
|
|
|
|
[
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'type' => 'link',
|
2022-01-02 14:11:05 +00:00
|
|
|
|
'title' => lang('VideoClip.retry'),
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'uri' => route_to('video-clip-retry', $videoClip->podcast_id, $videoClip->episode_id, $videoClip->id),
|
2022-01-02 14:11:05 +00:00
|
|
|
|
],
|
2021-12-24 17:55:56 +00:00
|
|
|
|
[
|
|
|
|
|
'type' => 'separator',
|
|
|
|
|
],
|
|
|
|
|
[
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'type' => 'link',
|
2021-12-24 17:55:56 +00:00
|
|
|
|
'title' => lang('VideoClip.delete'),
|
2023-06-12 14:47:38 +00:00
|
|
|
|
'uri' => route_to('video-clip-delete', $videoClip->podcast_id, $videoClip->episode_id, $videoClip->id),
|
2021-12-24 17:55:56 +00:00
|
|
|
|
'class' => 'font-semibold text-red-600',
|
|
|
|
|
],
|
|
|
|
|
])) . '" />' .
|
|
|
|
|
'</div>';
|
2021-12-21 16:25:03 +00:00
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
$videoClips,
|
2025-03-01 13:08:00 +00:00
|
|
|
|
'mb-6',
|
2021-12-21 16:25:03 +00:00
|
|
|
|
) ?>
|
|
|
|
|
|
|
|
|
|
<?= $pager->links() ?>
|
2021-12-07 16:58:12 +00:00
|
|
|
|
|
|
|
|
|
<?= $this->endSection() ?>
|