mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 09:54:44 +02:00
Add missing activity loggers on client area (#1060)
* Update Subuser Adds user deleted notification, Adds logger for creating subusers. * Update Tasks * ... * Update Schedule * Update Files * Update Database * Move `reinstall` to proper array * Add `:action` to deleted task log * Updates * Fix CreateSchedule * Fix Editing/Saving --------- Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
This commit is contained in:
parent
98ddb65509
commit
a9e4495c91
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Components\Forms\Actions;
|
namespace App\Filament\Components\Forms\Actions;
|
||||||
|
|
||||||
|
use App\Facades\Activity;
|
||||||
use App\Models\Database;
|
use App\Models\Database;
|
||||||
use App\Services\Databases\DatabasePasswordService;
|
use App\Services\Databases\DatabasePasswordService;
|
||||||
use Exception;
|
use Exception;
|
||||||
@ -44,6 +45,11 @@ class RotateDatabasePasswordAction extends Action
|
|||||||
$set('password', $database->password);
|
$set('password', $database->password);
|
||||||
$set('jdbc', $database->jdbc);
|
$set('jdbc', $database->jdbc);
|
||||||
|
|
||||||
|
Activity::event('server:database.rotate-password')
|
||||||
|
->subject($database)
|
||||||
|
->property('name', $database->database)
|
||||||
|
->log();
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title(trans('admin/databasehost.rotated'))
|
->title(trans('admin/databasehost.rotated'))
|
||||||
->success()
|
->success()
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Server\Resources\DatabaseResource\Pages;
|
namespace App\Filament\Server\Resources\DatabaseResource\Pages;
|
||||||
|
|
||||||
|
use App\Facades\Activity;
|
||||||
use App\Filament\Components\Forms\Actions\RotateDatabasePasswordAction;
|
use App\Filament\Components\Forms\Actions\RotateDatabasePasswordAction;
|
||||||
use App\Filament\Components\Tables\Columns\DateTimeColumn;
|
use App\Filament\Components\Tables\Columns\DateTimeColumn;
|
||||||
use App\Filament\Server\Resources\DatabaseResource;
|
use App\Filament\Server\Resources\DatabaseResource;
|
||||||
@ -75,7 +76,13 @@ class ListDatabases extends ListRecords
|
|||||||
->actions([
|
->actions([
|
||||||
ViewAction::make()
|
ViewAction::make()
|
||||||
->modalHeading(fn (Database $database) => 'Viewing ' . $database->database),
|
->modalHeading(fn (Database $database) => 'Viewing ' . $database->database),
|
||||||
DeleteAction::make(),
|
DeleteAction::make()
|
||||||
|
->after(function (Database $database) {
|
||||||
|
Activity::event('server:database.delete')
|
||||||
|
->subject($database)
|
||||||
|
->property('name', $database->database)
|
||||||
|
->log();
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,10 @@ class EditFiles extends Page
|
|||||||
/** @var Server $server */
|
/** @var Server $server */
|
||||||
$server = Filament::getTenant();
|
$server = Filament::getTenant();
|
||||||
|
|
||||||
|
Activity::event('server:file.read')
|
||||||
|
->property('file', $this->path)
|
||||||
|
->log();
|
||||||
|
|
||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Section::make('Editing: ' . $this->path)
|
Section::make('Editing: ' . $this->path)
|
||||||
|
@ -452,8 +452,8 @@ class ListFiles extends ListRecords
|
|||||||
->setServer($server)
|
->setServer($server)
|
||||||
->createDirectory($data['name'], $this->path);
|
->createDirectory($data['name'], $this->path);
|
||||||
|
|
||||||
Activity::event('server:file.write')
|
Activity::event('server:file.create-directory')
|
||||||
->property('file', join_paths($this->path, $data['name']))
|
->property(['directory' => $this->path, 'name' => $data['name']])
|
||||||
->log();
|
->log();
|
||||||
})
|
})
|
||||||
->form([
|
->form([
|
||||||
|
@ -3,8 +3,10 @@
|
|||||||
namespace App\Filament\Server\Resources\ScheduleResource\Pages;
|
namespace App\Filament\Server\Resources\ScheduleResource\Pages;
|
||||||
|
|
||||||
use App\Exceptions\DisplayException;
|
use App\Exceptions\DisplayException;
|
||||||
|
use App\Facades\Activity;
|
||||||
use App\Filament\Server\Resources\ScheduleResource;
|
use App\Filament\Server\Resources\ScheduleResource;
|
||||||
use App\Helpers\Utilities;
|
use App\Helpers\Utilities;
|
||||||
|
use App\Models\Schedule;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Exception;
|
use Exception;
|
||||||
@ -17,6 +19,16 @@ class CreateSchedule extends CreateRecord
|
|||||||
|
|
||||||
protected static bool $canCreateAnother = false;
|
protected static bool $canCreateAnother = false;
|
||||||
|
|
||||||
|
protected function afterCreate(): void
|
||||||
|
{
|
||||||
|
/** @var Schedule $schedule */
|
||||||
|
$schedule = $this->record;
|
||||||
|
|
||||||
|
Activity::event('server:schedule.create')
|
||||||
|
->property('name', $schedule->name)
|
||||||
|
->log();
|
||||||
|
}
|
||||||
|
|
||||||
protected function mutateFormDataBeforeCreate(array $data): array
|
protected function mutateFormDataBeforeCreate(array $data): array
|
||||||
{
|
{
|
||||||
if (!isset($data['server_id'])) {
|
if (!isset($data['server_id'])) {
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Filament\Server\Resources\ScheduleResource\Pages;
|
namespace App\Filament\Server\Resources\ScheduleResource\Pages;
|
||||||
|
|
||||||
|
use App\Facades\Activity;
|
||||||
use App\Filament\Server\Resources\ScheduleResource;
|
use App\Filament\Server\Resources\ScheduleResource;
|
||||||
|
use App\Models\Schedule;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
use Filament\Resources\Pages\EditRecord;
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
@ -10,10 +12,25 @@ class EditSchedule extends EditRecord
|
|||||||
{
|
{
|
||||||
protected static string $resource = ScheduleResource::class;
|
protected static string $resource = ScheduleResource::class;
|
||||||
|
|
||||||
|
protected function afterSave(): void
|
||||||
|
{
|
||||||
|
/** @var Schedule $schedule */
|
||||||
|
$schedule = $this->record;
|
||||||
|
|
||||||
|
Activity::event('server:schedule.update')
|
||||||
|
->property('name', $schedule->name)
|
||||||
|
->log();
|
||||||
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Actions\DeleteAction::make(),
|
Actions\DeleteAction::make()
|
||||||
|
->after(function ($record) {
|
||||||
|
Activity::event('server:schedule.delete')
|
||||||
|
->property('name', $record->name)
|
||||||
|
->log();
|
||||||
|
}),
|
||||||
$this->getSaveFormAction()->formId('form')->label('Save'),
|
$this->getSaveFormAction()->formId('form')->label('Save'),
|
||||||
$this->getCancelFormAction()->formId('form'),
|
$this->getCancelFormAction()->formId('form'),
|
||||||
];
|
];
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Server\Resources\ScheduleResource\Pages;
|
namespace App\Filament\Server\Resources\ScheduleResource\Pages;
|
||||||
|
|
||||||
|
use App\Facades\Activity;
|
||||||
use App\Filament\Server\Resources\ScheduleResource;
|
use App\Filament\Server\Resources\ScheduleResource;
|
||||||
use App\Models\Schedule;
|
use App\Models\Schedule;
|
||||||
use App\Filament\Components\Tables\Columns\DateTimeColumn;
|
use App\Filament\Components\Tables\Columns\DateTimeColumn;
|
||||||
@ -44,14 +45,20 @@ class ListSchedules extends ListRecords
|
|||||||
->actions([
|
->actions([
|
||||||
ViewAction::make(),
|
ViewAction::make(),
|
||||||
EditAction::make(),
|
EditAction::make(),
|
||||||
DeleteAction::make(),
|
DeleteAction::make()
|
||||||
|
->after(function (Schedule $schedule) {
|
||||||
|
Activity::event('server:schedule.delete')
|
||||||
|
->subject($schedule)
|
||||||
|
->property('name', $schedule->name)
|
||||||
|
->log();
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Actions\CreateAction::make(),
|
Actions\CreateAction::make()->label('New Schedule'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,8 +104,28 @@ class TasksRelationManager extends RelationManager
|
|||||||
$data['payload'] ??= '';
|
$data['payload'] ??= '';
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
|
})
|
||||||
|
->after(function ($data) {
|
||||||
|
/** @var Schedule $schedule */
|
||||||
|
$schedule = $this->getOwnerRecord();
|
||||||
|
|
||||||
|
Activity::event('server:task.update')
|
||||||
|
->subject($schedule)
|
||||||
|
->property(['name' => $schedule->name, 'action' => $data['action'], 'payload' => $data['payload']])
|
||||||
|
->log();
|
||||||
|
|
||||||
|
}),
|
||||||
|
DeleteAction::make()
|
||||||
|
->action(function (Task $task) {
|
||||||
|
/** @var Schedule $schedule */
|
||||||
|
$schedule = $this->getOwnerRecord();
|
||||||
|
$task->delete();
|
||||||
|
|
||||||
|
Activity::event('server:task.delete')
|
||||||
|
->subject($schedule)
|
||||||
|
->property(['name' => $schedule->name, 'action' => $task->action, 'payload' => $task->payload])
|
||||||
|
->log();
|
||||||
}),
|
}),
|
||||||
DeleteAction::make(),
|
|
||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
CreateAction::make()
|
CreateAction::make()
|
||||||
|
@ -108,6 +108,10 @@ class UserResource extends Resource
|
|||||||
$subuser = Subuser::query()->where('user_id', $user->id)->where('server_id', $server->id)->first();
|
$subuser = Subuser::query()->where('user_id', $user->id)->where('server_id', $server->id)->first();
|
||||||
$subuserDeletionService->handle($subuser, $server);
|
$subuserDeletionService->handle($subuser, $server);
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->title('User Deleted!')
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
}),
|
}),
|
||||||
EditAction::make()
|
EditAction::make()
|
||||||
->label('Edit User')
|
->label('Edit User')
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Server\Resources\UserResource\Pages;
|
namespace App\Filament\Server\Resources\UserResource\Pages;
|
||||||
|
|
||||||
|
use App\Facades\Activity;
|
||||||
use App\Filament\Server\Resources\UserResource;
|
use App\Filament\Server\Resources\UserResource;
|
||||||
use App\Models\Permission;
|
use App\Models\Permission;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
@ -395,6 +396,12 @@ class ListUsers extends ListRecords
|
|||||||
try {
|
try {
|
||||||
$service->handle($server, $email, $permissions);
|
$service->handle($server, $email, $permissions);
|
||||||
|
|
||||||
|
Activity::event('server:subuser.create')
|
||||||
|
->subject($data['email'])
|
||||||
|
->property([
|
||||||
|
'email' => $data['email'],
|
||||||
|
]);
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('User Invited!')
|
->title('User Invited!')
|
||||||
->success()
|
->success()
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Databases;
|
namespace App\Services\Databases;
|
||||||
|
|
||||||
|
use App\Facades\Activity;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\Database;
|
use App\Models\Database;
|
||||||
use App\Helpers\Utilities;
|
use App\Helpers\Utilities;
|
||||||
@ -105,6 +106,11 @@ class DatabaseManagementService
|
|||||||
$database->assignUserToDatabase($database->database, $database->username, $database->remote);
|
$database->assignUserToDatabase($database->database, $database->username, $database->remote);
|
||||||
$database->flush();
|
$database->flush();
|
||||||
|
|
||||||
|
Activity::event('server:database.create')
|
||||||
|
->subject($database)
|
||||||
|
->property('name', $database->database)
|
||||||
|
->log();
|
||||||
|
|
||||||
return $database;
|
return $database;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,6 @@ return [
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
'server' => [
|
'server' => [
|
||||||
'reinstall' => 'Reinstalled server',
|
|
||||||
'console' => [
|
'console' => [
|
||||||
'command' => 'Executed "<b>:command</b>" on the server',
|
'command' => 'Executed "<b>:command</b>" on the server',
|
||||||
],
|
],
|
||||||
@ -103,11 +102,12 @@ return [
|
|||||||
'task' => [
|
'task' => [
|
||||||
'create' => 'Created a new "<b>:action</b>" task for the <b>:name</b> schedule',
|
'create' => 'Created a new "<b>:action</b>" task for the <b>:name</b> schedule',
|
||||||
'update' => 'Updated the "<b>:action</b>" task for the <b>:name</b> schedule',
|
'update' => 'Updated the "<b>:action</b>" task for the <b>:name</b> schedule',
|
||||||
'delete' => 'Deleted a task for the <b>:name</b> schedule',
|
'delete' => 'Deleted the "<b>:action</b>" task for the <b>:name</b> schedule',
|
||||||
],
|
],
|
||||||
'settings' => [
|
'settings' => [
|
||||||
'rename' => 'Renamed the server from "<b>:old</b>" to "<b>:new</b>"',
|
'rename' => 'Renamed the server from "<b>:old</b>" to "<b>:new</b>"',
|
||||||
'description' => 'Changed the server description from "<b>:old</b>" to "<b>:new</b>"',
|
'description' => 'Changed the server description from "<b>:old</b>" to "<b>:new</b>"',
|
||||||
|
'reinstall' => 'Reinstalled server',
|
||||||
],
|
],
|
||||||
'startup' => [
|
'startup' => [
|
||||||
'edit' => 'Changed the <b>:variable</b> variable from "<b>:old</b>" to "<b>:new</b>"',
|
'edit' => 'Changed the <b>:variable</b> variable from "<b>:old</b>" to "<b>:new</b>"',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user