This commit is contained in:
Bozhidar 2024-04-26 22:38:16 +03:00
parent de5bf44a98
commit d8d95fe007
2 changed files with 19 additions and 11 deletions

View file

@ -97,18 +97,24 @@ class Modules extends Page
file_put_contents($this->installLogFilePath, 'Installing ' . $module . '...' . PHP_EOL); file_put_contents($this->installLogFilePath, 'Installing ' . $module . '...' . PHP_EOL);
$postInstall = app()->make('Modules\\' . $module . '\\PostInstall'); try {
if (method_exists($postInstall, 'run')) { $postInstall = app()->make('Modules\\' . $module . '\\PostInstall');
$postInstall->setLogFile($this->installLogFilePath); if (method_exists($postInstall, 'run')) {
$postInstall->run();
} else { $postInstall->setLogFile($this->installLogFilePath);
$postInstall->run();
$this->dispatch('open-modal', id: 'install-module-modal', props: ['module' => $module]);
}
} catch(\Exception $e) {
$newModule = new Module(); $newModule = new Module();
$newModule->name = $module; $newModule->name = $module;
$newModule->namespace = 'Modules\\' . $module; $newModule->namespace = 'Modules\\' . $module;
$newModule->installed = 1; $newModule->installed = 1;
$newModule->save(); $newModule->save();
$this->installLogPulling = false;
} }
$this->dispatch('open-modal', id: 'install-module-modal', props: ['module' => $module]);
} }
} }

View file

@ -43,16 +43,18 @@
<div class="flex flex-col items-center w-16"> <div class="flex flex-col items-center w-16">
<x-filament::icon :icon="$module['logoIcon']" <x-filament::icon :icon="$module['logoIcon']"
class="w-12 h-12 text-primary-500"/> class="w-12 h-12 text-primary-500"/>
@if ($module['installed'])
<x-filament::badge class="bg-green-500 text-white mt-2">Installed</x-filament::badge>
@endif
</div> </div>
</div> </div>
<div class="flex justify-between items-center w-full"> <div class="flex justify-between items-center w-full">
<div class="flex flex-col"> <div class="flex flex-col">
<p> <div class="flex gap-2 items-center">
{{$module['name']}} {{$module['name']}}
</p> @if ($module['installed'])
<svg xmlns="http://www.w3.org/2000/svg" class="-mt-1 text-primary-500" width="1em" height="1em" viewBox="0 0 24 24">
<path fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="m5 12l5 5L20 7"></path>
</svg>
@endif
</div>
<p class="text-xs mt-1"> <p class="text-xs mt-1">
{{$module['category']}} {{$module['category']}}