fix: service status indicator + oauth saving
This commit is contained in:
@@ -11,6 +11,8 @@ class OauthSetting extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['provider', 'client_id', 'client_secret', 'redirect_uri', 'tenant', 'base_url', 'enabled'];
|
||||
|
||||
protected function clientSecret(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
@@ -18,4 +20,16 @@ class OauthSetting extends Model
|
||||
set: fn (?string $value) => empty($value) ? null : Crypt::encryptString($value),
|
||||
);
|
||||
}
|
||||
|
||||
public function couldBeEnabled(): bool
|
||||
{
|
||||
switch ($this->provider) {
|
||||
case 'azure':
|
||||
return filled($this->client_id) && filled($this->client_secret) && filled($this->redirect_uri) && filled($this->tenant);
|
||||
case 'authentik':
|
||||
return filled($this->client_id) && filled($this->client_secret) && filled($this->redirect_uri) && filled($this->base_url);
|
||||
default:
|
||||
return filled($this->client_id) && filled($this->client_secret) && filled($this->redirect_uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class Service extends BaseModel
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
protected $appends = ['server_status'];
|
||||
protected $appends = ['server_status', 'status'];
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
@@ -105,12 +105,12 @@ class Service extends BaseModel
|
||||
|
||||
public function isRunning()
|
||||
{
|
||||
return (bool) str($this->status())->contains('running');
|
||||
return (bool) str($this->status)->contains('running');
|
||||
}
|
||||
|
||||
public function isExited()
|
||||
{
|
||||
return (bool) str($this->status())->contains('exited');
|
||||
return (bool) str($this->status)->contains('exited');
|
||||
}
|
||||
|
||||
public function type()
|
||||
@@ -213,7 +213,7 @@ class Service extends BaseModel
|
||||
instant_remote_process(["docker network rm {$uuid}"], $server, false);
|
||||
}
|
||||
|
||||
public function status()
|
||||
public function getStatusAttribute()
|
||||
{
|
||||
$applications = $this->applications;
|
||||
$databases = $this->databases;
|
||||
|
||||
Reference in New Issue
Block a user