66use Illuminate \Support \Facades \Auth ;
77use Illuminate \Support \Facades \Hash ;
88use Livewire \Component ;
9+ use Spatie \Url \Url ;
910
1011class ServiceApplicationView extends Component
1112{
@@ -31,13 +32,7 @@ class ServiceApplicationView extends Component
3132
3233 public function updatedApplicationFqdn ()
3334 {
34- $ this ->application ->fqdn = str ($ this ->application ->fqdn )->replaceEnd (', ' , '' )->trim ();
35- $ this ->application ->fqdn = str ($ this ->application ->fqdn )->replaceStart (', ' , '' )->trim ();
36- $ this ->application ->fqdn = str ($ this ->application ->fqdn )->trim ()->explode (', ' )->map (function ($ domain ) {
37- return str ($ domain )->trim ()->lower ();
38- });
39- $ this ->application ->fqdn = $ this ->application ->fqdn ->unique ()->implode (', ' );
40- $ this ->application ->save ();
35+
4136 }
4237
4338 public function instantSave ()
@@ -83,6 +78,14 @@ public function mount()
8378 public function submit ()
8479 {
8580 try {
81+ $ this ->application ->fqdn = str ($ this ->application ->fqdn )->replaceEnd (', ' , '' )->trim ();
82+ $ this ->application ->fqdn = str ($ this ->application ->fqdn )->replaceStart (', ' , '' )->trim ();
83+ $ this ->application ->fqdn = str ($ this ->application ->fqdn )->trim ()->explode (', ' )->map (function ($ domain ) {
84+ Url::fromString ($ domain , ['http ' , 'https ' ]);
85+ return str ($ domain )->trim ()->lower ();
86+ });
87+ $ this ->application ->fqdn = $ this ->application ->fqdn ->unique ()->implode (', ' );
88+
8689 check_domain_usage (resource: $ this ->application );
8790 $ this ->validate ();
8891 $ this ->application ->save ();
@@ -92,10 +95,13 @@ public function submit()
9295 } else {
9396 $ this ->dispatch ('success ' , 'Service saved. ' );
9497 }
98+ $ this ->dispatch ('generateDockerCompose ' );
9599 } catch (\Throwable $ e ) {
100+ $ originalFqdn = $ this ->application ->getOriginal ('fqdn ' );
101+ if ($ originalFqdn !== $ this ->application ->fqdn ) {
102+ $ this ->application ->fqdn = $ originalFqdn ;
103+ }
96104 return handleError ($ e , $ this );
97- } finally {
98- $ this ->dispatch ('generateDockerCompose ' );
99105 }
100106 }
101107
0 commit comments