This commit is contained in:
Bozhidar 2024-05-10 15:53:44 +03:00
parent d6a6875a70
commit 91bebbadc3
3 changed files with 26 additions and 12 deletions

View file

@ -18,6 +18,9 @@ class DownloadMicroweber implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public static $displayName = 'Download Microweber';
public static $displayDescription = 'Download Microweber core, modules and templates';
public function handle(): void
{
set_time_limit(0);

View file

@ -18,12 +18,18 @@ class JobQueueNotifications extends Component
$job->payload = json_decode($job->payload);
if (isset($job->payload->displayName)) {
$displayName = 'Unknown Job';
$displayDisplayDescription = '';
try {
$jobClassInstance = new $job->payload->displayName();
if (method_exists($jobClassInstance, 'getDisplayName')) {
$displayName = $jobClassInstance->getDisplayName();
$jobClassInstance = new \ReflectionClass($job->payload->displayName);
if ($jobClassInstance->getStaticPropertyValue('displayName')) {
$displayName = $jobClassInstance->getStaticPropertyValue('displayName');
}
if ($jobClassInstance->getStaticPropertyValue('displayDescription')) {
$displayDisplayDescription = $jobClassInstance->getStaticPropertyValue('displayDescription');
}
} catch (\Exception $e) {
$explodeDisplayName = explode('\\', $job->payload->displayName);
$displayName = end($explodeDisplayName);
@ -32,6 +38,7 @@ class JobQueueNotifications extends Component
$jobs[] = [
'id' => $job->id,
'displayName' => $displayName,
'displayDescription' => $displayDisplayDescription,
'status' => $job->attempts == 0 ? 'Pending' : 'Processing',
'createdAt' => $job->created_at
];

View file

@ -1,22 +1,26 @@
<div>
@foreach($jobs as $job)
<div class="fixed z-50 bottom-5 right-5 w-[22rem] rounded-xl text-black dark:text-white px-4 py-4 shadow-sm bg-white ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10">
<div class="fixed z-50 bottom-5 right-5 w-[24rem] rounded-xl text-black dark:text-white px-4 py-4 shadow-sm bg-white ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10">
<div class="w-full flex justify-between">
<div class="text-sm">
Runnning...
<div class="text-gray-500 dark:text-gray-400">
{{ $job['displayName'] }}
</div>
{{-- <div>
<svg xmlns="http://www.w3.org/2000/svg" class="w-4" viewBox="0 0 24 24">
<div>
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 text-gray-500 dark:text-gray-400 cursor-pointer" viewBox="0 0 24 24">
<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="m7 7l10 10M7 17L17 7" />
</svg>
</div>--}}
</div>
</div>
<div class="flex gap-2 items-center">
<div>
{{ $job['displayName']}}
<div class="flex gap-2 items-center mt-2">
<div class="text-sm">
@if(!empty($job['displayDescription']))
{{ $job['displayDescription'] }}
@else
Running...
@endif
</div>
</div>