This commit is contained in:
Bozhidar 2024-04-26 21:34:05 +03:00
parent 21b3b2074b
commit 8d231bf1b3
10 changed files with 101 additions and 7 deletions

View file

@ -4,6 +4,7 @@
"description": "", "description": "",
"keywords": [], "keywords": [],
"priority": 0, "priority": 0,
"hidden": true,
"providers": [ "providers": [
"Modules\\Customer\\App\\Providers\\CustomerServiceProvider" "Modules\\Customer\\App\\Providers\\CustomerServiceProvider"
], ],

View file

@ -4,6 +4,8 @@
"description": "", "description": "",
"keywords": [], "keywords": [],
"priority": 0, "priority": 0,
"logoIcon": "docker-logo",
"category": "DevOps",
"providers": [ "providers": [
"Modules\\Docker\\App\\Providers\\DockerServiceProvider" "Modules\\Docker\\App\\Providers\\DockerServiceProvider"
], ],

View file

@ -4,6 +4,8 @@
"description": "", "description": "",
"keywords": [], "keywords": [],
"priority": 0, "priority": 0,
"logoIcon": "lets_encrypt-logo",
"category": "Security",
"providers": [ "providers": [
"Modules\\LetsEncrypt\\App\\Providers\\LetsEncryptServiceProvider", "Modules\\LetsEncrypt\\App\\Providers\\LetsEncryptServiceProvider",
"Modules\\LetsEncrypt\\Providers\\Filament\\AdminPanelProvider" "Modules\\LetsEncrypt\\Providers\\Filament\\AdminPanelProvider"

View file

@ -4,6 +4,8 @@
"description": "", "description": "",
"keywords": [], "keywords": [],
"priority": 0, "priority": 0,
"logoIcon": "mw-mw_logo_small_white",
"category": "CMS",
"providers": [ "providers": [
"Modules\\Microweber\\App\\Providers\\MicroweberServiceProvider", "Modules\\Microweber\\App\\Providers\\MicroweberServiceProvider",
"Modules\\Microweber\\Providers\\Filament\\AdminPanelProvider" "Modules\\Microweber\\Providers\\Filament\\AdminPanelProvider"

View file

@ -18,6 +18,43 @@ class Modules extends Page
protected function getViewData(): array protected function getViewData(): array
{ {
$scanModules = scandir(base_path('Modules'));
$scanModules = array_diff($scanModules, ['.', '..']);
$modules = [];
foreach ($scanModules as $key => $module) {
if (!is_dir(base_path('Modules/' . $module))) {
unset($modules[$key]);
}
$moduleJson = file_get_contents(base_path('Modules/' . $module . '/module.json'));
$moduleJson = json_decode($moduleJson, true);
if (isset($moduleJson['hidden']) && $moduleJson['hidden'] == true) {
continue;
}
$category = 'All';
$logoIcon = 'heroicon-o-puzzle-piece';
if (isset($moduleJson['logoIcon'])) {
$logoIcon = $moduleJson['logoIcon'];
}
if (isset($moduleJson['category'])) {
$category = $moduleJson['category'];
}
$modules[$category][] = [
'name' => $module,
'description' => 'A drag and drop website builder and a powerful next-generation CMS.',
'url' => url('admin/' . $module),
'iconUrl' => url('images/modules/' . $module . '.png'),
'logoIcon' => $logoIcon,
'category' => 'Content Management',
];
}
return [
'categories' => $modules,
];
return [ return [
'categories' => [ 'categories' => [
'Security' => [ 'Security' => [

11
web/app/Models/Module.php Normal file
View file

@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Module extends Model
{
use HasFactory;
}

View file

@ -83,9 +83,9 @@ class AdminPanelProvider extends PanelProvider
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources') ->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages') ->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->discoverClusters(in: module_path('Microweber', 'Filament/Clusters'), for: 'Modules\\Microweber\\Filament\\Clusters') // ->discoverClusters(in: module_path('Microweber', 'Filament/Clusters'), for: 'Modules\\Microweber\\Filament\\Clusters')
->discoverClusters(in: module_path('LetsEncrypt', 'Filament/Clusters'), for: 'Modules\\LetsEncrypt\\Filament\\Clusters') // ->discoverClusters(in: module_path('LetsEncrypt', 'Filament/Clusters'), for: 'Modules\\LetsEncrypt\\Filament\\Clusters')
->discoverClusters(in: module_path('Docker', 'Filament/Clusters'), for: 'Modules\\Docker\\Filament\\Clusters') // ->discoverClusters(in: module_path('Docker', 'Filament/Clusters'), for: 'Modules\\Docker\\Filament\\Clusters')
->pages([ ->pages([
Pages\Dashboard::class, Pages\Dashboard::class,

View file

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('modules', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('namespace')->nullable();
$table->tinyInteger('installed')->nullable();
$table->string('version')->nullable();
$table->string('author')->nullable();
$table->string('description')->nullable();
$table->string('icon')->nullable();
$table->string('developer_url')->nullable();
$table->string('screenshot')->nullable();
$table->string('license')->nullable();
$table->string('license_url')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('modules');
}
};

View file

@ -16,7 +16,8 @@
<div class="mb-2"> <div class="mb-2">
<div class="w-12"> <div class="w-12">
<img src="{{$module['iconUrl']}}" /> <x-filament::icon :icon="$module['logoIcon']"
class="w-12 h-12 text-primary-500"/>
</div> </div>
</div> </div>