This commit is contained in:
guillaume91 2024-06-24 16:41:24 +02:00
parent 607a221028
commit cf5e2fea70
9 changed files with 138 additions and 119 deletions

View file

@ -4,6 +4,7 @@
use App\Models\ProjectDownload; use App\Models\ProjectDownload;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\PrivateChannel; use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow; use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
@ -26,8 +27,8 @@ public function __construct($projectDownload)
* Get the channels the event should broadcast on. * Get the channels the event should broadcast on.
* *
*/ */
public function broadcastOn(): array public function broadcastOn(): Channel
{ {
return [new PrivateChannel('download.'.$this->projectDownload->id)]; return new PrivateChannel('download.'.$this->projectDownload->id);
} }
} }

View file

@ -44,11 +44,13 @@ public function handle(): void
]; ];
$process = new Process($command); $process = new Process($command);
$process->setTimeout(3600); $process->setTimeout(600);
$process->run(); $process->run();
if (!$process->isSuccessful()) { if (!$process->isSuccessful()) {
logger('error', [$process->getErrorOutput()]); logger('error', [$process->getErrorOutput()]);
$this->download->setStatusFailed();
return;
} }
logger($process->getOutput()); logger($process->getOutput());

View file

@ -27,7 +27,7 @@ public function project(): \Illuminate\Database\Eloquent\Relations\BelongsTo
protected static function booted(): void protected static function booted(): void
{ {
parent::booted(); parent::booted();
static::updated(function (ProjectDownload $projectDownload) { self::updated(function (ProjectDownload $projectDownload) {
event(new ProjectDownloadStatus($projectDownload)); event(new ProjectDownloadStatus($projectDownload));
}); });
} }

View file

@ -1,12 +1,12 @@
<span class="inline-flex items-center rounded-md {{ $this->getColorClasses() }} px-1.5 py-0.5 text-xs font-medium" <span class="inline-flex items-center rounded-md {{ $this->getColorClasses() }} px-1.5 py-0.5 text-xs font-medium"
@if($this->type) @if($this->type)
x-init="Echo.private(`{{$this->type}}.@js($this->id)`).listen('Project{{ucfirst($this->type)}}Status', (e) => { x-init="Echo.private(`{{$this->type}}.{{$this->id}}`).listen('Project{{ucfirst($this->type)}}Status', (e) => {
if(e.project{{ucfirst($this->type)}}.status){ if(e.project{{ucfirst($this->type)}}.status){
$wire.setStatus(e.project{{ucfirst($this->type)}}.status); $wire.setStatus(e.project{{ucfirst($this->type)}}.status);
$wire.refreshPendingMessage(); $wire.refreshPendingMessage();
} }
});" });"
x-destroy="Echo.leaveChannel(`{{$this->type}}.@js($this->id)`);" x-destroy="Echo.leaveChannel(`{{$this->type}}.{{$this->id}}`);"
@endif @endif
> >
{{ $status }} {{ $status }}

View file

@ -1,10 +1,12 @@
<div class="m-2"> <div>
<div class="px-4">
<div class="sm:flex sm:flex-col"> <div class="sm:flex sm:flex-col">
<div class="flex flex-col md:flex-row md:justify-between items-center w-full my-4"> <div class="flex flex-col md:flex-row justify-between w-full my-4">
<h1 class="text-base font-semibold leading-6 text-gray-900">Downloads</h1> <h1 class="text-base font-semibold leading-6 text-gray-900">Downloads</h1>
<livewire:components.pending-message :project="$project" type="downloads"></livewire:components.pending-message> <livewire:components.pending-message :project="$project"
type="downloads"></livewire:components.pending-message>
</div> </div>
<div class="mt-4 sm:mt-0 flex flex-col sm:flex-row sm:justify-between gap-2"> <div class="flex flex-col md:flex-row mt-4 items-center md:justify-between w-full gap-2">
<x-search class="flex-1 w-full"></x-search> <x-search class="flex-1 w-full"></x-search>
<x-button wire:click="openDownloadModal" <x-button wire:click="openDownloadModal"
class="rounded-md bg-indigo-600 px-3 py-2 justify-center text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"> class="rounded-md bg-indigo-600 px-3 py-2 justify-center text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
@ -42,7 +44,9 @@ class="px-3 py-3.5 text-right pr-4 sm:pr-8 lg:pr-8 text-sm font-semibold text-gr
</td> </td>
<td class="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6 lg:pr-8" <td class="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6 lg:pr-8"
> >
<livewire:components.badge :status="$download->status" :id="$download->id" type="download" wire:key="{{$download->id}}"></livewire:components.badge> <livewire:components.badge :status="$download->status" :id="$download->id"
type="download"
wire:key="{{$download->id}}"></livewire:components.badge>
</td> </td>
</tr> </tr>
@endforeach @endforeach
@ -60,6 +64,7 @@ class="px-3 py-3.5 text-right pr-4 sm:pr-8 lg:pr-8 text-sm font-semibold text-gr
</div> </div>
</div> </div>
</div> </div>
</div>
<x-download-create-modal :manager="$this"/> <x-download-create-modal :manager="$this"/>
</div> </div>

