Skip to content

Commit

Permalink
fix: add missing declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
zaosoula committed Dec 11, 2024
1 parent 4d972f1 commit b6119f9
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 77 deletions.
15 changes: 9 additions & 6 deletions app/Livewire/Notifications/Pushover.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function mount()
{
try {
$this->team = auth()->user()->currentTeam();
$this->settings = $this->team->pushoverNotificationSettings();
$this->syncData();
} catch (\Throwable $e) {
return handleError($e, $this);
Expand All @@ -74,9 +75,10 @@ public function syncData(bool $toModel = false)
{
if ($toModel) {
$this->validate();
$this->team->pushover_enabled = $this->pushoverEnabled;
$this->team->pushover_user = $this->pushoverUser;
$this->team->pushover_token = $this->pushoverToken;
$this->settings->pushover_enabled = $this->pushoverEnabled;
$this->settings->pushover_user = $this->pushoverUser;
$this->settings->pushover_token = $this->pushoverToken;

$this->settings->deployment_success_pushover_notifications = $this->deploymentSuccessPushoverNotifications;
$this->settings->deployment_failure_pushover_notifications = $this->deploymentFailurePushoverNotifications;
$this->settings->status_change_pushover_notifications = $this->statusChangePushoverNotifications;
Expand All @@ -89,12 +91,13 @@ public function syncData(bool $toModel = false)
$this->settings->server_disk_usage_pushover_notifications = $this->serverDiskUsagePushoverNotifications;
$this->settings->server_reachable_pushover_notifications = $this->serverReachablePushoverNotifications;
$this->settings->server_unreachable_pushover_notifications = $this->serverUnreachablePushoverNotifications;

$this->settings->save();
refreshSession();
} else {
$this->pushoverEnabled = $this->team->pushover_enabled;
$this->pushoverUser = $this->team->pushover_user;
$this->pushoverToken = $this->team->pushover_token;
$this->pushoverEnabled = $this->settings->pushover_enabled;
$this->pushoverUser = $this->settings->pushover_user;
$this->pushoverToken = $this->settings->pushover_token;

$this->deploymentSuccessPushoverNotifications = $this->settings->deployment_success_pushover_notifications;
$this->deploymentFailurePushoverNotifications = $this->settings->deployment_failure_pushover_notifications;
Expand Down
1 change: 1 addition & 0 deletions app/Models/Team.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected static function booted()
$team->discordNotificationSettings()->create();
$team->slackNotificationSettings()->create();
$team->telegramNotificationSettings()->create();
$team->pushoverNotificationSettings()->create();
});

static::saving(function ($team) {
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/Channels/PushoverChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function send(SendsPushover $notifiable, Notification $notification): voi
$message = $notification->toPushover();
$pushoverSettings = $notifiable->pushoverNotificationSettings;

if (! $pushoverSettings || ! $pushoverSettings->isEnabled() || ! $pushoverSettings->slack_webhook_url) {
if (! $pushoverSettings || ! $pushoverSettings->isEnabled() || ! $pushoverSettings->pushover_user || ! $pushoverSettings->pushover_token) {
return;
}

Expand Down
2 changes: 0 additions & 2 deletions app/Notifications/Dto/PushoverMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

class PushoverMessage
{
private array $fields = [];

public function __construct(
public string $message,
public array $buttons = [],
Expand Down
1 change: 1 addition & 0 deletions app/Notifications/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function via(object $notifiable): array
'discord' => [DiscordChannel::class],
'telegram' => [TelegramChannel::class],
'slack' => [SlackChannel::class],
'pushover' => [PushoverChannel::class],
default => [],
};
} else {
Expand Down
136 changes: 68 additions & 68 deletions resources/views/livewire/notifications/pushover.blade.php
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
<div>
<x-slot:title>
Notifications | Coolify
</x-slot>
<x-notification.navbar />
<form wire:submit='submit' class="flex flex-col gap-4 pb-4">
<div class="flex items-center gap-2">
<h2>Pushover</h2>
<x-forms.button type="submit">
Save
</x-forms.button>
@if ($pushoverEnabled)
</x-slot>
<x-notification.navbar />
<form wire:submit='submit' class="flex flex-col gap-4 pb-4">
<div class="flex items-center gap-2">
<h2>Pushover</h2>
<x-forms.button type="submit">
Save
</x-forms.button>
@if ($pushoverEnabled)
<x-forms.button class="normal-case dark:text-white btn btn-xs no-animation btn-primary"
wire:click="sendTestNotification">
Send Test Notification
</x-forms.button>
@else
@else
<x-forms.button disabled class="normal-case dark:text-white btn btn-xs no-animation btn-primary">
Send Test Notification
</x-forms.button>
@endif
</div>
<div class="w-32">
<x-forms.checkbox instantSave="instantSavePushoverEnabled" id="pushoverEnabled" label="Enabled" />
</div>
<x-forms.input type="text"
helper="Generate a user key in Pushover.<br>Example: https://pushover.net/apps/build/...." required
id="pushoverUser" label="User" />
<x-forms.input type="password"
helper="Generate a token in Pushover.<br>Example: https://pushover.net/apps/build/...." required
id="pushoverToken" label="Token" />
</form>
<h2 class="mt-4">Notification Settings</h2>
<p class="mb-4">
Select events for which you would like to receive Pushover notifications.
</p>
<div class="flex flex-col gap-4 max-w-2xl">
<div class="border dark:border-coolgray-300 p-4 rounded-lg">
<h3 class="font-medium mb-3">Deployments</h3>
<div class="flex flex-col gap-1.5 pl-1">
<x-forms.checkbox instantSave="saveModel" id="deploymentSuccessPushoverNotifications"
label="Deployment Success" />
<x-forms.checkbox instantSave="saveModel" id="deploymentFailurePushoverNotifications"
label="Deployment Failure" />
<x-forms.checkbox instantSave="saveModel"
helper="Send a notification when a container status changes. It will notify for Stopped and Restarted events of a container."
id="statusChangePushoverNotifications" label="Container Status Changes" />
@endif
</div>
</div>
<div class="border dark:border-coolgray-300 p-4 rounded-lg">
<h3 class="font-medium mb-3">Backups</h3>
<div class="flex flex-col gap-1.5 pl-1">
<x-forms.checkbox instantSave="saveModel" id="backupSuccessPushoverNotifications"
label="Backup Success" />
<x-forms.checkbox instantSave="saveModel" id="backupFailurePushoverNotifications"
label="Backup Failure" />
<div class="w-32">
<x-forms.checkbox instantSave="instantSavePushoverEnabled" id="pushoverEnabled" label="Enabled" />
</div>
</div>
<div class="border dark:border-coolgray-300 p-4 rounded-lg">
<h3 class="font-medium mb-3">Scheduled Tasks</h3>
<div class="flex flex-col gap-1.5 pl-1">
<x-forms.checkbox instantSave="saveModel" id="scheduledTaskSuccessPushoverNotifications"
label="Scheduled Task Success" />
<x-forms.checkbox instantSave="saveModel" id="scheduledTaskFailurePushoverNotifications"
label="Scheduled Task Failure" />
<x-forms.input type="text"
helper="Generate a user key in Pushover.<br>Example: https://pushover.net/apps/build/...." required
id="pushoverUser" label="User" />
<x-forms.input type="password"
helper="Generate a token in Pushover.<br>Example: https://pushover.net/apps/build/...." required
id="pushoverToken" label="Token" />
</form>
<h2 class="mt-4">Notification Settings</h2>
<p class="mb-4">
Select events for which you would like to receive Pushover notifications.
</p>
<div class="flex flex-col gap-4 max-w-2xl">
<div class="border dark:border-coolgray-300 p-4 rounded-lg">
<h3 class="font-medium mb-3">Deployments</h3>
<div class="flex flex-col gap-1.5 pl-1">
<x-forms.checkbox instantSave="saveModel" id="deploymentSuccessPushoverNotifications"
label="Deployment Success" />
<x-forms.checkbox instantSave="saveModel" id="deploymentFailurePushoverNotifications"
label="Deployment Failure" />
<x-forms.checkbox instantSave="saveModel"
helper="Send a notification when a container status changes. It will notify for Stopped and Restarted events of a container."
id="statusChangePushoverNotifications" label="Container Status Changes" />
</div>
</div>
</div>
<div class="border dark:border-coolgray-300 p-4 rounded-lg">
<h3 class="font-medium mb-3">Server</h3>
<div class="flex flex-col gap-1.5 pl-1">
<x-forms.checkbox instantSave="saveModel" id="dockerCleanupSuccessPushoverNotifications"
label="Docker Cleanup Success" />
<x-forms.checkbox instantSave="saveModel" id="dockerCleanupFailurePushoverNotifications"
label="Docker Cleanup Failure" />
<x-forms.checkbox instantSave="saveModel" id="serverDiskUsagePushoverNotifications"
label="Server Disk Usage" />
<x-forms.checkbox instantSave="saveModel" id="serverReachablePushoverNotifications"
label="Server Reachable" />
<x-forms.checkbox instantSave="saveModel" id="serverUnreachablePushoverNotifications"
label="Server Unreachable" />
<div class="border dark:border-coolgray-300 p-4 rounded-lg">
<h3 class="font-medium mb-3">Backups</h3>
<div class="flex flex-col gap-1.5 pl-1">
<x-forms.checkbox instantSave="saveModel" id="backupSuccessPushoverNotifications"
label="Backup Success" />
<x-forms.checkbox instantSave="saveModel" id="backupFailurePushoverNotifications"
label="Backup Failure" />
</div>
</div>
<div class="border dark:border-coolgray-300 p-4 rounded-lg">
<h3 class="font-medium mb-3">Scheduled Tasks</h3>
<div class="flex flex-col gap-1.5 pl-1">
<x-forms.checkbox instantSave="saveModel" id="scheduledTaskSuccessPushoverNotifications"
label="Scheduled Task Success" />
<x-forms.checkbox instantSave="saveModel" id="scheduledTaskFailurePushoverNotifications"
label="Scheduled Task Failure" />
</div>
</div>
<div class="border dark:border-coolgray-300 p-4 rounded-lg">
<h3 class="font-medium mb-3">Server</h3>
<div class="flex flex-col gap-1.5 pl-1">
<x-forms.checkbox instantSave="saveModel" id="dockerCleanupSuccessPushoverNotifications"
label="Docker Cleanup Success" />
<x-forms.checkbox instantSave="saveModel" id="dockerCleanupFailurePushoverNotifications"
label="Docker Cleanup Failure" />
<x-forms.checkbox instantSave="saveModel" id="serverDiskUsagePushoverNotifications"
label="Server Disk Usage" />
<x-forms.checkbox instantSave="saveModel" id="serverReachablePushoverNotifications"
label="Server Reachable" />
<x-forms.checkbox instantSave="saveModel" id="serverUnreachablePushoverNotifications"
label="Server Unreachable" />
</div>
</div>
</div>
</div>
</div>
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use App\Livewire\Notifications\Email as NotificationEmail;
use App\Livewire\Notifications\Slack as NotificationSlack;
use App\Livewire\Notifications\Telegram as NotificationTelegram;
use App\Livewire\Notifications\Pushover as NotificationPushover;
use App\Livewire\Profile\Index as ProfileIndex;
use App\Livewire\Project\Application\Configuration as ApplicationConfiguration;
use App\Livewire\Project\Application\Deployment\Index as DeploymentIndex;
Expand Down Expand Up @@ -133,6 +134,7 @@
Route::get('/telegram', NotificationTelegram::class)->name('notifications.telegram');
Route::get('/discord', NotificationDiscord::class)->name('notifications.discord');
Route::get('/slack', NotificationSlack::class)->name('notifications.slack');
Route::get('/pushover', NotificationPushover::class)->name('notifications.pushover');
});

Route::prefix('storages')->group(function () {
Expand Down

0 comments on commit b6119f9

Please sign in to comment.