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,61 +1,66 @@
<div class="m-2"> <div>
<div class="sm:flex sm:flex-col"> <div class="px-4">
<div class="flex flex-col md:flex-row md:justify-between items-center w-full my-4"> <div class="sm:flex sm:flex-col">
<h1 class="text-base font-semibold leading-6 text-gray-900">Downloads</h1> <div class="flex flex-col md:flex-row justify-between w-full my-4">
<livewire:components.pending-message :project="$project" type="downloads"></livewire:components.pending-message> <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>
</div>
<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-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">
{{ __('Create Download') }}
</x-button>
</div>
</div> </div>
<div class="mt-4 sm:mt-0 flex flex-col sm:flex-row sm:justify-between gap-2"> <div class="mt-8 flow-root">
<x-search class="flex-1 w-full"></x-search> <div class="relative">
<x-button wire:click="openDownloadModal" <div class="">
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"> <div class="inline-block min-w-full py-2 align-middle">
{{ __('Create Download') }} <table class="min-w-full divide-y divide-gray-300">
</x-button> <thead>
</div>
</div>
<div class="mt-8 flow-root">
<div class="relative">
<div class="">
<div class="inline-block min-w-full py-2 align-middle">
<table class="min-w-full divide-y divide-gray-300">
<thead>
<tr>
<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">
Name
</th>
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
File
</th>
<th scope="col"
class="px-3 py-3.5 text-right pr-4 sm:pr-8 lg:pr-8 text-sm font-semibold text-gray-900">
Status
</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 bg-white">
@foreach($downloads as $download)
<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">{{ $download->name }}</td> <th scope="col"
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500"> class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 lg:pl-8">
{{ $download->path }} Name
</td> </th>
<td class="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6 lg:pr-8" <th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
> File
<livewire:components.badge :status="$download->status" :id="$download->id" type="download" wire:key="{{$download->id}}"></livewire:components.badge> </th>
</td> <th scope="col"
class="px-3 py-3.5 text-right pr-4 sm:pr-8 lg:pr-8 text-sm font-semibold text-gray-900">
Status
</th>
</tr> </tr>
@endforeach </thead>
</tbody> <tbody class="divide-y divide-gray-200 bg-white">
</table> @foreach($downloads as $download)
<tr>
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6 lg:pl-8">{{ $download->name }}</td>
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
{{ $download->path }}
</td>
<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>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="pt-4 flex justify-between items-center">
<div class="text-gray-700 text-sm">
Results: {{ \Illuminate\Support\Number::format($downloads->total()) }}
</div> </div>
<div class="pt-4 flex justify-between items-center">
<div class="text-gray-700 text-sm">
Results: {{ \Illuminate\Support\Number::format($downloads->total()) }}
</div>
{{ $downloads->links('livewire.pagination') }} {{ $downloads->links('livewire.pagination') }}
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -1,68 +1,75 @@
<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="inline-block min-w-full py-2 align-middle mb-10"> <div class="relative">
<div class=""> <div class="inline-block min-w-full py-2 align-middle mb-10">
<table class="min-w-full divide-y divide-gray-300"> <div class="">
<thead> <table class="min-w-full divide-y divide-gray-300">
<tr> <thead>
<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">
Id
</th>
<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('Subject')</th>
<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>
<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">@lang('Attachment')
</th>
<th scope="col" class="relative py-3.5 pl-3 pr-4 sm:pr-0">
<span class="sr-only">Edit</span>
</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
@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> <th scope="col"
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{ $mail->subject }}</td> class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6 lg:pl-8">
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500"> Id
<livewire:components.badge :status="$mail->status" :id="$mail->id" </th>
type="mailing" <th scope="col"
wire:key="{{$mail->id}}"></livewire:components.badge> 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>
</td> <th scope="col"
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{ $mail->recipients()->count() }}</td> 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>
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{ $mail->attachments()->pluck('name')->join( ', ') }}</td> <th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
<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}}})" </th>
class="text-indigo-600 hover:text-indigo-900">Show <th scope="col"
</button> class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">@lang('Attachment')
</td> </th>
<th scope="col" class="relative py-3.5 pl-3 pr-4 sm:pr-0">
<span class="sr-only">Edit</span>
</th>
</tr> </tr>
@endforeach </thead>
</tbody> <tbody class="divide-y divide-gray-200 bg-white">
</table> @foreach($mailings as $mail)
</div> <tr>
</div> <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>
<div class="pt-4 flex justify-between items-center"> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500 max-w-[300px] truncate ...">{{ $mail->subject }}</td>
<div class="text-gray-700 text-sm"> <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
Results: {{ \Illuminate\Support\Number::format($mailings->total()) }} <livewire:components.badge :status="$mail->status" :id="$mail->id"
type="mailing"
wire:key="{{$mail->id}}"></livewire:components.badge>
</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 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">
<button type="button" wire:click="showMailingDetailsModal({{ $mail->id }})"
x-on:click="$dispatch('preview',{mail: {{$mail}}})"
class="text-indigo-600 hover:text-indigo-900"><i class="fa-solid fa-eye"></i>
</button>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div> </div>
<div class="pt-4 flex justify-between items-center">
<div class="text-gray-700 text-sm">
Results: {{ \Illuminate\Support\Number::format($mailings->total()) }}
</div>
{{ $mailings->links('livewire.pagination') }} {{ $mailings->links('livewire.pagination') }}
</div>
</div> </div>
</div> </div>
</div> </div>

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">