View file

@ -1,17 +1,18 @@
<div> <div>
<div class="px-4 sm:px-6 lg:px-8"> <div class="px-4">
<div class="sm:flex sm:flex-col sm:items-center"> <div class="sm:flex sm:flex-col sm:items-center">
<div class="w-full flex justify-between my-4"> <div class="flex flex-col md:flex-row justify-between w-full my-4">
<h1 class="text-base font-semibold leading-6 text-gray-900">{{ __('Mailing') }}</h1> <h1 class="text-base font-semibold leading-6 text-gray-900">{{ __('Mailing') }}</h1>
<livewire:components.pending-message :project="$project" <livewire:components.pending-message :project="$project"
type="mailings"></livewire:components.pending-message> type="mailings"></livewire:components.pending-message>
</div> </div>
<div class="mt-4 sm:mt-0 sm:flex sm:justify-between w-full"> <div class="flex flex-col md:flex-row mt-4 items-center md:justify-between w-full gap-2">
<x-search></x-search> <x-search></x-search>
</div> </div>
</div> </div>
<div class="mt-8"> <div class="mt-8 flow-root overflow-x-scroll">
<div class=""> <div class="">
<div class="relative">
<div class="inline-block min-w-full py-2 align-middle mb-10"> <div class="inline-block min-w-full py-2 align-middle mb-10">
<div class=""> <div class="">
<table class="min-w-full divide-y divide-gray-300"> <table class="min-w-full divide-y divide-gray-300">
@ -25,7 +26,9 @@ class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 lg
class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 lg:pl-8">@lang('Subject')</th> class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 lg:pl-8">@lang('Subject')</th>
<th scope="col" <th scope="col"
class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 lg:pl-8">@lang('Status')</th> class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 lg:pl-8">@lang('Status')</th>
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">#</th> <th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
#
</th>
<th scope="col" <th scope="col"
class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">@lang('Attachment') class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">@lang('Attachment')
</th> </th>
@ -34,21 +37,24 @@ class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">@lang('Attachm
</th> </th>
</tr> </tr>
</thead> </thead>
<tbody class="divide-y divide-gray-200"> <tbody class="divide-y divide-gray-200 bg-white">
@foreach($mailings as $mail) @foreach($mailings as $mail)
<tr> <tr>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6 lg:pl-8">{{ $mail->id }}</td> <td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6 lg:pl-8">{{ $mail->id }}</td>
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{ $mail->subject }}</td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500 max-w-[300px] truncate ...">{{ $mail->subject }}</td>
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500"> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
<livewire:components.badge :status="$mail->status" :id="$mail->id" <livewire:components.badge :status="$mail->status" :id="$mail->id"
type="mailing" type="mailing"
wire:key="{{$mail->id}}"></livewire:components.badge> wire:key="{{$mail->id}}"></livewire:components.badge>
</td> </td>
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{ $mail->recipients()->count() }}</td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{ $mail->recipients()->count() }}</td>
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{ $mail->attachments()->pluck('name')->join( ', ') }}</td> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500 max-w-[250px] truncate ...">
{{ $mail->attachments()->pluck('name')->join( ', ') }}
</td>
<td class="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-0"> <td class="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-0">
<button type="button" wire:click="showMailingDetailsModal({{ $mail->id }})" x-on:click="$dispatch('preview',{mail: {{$mail}}})" <button type="button" wire:click="showMailingDetailsModal({{ $mail->id }})"
class="text-indigo-600 hover:text-indigo-900">Show x-on:click="$dispatch('preview',{mail: {{$mail}}})"
class="text-indigo-600 hover:text-indigo-900"><i class="fa-solid fa-eye"></i>
</button> </button>
</td> </td>
</tr> </tr>
@ -67,6 +73,7 @@ class="text-indigo-600 hover:text-indigo-900">Show
</div> </div>
</div> </div>
</div> </div>
</div>
<x-modal wire:model="mailingDetailsModal"> <x-modal wire:model="mailingDetailsModal">
<x-form-modal submit="saveProject"> <x-form-modal submit="saveProject">
<x-slot name="title"> <x-slot name="title">

