fix notifications
This commit is contained in:
@@ -41,7 +41,7 @@ class Discord extends Component
|
|||||||
$this->team = auth()->user()->currentTeam();
|
$this->team = auth()->user()->currentTeam();
|
||||||
$this->syncData();
|
$this->syncData();
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
handleError($e, $this);
|
return handleError($e, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,11 +57,8 @@ class Discord extends Component
|
|||||||
$this->team->discord_notifications_database_backups = $this->discordNotificationsDatabaseBackups;
|
$this->team->discord_notifications_database_backups = $this->discordNotificationsDatabaseBackups;
|
||||||
$this->team->discord_notifications_scheduled_tasks = $this->discordNotificationsScheduledTasks;
|
$this->team->discord_notifications_scheduled_tasks = $this->discordNotificationsScheduledTasks;
|
||||||
$this->team->discord_notifications_server_disk_usage = $this->discordNotificationsServerDiskUsage;
|
$this->team->discord_notifications_server_disk_usage = $this->discordNotificationsServerDiskUsage;
|
||||||
try {
|
$this->team->save();
|
||||||
$this->saveModel();
|
refreshSession();
|
||||||
} catch (\Throwable $e) {
|
|
||||||
return handleError($e, $this);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$this->discordEnabled = $this->team->discord_enabled;
|
$this->discordEnabled = $this->team->discord_enabled;
|
||||||
$this->discordWebhookUrl = $this->team->discord_webhook_url;
|
$this->discordWebhookUrl = $this->team->discord_webhook_url;
|
||||||
@@ -74,6 +71,22 @@ class Discord extends Component
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function instantSaveDiscordEnabled()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->validate([
|
||||||
|
'discordWebhookUrl' => 'required',
|
||||||
|
], [
|
||||||
|
'discordWebhookUrl.required' => 'Discord Webhook URL is required.',
|
||||||
|
]);
|
||||||
|
$this->saveModel();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->discordEnabled = false;
|
||||||
|
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function instantSave()
|
public function instantSave()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -96,7 +109,7 @@ class Discord extends Component
|
|||||||
|
|
||||||
public function saveModel()
|
public function saveModel()
|
||||||
{
|
{
|
||||||
$this->team->save();
|
$this->syncData(true);
|
||||||
refreshSession();
|
refreshSession();
|
||||||
$this->dispatch('success', 'Settings saved.');
|
$this->dispatch('success', 'Settings saved.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ class Email extends Component
|
|||||||
$this->team->resend_enabled = $this->resendEnabled;
|
$this->team->resend_enabled = $this->resendEnabled;
|
||||||
$this->team->resend_api_key = $this->resendApiKey;
|
$this->team->resend_api_key = $this->resendApiKey;
|
||||||
$this->team->save();
|
$this->team->save();
|
||||||
|
refreshSession();
|
||||||
} else {
|
} else {
|
||||||
$this->smtpEnabled = $this->team->smtp_enabled;
|
$this->smtpEnabled = $this->team->smtp_enabled;
|
||||||
$this->smtpFromAddress = $this->team->smtp_from_address;
|
$this->smtpFromAddress = $this->team->smtp_from_address;
|
||||||
@@ -170,8 +171,8 @@ class Email extends Component
|
|||||||
'smtpHost' => 'required',
|
'smtpHost' => 'required',
|
||||||
'smtpPort' => 'required|numeric',
|
'smtpPort' => 'required|numeric',
|
||||||
], [
|
], [
|
||||||
'smtpHost.required' => 'SMTP Host is required',
|
'smtpHost.required' => 'SMTP Host is required.',
|
||||||
'smtpPort.required' => 'SMTP Port is required',
|
'smtpPort.required' => 'SMTP Port is required.',
|
||||||
]);
|
]);
|
||||||
$this->resendEnabled = false;
|
$this->resendEnabled = false;
|
||||||
$this->saveModel();
|
$this->saveModel();
|
||||||
@@ -186,9 +187,8 @@ class Email extends Component
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->validate([
|
$this->validate([
|
||||||
'resendApiKey' => 'required',
|
|
||||||
], [
|
], [
|
||||||
'resendApiKey.required' => 'Resend API Key is required',
|
'resendApiKey.required' => 'Resend API Key is required.',
|
||||||
]);
|
]);
|
||||||
$this->smtpEnabled = false;
|
$this->smtpEnabled = false;
|
||||||
$this->saveModel();
|
$this->saveModel();
|
||||||
|
|||||||
@@ -81,11 +81,8 @@ class Telegram extends Component
|
|||||||
$this->team->telegram_notifications_database_backups_message_thread_id = $this->telegramNotificationsDatabaseBackupsMessageThreadId;
|
$this->team->telegram_notifications_database_backups_message_thread_id = $this->telegramNotificationsDatabaseBackupsMessageThreadId;
|
||||||
$this->team->telegram_notifications_scheduled_tasks_thread_id = $this->telegramNotificationsScheduledTasksThreadId;
|
$this->team->telegram_notifications_scheduled_tasks_thread_id = $this->telegramNotificationsScheduledTasksThreadId;
|
||||||
$this->team->telegram_notifications_server_disk_usage = $this->telegramNotificationsServerDiskUsage;
|
$this->team->telegram_notifications_server_disk_usage = $this->telegramNotificationsServerDiskUsage;
|
||||||
try {
|
$this->team->save();
|
||||||
$this->saveModel();
|
refreshSession();
|
||||||
} catch (\Throwable $e) {
|
|
||||||
return handleError($e, $this);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$this->telegramEnabled = $this->team->telegram_enabled;
|
$this->telegramEnabled = $this->team->telegram_enabled;
|
||||||
$this->telegramToken = $this->team->telegram_token;
|
$this->telegramToken = $this->team->telegram_token;
|
||||||
@@ -125,9 +122,27 @@ class Telegram extends Component
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function instantSaveTelegramEnabled()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->validate([
|
||||||
|
'telegramToken' => 'required',
|
||||||
|
'telegramChatId' => 'required',
|
||||||
|
], [
|
||||||
|
'telegramToken.required' => 'Telegram Token is required.',
|
||||||
|
'telegramChatId.required' => 'Telegram Chat ID is required.',
|
||||||
|
]);
|
||||||
|
$this->saveModel();
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->telegramEnabled = false;
|
||||||
|
|
||||||
|
return handleError($e, $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function saveModel()
|
public function saveModel()
|
||||||
{
|
{
|
||||||
$this->team->save();
|
$this->syncData(true);
|
||||||
refreshSession();
|
refreshSession();
|
||||||
$this->dispatch('success', 'Settings saved.');
|
$this->dispatch('success', 'Settings saved.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,15 @@
|
|||||||
<div class="subtitle">Get notified about your infrastructure.</div>
|
<div class="subtitle">Get notified about your infrastructure.</div>
|
||||||
<div class="navbar-main">
|
<div class="navbar-main">
|
||||||
<nav class="flex items-center gap-6 min-h-10">
|
<nav class="flex items-center gap-6 min-h-10">
|
||||||
<a class="{{ request()->routeIs('notifications.email') ? 'dark:text-white' : '' }}"
|
<a wire:navigate class="{{ request()->routeIs('notifications.email') ? 'dark:text-white' : '' }}"
|
||||||
href="{{ route('notifications.email') }}">
|
href="{{ route('notifications.email') }}">
|
||||||
<button>Email</button>
|
<button>Email</button>
|
||||||
</a>
|
</a>
|
||||||
<a class="{{ request()->routeIs('notifications.telegram') ? 'dark:text-white' : '' }}"
|
<a wire:navigate class="{{ request()->routeIs('notifications.telegram') ? 'dark:text-white' : '' }}"
|
||||||
href="{{ route('notifications.telegram') }}">
|
href="{{ route('notifications.telegram') }}">
|
||||||
<button>Telegram</button>
|
<button>Telegram</button>
|
||||||
</a>
|
</a>
|
||||||
<a class="{{ request()->routeIs('notifications.discord') ? 'dark:text-white' : '' }}"
|
<a wire:navigate class="{{ request()->routeIs('notifications.discord') ? 'dark:text-white' : '' }}"
|
||||||
href="{{ route('notifications.discord') }}">
|
href="{{ route('notifications.discord') }}">
|
||||||
<button>Discord</button>
|
<button>Discord</button>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div class="w-32">
|
<div class="w-32">
|
||||||
<x-forms.checkbox instantSave id="discordEnabled" label="Enabled" />
|
<x-forms.checkbox instantSave="instantSaveDiscordEnabled" id="discordEnabled" label="Enabled" />
|
||||||
</div>
|
</div>
|
||||||
<x-forms.input type="password"
|
<x-forms.input type="password"
|
||||||
helper="Generate a webhook in Discord.<br>Example: https://discord.com/api/webhooks/...." required
|
helper="Generate a webhook in Discord.<br>Example: https://discord.com/api/webhooks/...." required
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div class="w-32">
|
<div class="w-32">
|
||||||
<x-forms.checkbox instantSave id="telegramEnabled" label="Enabled" />
|
<x-forms.checkbox instantSave="instantSaveTelegramEnabled" id="telegramEnabled" label="Enabled" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user