fix: broken download, added to queue alert, download list component; feat: monitor list
This commit is contained in:
@@ -48,7 +48,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
* @var Collection<int, Monitor>
|
||||
*/
|
||||
#[ORM\OneToMany(targetEntity: Monitor::class, mappedBy: 'user', orphanRemoval: true)]
|
||||
private Collection $yes;
|
||||
private Collection $monitors;
|
||||
|
||||
/**
|
||||
* @var Collection<int, Download>
|
||||
@@ -59,7 +59,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
public function __construct()
|
||||
{
|
||||
$this->userPreferences = new ArrayCollection();
|
||||
$this->yes = new ArrayCollection();
|
||||
$this->monitors = new ArrayCollection();
|
||||
$this->downloads = new ArrayCollection();
|
||||
}
|
||||
|
||||
@@ -226,27 +226,27 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
/**
|
||||
* @return Collection<int, Monitor>
|
||||
*/
|
||||
public function getYes(): Collection
|
||||
public function getMonitors(): Collection
|
||||
{
|
||||
return $this->yes;
|
||||
return $this->monitors;
|
||||
}
|
||||
|
||||
public function addYe(Monitor $ye): static
|
||||
public function addMonitor(Monitor $monitor): static
|
||||
{
|
||||
if (!$this->yes->contains($ye)) {
|
||||
$this->yes->add($ye);
|
||||
$ye->setUser($this);
|
||||
if (!$this->monitors->contains($monitor)) {
|
||||
$this->monitors->add($monitor);
|
||||
$monitor->setUser($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeYe(Monitor $ye): static
|
||||
public function removeMonitor(Monitor $monitor): static
|
||||
{
|
||||
if ($this->yes->removeElement($ye)) {
|
||||
if ($this->monitors->removeElement($monitor)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($ye->getUser() === $this) {
|
||||
$ye->setUser(null);
|
||||
if ($monitor->getUser() === $this) {
|
||||
$monitor->setUser(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,4 +302,14 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function queryDownloads(string $type = 'complete', int $limit = 5)
|
||||
{
|
||||
if ($type === 'complete') {
|
||||
return $this->downloads->filter(fn($item) => in_array($item->getStatus(), ['Complete']))->slice(0, $limit);
|
||||
} elseif ($type === 'in-progress') {
|
||||
return $this->downloads->filter(fn($item) => in_array($item->getStatus(), ['New', 'In Progress']))->slice(0, $limit);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user