-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add database notifications to all panels * add successful param to Installed event * add listener for Installed event * create event for subuser creation * add listener for SubUserAdded event * always send Installed event * create event for subuser removal * add listener for SubUserRemoved event * add prefix to server name * remove view action from SubUserRemoved notification
- Loading branch information
Showing
16 changed files
with
176 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\Events\Server; | ||
|
||
use App\Events\Event; | ||
use App\Models\Subuser; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class SubUserAdded extends Event | ||
{ | ||
use SerializesModels; | ||
|
||
/** | ||
* Create a new event instance. | ||
*/ | ||
public function __construct(public Subuser $subuser) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Events\Server; | ||
|
||
use App\Events\Event; | ||
use App\Models\Server; | ||
use App\Models\User; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class SubUserRemoved extends Event | ||
{ | ||
use SerializesModels; | ||
|
||
/** | ||
* Create a new event instance. | ||
*/ | ||
public function __construct(public Server $server, public User $user) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Listeners\Server; | ||
|
||
use App\Events\Server\Installed; | ||
use App\Filament\Server\Pages\Console; | ||
use Filament\Notifications\Actions\Action; | ||
use Filament\Notifications\Notification; | ||
|
||
class ServerInstalledListener | ||
{ | ||
public function handle(Installed $event): void | ||
{ | ||
$event->server->loadMissing('user'); | ||
|
||
Notification::make() | ||
->status($event->successful ? 'success' : 'danger') | ||
->title('Server ' . ($event->initialInstall ? 'Installation' : 'Reinstallation') . ' ' . ($event->successful ? 'completed' : 'failed')) | ||
->body('Server Name: ' . $event->server->name) | ||
->actions([ | ||
Action::make('view') | ||
->button() | ||
->label('Open Server') | ||
->markAsRead() | ||
->url(fn () => Console::getUrl(panel: 'server', tenant: $event->server)), | ||
]) | ||
->sendToDatabase($event->server->user); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Listeners\Server; | ||
|
||
use App\Events\Server\SubUserAdded; | ||
use App\Filament\Server\Pages\Console; | ||
use Filament\Notifications\Actions\Action; | ||
use Filament\Notifications\Notification; | ||
|
||
class SubUserAddedListener | ||
{ | ||
public function handle(SubUserAdded $event): void | ||
{ | ||
$event->subuser->loadMissing('server'); | ||
$event->subuser->loadMissing('user'); | ||
|
||
Notification::make() | ||
->title('Added to Server') | ||
->body('You have been added as a subuser to ' . $event->subuser->server->name . '.') | ||
->actions([ | ||
Action::make('view') | ||
->button() | ||
->label('Open Server') | ||
->markAsRead() | ||
->url(fn () => Console::getUrl(panel: 'server', tenant: $event->subuser->server)), | ||
]) | ||
->sendToDatabase($event->subuser->user); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\Listeners\Server; | ||
|
||
use App\Events\Server\SubUserRemoved; | ||
use Filament\Notifications\Notification; | ||
|
||
class SubUserRemovedListener | ||
{ | ||
public function handle(SubUserRemoved $event): void | ||
{ | ||
Notification::make() | ||
->title('Removed from Server') | ||
->body('You have been removed as a subuser from ' . $event->server->name . '.') | ||
->sendToDatabase($event->user); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters