mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-25 17:10:29 +00:00
update
This commit is contained in:
parent
c9ee8064b0
commit
1c879c04fe
4 changed files with 118 additions and 86 deletions
|
@ -6,6 +6,7 @@
|
|||
"priority": 0,
|
||||
"logoIcon": "docker-logo",
|
||||
"category": "DevOps",
|
||||
"adminUrl": "/admin/docker/docker-catalog",
|
||||
"providers": [
|
||||
"Modules\\Docker\\App\\Providers\\DockerServiceProvider"
|
||||
],
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Models\Module;
|
||||
use App\ModulesManager;
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
|
@ -25,42 +26,10 @@ class Modules extends Page
|
|||
|
||||
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'];
|
||||
}
|
||||
$url = '';
|
||||
$installed = 0;
|
||||
$findModule = Module::where('name', $module)->first();
|
||||
if ($findModule) {
|
||||
$installed = 1;
|
||||
}
|
||||
$modules[$category][] = [
|
||||
'name' => $module,
|
||||
'description' => 'A drag and drop website builder and a powerful next-generation CMS.',
|
||||
'url' => $url,
|
||||
'iconUrl' => url('images/modules/' . $module . '.png'),
|
||||
'logoIcon' => $logoIcon,
|
||||
'category' => 'Content Management',
|
||||
'installed'=>$installed,
|
||||
];
|
||||
$scanModules = ModulesManager::getModules();
|
||||
foreach ($scanModules as $module) {
|
||||
$modules[$module['category']][] = $module;
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -79,11 +48,8 @@ class Modules extends Page
|
|||
|
||||
if (Str::contains($this->installLog, 'Done')) {
|
||||
$this->installLogPulling = false;
|
||||
$newModule = new Module();
|
||||
$newModule->name = $this->installModule;
|
||||
$newModule->namespace = 'Modules\\' . $this->installModule;
|
||||
$newModule->installed = 1;
|
||||
$newModule->save();
|
||||
|
||||
ModulesManager::saveInstalledModule($this->installModule);
|
||||
|
||||
$this->dispatch('close-modal', id: 'install-module-modal');
|
||||
}
|
||||
|
@ -125,11 +91,7 @@ class Modules extends Page
|
|||
// dd($e->getMessage());
|
||||
}
|
||||
|
||||
$newModule = new Module();
|
||||
$newModule->name = $module;
|
||||
$newModule->namespace = 'Modules\\' . $module;
|
||||
$newModule->installed = 1;
|
||||
$newModule->save();
|
||||
ModulesManager::saveInstalledModule($module);
|
||||
|
||||
$this->installLogPulling = false;
|
||||
|
||||
|
|
72
web/app/ModulesManager.php
Normal file
72
web/app/ModulesManager.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use App\Models\Module;
|
||||
|
||||
class ModulesManager
|
||||
{
|
||||
public static function getModules()
|
||||
{
|
||||
$scanModules = scandir(base_path('Modules'));
|
||||
$scanModules = array_diff($scanModules, ['.', '..']);
|
||||
|
||||
$modules = [];
|
||||
foreach ($scanModules as $key => $module) {
|
||||
|
||||
$moduleInfo = self::getModuleInfo($module);
|
||||
if (empty($moduleInfo)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$modules[] = $moduleInfo;
|
||||
|
||||
}
|
||||
|
||||
return $modules;
|
||||
}
|
||||
|
||||
public static function getModuleInfo($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) {
|
||||
return [];
|
||||
}
|
||||
$category = 'All';
|
||||
$logoIcon = 'heroicon-o-puzzle-piece';
|
||||
if (isset($moduleJson['logoIcon'])) {
|
||||
$logoIcon = $moduleJson['logoIcon'];
|
||||
}
|
||||
if (isset($moduleJson['category'])) {
|
||||
$category = $moduleJson['category'];
|
||||
}
|
||||
$url = '';
|
||||
$installed = 0;
|
||||
$findModule = Module::where('name', $module)->first();
|
||||
if ($findModule) {
|
||||
$installed = 1;
|
||||
}
|
||||
return [
|
||||
'name' => $module,
|
||||
'description' => 'A drag and drop website builder and a powerful next-generation CMS.',
|
||||
'url' => $url,
|
||||
'iconUrl' => url('images/modules/' . $module . '.png'),
|
||||
'logoIcon' => $logoIcon,
|
||||
'category' => $category,
|
||||
'installed'=>$installed,
|
||||
];
|
||||
}
|
||||
|
||||
public static function saveInstalledModule($module)
|
||||
{
|
||||
$newModule = new Module();
|
||||
$newModule->name = $module;
|
||||
$newModule->namespace = 'Modules\\' . $module;
|
||||
$newModule->installed = 1;
|
||||
$newModule->save();
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ use App\Filament\Widgets\ServerDiskUsageStatistic;
|
|||
use App\Filament\Widgets\ServerMemoryStatistic;
|
||||
use App\Filament\Widgets\ServerMemoryStatisticCount;
|
||||
use App\Filament\Widgets\Websites;
|
||||
use App\Models\Module;
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||
|
@ -32,23 +33,8 @@ class AdminPanelProvider extends PanelProvider
|
|||
{
|
||||
public function panel(Panel $panel): Panel
|
||||
{
|
||||
$defaultColor = Color::Yellow;
|
||||
$brandLogo = asset('images/phyre-logo.svg');
|
||||
|
||||
if (!app()->runningInConsole()) {
|
||||
$isAppInstalled = file_exists(storage_path('installed'));
|
||||
if ($isAppInstalled) {
|
||||
if (setting('general.brand_logo_url')) {
|
||||
$brandLogo = setting('general.brand_logo_url');
|
||||
}
|
||||
if (setting('general.brand_primary_color')) {
|
||||
$defaultColor = Color::hex(setting('general.brand_primary_color'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $panel
|
||||
->default()
|
||||
$panel->default()
|
||||
->darkMode(true)
|
||||
->id('admin')
|
||||
->path('admin')
|
||||
|
@ -56,37 +42,12 @@ class AdminPanelProvider extends PanelProvider
|
|||
->font('Albert Sans')
|
||||
->sidebarWidth('15rem')
|
||||
// ->brandLogo(fn () => view('filament.admin.logo'))
|
||||
->brandLogo($brandLogo)
|
||||
->brandLogoHeight('2.2rem')
|
||||
->colors([
|
||||
'primary'=>$defaultColor,
|
||||
])
|
||||
// ->colors([
|
||||
// 'primary' => [
|
||||
// 50 => '249, 206, 38',
|
||||
// 100 => '249, 206, 38',
|
||||
// 200 => '249, 206, 38',
|
||||
// 300 => '249, 206, 38',
|
||||
// 400 => '249, 206, 38',
|
||||
// 500 => '249, 206, 38',
|
||||
// 600 => '249, 206, 38',
|
||||
// 700 => '249, 206, 38',
|
||||
// 800 => '249, 206, 38',
|
||||
// 900 => '249, 206, 38',
|
||||
// 950 => '249, 206, 38',
|
||||
// ],
|
||||
// ])
|
||||
->navigationGroups([
|
||||
'Hosting Services' => NavigationGroup::make()->label('Hosting Services'),
|
||||
'Server Management' => NavigationGroup::make()->label('Server Management'),
|
||||
])
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
|
||||
->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('LetsEncrypt', 'Filament/Clusters'), for: 'Modules\\LetsEncrypt\\Filament\\Clusters')
|
||||
// ->discoverClusters(in: module_path('Docker', 'Filament/Clusters'), for: 'Modules\\Docker\\Filament\\Clusters')
|
||||
|
||||
->pages([
|
||||
Pages\Dashboard::class,
|
||||
])
|
||||
|
@ -121,5 +82,41 @@ class AdminPanelProvider extends PanelProvider
|
|||
->authMiddleware([
|
||||
Authenticate::class,
|
||||
]);
|
||||
|
||||
$defaultColor = Color::Yellow;
|
||||
$brandLogo = asset('images/phyre-logo.svg');
|
||||
|
||||
if (!app()->runningInConsole()) {
|
||||
$isAppInstalled = file_exists(storage_path('installed'));
|
||||
if ($isAppInstalled) {
|
||||
if (setting('general.brand_logo_url')) {
|
||||
$brandLogo = setting('general.brand_logo_url');
|
||||
}
|
||||
if (setting('general.brand_primary_color')) {
|
||||
$defaultColor = Color::hex(setting('general.brand_primary_color'));
|
||||
}
|
||||
$findModules = Module::where('installed', 1)->get();
|
||||
if ($findModules->count() > 0) {
|
||||
foreach ($findModules as $module) {
|
||||
$modulePath = module_path($module->name, 'Filament/Clusters');
|
||||
if (is_dir($modulePath)) {
|
||||
$panel->discoverClusters(in: $modulePath, for: 'Modules\\' . $module->name . '\\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('Docker', 'Filament/Clusters'), for: 'Modules\\Docker\\Filament\\Clusters')
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$panel->brandLogo($brandLogo)
|
||||
->brandLogoHeight('2.2rem')
|
||||
->colors([
|
||||
'primary'=>$defaultColor,
|
||||
]);
|
||||
|
||||
return $panel;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue