okay, now it is way better
This commit is contained in:
@@ -3,15 +3,12 @@
|
||||
namespace App\Http\Livewire\Project\Service;
|
||||
|
||||
use App\Models\ServiceApplication;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Component;
|
||||
|
||||
class Application extends Component
|
||||
{
|
||||
public ServiceApplication $application;
|
||||
public $parameters;
|
||||
public $fileStorages;
|
||||
protected $listeners = ["refreshFileStorages"];
|
||||
protected $rules = [
|
||||
'application.human_name' => 'nullable',
|
||||
'application.description' => 'nullable',
|
||||
@@ -28,10 +25,7 @@ class Application extends Component
|
||||
{
|
||||
$this->submit();
|
||||
}
|
||||
public function refreshFileStorages()
|
||||
{
|
||||
$this->fileStorages = $this->application->fileStorages()->get();
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
try {
|
||||
@@ -45,18 +39,16 @@ class Application extends Component
|
||||
public function mount()
|
||||
{
|
||||
$this->parameters = get_route_parameters();
|
||||
$this->fileStorages = collect();
|
||||
$this->refreshFileStorages();
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
try {
|
||||
$this->validate();
|
||||
$this->application->save();
|
||||
switchImage($this->application);
|
||||
updateCompose($this->application);
|
||||
$this->emit('success', 'Application saved successfully.');
|
||||
} catch (\Throwable $e) {
|
||||
ray($e);
|
||||
return handleError($e, $this);
|
||||
} finally {
|
||||
$this->emit('generateDockerCompose');
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class Database extends Component
|
||||
try {
|
||||
$this->validate();
|
||||
$this->database->save();
|
||||
switchImage($this->database);
|
||||
updateCompose($this->database);
|
||||
$this->emit('success', 'Database saved successfully.');
|
||||
} catch (\Throwable $e) {
|
||||
ray($e);
|
||||
|
||||
@@ -20,13 +20,17 @@ class FileStorage extends Component
|
||||
'fileStorage.mount_path' => 'required',
|
||||
'fileStorage.content' => 'nullable',
|
||||
];
|
||||
public function mount() {
|
||||
public function mount()
|
||||
{
|
||||
$this->service = $this->fileStorage->service;
|
||||
$this->fs_path = Str::of($this->fileStorage->fs_path)->beforeLast('/');
|
||||
$file = Str::of($this->fileStorage->fs_path)->afterLast('/');
|
||||
if (Str::of($this->fs_path)->startsWith('.')) {
|
||||
$this->fs_path = Str::of($this->fs_path)->after('.');
|
||||
$this->fs_path = $this->service->service->workdir() . $this->fs_path . "/" .$file;
|
||||
$this->fs_path = $this->service->service->workdir() . $this->fs_path . "/" . $file;
|
||||
}
|
||||
if ($this->fileStorage->is_directory) {
|
||||
$this->fs_path = Str::of($this->fileStorage->fs_path);
|
||||
}
|
||||
}
|
||||
public function submit()
|
||||
@@ -40,7 +44,8 @@ class FileStorage extends Component
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
public function instantSave() {
|
||||
public function instantSave()
|
||||
{
|
||||
$this->submit();
|
||||
}
|
||||
public function render()
|
||||
|
||||
@@ -34,19 +34,11 @@ class Index extends Component
|
||||
{
|
||||
$this->applications = $this->service->applications->sort();
|
||||
$this->applications->each(function ($application) {
|
||||
$application->fileStorages()->get()->each(function ($fileStorage) use ($application) {
|
||||
if (!$fileStorage->is_directory && $fileStorage->content == null) {
|
||||
$application->hasMissingFiles = true;
|
||||
}
|
||||
});
|
||||
$application->configuration_required = $application->configurationRequired();
|
||||
});
|
||||
$this->databases = $this->service->databases->sort();
|
||||
$this->databases->each(function ($database) {
|
||||
$database->fileStorages()->get()->each(function ($fileStorage) use ($database) {
|
||||
if (!$fileStorage->is_directory && $fileStorage->content == null) {
|
||||
$database->hasMissingFiles = true;
|
||||
}
|
||||
});
|
||||
$database->configuration_required = $database->configurationRequired();
|
||||
});
|
||||
$this->emit('success', 'Stack refreshed successfully.');
|
||||
}
|
||||
@@ -61,24 +53,29 @@ class Index extends Component
|
||||
{
|
||||
return view('livewire.project.service.index');
|
||||
}
|
||||
public function save()
|
||||
{
|
||||
try {
|
||||
$this->service->save();
|
||||
$this->service->parse();
|
||||
$this->service->refresh();
|
||||
$this->emit('refreshEnvs');
|
||||
$this->emit('success', 'Service saved successfully.');
|
||||
$this->service->saveComposeConfigs();
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
// public function save()
|
||||
// {
|
||||
// try {
|
||||
// $this->service->save();
|
||||
// $this->service->parse();
|
||||
// $this->service->refresh();
|
||||
// $this->emit('refreshEnvs');
|
||||
// $this->emit('success', 'Service saved successfully.');
|
||||
// $this->service->saveComposeConfigs();
|
||||
// } catch (\Throwable $e) {
|
||||
// return handleError($e, $this);
|
||||
// }
|
||||
// }
|
||||
public function submit()
|
||||
{
|
||||
try {
|
||||
$this->validate();
|
||||
$this->service->save();
|
||||
$this->service->parse();
|
||||
$this->service->refresh();
|
||||
$this->service->saveComposeConfigs();
|
||||
$this->refreshStack();
|
||||
$this->emit('refreshEnvs');
|
||||
$this->emit('success', 'Service saved successfully.');
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
|
||||
Reference in New Issue
Block a user