Merge branch 'next' of https://github.com/coollabsio/coolify into next
This commit is contained in:
		@@ -218,7 +218,7 @@ class Kernel extends ConsoleKernel
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if ($service) {
 | 
					            if ($service) {
 | 
				
			||||||
                if (str($service->status())->contains('running') === false) {
 | 
					                if (str($service->status)->contains('running') === false) {
 | 
				
			||||||
                    continue;
 | 
					                    continue;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,11 +53,7 @@ class ResourcesController extends Controller
 | 
				
			|||||||
        $resources = $resources->flatten();
 | 
					        $resources = $resources->flatten();
 | 
				
			||||||
        $resources = $resources->map(function ($resource) {
 | 
					        $resources = $resources->map(function ($resource) {
 | 
				
			||||||
            $payload = $resource->toArray();
 | 
					            $payload = $resource->toArray();
 | 
				
			||||||
            if ($resource->getMorphClass() === \App\Models\Service::class) {
 | 
					            $payload['status'] = $resource->status;
 | 
				
			||||||
                $payload['status'] = $resource->status();
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                $payload['status'] = $resource->status;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            $payload['type'] = $resource->type();
 | 
					            $payload['type'] = $resource->type();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return $payload;
 | 
					            return $payload;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -154,11 +154,7 @@ class ServersController extends Controller
 | 
				
			|||||||
                    'created_at' => $resource->created_at,
 | 
					                    'created_at' => $resource->created_at,
 | 
				
			||||||
                    'updated_at' => $resource->updated_at,
 | 
					                    'updated_at' => $resource->updated_at,
 | 
				
			||||||
                ];
 | 
					                ];
 | 
				
			||||||
                if ($resource->type() === 'service') {
 | 
					                $payload['status'] = $resource->status;
 | 
				
			||||||
                    $payload['status'] = $resource->status();
 | 
					 | 
				
			||||||
                } else {
 | 
					 | 
				
			||||||
                    $payload['status'] = $resource->status;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                return $payload;
 | 
					                return $payload;
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
@@ -237,11 +233,7 @@ class ServersController extends Controller
 | 
				
			|||||||
                'created_at' => $resource->created_at,
 | 
					                'created_at' => $resource->created_at,
 | 
				
			||||||
                'updated_at' => $resource->updated_at,
 | 
					                'updated_at' => $resource->updated_at,
 | 
				
			||||||
            ];
 | 
					            ];
 | 
				
			||||||
            if ($resource->type() === 'service') {
 | 
					            $payload['status'] = $resource->status;
 | 
				
			||||||
                $payload['status'] = $resource->status();
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                $payload['status'] = $resource->status;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return $payload;
 | 
					            return $payload;
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1072,7 +1072,7 @@ class ServicesController extends Controller
 | 
				
			|||||||
        if (! $service) {
 | 
					        if (! $service) {
 | 
				
			||||||
            return response()->json(['message' => 'Service not found.'], 404);
 | 
					            return response()->json(['message' => 'Service not found.'], 404);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (str($service->status())->contains('running')) {
 | 
					        if (str($service->status)->contains('running')) {
 | 
				
			||||||
            return response()->json(['message' => 'Service is already running.'], 400);
 | 
					            return response()->json(['message' => 'Service is already running.'], 400);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        StartService::dispatch($service);
 | 
					        StartService::dispatch($service);
 | 
				
			||||||
@@ -1150,7 +1150,7 @@ class ServicesController extends Controller
 | 
				
			|||||||
        if (! $service) {
 | 
					        if (! $service) {
 | 
				
			||||||
            return response()->json(['message' => 'Service not found.'], 404);
 | 
					            return response()->json(['message' => 'Service not found.'], 404);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (str($service->status())->contains('stopped') || str($service->status())->contains('exited')) {
 | 
					        if (str($service->status)->contains('stopped') || str($service->status)->contains('exited')) {
 | 
				
			||||||
            return response()->json(['message' => 'Service is already stopped.'], 400);
 | 
					            return response()->json(['message' => 'Service is already stopped.'], 400);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        StopService::dispatch($service);
 | 
					        StopService::dispatch($service);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,7 +27,7 @@ class Navbar extends Component
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function mount()
 | 
					    public function mount()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (str($this->service->status())->contains('running') && is_null($this->service->config_hash)) {
 | 
					        if (str($this->service->status)->contains('running') && is_null($this->service->config_hash)) {
 | 
				
			||||||
            $this->service->isConfigurationChanged(true);
 | 
					            $this->service->isConfigurationChanged(true);
 | 
				
			||||||
            $this->dispatch('configurationChanged');
 | 
					            $this->dispatch('configurationChanged');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,16 +35,26 @@ class SettingsOauth extends Component
 | 
				
			|||||||
        }, []);
 | 
					        }, []);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private function updateOauthSettings()
 | 
					    private function updateOauthSettings(?string $provider = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        foreach (array_values($this->oauth_settings_map) as &$setting) {
 | 
					        if ($provider) {
 | 
				
			||||||
            $setting->save();
 | 
					            $oauth = $this->oauth_settings_map[$provider];
 | 
				
			||||||
 | 
					            if (! $oauth->couldBeEnabled()) {
 | 
				
			||||||
 | 
					                $oauth->update(['enabled' => false]);
 | 
				
			||||||
 | 
					                throw new \Exception('OAuth settings are not complete for '.$oauth->provider.'.<br/>Please fill in all required fields.');
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            $oauth->save();
 | 
				
			||||||
 | 
					            $this->dispatch('success', 'OAuth settings for '.$oauth->provider.' updated successfully!');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function instantSave()
 | 
					    public function instantSave(string $provider)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->updateOauthSettings();
 | 
					        try {
 | 
				
			||||||
 | 
					            $this->updateOauthSettings($provider);
 | 
				
			||||||
 | 
					        } catch (\Exception $e) {
 | 
				
			||||||
 | 
					            return handleError($e, $this);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function submit()
 | 
					    public function submit()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,6 +11,8 @@ class OauthSetting extends Model
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    use HasFactory;
 | 
					    use HasFactory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected $fillable = ['provider', 'client_id', 'client_secret', 'redirect_uri', 'tenant', 'base_url', 'enabled'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected function clientSecret(): Attribute
 | 
					    protected function clientSecret(): Attribute
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return Attribute::make(
 | 
					        return Attribute::make(
 | 
				
			||||||
@@ -18,4 +20,16 @@ class OauthSetting extends Model
 | 
				
			|||||||
            set: fn (?string $value) => empty($value) ? null : Crypt::encryptString($value),
 | 
					            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 $guarded = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected $appends = ['server_status'];
 | 
					    protected $appends = ['server_status', 'status'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected static function booted()
 | 
					    protected static function booted()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -105,12 +105,12 @@ class Service extends BaseModel
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function isRunning()
 | 
					    public function isRunning()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return (bool) str($this->status())->contains('running');
 | 
					        return (bool) str($this->status)->contains('running');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function isExited()
 | 
					    public function isExited()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return (bool) str($this->status())->contains('exited');
 | 
					        return (bool) str($this->status)->contains('exited');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function type()
 | 
					    public function type()
 | 
				
			||||||
@@ -213,7 +213,7 @@ class Service extends BaseModel
 | 
				
			|||||||
        instant_remote_process(["docker network rm {$uuid}"], $server, false);
 | 
					        instant_remote_process(["docker network rm {$uuid}"], $server, false);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function status()
 | 
					    public function getStatusAttribute()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $applications = $this->applications;
 | 
					        $applications = $this->applications;
 | 
				
			||||||
        $databases = $this->databases;
 | 
					        $databases = $this->databases;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,7 @@ class Services extends Component
 | 
				
			|||||||
        public string $complexStatus = 'exited',
 | 
					        public string $complexStatus = 'exited',
 | 
				
			||||||
        public bool $showRefreshButton = true
 | 
					        public bool $showRefreshButton = true
 | 
				
			||||||
    ) {
 | 
					    ) {
 | 
				
			||||||
        $this->complexStatus = $service->status();
 | 
					        $this->complexStatus = $service->status;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,7 +22,7 @@
 | 
				
			|||||||
        </nav>
 | 
					        </nav>
 | 
				
			||||||
        @if ($service->isDeployable)
 | 
					        @if ($service->isDeployable)
 | 
				
			||||||
            <div class="flex flex-wrap order-first gap-2 items-center sm:order-last">
 | 
					            <div class="flex flex-wrap order-first gap-2 items-center sm:order-last">
 | 
				
			||||||
                @if (str($service->status())->contains('running'))
 | 
					                @if (str($service->status)->contains('running'))
 | 
				
			||||||
                    <x-dropdown>
 | 
					                    <x-dropdown>
 | 
				
			||||||
                        <x-slot:title>
 | 
					                        <x-slot:title>
 | 
				
			||||||
                            Advanced
 | 
					                            Advanced
 | 
				
			||||||
@@ -70,7 +70,7 @@
 | 
				
			|||||||
                            Stop
 | 
					                            Stop
 | 
				
			||||||
                        </x-slot:button-title>
 | 
					                        </x-slot:button-title>
 | 
				
			||||||
                    </x-modal-confirmation>
 | 
					                    </x-modal-confirmation>
 | 
				
			||||||
                @elseif (str($service->status())->contains('degraded'))
 | 
					                @elseif (str($service->status)->contains('degraded'))
 | 
				
			||||||
                    <button @click="$wire.dispatch('startEvent')" class="gap-2 button">
 | 
					                    <button @click="$wire.dispatch('startEvent')" class="gap-2 button">
 | 
				
			||||||
                        <svg class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
 | 
					                        <svg class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
 | 
				
			||||||
                            <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
 | 
					                            <g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
 | 
				
			||||||
@@ -99,7 +99,7 @@
 | 
				
			|||||||
                            Stop
 | 
					                            Stop
 | 
				
			||||||
                        </x-slot:button-title>
 | 
					                        </x-slot:button-title>
 | 
				
			||||||
                    </x-modal-confirmation>
 | 
					                    </x-modal-confirmation>
 | 
				
			||||||
                @elseif (str($service->status())->contains('exited'))
 | 
					                @elseif (str($service->status)->contains('exited'))
 | 
				
			||||||
                    <button wire:click='stop(true)' class="gap-2 button">
 | 
					                    <button wire:click='stop(true)' class="gap-2 button">
 | 
				
			||||||
                        <svg class="w-5 h-5" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
 | 
					                        <svg class="w-5 h-5" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
 | 
				
			||||||
                            <path fill="red" d="M26 20h-6v-2h6zm4 8h-6v-2h6zm-2-4h-6v-2h6z" />
 | 
					                            <path fill="red" d="M26 20h-6v-2h6zm4 8h-6v-2h6zm-2-4h-6v-2h6z" />
 | 
				
			||||||
@@ -150,8 +150,7 @@
 | 
				
			|||||||
        @else
 | 
					        @else
 | 
				
			||||||
            <div class="flex flex-wrap order-first gap-2 items-center sm:order-last">
 | 
					            <div class="flex flex-wrap order-first gap-2 items-center sm:order-last">
 | 
				
			||||||
                <div class="text-error">
 | 
					                <div class="text-error">
 | 
				
			||||||
                    Unable to deploy. <a
 | 
					                    Unable to deploy. <a class="underline font-bold cursor-pointer"
 | 
				
			||||||
                        class="underline font-bold cursor-pointer"
 | 
					 | 
				
			||||||
                        @click.prevent="activeTab = 'environment-variables'; window.location.hash = 'environment-variables'">
 | 
					                        @click.prevent="activeTab = 'environment-variables'; window.location.hash = 'environment-variables'">
 | 
				
			||||||
                        Required environment variables missing.</a>
 | 
					                        Required environment variables missing.</a>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,8 +18,8 @@
 | 
				
			|||||||
                <div class="p-4 border dark:border-coolgray-300">
 | 
					                <div class="p-4 border dark:border-coolgray-300">
 | 
				
			||||||
                    <h3>{{ ucfirst($oauth_setting->provider) }}</h3>
 | 
					                    <h3>{{ ucfirst($oauth_setting->provider) }}</h3>
 | 
				
			||||||
                    <div class="w-32">
 | 
					                    <div class="w-32">
 | 
				
			||||||
                        <x-forms.checkbox instantSave id="oauth_settings_map.{{ $oauth_setting->provider }}.enabled"
 | 
					                        <x-forms.checkbox instantSave="instantSave('{{ $oauth_setting->provider }}')"
 | 
				
			||||||
                            label="Enabled" />
 | 
					                            id="oauth_settings_map.{{ $oauth_setting->provider }}.enabled" label="Enabled" />
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                    <div class="flex flex-col w-full gap-2 xl:flex-row">
 | 
					                    <div class="flex flex-col w-full gap-2 xl:flex-row">
 | 
				
			||||||
                        <x-forms.input id="oauth_settings_map.{{ $oauth_setting->provider }}.client_id"
 | 
					                        <x-forms.input id="oauth_settings_map.{{ $oauth_setting->provider }}.client_id"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user