wip-feat: lists active & recent downloads on landing page
This commit is contained in:
@@ -2,17 +2,23 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Download\Framework\Repository\DownloadRepository;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
final class IndexController extends AbstractController
|
final class IndexController extends AbstractController
|
||||||
{
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly DownloadRepository $downloadRepository,
|
||||||
|
) {}
|
||||||
|
|
||||||
#[Route('/', name: 'app_index')]
|
#[Route('/', name: 'app_index')]
|
||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
return $this->render('index/index.html.twig', [
|
return $this->render('index/index.html.twig', [
|
||||||
'controller_name' => 'IndexController',
|
'active_downloads' => [],
|
||||||
|
'recent_downloads' => $this->downloadRepository->latest(5)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,4 +115,15 @@ class DownloadRepository extends ServiceEntityRepository
|
|||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function latest(int $limit = 1)
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('d')
|
||||||
|
->andWhere('d.status IN (:statuses)')
|
||||||
|
->setParameter('statuses', ['Complete'])
|
||||||
|
->setMaxResults($limit)
|
||||||
|
->orderBy('d.id', 'DESC')
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
{% extends 'base.html.twig' %}
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
{% block title %}Dashboard &mdash - Torsearch{% endblock %}
|
{% block title %}Dashboard — Torsearch{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="p-4 flex flex-col grow gap-4">
|
<div class="p-4 flex flex-col grow gap-4">
|
||||||
<h2 class="mb-2 text-3xl font-bold text-gray-50">Dashboard</h2>
|
<h2 class="mb-2 text-3xl font-bold text-gray-50">Dashboard</h2>
|
||||||
<div class="flex flex-row gap-4">
|
<div class="flex flex-row gap-4">
|
||||||
<twig:Card title="Active Downloads" class="w-full">
|
<twig:Card title="Active Downloads" class="w-full">
|
||||||
<table class="divide-y divide-gray-200 dark:divide-gray-50 dark:bg-gray-50">
|
<table class="divide-y divide-gray-200 dark:divide-gray-50 dark:bg-gray-50 table-fixed">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="dark:bg-gray-50">
|
<tr class="dark:bg-gray-50">
|
||||||
<th scope="col"
|
<th scope="col"
|
||||||
@@ -21,44 +21,32 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="divide-y divide-gray-200 dark:divide-gray-50">
|
<tbody class="divide-y divide-gray-200 dark:divide-gray-50">
|
||||||
<tr>
|
{% if active_downloads|length > 0 %}
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-stone-800">
|
{% for download in active_downloads %}
|
||||||
The Wolf of Wallstreet
|
<tr>
|
||||||
</td>
|
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-stone-800">
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-end text-gray-800 dark:text-gray-50">
|
{{ download.title }}
|
||||||
<span class="p-1.5 bg-purple-600 rounded-full">
|
</td>
|
||||||
<span class="text-gray-50">11</span>
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-end text-gray-800 dark:text-gray-50">
|
||||||
</span>
|
<span class="p-1.5 bg-purple-600 rounded-full">
|
||||||
</td>
|
<span class="w-4 inline-block text-center text-gray-50">{{ download.progress }}</span>
|
||||||
</tr>
|
</span>
|
||||||
|
</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-stone-800">
|
{% endfor %}
|
||||||
Inception
|
{% else %}
|
||||||
</td>
|
<tr>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-end text-gray-800 dark:text-gray-50">
|
<td class="px-6 py-4 whitespace-nowrap text-xs uppercase text-center col-span-2 font-medium text-gray-800 dark:text-stone-800" colspan="2">
|
||||||
<span class="p-1.5 bg-purple-600 rounded-full">
|
No active downloads
|
||||||
<span class="text-gray-50">36</span>
|
</td>
|
||||||
</span>
|
</tr>
|
||||||
</td>
|
{% endif %}
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-stone-800">
|
|
||||||
Hop
|
|
||||||
</td>
|
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-end text-gray-800 dark:text-gray-50">
|
|
||||||
<span class="p-1.5 bg-purple-600 rounded-full">
|
|
||||||
<span class="text-gray-50">0</span>
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</twig:Card>
|
</twig:Card>
|
||||||
|
|
||||||
<twig:Card title="Recent Downloads" class="w-full">
|
<twig:Card title="Recent Downloads" class="w-full">
|
||||||
<table class="divide-y divide-gray-200 dark:divide-gray-50 dark:bg-gray-50">
|
<table class="divide-y divide-gray-200 dark:divide-gray-50 dark:bg-gray-50 table-fixed">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="dark:bg-gray-50">
|
<tr class="dark:bg-gray-50">
|
||||||
<th scope="col"
|
<th scope="col"
|
||||||
@@ -66,44 +54,37 @@
|
|||||||
Title
|
Title
|
||||||
</th>
|
</th>
|
||||||
<th scope="col"
|
<th scope="col"
|
||||||
class="px-6 py-3 text-start text-xs font-medium text-end text-gray-500 uppercase dark:text-stone-800">
|
class="px-6 py-3 text-start text-xs font-medium text-gray-500 uppercase dark:text-stone-800">
|
||||||
Status
|
Status
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="divide-y divide-gray-200 dark:divide-gray-50">
|
<tbody class="divide-y divide-gray-200 dark:divide-gray-50">
|
||||||
<tr>
|
{% if recent_downloads|length > 0 %}
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-stone-800">
|
{% for download in recent_downloads %}
|
||||||
The Family Plan
|
<tr>
|
||||||
</td>
|
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-stone-800">
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-end text-gray-800 dark:text-gray-50">
|
{{ download.title }}
|
||||||
<span class="p-1 bg-green-600 rounded-lg">
|
</td>
|
||||||
<span class="text-gray-50">Complete</span>
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-end text-gray-800 dark:text-gray-50">
|
||||||
</span>
|
<span class="p-1 bg-green-600 rounded-lg">
|
||||||
</td>
|
<span class="text-gray-50">Complete</span>
|
||||||
</tr>
|
</span>
|
||||||
|
</td>
|
||||||
<tr>
|
</tr>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-stone-800">
|
{% endfor %}
|
||||||
It
|
<tr class="bg-blue-400">
|
||||||
</td>
|
<td class="px-6 py-3 whitespace-nowrap text-xs uppercase text-center col-span-2 font-medium text-gray-800 dark:text-stone-800" colspan="2">
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-end text-gray-800 dark:text-gray-50">
|
<a href="#">View all downloads</a>
|
||||||
<span class="p-1 bg-green-600 rounded-lg">
|
</td>
|
||||||
<span class="text-gray-50">Complete</span>
|
</tr>
|
||||||
</span>
|
{% else %}
|
||||||
</td>
|
<tr>
|
||||||
</tr>
|
<td class="px-6 py-4 whitespace-nowrap text-xs uppercase text-center col-span-2 font-medium text-gray-800 dark:text-stone-800" colspan="2">
|
||||||
|
No recent downloads
|
||||||
<tr>
|
</td>
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-800 dark:text-stone-800">
|
</tr>
|
||||||
Silicon Cowboys
|
{% endif %}
|
||||||
</td>
|
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm text-end text-gray-800 dark:text-gray-50">
|
|
||||||
<span class="p-1 bg-green-600 rounded-lg">
|
|
||||||
<span class="text-gray-50">Complete</span>
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</twig:Card>
|
</twig:Card>
|
||||||
|
|||||||
@@ -60,4 +60,9 @@
|
|||||||
{# </select>#}
|
{# </select>#}
|
||||||
{# </label>#}
|
{# </label>#}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<span {{ stimulus_controller('loading_icon', {total: (results.media.mediaType == "tvshows") ? results.media.episodes[1]|length : 1, count: 0}) }}
|
||||||
|
class="loading-icon"
|
||||||
|
>
|
||||||
|
<twig:ux:icon name="codex:loader" height="20" width="20" data-loading-icon-target="icon" class="text-end" />
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -17,11 +17,6 @@
|
|||||||
{{ results.media.description }}
|
{{ results.media.description }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<span {{ stimulus_controller('loading_icon', {total: (results.media.mediaType == "tvshows") ? results.media.episodes[1]|length : 1, count: 0}) }}
|
|
||||||
class="loading-icon"
|
|
||||||
>
|
|
||||||
<twig:ux:icon name="codex:loader" height="20" width="20" data-loading-icon-target="icon" />
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ include('search/partial/filter.html.twig') }}
|
{{ include('search/partial/filter.html.twig') }}
|
||||||
|
|||||||
Reference in New Issue
Block a user