mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-25 00:50:32 +00:00
update
This commit is contained in:
parent
828d650d6d
commit
4a502ffb15
6 changed files with 84 additions and 15 deletions
|
@ -113,6 +113,26 @@ class BackupResource extends Resource
|
|||
|
||||
return redirect($tempUrl);
|
||||
}),
|
||||
|
||||
Tables\Actions\Action::make('viewLog')
|
||||
->label('View Log')
|
||||
->icon('heroicon-o-document')
|
||||
->hidden(function (Backup $backup) {
|
||||
$hide = false;
|
||||
if ($backup->status === BackupStatus::Completed) {
|
||||
$hide = true;
|
||||
}
|
||||
return $hide;
|
||||
})
|
||||
->modalContent(function (Backup $backup) {
|
||||
return view('filament.modals.view-livewire-component', [
|
||||
'component' => 'backup-log',
|
||||
'componentProps' => [
|
||||
'backupId' => $backup->id,
|
||||
],
|
||||
]);
|
||||
}),
|
||||
|
||||
Tables\Actions\ViewAction::make(),
|
||||
])
|
||||
->defaultSort('id', 'desc')
|
||||
|
@ -132,7 +152,7 @@ class BackupResource extends Resource
|
|||
public static function getWidgets(): array
|
||||
{
|
||||
return [
|
||||
BackupStats::class,
|
||||
// BackupStats::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ use Filament\Widgets\StatsOverviewWidget as BaseWidget;
|
|||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
||||
use Flowframe\Trend\Trend;
|
||||
use Flowframe\Trend\TrendValue;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class BackupStats extends BaseWidget
|
||||
{
|
||||
|
@ -25,21 +26,28 @@ class BackupStats extends BaseWidget
|
|||
|
||||
protected function getStats(): array
|
||||
{
|
||||
$findBackups = Backup::select(['id'])->where('status', 'processing')->get();
|
||||
if ($findBackups->count() > 0) {
|
||||
foreach ($findBackups as $backup) {
|
||||
$backup->checkBackup();
|
||||
|
||||
$stats = Cache::remember('backup-stats', 300, function () {
|
||||
$findBackups = Backup::select(['id'])->where('status', 'processing')->get();
|
||||
if ($findBackups->count() > 0) {
|
||||
foreach ($findBackups as $backup) {
|
||||
$backup->checkBackup();
|
||||
}
|
||||
}
|
||||
}
|
||||
$usedSpace = 0;
|
||||
$backupPath = BackupStorage::getPath();
|
||||
if (is_dir($backupPath)) {
|
||||
$usedSpace = $this->getDirectorySize($backupPath);
|
||||
}
|
||||
$usedSpace = 0;
|
||||
$backupPath = BackupStorage::getPath();
|
||||
if (is_dir($backupPath)) {
|
||||
$usedSpace = $this->getDirectorySize($backupPath);
|
||||
}
|
||||
return [
|
||||
'totalBackups' => Backup::count(),
|
||||
'usedSpace' => $usedSpace,
|
||||
];
|
||||
});
|
||||
|
||||
return [
|
||||
Stat::make('Total backups', Backup::count()),
|
||||
Stat::make('Total used space', $usedSpace),
|
||||
Stat::make('Total backups', $stats['totalBackups']),
|
||||
Stat::make('Total used space', $stats['usedSpace']),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
37
web/app/Livewire/BackupLog.php
Normal file
37
web/app/Livewire/BackupLog.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class BackupLog extends Component
|
||||
{
|
||||
public $backupId;
|
||||
|
||||
public $backupLog;
|
||||
|
||||
public function pullBackupLog()
|
||||
{
|
||||
$findBackup = \App\Models\Backup::where('id', $this->backupId)->first();
|
||||
if ($findBackup) {
|
||||
$backupLog = $findBackup->path . '/backup.log';
|
||||
if (file_exists($backupLog)) {
|
||||
$backupLogContent = file_get_contents($backupLog);
|
||||
// Get last 1000 lines of the log
|
||||
$backupLogContent = substr($backupLogContent, -5000, 5000);
|
||||
$backupLogContent = str_replace("\n", "<br>", $backupLogContent);
|
||||
|
||||
$this->backupLog = $backupLogContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
public function mount($backupId)
|
||||
{
|
||||
$this->backupId = $backupId;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.hosting-subscription-backup-log');
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ class HostingSubscriptionBackupLog extends Component
|
|||
$this->hostingSubscriptionBackupId = $hostingSubscriptionBackupId;
|
||||
}
|
||||
|
||||
public function view()
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.hosting-subscription-backup-log');
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ use App\Listeners\ModelDomainCreatedListener;
|
|||
use App\Listeners\ModelDomainDeletingListener;
|
||||
use App\Listeners\ModelHostingSubscriptionCreatingListener;
|
||||
use App\Listeners\ModelHostingSubscriptionDeletingListener;
|
||||
use App\Livewire\BackupLog;
|
||||
use App\Livewire\Components\QuickServiceRestartMenu;
|
||||
use App\Livewire\HostingSubscriptionBackupLog;
|
||||
use App\Models\Domain;
|
||||
|
@ -65,6 +66,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
|
||||
Livewire::component('quick-service-restart-menu', QuickServiceRestartMenu::class);
|
||||
Livewire::component('hosting-subscription-backup-log', HostingSubscriptionBackupLog::class);
|
||||
Livewire::component('backup-log', BackupLog::class);
|
||||
|
||||
Gate::define('delete-customer', [CustomerPolicy::class, 'delete']);
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<div>
|
||||
@livewire($component, $componentProps, key($component))
|
||||
|
||||
@livewire($component, $componentProps)
|
||||
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue