46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Components;
|
|
|
|
use App\Models\Project;
|
|
use Livewire\Attributes\On;
|
|
use Livewire\Component;
|
|
|
|
class DownloadNotification extends Component
|
|
{
|
|
public $show_download_notification;
|
|
public Project $project;
|
|
|
|
public function mount(Project $project)
|
|
{
|
|
$this->show_download_notification = session()->get('show-download.'.$project->id,$project->hasMissingDownloadsDateInHarvestFile());
|
|
$this->project = $project;
|
|
}
|
|
|
|
public function getSessionKey()
|
|
{
|
|
return 'show-download.'.$this->project->id;
|
|
}
|
|
|
|
#[On('download_notify')]
|
|
public function open()
|
|
{
|
|
$this->show_download_notification = true;
|
|
session([$this->getSessionKey()=>true]);
|
|
}
|
|
public function close(): void
|
|
{
|
|
$this->show_download_notification = false;
|
|
session([$this->getSessionKey()=>false]);
|
|
}
|
|
|
|
public function startDownloads()
|
|
{
|
|
$this->project->handleMissingDownloads();
|
|
$this->close();
|
|
$this->dispatch('notify',message:'Downloads added to the queue.',type:'success');
|
|
}
|
|
|
|
|
|
}
|