mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-22 07:30:25 +00:00
add hosting backup view log
This commit is contained in:
parent
18a7c686c4
commit
538246e795
5 changed files with 70 additions and 0 deletions
|
@ -12,6 +12,7 @@ use App\Models\DatabaseUser;
|
||||||
use App\Models\HostingSubscriptionBackup;
|
use App\Models\HostingSubscriptionBackup;
|
||||||
use App\Models\RemoteDatabaseServer;
|
use App\Models\RemoteDatabaseServer;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Infolists\Components\IconEntry;
|
use Filament\Infolists\Components\IconEntry;
|
||||||
use Filament\Infolists\Components\TextEntry;
|
use Filament\Infolists\Components\TextEntry;
|
||||||
|
@ -141,6 +142,19 @@ class ManageHostingSubscriptionBackups extends ManageRelatedRecords
|
||||||
|
|
||||||
return redirect($tempUrl);
|
return redirect($tempUrl);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
Tables\Actions\Action::make('viewLog')
|
||||||
|
->label('View Log')
|
||||||
|
->icon('heroicon-o-document')
|
||||||
|
->modalContent(function (HostingSubscriptionBackup $backup) {
|
||||||
|
return view('filament.modals.view-livewire-component', [
|
||||||
|
'component' => 'hosting-subscription-backup-log',
|
||||||
|
'componentProps' => [
|
||||||
|
'hostingSubscriptionBackupId' => $backup->id,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}),
|
||||||
|
|
||||||
Tables\Actions\ViewAction::make(),
|
Tables\Actions\ViewAction::make(),
|
||||||
// Tables\Actions\EditAction::make(),
|
// Tables\Actions\EditAction::make(),
|
||||||
Tables\Actions\DeleteAction::make(),
|
Tables\Actions\DeleteAction::make(),
|
||||||
|
|
37
web/app/Livewire/HostingSubscriptionBackupLog.php
Normal file
37
web/app/Livewire/HostingSubscriptionBackupLog.php
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class HostingSubscriptionBackupLog extends Component
|
||||||
|
{
|
||||||
|
public $hostingSubscriptionBackupId;
|
||||||
|
|
||||||
|
public $backupLog;
|
||||||
|
|
||||||
|
public function pullBackupLog()
|
||||||
|
{
|
||||||
|
$findHsb = \App\Models\HostingSubscriptionBackup::where('id', $this->hostingSubscriptionBackupId)->first();
|
||||||
|
if ($findHsb) {
|
||||||
|
$backupLog = $findHsb->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($hostingSubscriptionBackupId)
|
||||||
|
{
|
||||||
|
$this->hostingSubscriptionBackupId = $hostingSubscriptionBackupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function view()
|
||||||
|
{
|
||||||
|
return view('livewire.hosting-subscription-backup-log');
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ use App\Listeners\ModelDomainDeletingListener;
|
||||||
use App\Listeners\ModelHostingSubscriptionCreatingListener;
|
use App\Listeners\ModelHostingSubscriptionCreatingListener;
|
||||||
use App\Listeners\ModelHostingSubscriptionDeletingListener;
|
use App\Listeners\ModelHostingSubscriptionDeletingListener;
|
||||||
use App\Livewire\Components\QuickServiceRestartMenu;
|
use App\Livewire\Components\QuickServiceRestartMenu;
|
||||||
|
use App\Livewire\HostingSubscriptionBackupLog;
|
||||||
use App\Models\Domain;
|
use App\Models\Domain;
|
||||||
use App\Models\HostingSubscription;
|
use App\Models\HostingSubscription;
|
||||||
use App\Policies\CustomerPolicy;
|
use App\Policies\CustomerPolicy;
|
||||||
|
@ -63,6 +64,7 @@ class AppServiceProvider extends ServiceProvider
|
||||||
});
|
});
|
||||||
|
|
||||||
Livewire::component('quick-service-restart-menu', QuickServiceRestartMenu::class);
|
Livewire::component('quick-service-restart-menu', QuickServiceRestartMenu::class);
|
||||||
|
Livewire::component('hosting-subscription-backup-log', HostingSubscriptionBackupLog::class);
|
||||||
|
|
||||||
Gate::define('delete-customer', [CustomerPolicy::class, 'delete']);
|
Gate::define('delete-customer', [CustomerPolicy::class, 'delete']);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<div>
|
||||||
|
@livewire($component, $componentProps, key($component))
|
||||||
|
</div>
|
|
@ -0,0 +1,14 @@
|
||||||
|
<div>
|
||||||
|
<div id="js-backup-log" wire:poll="pullBackupLog" class="text-left text-sm font-medium text-gray-950 dark:text-yellow-500 h-[20rem] overflow-y-scroll">
|
||||||
|
|
||||||
|
{!! $this->backupLog !!}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.setInterval(function() {
|
||||||
|
var elem = document.getElementById('js-backup-log');
|
||||||
|
elem.scrollTop = elem.scrollHeight;
|
||||||
|
}, 3000);
|
||||||
|
</script>
|
||||||
|
</div>
|
Loading…
Reference in a new issue