Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 08d28d9a4f |
@@ -16,6 +16,9 @@ final class MonitorList extends AbstractController
|
|||||||
|
|
||||||
use PaginateTrait;
|
use PaginateTrait;
|
||||||
|
|
||||||
|
#[LiveProp(writable: true)]
|
||||||
|
public string $type;
|
||||||
|
|
||||||
#[LiveProp(writable: true)]
|
#[LiveProp(writable: true)]
|
||||||
public bool $isWidget = true;
|
public bool $isWidget = true;
|
||||||
|
|
||||||
@@ -24,8 +27,34 @@ final class MonitorList extends AbstractController
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
#[LiveAction]
|
#[LiveAction]
|
||||||
public function getUserMonitors()
|
public function getMonitors()
|
||||||
{
|
{
|
||||||
return $this->monitorRepository->getUserMonitorsPaginated($this->getUser(), $this->pageNumber, $this->perPage);
|
if ($this->type === "active") {
|
||||||
|
return $this->getActiveUserMonitors();
|
||||||
|
} elseif ($this->type === "complete") {
|
||||||
|
return $this->getCompleteUserMonitors();
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
#[LiveAction]
|
||||||
|
public function getActiveUserMonitors()
|
||||||
|
{
|
||||||
|
return $this->asPaginator($this->monitorRepository->createQueryBuilder('m')
|
||||||
|
->andWhere('m.status IN (:statuses)')
|
||||||
|
->setParameter('statuses', ['New', 'In Progress'])
|
||||||
|
->getQuery()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[LiveAction]
|
||||||
|
public function getCompleteUserMonitors()
|
||||||
|
{
|
||||||
|
return $this->asPaginator($this->monitorRepository->createQueryBuilder('m')
|
||||||
|
->andWhere('m.status = :status')
|
||||||
|
->setParameter('status', 'Complete')
|
||||||
|
->getQuery()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,8 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id="monitors" class="divide-y divide-gray-50">
|
<tbody id="monitors" class="divide-y divide-gray-50">
|
||||||
{% if this.userMonitors.items|length > 0 %}
|
{% if this.monitors.items|length > 0 %}
|
||||||
{% for monitor in this.userMonitors.items %}
|
{% for monitor in this.monitors.items %}
|
||||||
<tr id="monitor_{{ monitor.id }}">
|
<tr id="monitor_{{ monitor.id }}">
|
||||||
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-stone-800 min-w-[50ch] max-w-[50ch] truncate">
|
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-stone-800 min-w-[50ch] max-w-[50ch] truncate">
|
||||||
{{ monitor.title }}
|
{{ monitor.title }}
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if this.isWidget and this.userMonitors.items|length > 5 %}
|
{% if this.isWidget and this.monitors.items|length > 5 %}
|
||||||
<tr id="monitor_view_all">
|
<tr id="monitor_view_all">
|
||||||
<td colspan="100%" class="py-2 whitespace-nowrap bg-orange-500 uppercase text-sm font-medium text-center text-white min-w-[50ch] max-w-[50ch] truncate">
|
<td colspan="100%" class="py-2 whitespace-nowrap bg-orange-500 uppercase text-sm font-medium text-center text-white min-w-[50ch] max-w-[50ch] truncate">
|
||||||
<a href="{{ path('app_monitors') }}">View All Monitors</a>
|
<a href="{{ path('app_monitors') }}">View All Monitors</a>
|
||||||
@@ -79,8 +79,8 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
{% if this.isWidget == false %}
|
{% if this.isWidget == false %}
|
||||||
{% if this.userMonitors.items|length > 0 %}
|
{% if this.monitors.items|length > 0 %}
|
||||||
{% set paginator = this.userMonitors %}
|
{% set paginator = this.monitors %}
|
||||||
{% include 'partial/paginator.html.twig' %}
|
{% include 'partial/paginator.html.twig' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row gap-4">
|
<div class="flex flex-row gap-4">
|
||||||
<twig:Card title="Monitors" class="w-full">
|
<twig:Card title="Monitors" class="w-full">
|
||||||
<twig:MonitorList />
|
<twig:MonitorList :type="'active'" :isWidget="true" />
|
||||||
</twig:Card>
|
</twig:Card>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
|
|||||||
@@ -5,8 +5,14 @@
|
|||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="p-4">
|
<div class="p-4">
|
||||||
<twig:Card title="Monitors">
|
<twig:Card title="Active Monitors">
|
||||||
<twig:MonitorList :isWidget="false" :perPage="10"></twig:MonitorList>
|
<twig:MonitorList :type="'active'" :isWidget="false" :perPage="10"></twig:MonitorList>
|
||||||
|
</twig:Card>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="p-4">
|
||||||
|
<twig:Card title="Complete Monitors">
|
||||||
|
<twig:MonitorList :type="'complete'" :isWidget="false" :perPage="10"></twig:MonitorList>
|
||||||
</twig:Card>
|
</twig:Card>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user