|
2 | 2 |
|
3 | 3 | namespace App\Livewire\Project\Application;
|
4 | 4 |
|
| 5 | +use App\Actions\Application\GenerateConfig; |
5 | 6 | use App\Models\Application;
|
6 | 7 | use Illuminate\Support\Collection;
|
7 | 8 | use Livewire\Component;
|
@@ -243,12 +244,19 @@ public function updatedApplicationBaseDirectory()
|
243 | 244 |
|
244 | 245 | public function updatedApplicationFqdn()
|
245 | 246 | {
|
246 |
| - $this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim(); |
247 |
| - $this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim(); |
248 |
| - $this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) { |
249 |
| - return str($domain)->trim()->lower(); |
250 |
| - }); |
251 |
| - $this->application->fqdn = $this->application->fqdn->unique()->implode(','); |
| 247 | + try { |
| 248 | + $this->application->fqdn = str($this->application->fqdn)->replaceEnd(',', '')->trim(); |
| 249 | + $this->application->fqdn = str($this->application->fqdn)->replaceStart(',', '')->trim(); |
| 250 | + $this->application->fqdn = str($this->application->fqdn)->trim()->explode(',')->map(function ($domain) { |
| 251 | + return str($domain)->trim()->lower(); |
| 252 | + }); |
| 253 | + $this->application->fqdn = $this->application->fqdn->unique()->implode(','); |
| 254 | + $this->application->save(); |
| 255 | + } catch (\Throwable $e) { |
| 256 | + $originalFqdn = $this->application->getOriginal('fqdn'); |
| 257 | + $this->application->fqdn = $originalFqdn; |
| 258 | + return handleError($e, $this); |
| 259 | + } |
252 | 260 | $this->resetDefaultLabels();
|
253 | 261 | }
|
254 | 262 |
|
@@ -287,18 +295,22 @@ public function getWildcardDomain()
|
287 | 295 |
|
288 | 296 | public function resetDefaultLabels()
|
289 | 297 | {
|
290 |
| - if ($this->application->settings->is_container_label_readonly_enabled) { |
291 |
| - return; |
292 |
| - } |
293 |
| - $this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n"); |
294 |
| - $this->ports_exposes = $this->application->ports_exposes; |
295 |
| - $this->is_container_label_escape_enabled = $this->application->settings->is_container_label_escape_enabled; |
296 |
| - $this->application->custom_labels = base64_encode($this->customLabels); |
297 |
| - $this->application->save(); |
298 |
| - if ($this->application->build_pack === 'dockercompose') { |
299 |
| - $this->loadComposeFile(); |
| 298 | + try { |
| 299 | + if ($this->application->settings->is_container_label_readonly_enabled) { |
| 300 | + return; |
| 301 | + } |
| 302 | + $this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n"); |
| 303 | + $this->ports_exposes = $this->application->ports_exposes; |
| 304 | + $this->is_container_label_escape_enabled = $this->application->settings->is_container_label_escape_enabled; |
| 305 | + $this->application->custom_labels = base64_encode($this->customLabels); |
| 306 | + $this->application->save(); |
| 307 | + if ($this->application->build_pack === 'dockercompose') { |
| 308 | + $this->loadComposeFile(); |
| 309 | + } |
| 310 | + $this->dispatch('configurationChanged'); |
| 311 | + } catch (\Throwable $e) { |
| 312 | + return handleError($e, $this); |
300 | 313 | }
|
301 |
| - $this->dispatch('configurationChanged'); |
302 | 314 | }
|
303 | 315 |
|
304 | 316 | public function checkFqdns($showToaster = true)
|
@@ -413,4 +425,16 @@ public function submit($showToaster = true)
|
413 | 425 | $this->dispatch('configurationChanged');
|
414 | 426 | }
|
415 | 427 | }
|
| 428 | + public function downloadConfig() |
| 429 | + { |
| 430 | + $config = GenerateConfig::run($this->application, true); |
| 431 | + $fileName = str($this->application->name)->slug()->append('_config.json'); |
| 432 | + |
| 433 | + return response()->streamDownload(function () use ($config) { |
| 434 | + echo $config; |
| 435 | + }, $fileName, [ |
| 436 | + 'Content-Type' => 'application/json', |
| 437 | + 'Content-Disposition' => 'attachment; filename=' . $fileName, |
| 438 | + ]); |
| 439 | + } |
416 | 440 | }
|
0 commit comments