-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f585b7
commit f0b8aac
Showing
25 changed files
with
500 additions
and
75 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
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
7 changes: 7 additions & 0 deletions
7
app/Events/NodeTaskGroups/BackupCreate/BackupCreateCompleted.php
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,7 @@ | ||
<?php | ||
|
||
namespace App\Events\NodeTaskGroups\BackupCreate; | ||
|
||
use App\Events\NodeTaskGroups\BaseTaskGroupEvent; | ||
|
||
class BackupCreateCompleted extends BaseTaskGroupEvent {} |
7 changes: 7 additions & 0 deletions
7
app/Events/NodeTaskGroups/BackupCreate/BackupCreateFailed.php
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,7 @@ | ||
<?php | ||
|
||
namespace App\Events\NodeTaskGroups\BackupCreate; | ||
|
||
use App\Events\NodeTaskGroups\BaseTaskGroupEvent; | ||
|
||
class BackupCreateFailed extends BaseTaskGroupEvent {} |
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,34 @@ | ||
<?php | ||
|
||
namespace App\Events\NodeTaskGroups; | ||
|
||
use App\Models\NodeTaskGroup; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Broadcasting\PrivateChannel; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class BaseTaskGroupEvent | ||
{ | ||
use Dispatchable, InteractsWithSockets, SerializesModels; | ||
|
||
/** | ||
* Create a new event instance. | ||
*/ | ||
public function __construct(public NodeTaskGroup $taskGroup) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Get the channels the event should broadcast on. | ||
* | ||
* @return array<int, \Illuminate\Broadcasting\Channel> | ||
*/ | ||
public function broadcastOn(): array | ||
{ | ||
return [ | ||
new PrivateChannel('channel-name'), | ||
]; | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\Backup; | ||
use App\Models\Service; | ||
use Inertia\Inertia; | ||
use Inertia\Response; | ||
|
||
class ServiceBackupController extends Controller | ||
{ | ||
public function index(Service $service): Response | ||
{ | ||
$backups = Backup::where('service_id', $service->id)->latest()->paginate(); | ||
$s3Storages = $service->swarm->data->s3Storages; | ||
|
||
return Inertia::render('Services/Backups', ['service' => $service, 'backups' => $backups, 's3Storages' => $s3Storages]); | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
namespace App\Listeners; | ||
|
||
use App\Events\NodeTaskGroups\BackupCreate\BackupCreateCompleted; | ||
use App\Events\NodeTaskGroups\BackupCreate\BackupCreateFailed; | ||
use App\Models\Backup; | ||
use App\Models\BackupStatus; | ||
use Illuminate\Events\Dispatcher; | ||
|
||
class RecordBackupStatus | ||
{ | ||
/** | ||
* Create the event listener. | ||
*/ | ||
public function __construct() | ||
{ | ||
// | ||
} | ||
|
||
public function subscribe(Dispatcher $dispatcher): array | ||
{ | ||
return [ | ||
BackupCreateCompleted::class => 'handleCompleted', | ||
BackupCreateFailed::class => 'handleFailed', | ||
]; | ||
} | ||
|
||
/** | ||
* Handle the event. | ||
*/ | ||
public function handleCompleted(BackupCreateCompleted $event): void | ||
{ | ||
Backup::where('task_group_id', $event->taskGroup->id)->update(['status' => BackupStatus::Succeeded, 'ended_at' => now()]); | ||
} | ||
|
||
public function handleFailed(BackupCreateFailed $event): void | ||
{ | ||
Backup::where('task_group_id', $event->taskGroup->id)->update(['status' => BackupStatus::Failed, 'ended_at' => now()]); | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use App\Traits\HasOwningTeam; | ||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Backup extends Model | ||
{ | ||
use HasFactory; | ||
use HasOwningTeam; | ||
} |
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,10 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
enum BackupStatus: string | ||
{ | ||
case InProgress = 'in_progress'; | ||
case Succeeded = 'succeeded'; | ||
case Failed = 'failed'; | ||
} |
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,12 @@ | ||
<?php | ||
|
||
namespace App\Models\DeploymentData; | ||
|
||
use Spatie\LaravelData\Data; | ||
|
||
class BackupRestoreOptions extends Data | ||
{ | ||
public function __construct( | ||
public ?Volume $restoreVolume, | ||
) {} | ||
} |
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
Oops, something went wrong.