diff --git a/laravel_app/app/Livewire/Projects/Tabs/Download.php b/laravel_app/app/Livewire/Projects/Tabs/Download.php new file mode 100644 index 0000000..8ed6328 --- /dev/null +++ b/laravel_app/app/Livewire/Projects/Tabs/Download.php @@ -0,0 +1,96 @@ +path = $project->download_path; + $this->formData = [ + 'dateRange' => sprintf('%s to %s', + now()->subDays(6)->format('Y/m/d'), + now()->format('Y/m/d') + ) + ]; + } + + public function update($property) + { + if ($property === 'search') { + $this->resetPage('downloadPage'); + } + } + + public function openDownloadModal() + { + $this->showDownloadModal = true; + } + + public function saveDownloads() + { + $this->validate([ + 'formData.dateRange' => [ + 'required', + new DownloadDateRangeRule(), + ] + ]); + + $dateRange = explode(' to ', $this->formData['dateRange']); + + $period = CarbonPeriod::create( + Carbon::parse($dateRange[0]), + Carbon::parse($dateRange[1]) + ); + + collect($period)->each(function ($date) { + $this->project->startDownload($date); + }); + + $this->showDownloadModal = false; + } + + private function applySearch($query) + { + if ($this->search) { + $query->where('name', 'like', '%' . $this->search . '%'); + } + return $query; + } + + public function placeholder() + { + return view('livewire.projects.download-manager-placeholder'); + } + + + public function render() + { + $query = $this->project->downloads()->orderBy('name', 'desc'); + $query = $this->applySearch($query); + $downloads = $query->paginate(10, pageName: 'downloadPage'); + + return view('livewire.projects.tabs.download', + compact('downloads') + ); + } +} diff --git a/laravel_app/resources/views/livewire/projects/tabs/download.blade.php b/laravel_app/resources/views/livewire/projects/tabs/download.blade.php new file mode 100644 index 0000000..ae3dd49 --- /dev/null +++ b/laravel_app/resources/views/livewire/projects/tabs/download.blade.php @@ -0,0 +1,76 @@ +
hasPendingDownload())--}} +{{-- wire:poll.1s=""--}} +{{-- @endif--}} +{{-- TODO Put Back the poll but to the list of downloads only--}} +> +
+
+
+

Downloads

+ @if ($project->hasPendingDownload()) +

+ Pending downloads for this project: {{ $project->downloads()->statusPending()->count() }} +

+ @endif +
+
+ + + {{ __('Create Download') }} + +
+
+
+
+
+
+ + + + + + + + + + + @foreach($downloads as $download) + + + + + + @endforeach + +
+ Name + + File + + Status +
{{ $download->name }} + {{ $download->path }} + + +
+ +
+
+
+ Results: {{ \Illuminate\Support\Number::format($downloads->total()) }} +
+ + {{ $downloads->links('livewire.pagination') }} +
+
+ {{--
--}} +
+
+
+ +
+