wip
This commit is contained in:
13
app/Data/ServerMetadata.php
Normal file
13
app/Data/ServerMetadata.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Data;
|
||||
|
||||
use App\Enums\ProxyTypes;
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
class ServerMetadata extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public ?ProxyTypes $proxy,
|
||||
) {}
|
||||
}
|
||||
10
app/Enums/ProxyTypes.php
Normal file
10
app/Enums/ProxyTypes.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum ProxyTypes: string
|
||||
{
|
||||
case TRAEFIK_V2 = 'TRAEFIK_V2';
|
||||
case NGINX = 'NGINX';
|
||||
case CADDY = 'CADDY';
|
||||
}
|
||||
@@ -62,6 +62,7 @@ class ProjectController extends Controller
|
||||
if (!$application) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
|
||||
$activity = Activity::query()
|
||||
->where('properties->type', '=', 'deployment')
|
||||
->where('properties->uuid', '=', $deployment_uuid)
|
||||
|
||||
16
app/Http/Controllers/ServerController.php
Normal file
16
app/Http/Controllers/ServerController.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Server;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ServerController extends Controller
|
||||
{
|
||||
public function show(Server $server)
|
||||
{
|
||||
return view('server.show', [
|
||||
'server' => $server,
|
||||
]);
|
||||
}
|
||||
}
|
||||
44
app/Http/Livewire/ActivityMonitor.php
Normal file
44
app/Http/Livewire/ActivityMonitor.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class ActivityMonitor extends Component
|
||||
{
|
||||
public $activityId;
|
||||
public $isPollingActive = false;
|
||||
|
||||
protected $activity;
|
||||
protected $listeners = ['newMonitorActivity'];
|
||||
|
||||
public function hydrateActivity()
|
||||
{
|
||||
$this->activity = Activity::query()
|
||||
->find($this->activityId);
|
||||
}
|
||||
|
||||
public function newMonitorActivity($activityId)
|
||||
{
|
||||
$this->activityId = $activityId;
|
||||
|
||||
$this->hydrateActivity();
|
||||
|
||||
$this->isPollingActive = true;
|
||||
}
|
||||
|
||||
public function polling()
|
||||
{
|
||||
$this->hydrateActivity();
|
||||
|
||||
if (data_get($this->activity, 'properties.exitCode') !== null) {
|
||||
$this->isPollingActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.activity-monitor');
|
||||
}
|
||||
}
|
||||
30
app/Http/Livewire/Server/Proxy.php
Normal file
30
app/Http/Livewire/Server/Proxy.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Server;
|
||||
|
||||
use App\Models\Server;
|
||||
use Livewire\Component;
|
||||
|
||||
class Proxy extends Component
|
||||
{
|
||||
public Server $server;
|
||||
|
||||
protected string $selectedProxy = '';
|
||||
|
||||
public function mount(Server $server)
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
|
||||
public function runInstallProxy()
|
||||
{
|
||||
$activity = remoteProcess(['ls -alh'], $this->server);
|
||||
|
||||
$this->emit('newMonitorActivity', $activity->id);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.server.proxy');
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Spatie\SchemalessAttributes\Casts\SchemalessAttributes;
|
||||
|
||||
class Server extends BaseModel
|
||||
{
|
||||
protected static function booted()
|
||||
@@ -12,10 +15,21 @@ class Server extends BaseModel
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
public $casts = [
|
||||
'extra_attributes' => SchemalessAttributes::class,
|
||||
];
|
||||
|
||||
public function scopeWithExtraAttributes(): Builder
|
||||
{
|
||||
return $this->extra_attributes->modelScope();
|
||||
}
|
||||
|
||||
public function privateKey()
|
||||
{
|
||||
return $this->belongsTo(PrivateKey::class);
|
||||
}
|
||||
|
||||
public function settings()
|
||||
{
|
||||
return $this->hasOne(ServerSetting::class);
|
||||
|
||||
Reference in New Issue
Block a user