feat: configuration checker for all resources
This commit is contained in:
@@ -24,7 +24,6 @@ class General extends Component
|
||||
|
||||
public $customLabels;
|
||||
public bool $labelsChanged = false;
|
||||
public bool $isConfigurationChanged = false;
|
||||
public bool $initLoadingCompose = false;
|
||||
|
||||
public ?string $initialDockerComposeLocation = null;
|
||||
@@ -124,13 +123,8 @@ class General extends Component
|
||||
$this->application->settings->save();
|
||||
}
|
||||
$this->parsedServiceDomains = $this->application->docker_compose_domains ? json_decode($this->application->docker_compose_domains, true) : [];
|
||||
|
||||
$this->ports_exposes = $this->application->ports_exposes;
|
||||
if (str($this->application->status)->startsWith('running') && is_null($this->application->config_hash)) {
|
||||
$this->application->isConfigurationChanged(true);
|
||||
}
|
||||
$this->isConfigurationChanged = $this->application->isConfigurationChanged();
|
||||
$this->customLabels = $this->application->parseContainerLabels();
|
||||
$this->customLabels = $this->application->parseContainerLabels();
|
||||
if (!$this->customLabels && $this->application->destination->server->proxyType() !== 'NONE') {
|
||||
$this->customLabels = str(implode("|", generateLabelsApplication($this->application)))->replace("|", "\n");
|
||||
$this->application->custom_labels = base64_encode($this->customLabels);
|
||||
@@ -141,6 +135,10 @@ class General extends Component
|
||||
$this->initLoadingCompose = true;
|
||||
$this->dispatch('info', 'Loading docker compose file...');
|
||||
}
|
||||
|
||||
if (str($this->application->status)->startsWith('running') && is_null($this->application->config_hash)) {
|
||||
$this->dispatch('configurationChanged');
|
||||
}
|
||||
}
|
||||
public function instantSave()
|
||||
{
|
||||
@@ -316,7 +314,7 @@ class General extends Component
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
} finally {
|
||||
$this->isConfigurationChanged = $this->application->isConfigurationChanged();
|
||||
$this->dispatch('configurationChanged');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,26 +86,6 @@ class General extends Component
|
||||
return handleError($e, $this);
|
||||
}
|
||||
}
|
||||
// public function save_init_script($script)
|
||||
// {
|
||||
// $this->database->init_scripts = filter($this->database->init_scripts, fn ($s) => $s['filename'] !== $script['filename']);
|
||||
// $this->database->init_scripts = array_merge($this->database->init_scripts, [$script]);
|
||||
// $this->database->save();
|
||||
// $this->dispatch('success', 'Init script saved.');
|
||||
// }
|
||||
|
||||
// public function delete_init_script($script)
|
||||
// {
|
||||
// $collection = collect($this->database->init_scripts);
|
||||
// $found = $collection->firstWhere('filename', $script['filename']);
|
||||
// if ($found) {
|
||||
// $this->database->init_scripts = $collection->filter(fn ($s) => $s['filename'] !== $script['filename'])->toArray();
|
||||
// $this->database->save();
|
||||
// $this->refresh();
|
||||
// $this->dispatch('success', 'Init script deleted.');
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
public function refresh(): void
|
||||
{
|
||||
@@ -124,6 +104,12 @@ class General extends Component
|
||||
$this->dispatch('success', 'Database updated.');
|
||||
} catch (Exception $e) {
|
||||
return handleError($e, $this);
|
||||
} finally {
|
||||
if (is_null($this->database->config_hash)) {
|
||||
$this->database->isConfigurationChanged(true);
|
||||
} else {
|
||||
$this->dispatch('configurationChanged');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ use Livewire\Component;
|
||||
class Configuration extends Component
|
||||
{
|
||||
public $database;
|
||||
public function mount() {
|
||||
public function mount()
|
||||
{
|
||||
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||
if (!$project) {
|
||||
return redirect()->route('dashboard');
|
||||
@@ -21,6 +22,10 @@ class Configuration extends Component
|
||||
return redirect()->route('dashboard');
|
||||
}
|
||||
$this->database = $database;
|
||||
if (str($this->database->status)->startsWith('running') && is_null($this->database->config_hash)) {
|
||||
$this->database->isConfigurationChanged(true);
|
||||
$this->dispatch('configurationChanged');
|
||||
}
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
|
||||
@@ -19,7 +19,6 @@ class General extends Component
|
||||
protected $rules = [
|
||||
'database.name' => 'required',
|
||||
'database.description' => 'nullable',
|
||||
'database.dragonfly_conf' => 'nullable',
|
||||
'database.dragonfly_password' => 'required',
|
||||
'database.image' => 'required',
|
||||
'database.ports_mappings' => 'nullable',
|
||||
@@ -30,7 +29,6 @@ class General extends Component
|
||||
protected $validationAttributes = [
|
||||
'database.name' => 'Name',
|
||||
'database.description' => 'Description',
|
||||
'database.dragonfly_conf' => 'Redis Configuration',
|
||||
'database.dragonfly_password' => 'Redis Password',
|
||||
'database.image' => 'Image',
|
||||
'database.ports_mappings' => 'Port Mapping',
|
||||
@@ -62,13 +60,16 @@ class General extends Component
|
||||
{
|
||||
try {
|
||||
$this->validate();
|
||||
if ($this->database->dragonfly_conf === "") {
|
||||
$this->database->dragonfly_conf = null;
|
||||
}
|
||||
$this->database->save();
|
||||
$this->dispatch('success', 'Database updated.');
|
||||
} catch (Exception $e) {
|
||||
return handleError($e, $this);
|
||||
} finally {
|
||||
if (is_null($this->database->config_hash)) {
|
||||
$this->database->isConfigurationChanged(true);
|
||||
} else {
|
||||
$this->dispatch('configurationChanged');
|
||||
}
|
||||
}
|
||||
}
|
||||
public function instantSave()
|
||||
|
||||
@@ -34,6 +34,12 @@ class Heading extends Component
|
||||
]);
|
||||
$this->dispatch('refresh');
|
||||
$this->check_status();
|
||||
if (is_null($this->database->config_hash) || $this->database->isConfigurationChanged()) {
|
||||
$this->database->isConfigurationChanged(true);
|
||||
$this->dispatch('configurationChanged');
|
||||
} else {
|
||||
$this->dispatch('configurationChanged');
|
||||
}
|
||||
}
|
||||
|
||||
public function check_status($showNotification = false)
|
||||
|
||||
@@ -69,6 +69,12 @@ class General extends Component
|
||||
$this->dispatch('success', 'Database updated.');
|
||||
} catch (Exception $e) {
|
||||
return handleError($e, $this);
|
||||
} finally {
|
||||
if (is_null($this->database->config_hash)) {
|
||||
$this->database->isConfigurationChanged(true);
|
||||
} else {
|
||||
$this->dispatch('configurationChanged');
|
||||
}
|
||||
}
|
||||
}
|
||||
public function instantSave()
|
||||
|
||||
@@ -76,6 +76,12 @@ class General extends Component
|
||||
$this->dispatch('success', 'Database updated.');
|
||||
} catch (Exception $e) {
|
||||
return handleError($e, $this);
|
||||
} finally {
|
||||
if (is_null($this->database->config_hash)) {
|
||||
$this->database->isConfigurationChanged(true);
|
||||
} else {
|
||||
$this->dispatch('configurationChanged');
|
||||
}
|
||||
}
|
||||
}
|
||||
public function instantSave()
|
||||
|
||||
@@ -78,6 +78,12 @@ class General extends Component
|
||||
$this->dispatch('success', 'Database updated.');
|
||||
} catch (Exception $e) {
|
||||
return handleError($e, $this);
|
||||
} finally {
|
||||
if (is_null($this->database->config_hash)) {
|
||||
$this->database->isConfigurationChanged(true);
|
||||
} else {
|
||||
$this->dispatch('configurationChanged');
|
||||
}
|
||||
}
|
||||
}
|
||||
public function instantSave()
|
||||
|
||||
@@ -77,6 +77,12 @@ class General extends Component
|
||||
$this->dispatch('success', 'Database updated.');
|
||||
} catch (Exception $e) {
|
||||
return handleError($e, $this);
|
||||
} finally {
|
||||
if (is_null($this->database->config_hash)) {
|
||||
$this->database->isConfigurationChanged(true);
|
||||
} else {
|
||||
$this->dispatch('configurationChanged');
|
||||
}
|
||||
}
|
||||
}
|
||||
public function instantSave()
|
||||
|
||||
@@ -58,7 +58,8 @@ class General extends Component
|
||||
$this->db_url_public = $this->database->get_db_url();
|
||||
}
|
||||
}
|
||||
public function instantSaveAdvanced() {
|
||||
public function instantSaveAdvanced()
|
||||
{
|
||||
try {
|
||||
if (!$this->database->destination->server->isLogDrainEnabled()) {
|
||||
$this->database->is_log_drain_enabled = false;
|
||||
@@ -164,6 +165,12 @@ class General extends Component
|
||||
$this->dispatch('success', 'Database updated.');
|
||||
} catch (Exception $e) {
|
||||
return handleError($e, $this);
|
||||
} finally {
|
||||
if (is_null($this->database->config_hash)) {
|
||||
$this->database->isConfigurationChanged(true);
|
||||
} else {
|
||||
$this->dispatch('configurationChanged');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ class EditDomain extends Component
|
||||
} finally {
|
||||
$this->dispatch('generateDockerCompose');
|
||||
$this->dispatch('refresh');
|
||||
$this->dispatch('configurationChanged');
|
||||
}
|
||||
}
|
||||
public function render()
|
||||
|
||||
@@ -17,6 +17,14 @@ class Navbar extends Component
|
||||
public array $query;
|
||||
public $isDeploymentProgress = false;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
if (str($this->service->status())->contains('running') && is_null($this->service->config_hash)) {
|
||||
ray('isConfigurationChanged init');
|
||||
$this->service->isConfigurationChanged(true);
|
||||
$this->dispatch('configurationChanged');
|
||||
}
|
||||
}
|
||||
public function getListeners()
|
||||
{
|
||||
$userId = auth()->user()->id;
|
||||
@@ -25,12 +33,19 @@ class Navbar extends Component
|
||||
"serviceStatusChanged"
|
||||
];
|
||||
}
|
||||
public function serviceStarted() {
|
||||
public function serviceStarted()
|
||||
{
|
||||
$this->dispatch('success', 'Service status changed.');
|
||||
}
|
||||
public function serviceStatusChanged()
|
||||
{
|
||||
$this->dispatch('refresh')->self();
|
||||
// if (is_null($this->service->config_hash) || $this->service->isConfigurationChanged()) {
|
||||
// $this->service->isConfigurationChanged(true);
|
||||
// $this->dispatch('configurationChanged');
|
||||
// } else {
|
||||
// $this->dispatch('configurationChanged');
|
||||
// }
|
||||
}
|
||||
public function check_status()
|
||||
{
|
||||
|
||||
@@ -69,6 +69,13 @@ class StackForm extends Component
|
||||
$this->dispatch('success', 'Service saved.');
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e, $this);
|
||||
} finally {
|
||||
if (is_null($this->service->config_hash)) {
|
||||
ray('asdf');
|
||||
$this->service->isConfigurationChanged(true);
|
||||
} else {
|
||||
$this->dispatch('configurationChanged');
|
||||
}
|
||||
}
|
||||
}
|
||||
public function render()
|
||||
|
||||
34
app/Livewire/Project/Shared/ConfigurationChecker.php
Normal file
34
app/Livewire/Project/Shared/ConfigurationChecker.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire\Project\Shared;
|
||||
|
||||
use App\Models\Application;
|
||||
use App\Models\Service;
|
||||
use App\Models\StandaloneClickhouse;
|
||||
use App\Models\StandaloneDragonfly;
|
||||
use App\Models\StandaloneKeydb;
|
||||
use App\Models\StandaloneMariadb;
|
||||
use App\Models\StandaloneMongodb;
|
||||
use App\Models\StandaloneMysql;
|
||||
use App\Models\StandalonePostgresql;
|
||||
use App\Models\StandaloneRedis;
|
||||
use Livewire\Component;
|
||||
|
||||
class ConfigurationChecker extends Component
|
||||
{
|
||||
public bool $isConfigurationChanged = false;
|
||||
public Application|Service|StandaloneRedis|StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|StandaloneKeydb|StandaloneDragonfly|StandaloneClickhouse $resource;
|
||||
protected $listeners = ['configurationChanged'];
|
||||
public function mount()
|
||||
{
|
||||
$this->configurationChanged();
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.project.shared.configuration-checker');
|
||||
}
|
||||
public function configurationChanged()
|
||||
{
|
||||
$this->isConfigurationChanged = $this->resource->isConfigurationChanged();
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ class Danger extends Component
|
||||
public $resource;
|
||||
public $projectUuid;
|
||||
public $environmentName;
|
||||
public bool $delete_configurations = false;
|
||||
public bool $delete_configurations = true;
|
||||
public ?string $modalId = null;
|
||||
|
||||
public function mount()
|
||||
@@ -21,7 +21,6 @@ class Danger extends Component
|
||||
$this->projectUuid = data_get($parameters, 'project_uuid');
|
||||
$this->environmentName = data_get($parameters, 'environment_name');
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user