View file

@ -1,7 +1,7 @@
<div> <div>
<div class="px-4"> <div class="px-4">
<div class="sm:flex sm:flex-col sm:items-center"> <div class="sm:flex sm:flex-col sm:items-center">
<div class="flex justify-between w-full my-4"> <div class="flex flex-col md:flex-row justify-between w-full my-4">
<h1 class="text-base font-semibold leading-6 text-gray-900">Mosaics</h1> <h1 class="text-base font-semibold leading-6 text-gray-900">Mosaics</h1>
<livewire:components.pending-message :project="$project" type="mosaics"></livewire:components.pending-message> <livewire:components.pending-message :project="$project" type="mosaics"></livewire:components.pending-message>
</div> </div>

View file

@ -1,11 +1,11 @@
<div class="m-2"> <div>
<div class=""> <div class="px-4">
<div class="sm:flex sm:flex-col sm:items-center"> <div class="sm:flex sm:flex-col sm:items-center">
<div class="w-full flex justify-between my-4"> <div class="flex flex-col md:flex-row justify-between w-full my-4">
<h1 class="text-base font-semibold leading-6 text-gray-900">Reports</h1> <h1 class="text-base font-semibold leading-6 text-gray-900">Reports</h1>
<livewire:components.pending-message :project="$project" type="reports"></livewire:components.pending-message> <livewire:components.pending-message :project="$project" type="reports"></livewire:components.pending-message>
</div> </div>
<div class="mt-4 md:mt-0 flex flex-col md:flex md:justify-between md:flex-row w-full gap-2"> <div class="flex flex-col md:flex-row mt-4 items-center md:justify-between w-full gap-2">
<x-search></x-search> <x-search></x-search>
<x-button wire:click="openCreateReportModal" <x-button wire:click="openCreateReportModal"
class="flex justify-center rounded-md bg-indigo-600 px-3 py-2 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"> class="flex justify-center rounded-md bg-indigo-600 px-3 py-2 text-center text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
@ -52,7 +52,6 @@ class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 lg
</div> </div>
</div> </div>
</div> </div>
<x-report-manager-properties-modal :reportManager="$this"/> <x-report-manager-properties-modal :reportManager="$this"/>
</div> </div>

View file

@ -40,10 +40,9 @@
this.initMap(); this.initMap();
this.initMapLayer(); this.initMapLayer();
this.addLayer(data,type); this.addLayer(data,type);
console.log('GeoJson loaded on the map.'); console.log('GeoJson loaded.');
}, },
addLayerData(data,layer){ addLayerData(data,layer){
console.log('here');
var basicColors = ['orange', 'purple']; var basicColors = ['orange', 'purple'];
if(data && layer){ if(data && layer){
layer.clearLayers(); layer.clearLayers();
@ -64,9 +63,11 @@
switch(type){ switch(type){
case 'pivot_file': case 'pivot_file':
this.addLayerData(layerData,window.pivotLayer); this.addLayerData(layerData,window.pivotLayer);
console.log('Pivot file added.');
break; break;
case 'span_file': case 'span_file':
this.addLayerData(layerData,window.spanLayer); this.addLayerData(layerData,window.spanLayer);
console.log('Span file added.');
break; break;
default: default:
break; break;
@ -87,8 +88,12 @@
<div class="md:w-2/3"> <div class="md:w-2/3">
<form x-init=" <form x-init="
$nextTick(() => { $nextTick(() => {
@if($formData['pivot_file'])
showMap({{$formData['pivot_file']}},'pivot_file'); showMap({{$formData['pivot_file']}},'pivot_file');
showMap({{$formData['span_file']}},'span_file') @endif
@if($formData['span_file'])
showMap({{$formData['span_file']}},'span_file');
@endif
}) })
"> ">
<div id="map"> <div id="map">