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 Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Queue\SerializesModels;
@ -26,8 +27,8 @@ public function __construct($projectDownload)
* 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->setTimeout(3600);
$process->setTimeout(600);
$process->run();
if (!$process->isSuccessful()) {
logger('error', [$process->getErrorOutput()]);
$this->download->setStatusFailed();
return;
}
logger($process->getOutput());

View file

@ -27,7 +27,7 @@ public function project(): \Illuminate\Database\Eloquent\Relations\BelongsTo
protected static function booted(): void
{
parent::booted();
static::updated(function (ProjectDownload $projectDownload) {
self::updated(function (ProjectDownload $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"
@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){
$wire.setStatus(e.project{{ucfirst($this->type)}}.status);
$wire.refreshPendingMessage();
}
});"
x-destroy="Echo.leaveChannel(`{{$this->type}}.@js($this->id)`);"
x-destroy="Echo.leaveChannel(`{{$this->type}}.{{$this->id}}`);"
@endif
>
{{ $status }}

View file

@ -1,61 +1,66 @@
<div class="m-2">
<div class="sm:flex sm:flex-col">
<div class="flex flex-col md:flex-row md:justify-between items-center w-full my-4">
<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="px-4">
<div class="sm:flex sm:flex-col">
<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>
<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 class="mt-4 sm:mt-0 flex flex-col sm:flex-row sm:justify-between 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 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)
<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>
<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>
<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>
@endforeach
</tbody>
</table>
</thead>
<tbody class="divide-y divide-gray-200 bg-white">
@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 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>

View file

@ -1,68 +1,75 @@
<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="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>
<livewire:components.pending-message :project="$project"
type="mailings"></livewire:components.pending-message>
</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>
</div>
</div>
<div class="mt-8">
<div class="mt-8 flow-root overflow-x-scroll">
<div class="">
<div class="inline-block min-w-full py-2 align-middle mb-10">
<div class="">
<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">
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)
<div class="relative">
<div class="inline-block min-w-full py-2 align-middle mb-10">
<div class="">
<table class="min-w-full divide-y divide-gray-300">
<thead>
<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 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">
<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">{{ $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">Show
</button>
</td>
<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>
@endforeach
</tbody>
</table>
</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()) }}
</thead>
<tbody class="divide-y divide-gray-200 bg-white">
@foreach($mailings as $mail)
<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 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">
<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 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>

View file

@ -1,7 +1,7 @@
<div>
<div class="px-4 ">
<div class="px-4">
<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>
<livewire:components.pending-message :project="$project" type="mosaics"></livewire:components.pending-message>
</div>

View file

@ -1,11 +1,11 @@
<div class="m-2">
<div class="">
<div>
<div class="px-4">
<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>
<livewire:components.pending-message :project="$project" type="reports"></livewire:components.pending-message>
</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-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">
@ -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>
<x-report-manager-properties-modal :reportManager="$this"/>
</div>

View file

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