This commit is contained in:
Andras Bacsai
2023-04-19 12:42:15 +02:00
parent d6c725ea83
commit d947175e4b
35 changed files with 333 additions and 112 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Http\Livewire;
use App\Jobs\DeployApplicationJob;
use App\Models\Application;
use Illuminate\Support\Facades\Route;
use Livewire\Component;
use Visus\Cuid2\Cuid2;
@@ -14,36 +15,31 @@ class DeployApplication extends Component
public $status;
public Application $application;
public $destination;
public array $parameters;
protected string $deployment_uuid;
protected array $command = [];
protected $source;
public function mount($applicationId)
public function mount()
{
$this->application = Application::find($applicationId)->first();
$this->parameters = Route::current()->parameters();
$this->application = Application::find($this->applicationId)->first();
$this->destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first();
}
public function render()
{
return view('livewire.deploy-application');
}
public function start()
{
// Create Deployment ID
$this->deployment_uuid = new Cuid2(7);
$this->parameters['deployment_uuid'] = $this->deployment_uuid;
dispatch(new DeployApplicationJob(
deployment_uuid: $this->deployment_uuid,
application_uuid: $this->application->uuid,
));
$currentUrl = url()->previous();
$deploymentUrl = "$currentUrl/deployment/$this->deployment_uuid";
return redirect($deploymentUrl);
return redirect()->route('project.applications.deployment', $this->parameters);
}
public function stop()