Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix: logdrain settings

Andras Bacsai40cc49537e7a
diff --git a/app/Livewire/Server/LogDrains.php b/app/Livewire/Server/LogDrains.php
index 6599149c4e..edddfc7557 100644
--- a/app/Livewire/Server/LogDrains.php
+++ b/app/Livewire/Server/LogDrains.php
@@ -49,36 +49,76 @@ class LogDrains extends Component
}
}
- public function syncData(bool $toModel = false)
+ public function syncDataNewRelic(bool $toModel = false)
{
if ($toModel) {
- $this->customValidation();
$this->server->settings->is_logdrain_newrelic_enabled = $this->isLogDrainNewRelicEnabled;
- $this->server->settings->is_logdrain_axiom_enabled = $this->isLogDrainAxiomEnabled;
- $this->server->settings->is_logdrain_custom_enabled = $this->isLogDrainCustomEnabled;
-
$this->server->settings->logdrain_newrelic_license_key = $this->logDrainNewRelicLicenseKey;
$this->server->settings->logdrain_newrelic_base_uri = $this->logDrainNewRelicBaseUri;
- $this->server->settings->logdrain_axiom_dataset_name = $this->logDrainAxiomDatasetName;
- $this->server->settings->logdrain_axiom_api_key = $this->logDrainAxiomApiKey;
- $this->server->settings->logdrain_custom_config = $this->logDrainCustomConfig;
- $this->server->settings->logdrain_custom_config_parser = $this->logDrainCustomConfigParser;
-
- $this->server->settings->save();
} else {
$this->isLogDrainNewRelicEnabled = $this->server->settings->is_logdrain_newrelic_enabled;
- $this->isLogDrainAxiomEnabled = $this->server->settings->is_logdrain_axiom_enabled;
- $this->isLogDrainCustomEnabled = $this->server->settings->is_logdrain_custom_enabled;
-
$this->logDrainNewRelicLicenseKey = $this->server->settings->logdrain_newrelic_license_key;
$this->logDrainNewRelicBaseUri = $this->server->settings->logdrain_newrelic_base_uri;
+ }
+ }
+
+ public function syncDataAxiom(bool $toModel = false)
+ {
+ if ($toModel) {
+ $this->server->settings->is_logdrain_axiom_enabled = $this->isLogDrainAxiomEnabled;
+ $this->server->settings->logdrain_axiom_dataset_name = $this->logDrainAxiomDatasetName;
+ $this->server->settings->logdrain_axiom_api_key = $this->logDrainAxiomApiKey;
+ } else {
+ $this->isLogDrainAxiomEnabled = $this->server->settings->is_logdrain_axiom_enabled;
$this->logDrainAxiomDatasetName = $this->server->settings->logdrain_axiom_dataset_name;
$this->logDrainAxiomApiKey = $this->server->settings->logdrain_axiom_api_key;
+ }
+ }
+
+ public function syncDataCustom(bool $toModel = false)
+ {
+ if ($toModel) {
+ $this->server->settings->is_logdrain_custom_enabled = $this->isLogDrainCustomEnabled;
+ $this->server->settings->logdrain_custom_config = $this->logDrainCustomConfig;
+ $this->server->settings->logdrain_custom_config_parser = $this->logDrainCustomConfigParser;
+ } else {
+ $this->isLogDrainCustomEnabled = $this->server->settings->is_logdrain_custom_enabled;
$this->logDrainCustomConfig = $this->server->settings->logdrain_custom_config;
$this->logDrainCustomConfigParser = $this->server->settings->logdrain_custom_config_parser;
}
}
+ public function syncData(bool $toModel = false, ?string $type = null)
+ {
+ if ($toModel) {
+ $this->customValidation();
+ if ($type === 'newrelic') {
+ $this->syncDataNewRelic($toModel);
+ } elseif ($type === 'axiom') {
+ $this->syncDataAxiom($toModel);
+ } elseif ($type === 'custom') {
+ $this->syncDataCustom($toModel);
+ } else {
+ $this->syncDataNewRelic($toModel);
+ $this->syncDataAxiom($toModel);
+ $this->syncDataCustom($toModel);
+ }
+ $this->server->settings->save();
+ } else {
+ if ($type === 'newrelic') {
+ $this->syncDataNewRelic($toModel);
+ } elseif ($type === 'axiom') {
+ $this->syncDataAxiom($toModel);
+ } elseif ($type === 'custom') {
+ $this->syncDataCustom($toModel);
+ } else {
+ $this->syncDataNewRelic($toModel);
+ $this->syncDataAxiom($toModel);
+ $this->syncDataCustom($toModel);
+ }
+ }
+ }
+
public function customValidation()
{
if ($this->isLogDrainNewRelicEnabled) {
@@ -136,7 +176,7 @@ class LogDrains extends Component
public function submit(string $type)
{
try {
- $this->syncData(true);
+ $this->syncData(true, $type);
$this->dispatch('success', 'Settings saved.');
} catch (\Throwable $e) {
return handleError($e, $this);