Skip to content

Modern Docker Management, Designed for Everyone

feat: apprise notifications support (#899)

Kyle Mendellf2a2137b1375
diff --git a/backend/internal/api/notification_handler.go b/backend/internal/api/notification_handler.go
index 188c9eec6..a5730ee0a 100644
--- a/backend/internal/api/notification_handler.go
+++ b/backend/internal/api/notification_handler.go
@@ -12,11 +12,13 @@ import (
type NotificationHandler struct {
notificationService *services.NotificationService
+ appriseService *services.AppriseService
}
-func NewNotificationHandler(group *gin.RouterGroup, notificationService *services.NotificationService, authMiddleware *middleware.AuthMiddleware) {
+func NewNotificationHandler(group *gin.RouterGroup, notificationService *services.NotificationService, appriseService *services.AppriseService, authMiddleware *middleware.AuthMiddleware) {
handler := &NotificationHandler{
notificationService: notificationService,
+ appriseService: appriseService,
}
notifications := group.Group("/environments/:id/notifications")
@@ -27,6 +29,10 @@ func NewNotificationHandler(group *gin.RouterGroup, notificationService *service
notifications.POST("/settings", handler.CreateOrUpdateSettings)
notifications.DELETE("/settings/:provider", handler.DeleteSettings)
notifications.POST("/test/:provider", handler.TestNotification)
+
+ notifications.GET("/apprise", handler.GetAppriseSettings)
+ notifications.POST("/apprise", handler.CreateOrUpdateAppriseSettings)
+ notifications.POST("/apprise/test", handler.TestAppriseNotification)
}
}
@@ -145,3 +151,60 @@ func (h *NotificationHandler) TestNotification(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "Test notification sent successfully"})
}
+
+func (h *NotificationHandler) GetAppriseSettings(c *gin.Context) {
+ settings, err := h.appriseService.GetSettings(c.Request.Context())
+ if err != nil {
+ c.JSON(http.StatusNotFound, gin.H{"error": "Apprise settings not found"})
+ return
+ }
+
+ response := dto.AppriseSettingsResponse{
+ ID: settings.ID,
+ APIURL: settings.APIURL,
+ Enabled: settings.Enabled,
+ ImageUpdateTag: settings.ImageUpdateTag,
+ ContainerUpdateTag: settings.ContainerUpdateTag,
+ }
+
+ c.JSON(http.StatusOK, response)
+}
+
+func (h *NotificationHandler) CreateOrUpdateAppriseSettings(c *gin.Context) {
+ var req dto.AppriseSettingsRequest
+ if err := c.ShouldBindJSON(&req); err != nil {
+ c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
+ return
+ }
+
+ settings, err := h.appriseService.CreateOrUpdateSettings(
+ c.Request.Context(),
+ req.APIURL,
+ req.Enabled,
+ req.ImageUpdateTag,
+ req.ContainerUpdateTag,
+ )
+ if err != nil {
+ c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
+ return
+ }
+
+ response := dto.AppriseSettingsResponse{
+ ID: settings.ID,
+ APIURL: settings.APIURL,
+ Enabled: settings.Enabled,
+ ImageUpdateTag: settings.ImageUpdateTag,
+ ContainerUpdateTag: settings.ContainerUpdateTag,
+ }
+
+ c.JSON(http.StatusOK, response)
+}
+
+func (h *NotificationHandler) TestAppriseNotification(c *gin.Context) {
+ if err := h.appriseService.TestNotification(c.Request.Context()); err != nil {
+ c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
+ return
+ }
+
+ c.JSON(http.StatusOK, gin.H{"message": "Test notification sent successfully"})
+}
diff --git a/backend/internal/bootstrap/router_bootstrap.go b/backend/internal/bootstrap/router_bootstrap.go
index b67aeaff3..bb4ff8583 100644
--- a/backend/internal/bootstrap/router_bootstrap.go
+++ b/backend/internal/bootstrap/router_bootstrap.go
@@ -105,7 +105,7 @@ func setupRouter(cfg *config.Config, appServices *Services) *gin.Engine {
api.NewSystemHandler(apiGroup, appServices.Docker, appServices.System, appServices.SystemUpgrade, authMiddleware, cfg)
api.NewUpdaterHandler(apiGroup, appServices.Updater, authMiddleware)
api.NewVolumeHandler(apiGroup, appServices.Docker, appServices.Volume, authMiddleware)
- api.NewNotificationHandler(apiGroup, appServices.Notification, authMiddleware)
+ api.NewNotificationHandler(apiGroup, appServices.Notification, appServices.Apprise, authMiddleware)
api.NewSettingsHandler(apiGroup, appServices.Settings, appServices.SettingsSearch, authMiddleware)
api.NewCustomizeHandler(apiGroup, appServices.CustomizeSearch, authMiddleware)
diff --git a/backend/internal/bootstrap/services_bootstrap.go b/backend/internal/bootstrap/services_bootstrap.go
index 61a0516ca..ce11418c9 100644
--- a/backend/internal/bootstrap/services_bootstrap.go
+++ b/backend/internal/bootstrap/services_bootstrap.go
@@ -35,6 +35,7 @@ type Services struct {
Event *services.EventService
Version *services.VersionService
Notification *services.NotificationService
+ Apprise *services.AppriseService
}
func initializeServices(ctx context.Context, db *database.DB, cfg *config.Config, httpClient *http.Client) (svcs *Services, dockerSrvice *services.DockerClientService, err error) {
@@ -53,6 +54,7 @@ func initializeServices(ctx context.Context, db *database.DB, cfg *config.Config
svcs.User = services.NewUserService(db)
svcs.ContainerRegistry = services.NewContainerRegistryService(db)
svcs.Notification = services.NewNotificationService(db, cfg)
+ svcs.Apprise = services.NewAppriseService(db, cfg)
svcs.ImageUpdate = services.NewImageUpdateService(db, svcs.Settings, svcs.ContainerRegistry, svcs.Docker, svcs.Event, svcs.Notification)
svcs.Image = services.NewImageService(db, svcs.Docker, svcs.ContainerRegistry, svcs.ImageUpdate, svcs.Event)
svcs.Project = services.NewProjectService(db, svcs.Settings, svcs.Event, svcs.Image)
diff --git a/backend/internal/dto/notification_dto.go b/backend/internal/dto/notification_dto.go
index 0896d2c83..ddd5bb108 100644
--- a/backend/internal/dto/notification_dto.go
+++ b/backend/internal/dto/notification_dto.go
@@ -14,3 +14,18 @@ type NotificationSettingsResponse struct {
Enabled bool `json:"enabled"`
Config models.JSON `json:"config"`
}
+
+type AppriseSettingsRequest struct {
+ APIURL string `json:"apiUrl" binding:"required"`
+ Enabled bool `json:"enabled"`
+ ImageUpdateTag string `json:"imageUpdateTag"`
+ ContainerUpdateTag string `json:"containerUpdateTag"`
+}
+
+type AppriseSettingsResponse struct {
+ ID uint `json:"id"`
+ APIURL string `json:"apiUrl"`
+ Enabled bool `json:"enabled"`
+ ImageUpdateTag string `json:"imageUpdateTag"`
+ ContainerUpdateTag string `json:"containerUpdateTag"`
+}
diff --git a/backend/internal/models/notification.go b/backend/internal/models/notification.go
index 4317c4a3d..1f428e035 100644
--- a/backend/internal/models/notification.go
+++ b/backend/internal/models/notification.go
@@ -72,3 +72,17 @@ type EmailConfig struct {
TLSMode EmailTLSMode `json:"tlsMode"`
Events map[NotificationEventType]bool `json:"events,omitempty"`
}
+
+type AppriseSettings struct {
+ ID uint `json:"id" gorm:"primaryKey"`
+ APIURL string `json:"apiUrl" gorm:"not null"`
+ Enabled bool `json:"enabled" gorm:"default:false"`
+ ImageUpdateTag string `json:"imageUpdateTag" gorm:"type:varchar(255)"`
+ ContainerUpdateTag string `json:"containerUpdateTag" gorm:"type:varchar(255)"`
+ CreatedAt time.Time `json:"createdAt"`
+ UpdatedAt time.Time `json:"updatedAt"`
+}
+
+func (AppriseSettings) TableName() string {
+ return "apprise_settings"
+}
diff --git a/backend/internal/services/apprise_service.go b/backend/internal/services/apprise_service.go
new file mode 100644
index 000000000..ef00b83d9
--- /dev/null
+++ b/backend/internal/services/apprise_service.go
@@ -0,0 +1,210 @@
+package services
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "fmt"
+ "io"
+ "log/slog"
+ "net/http"
+ "time"
+
+ "github.com/ofkm/arcane-backend/internal/config"
+ "github.com/ofkm/arcane-backend/internal/database"
+ "github.com/ofkm/arcane-backend/internal/dto"
+ "github.com/ofkm/arcane-backend/internal/models"
+)
+
+type AppriseService struct {
+ db *database.DB
+ config *config.Config
+}
+
+func NewAppriseService(db *database.DB, cfg *config.Config) *AppriseService {
+ return &AppriseService{
+ db: db,
+ config: cfg,
+ }
+}
+
+type AppriseNotificationPayload struct {
+ Body string `json:"body"`
+ Title string `json:"title,omitempty"`
+ Type string `json:"type,omitempty"`
+ Tag []string `json:"tag,omitempty"`
+ Format string `json:"format,omitempty"`
+}
+
+func (s *AppriseService) GetSettings(ctx context.Context) (*models.AppriseSettings, error) {
+ var settings models.AppriseSettings
+ if err := s.db.WithContext(ctx).First(&settings).Error; err != nil {
+ return nil, err
+ }
+ return &settings, nil
+}
+
+func (s *AppriseService) CreateOrUpdateSettings(ctx context.Context, apiURL string, enabled bool, imageUpdateTag, containerUpdateTag string) (*models.AppriseSettings, error) {
+ var settings models.AppriseSettings
+
+ err := s.db.WithContext(ctx).First(&settings).Error
+ if err != nil {
+ settings = models.AppriseSettings{
+ APIURL: apiURL,
+ Enabled: enabled,
+ ImageUpdateTag: imageUpdateTag,
+ ContainerUpdateTag: containerUpdateTag,
+ }
+ if err := s.db.WithContext(ctx).Create(&settings).Error; err != nil {
+ return nil, fmt.Errorf("failed to create apprise settings: %w", err)
+ }
+ } else {
+ settings.APIURL = apiURL
+ settings.Enabled = enabled
+ settings.ImageUpdateTag = imageUpdateTag
+ settings.ContainerUpdateTag = containerUpdateTag
+ if err := s.db.WithContext(ctx).Save(&settings).Error; err != nil {
+ return nil, fmt.Errorf("failed to update apprise settings: %w", err)
+ }
+ }
+
+ return &settings, nil
+}
+
+func (s *AppriseService) SendNotification(ctx context.Context, title, body, format string, notificationType models.NotificationEventType) error {
+ settings, err := s.GetSettings(ctx)
+ if err != nil {
+ return fmt.Errorf("failed to get apprise settings: %w", err)
+ }
+
+ if !settings.Enabled {
+ return nil
+ }
+
+ if settings.APIURL == "" {
+ return fmt.Errorf("apprise API URL not configured")
+ }
+
+ var tags []string
+ switch notificationType {
+ case models.NotificationEventImageUpdate:
+ if settings.ImageUpdateTag != "" {
+ tags = []string{settings.ImageUpdateTag}
+ }
+ case models.NotificationEventContainerUpdate:
+ if settings.ContainerUpdateTag != "" {
+ tags = []string{settings.ContainerUpdateTag}
+ }
+ }
+
+ payload := AppriseNotificationPayload{
+ Title: title,
+ Body: body,
+ Type: "info",
+ Tag: tags,
+ Format: format,
+ }
+
+ jsonData, err := json.Marshal(payload)
+ if err != nil {
+ return fmt.Errorf("failed to marshal notification payload: %w", err)
+ }
+
+ slog.InfoContext(ctx, "Sending Apprise notification",
+ slog.String("url", settings.APIURL),
+ slog.String("title", title),
+ slog.Any("tags", tags),
+ slog.String("type", string(notificationType)))
+
+ req, err := http.NewRequestWithContext(ctx, http.MethodPost, settings.APIURL, bytes.NewBuffer(jsonData))
+ if err != nil {
+ return fmt.Errorf("failed to create request: %w", err)
+ }
+ req.Header.Set("Content-Type", "application/json")
+
+ client := &http.Client{Timeout: 10 * time.Second}
+ resp, err := client.Do(req)
+ if err != nil {
+ return fmt.Errorf("failed to send notification: %w", err)
+ }
+ defer resp.Body.Close()
+
+ // Read response body for debugging
+ bodyBytes, _ := io.ReadAll(resp.Body)
+ bodyString := string(bodyBytes)
+
+ if resp.StatusCode != http.StatusOK {
+ slog.ErrorContext(ctx, "Apprise API returned error",
+ slog.Int("status", resp.StatusCode),
+ slog.String("response", bodyString),
+ slog.String("url", settings.APIURL))
+ return fmt.Errorf("apprise API returned status %d: %s", resp.StatusCode, bodyString)
+ }
+
+ slog.InfoContext(ctx, "Apprise notification sent successfully",
+ slog.Int("status", resp.StatusCode),
+ slog.String("response", bodyString))
+
+ return nil
+}
+
+func (s *AppriseService) SendImageUpdateNotification(ctx context.Context, imageRef string, updateInfo *dto.ImageUpdateResponse) error {
+ title := fmt.Sprintf("Container Image Update Available: %s", imageRef)
+ body := fmt.Sprintf(
+ "Image: %s\nUpdate Type: %s\nCurrent Digest: %s\nLatest Digest: %s",
+ imageRef,
+ updateInfo.UpdateType,
+ truncateDigest(updateInfo.CurrentDigest),
+ truncateDigest(updateInfo.LatestDigest),
+ )
+ return s.SendNotification(ctx, title, body, "text", models.NotificationEventImageUpdate)
+}
+
+func (s *AppriseService) SendContainerUpdateNotification(ctx context.Context, containerName, imageRef, oldDigest, newDigest string) error {
+ title := fmt.Sprintf("Container Updated: %s", containerName)
+ body := fmt.Sprintf(
+ "Container: %s\nImage: %s\nPrevious Version: %s\nCurrent Version: %s\nStatus: Updated Successfully",
+ containerName,
+ imageRef,
+ truncateDigest(oldDigest),
+ truncateDigest(newDigest),
+ )
+ return s.SendNotification(ctx, title, body, "text", models.NotificationEventContainerUpdate)
+}
+
+func (s *AppriseService) SendBatchImageUpdateNotification(ctx context.Context, updates map[string]*dto.ImageUpdateResponse) error {
+ if len(updates) == 0 {
+ return nil
+ }
+
+ updatesWithChanges := make(map[string]*dto.ImageUpdateResponse)
+ for imageRef, update := range updates {
+ if update != nil && update.HasUpdate {
+ updatesWithChanges[imageRef] = update
+ }
+ }
+
+ if len(updatesWithChanges) == 0 {
+ return nil
+ }
+
+ title := fmt.Sprintf("%d Container Image Update(s) Available", len(updatesWithChanges))
+ body := "The following images have updates available:\n\n"
+
+ for imageRef, update := range updatesWithChanges {
+ body += fmt.Sprintf("• %s\n Type: %s\n Current: %s\n Latest: %s\n\n",
+ imageRef,
+ update.UpdateType,
+ truncateDigest(update.CurrentDigest),
+ truncateDigest(update.LatestDigest),
+ )
+ }
+
+ return s.SendNotification(ctx, title, body, "text", models.NotificationEventImageUpdate)
+}
+
+func (s *AppriseService) TestNotification(ctx context.Context) error {
+ title := "Test Notification from Arcane"
+ body := "If you're reading this, your Apprise integration is working correctly!"
+ return s.SendNotification(ctx, title, body, "text", models.NotificationEventImageUpdate)
+}
diff --git a/backend/internal/services/notification_service.go b/backend/internal/services/notification_service.go
index 81325eaed..7e397815e 100644
--- a/backend/internal/services/notification_service.go
+++ b/backend/internal/services/notification_service.go
@@ -24,14 +24,16 @@ import (
)
type NotificationService struct {
- db *database.DB
- config *config.Config
+ db *database.DB
+ config *config.Config
+ appriseService *AppriseService
}
func NewNotificationService(db *database.DB, cfg *config.Config) *NotificationService {
return &NotificationService{
- db: db,
- config: cfg,
+ db: db,
+ config: cfg,
+ appriseService: NewAppriseService(db, cfg),
}
}
@@ -88,6 +90,11 @@ func (s *NotificationService) DeleteSettings(ctx context.Context, provider model
}
func (s *NotificationService) SendImageUpdateNotification(ctx context.Context, imageRef string, updateInfo *dto.ImageUpdateResponse, eventType models.NotificationEventType) error {
+ // Send to Apprise if enabled (don't block on error)
+ if appriseErr := s.appriseService.SendImageUpdateNotification(ctx, imageRef, updateInfo); appriseErr != nil {
+ slog.WarnContext(ctx, "Failed to send Apprise notification", "error", appriseErr)
+ }
+
settings, err := s.GetAllSettings(ctx)
if err != nil {
return fmt.Errorf("failed to get notification settings: %w", err)
@@ -166,6 +173,11 @@ func (s *NotificationService) isEventEnabled(config models.JSON, eventType model
}
func (s *NotificationService) SendContainerUpdateNotification(ctx context.Context, containerName, imageRef, oldDigest, newDigest string) error {
+ // Send to Apprise if enabled (don't block on error)
+ if appriseErr := s.appriseService.SendContainerUpdateNotification(ctx, containerName, imageRef, oldDigest, newDigest); appriseErr != nil {
+ slog.WarnContext(ctx, "Failed to send Apprise notification", "error", appriseErr)
+ }
+
settings, err := s.GetAllSettings(ctx)
if err != nil {
return fmt.Errorf("failed to get notification settings: %w", err)
@@ -779,6 +791,11 @@ func (s *NotificationService) SendBatchImageUpdateNotification(ctx context.Conte
return nil
}
+ // Send to Apprise if enabled
+ if appriseErr := s.appriseService.SendBatchImageUpdateNotification(ctx, updatesWithChanges); appriseErr != nil {
+ slog.WarnContext(ctx, "Failed to send Apprise notification", "error", appriseErr)
+ }
+
settings, err := s.GetAllSettings(ctx)
if err != nil {
return fmt.Errorf("failed to get notification settings: %w", err)
diff --git a/backend/resources/migrations/postgres/023_add_apprise_settings.down.sql b/backend/resources/migrations/postgres/023_add_apprise_settings.down.sql
new file mode 100644
index 000000000..954f2e5d2
--- /dev/null
+++ b/backend/resources/migrations/postgres/023_add_apprise_settings.down.sql
@@ -0,0 +1 @@
+DROP TABLE IF EXISTS apprise_settings;
diff --git a/backend/resources/migrations/postgres/023_add_apprise_settings.up.sql b/backend/resources/migrations/postgres/023_add_apprise_settings.up.sql
new file mode 100644
index 000000000..2d32481de
--- /dev/null
+++ b/backend/resources/migrations/postgres/023_add_apprise_settings.up.sql
@@ -0,0 +1,9 @@
+CREATE TABLE IF NOT EXISTS apprise_settings (
+ id SERIAL PRIMARY KEY,
+ api_url VARCHAR(512) NOT NULL,
+ enabled BOOLEAN DEFAULT FALSE,
+ image_update_tag VARCHAR(255),
+ container_update_tag VARCHAR(255),
+ created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
diff --git a/backend/resources/migrations/sqlite/023_add_apprise_settings.down.sql b/backend/resources/migrations/sqlite/023_add_apprise_settings.down.sql
new file mode 100644
index 000000000..954f2e5d2
--- /dev/null
+++ b/backend/resources/migrations/sqlite/023_add_apprise_settings.down.sql
@@ -0,0 +1 @@
+DROP TABLE IF EXISTS apprise_settings;
diff --git a/backend/resources/migrations/sqlite/023_add_apprise_settings.up.sql b/backend/resources/migrations/sqlite/023_add_apprise_settings.up.sql
new file mode 100644
index 000000000..afabd152e
--- /dev/null
+++ b/backend/resources/migrations/sqlite/023_add_apprise_settings.up.sql
@@ -0,0 +1,9 @@
+CREATE TABLE IF NOT EXISTS apprise_settings (
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
+ api_url TEXT NOT NULL,
+ enabled INTEGER DEFAULT 0,
+ image_update_tag TEXT,
+ container_update_tag TEXT,
+ created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index d55952af2..195585ef0 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -1374,6 +1374,8 @@
"sidebar_light_mode": "Light",
"notifications_title": "Notifications",
"notifications_description": "Configure notifications for container updates",
+ "notifications_tab_built_in": "Built-in Notifications",
+ "notifications_tab_apprise": "Apprise",
"notifications_read_only_title": "Read-only Mode",
"notifications_read_only_description": "Settings are read-only in this environment. Configuration changes are disabled.",
"notifications_discord_title": "Discord Notifications",
@@ -1427,6 +1429,28 @@
"notifications_event_image_update_description": "Notify when a new image version is available",
"notifications_event_container_update_label": "Container Updated",
"notifications_event_container_update_description": "Notify when a container is actually updated/restarted",
+ "notifications_email_tls_mode_label": "TLS Mode",
+ "notifications_email_tls_mode_placeholder": "Select TLS mode",
+ "notifications_email_tls_mode_description": "StartTLS (default) upgrades from plain connection. SSL/TLS uses encryption from start. None uses no encryption.",
+ "notifications_email_test_simple": "Simple Test Email",
+ "notifications_email_test_image_update": "Image Update Email",
+ "notifications_apprise_title": "Apprise Integration",
+ "notifications_apprise_description": "Configure Apprise API for unified notifications across multiple services",
+ "notifications_apprise_enabled_label": "Enable Apprise",
+ "notifications_apprise_enabled_description": "Send notifications through your Apprise API server",
+ "notifications_apprise_api_url_label": "Apprise API URL",
+ "notifications_apprise_api_url_placeholder": "http://localhost:8000/notify",
+ "notifications_apprise_api_url_help": "URL of your Apprise API endpoint",
+ "notifications_apprise_image_tag_label": "Image Update Tag",
+ "notifications_apprise_image_tag_placeholder": "image-updates",
+ "notifications_apprise_image_tag_help": "Optional tag for image update notifications",
+ "notifications_apprise_container_tag_label": "Container Update Tag",
+ "notifications_apprise_container_tag_placeholder": "container-updates",
+ "notifications_apprise_container_tag_help": "Optional tag for container update notifications",
+ "notifications_apprise_test_button": "Test Apprise",
+ "notifications_unsaved_changes_title": "Unsaved Changes",
+ "notifications_unsaved_changes_description": "You have unsaved changes. Would you like to save them before testing?",
+ "notifications_unsaved_changes_save_and_test": "Save & Test",
"glass_effect_title": "Glass Effect (Preview)",
"glass_effect_description": "Enable modern glassmorphism design with blur, gradients, and ambient effects",
"glass_effect_label": "Glassmorphism UI",
diff --git a/frontend/src/lib/services/notification-service.ts b/frontend/src/lib/services/notification-service.ts
index 0c5ffd575..a548390b7 100644
--- a/frontend/src/lib/services/notification-service.ts
+++ b/frontend/src/lib/services/notification-service.ts
@@ -1,5 +1,5 @@
import BaseAPIService from './api-service';
-import type { NotificationSettings, TestNotificationResponse } from '$lib/types/notification.type';
+import type { NotificationSettings, TestNotificationResponse, AppriseSettings } from '$lib/types/notification.type';
import { environmentStore } from '$lib/stores/environment.store.svelte';
export default class NotificationService extends BaseAPIService {
@@ -19,6 +19,23 @@ export default class NotificationService extends BaseAPIService {
const envId = await environmentStore.getCurrentEnvironmentId();
return this.handleResponse(this.api.post(`/environments/${envId}/notifications/test/${provider}?type=${type}`));
}
+
+ async getAppriseSettings(environmentId?: string): Promise<AppriseSettings> {
+ const envId = environmentId || (await environmentStore.getCurrentEnvironmentId());
+ const res = await this.api.get(`/environments/${envId}/notifications/apprise`);
+ return res.data;
+ }
+
+ async updateAppriseSettings(settings: AppriseSettings): Promise<AppriseSettings> {
+ const envId = await environmentStore.getCurrentEnvironmentId();
+ const res = await this.api.post(`/environments/${envId}/notifications/apprise`, settings);
+ return res.data;
+ }
+
+ async testAppriseNotification(): Promise<TestNotificationResponse> {
+ const envId = await environmentStore.getCurrentEnvironmentId();
+ return this.handleResponse(this.api.post(`/environments/${envId}/notifications/apprise/test`));
+ }
}
export const notificationService = new NotificationService();
diff --git a/frontend/src/lib/types/notification.type.ts b/frontend/src/lib/types/notification.type.ts
index a5e1515d7..582e86678 100644
--- a/frontend/src/lib/types/notification.type.ts
+++ b/frontend/src/lib/types/notification.type.ts
@@ -25,6 +25,14 @@ export interface NotificationSettings {
config?: Record<string, any>;
}
+export interface AppriseSettings {
+ id?: number;
+ apiUrl: string;
+ enabled: boolean;
+ imageUpdateTag: string;
+ containerUpdateTag: string;
+}
+
export interface TestNotificationResponse {
success: boolean;
message?: string;
diff --git a/frontend/src/routes/settings/notifications/+page.svelte b/frontend/src/routes/settings/notifications/+page.svelte
index ec134fb72..d964ba42e 100644
--- a/frontend/src/routes/settings/notifications/+page.svelte
+++ b/frontend/src/routes/settings/notifications/+page.svelte
@@ -2,6 +2,8 @@
import * as Card from '$lib/components/ui/card';
import * as Alert from '$lib/components/ui/alert';
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
+ import * as Tabs from '$lib/components/ui/tabs';
+ import * as Dialog from '$lib/components/ui/dialog';
import { Button } from '$lib/components/ui/button';
import { Spinner } from '$lib/components/ui/spinner';
import { toast } from 'svelte-sonner';
@@ -21,7 +23,7 @@
import Textarea from '$lib/components/ui/textarea/textarea.svelte';
import { m } from '$lib/paraglide/messages';
import { notificationService } from '$lib/services/notification-service';
- import type { EmailTLSMode } from '$lib/types/notification.type';
+ import type { EmailTLSMode, AppriseSettings } from '$lib/types/notification.type';
interface FormNotificationSettings {
discordEnabled: boolean;
@@ -46,9 +48,33 @@
let hasChanges = $state(false);
let isLoading = $state(false);
let isTesting = $state(false);
+ let showUnsavedDialog = $state(false);
+ let pendingTestAction: (() => Promise<void>) | null = $state(null);
const isReadOnly = $derived.by(() => $settingsStore.uiConfigDisabled);
const formState = getContext('settingsFormState') as any;
+ let appriseSettings: AppriseSettings = $state({
+ apiUrl: '',
+ enabled: false,
+ imageUpdateTag: '',
+ containerUpdateTag: ''
+ });
+
+ let savedAppriseSettings: AppriseSettings = $state({
+ apiUrl: '',
+ enabled: false,
+ imageUpdateTag: '',
+ containerUpdateTag: ''
+ });
+
+ const hasUnsavedChanges = $derived.by(() => {
+ const formData = form.validate();
+ if (!formData) return false;
+
+ const formChanged = JSON.stringify(formData) !== JSON.stringify(currentSettings);
+ const appriseChanged = JSON.stringify(appriseSettings) !== JSON.stringify(savedAppriseSettings);
+ return formChanged || appriseChanged;
+ });
let currentSettings = $state<FormNotificationSettings>({
discordEnabled: false,
discordWebhookUrl: '',
@@ -174,7 +200,11 @@
$formInputs.emailToAddresses.value !== currentSettings.emailToAddresses ||
$formInputs.emailTlsMode.value !== currentSettings.emailTlsMode ||
$formInputs.emailEventImageUpdate.value !== currentSettings.emailEventImageUpdate ||
- $formInputs.emailEventContainerUpdate.value !== currentSettings.emailEventContainerUpdate
+ $formInputs.emailEventContainerUpdate.value !== currentSettings.emailEventContainerUpdate ||
+ appriseSettings.enabled !== savedAppriseSettings.enabled ||
+ appriseSettings.apiUrl !== savedAppriseSettings.apiUrl ||
+ appriseSettings.imageUpdateTag !== savedAppriseSettings.imageUpdateTag ||
+ appriseSettings.containerUpdateTag !== savedAppriseSettings.containerUpdateTag
);
$effect(() => {
@@ -185,7 +215,7 @@
}
});
- onMount(() => {
+ onMount(async () => {
// Initialize settings from loaded data
if (data?.notificationSettings) {
const discordSetting = data.notificationSettings.find((s) => s.provider === 'discord');
@@ -231,6 +261,15 @@
$formInputs.emailEventContainerUpdate.value = currentSettings.emailEventContainerUpdate;
}
+ // Load Apprise settings
+ try {
+ const settings = await notificationService.getAppriseSettings();
+ appriseSettings = settings;
+ savedAppriseSettings = { ...settings };
+ } catch (error) {
+ // Apprise not configured yet, keep defaults
+ }
+
if (formState) {
formState.saveFunction = onSubmit;
formState.resetFunction = resetForm;
@@ -298,8 +337,17 @@
errors.push(m.notifications_saved_failed({ provider: 'Email', error: errorMsg }));
}
+ // Save Apprise settings
+ try {
+ await notificationService.updateAppriseSettings(appriseSettings);
+ } catch (error: any) {
+ const errorMsg = error?.response?.data?.error || error.message || m.common_unknown();
+ errors.push(m.notifications_saved_failed({ provider: 'Apprise', error: errorMsg }));
+ }
+
if (errors.length === 0) {
currentSettings = formData;
+ savedAppriseSettings = { ...appriseSettings };
toast.success(m.general_settings_saved());
} else {
errors.forEach((err) => toast.error(err));
@@ -329,14 +377,44 @@
$formInputs.emailTlsMode.value = currentSettings.emailTlsMode;
$formInputs.emailEventImageUpdate.value = currentSettings.emailEventImageUpdate;
$formInputs.emailEventContainerUpdate.value = currentSettings.emailEventContainerUpdate;
+ appriseSettings = { ...savedAppriseSettings };
+ }
+
+ async function testNotification(provider: 'discord' | 'email', testType: string = 'simple') {
+ if (hasUnsavedChanges) {
+ pendingTestAction = () => executeTest(provider, testType);
+ showUnsavedDialog = true;
+ return;
+ }
+ await executeTest(provider, testType);
+ }
+
+ async function executeTest(provider: 'discord' | 'email', testType: string = 'simple') {
+ isTesting = true;
+ try {
+ await notificationService.testNotification(provider, testType);
+ toast.success(m.notifications_test_success({ provider: provider.charAt(0).toUpperCase() + provider.slice(1) }));
+ } catch (error: any) {
+ const errorMsg = error?.response?.data?.error || error.message || m.common_unknown();
+ toast.error(m.notifications_test_failed({ error: errorMsg }));
+ } finally {
+ isTesting = false;
+ }
+ }
+ async function testAppriseNotification() {
+ if (hasUnsavedChanges) {
+ pendingTestAction = executeAppriseTest;
+ showUnsavedDialog = true;
+ return;
+ }
+ await executeAppriseTest();
}
- async function testNotification(provider: string, type: string = 'simple') {
+ async function executeAppriseTest() {
isTesting = true;
try {
- await notificationService.testNotification(provider, type);
- const typeLabel = type === 'image-update' ? 'Image Update' : 'Simple Test';
- toast.success(`${typeLabel} notification sent successfully to ${provider}`);
+ await notificationService.testAppriseNotification();
+ toast.success(m.notifications_test_success({ provider: 'Apprise' }));
} catch (error: any) {
const errorMsg = error?.response?.data?.error || error.message || m.common_unknown();
toast.error(m.notifications_test_failed({ error: errorMsg }));
@@ -344,6 +422,15 @@
isTesting = false;
}
}
+
+ async function handleSaveAndTest() {
+ showUnsavedDialog = false;
+ await onSubmit();
+ if (pendingTestAction) {
+ await pendingTestAction();
+ pendingTestAction = null;
+ }
+ }
</script>
<SettingsPageLayout
@@ -355,266 +442,353 @@
>
{#snippet mainContent()}
<fieldset disabled={isReadOnly} class="relative">
- <div class="space-y-4 sm:space-y-6">
- {#if isReadOnly}
- <Alert.Root variant="default">
- <Alert.Title>{m.notifications_read_only_title()}</Alert.Title>
- <Alert.Description>{m.notifications_read_only_description()}</Alert.Description>
- </Alert.Root>
- {/if}
-
- <Card.Root>
- <Card.Header icon={BellIcon}>
- <div class="flex flex-col space-y-1.5">
- <Card.Title>{m.notifications_discord_title()}</Card.Title>
- <Card.Description>{m.notifications_discord_description()}</Card.Description>
- </div>
- </Card.Header>
- <Card.Content class="space-y-4 px-3 py-4 sm:px-6">
- <SwitchWithLabel
- id="discord-enabled"
- bind:checked={$formInputs.discordEnabled.value}
- disabled={isReadOnly}
- label={m.notifications_discord_enabled_label()}
- description={m.notifications_discord_enabled_description()}
- />
-
- {#if $formInputs.discordEnabled.value}
- <div class="space-y-4 border-l-2 pl-4">
- <TextInputWithLabel
- bind:value={$formInputs.discordWebhookUrl.value}
- disabled={isReadOnly}
- label={m.notifications_discord_webhook_url_label()}
- placeholder={m.notifications_discord_webhook_url_placeholder()}
- type="text"
- autocomplete="off"
- helpText={m.notifications_discord_webhook_url_help()}
- />
- {#if $formInputs.discordWebhookUrl.error}
- <p class="text-destructive -mt-2 text-sm">{$formInputs.discordWebhookUrl.error}</p>
- {/if}
-
- <TextInputWithLabel
- bind:value={$formInputs.discordUsername.value}
- disabled={isReadOnly}
- label={m.notifications_discord_username_label()}
- placeholder={m.notifications_discord_username_placeholder()}
- type="text"
- autocomplete="off"
- helpText={m.notifications_discord_username_help()}
- />
-
- <TextInputWithLabel
- bind:value={$formInputs.discordAvatarUrl.value}
- disabled={isReadOnly}
- label={m.notifications_discord_avatar_url_label()}
- placeholder={m.notifications_discord_avatar_url_placeholder()}
- type="text"
- autocomplete="off"
- helpText={m.notifications_discord_avatar_url_help()}
- />
-
- <div class="space-y-3 pt-2">
- <Label class="text-sm font-medium">{m.notifications_events_title()}</Label>
- <p class="text-muted-foreground text-xs">{m.notifications_events_description()}</p>
- <div class="space-y-2">
- <SwitchWithLabel
- id="discord-event-image-update"
- bind:checked={$formInputs.discordEventImageUpdate.value}
- disabled={isReadOnly}
- label={m.notifications_event_image_update_label()}
- description={m.notifications_event_image_update_description()}
- />
- <SwitchWithLabel
- id="discord-event-container-update"
- bind:checked={$formInputs.discordEventContainerUpdate.value}
- disabled={isReadOnly}
- label={m.notifications_event_container_update_label()}
- description={m.notifications_event_container_update_description()}
- />
- </div>
- </div>
+ {#if isReadOnly}
+ <Alert.Root variant="default" class="mb-4 sm:mb-6">
+ <Alert.Title>{m.notifications_read_only_title()}</Alert.Title>
+ <Alert.Description>{m.notifications_read_only_description()}</Alert.Description>
+ </Alert.Root>
+ {/if}
+
+ <Tabs.Root value="built-in">
+ <Tabs.List class="inline-flex w-auto">
+ <Tabs.Trigger value="built-in">{m.notifications_tab_built_in()}</Tabs.Trigger>
+ <Tabs.Trigger value="apprise">{m.notifications_tab_apprise()}</Tabs.Trigger>
+ </Tabs.List>
+
+ <Tabs.Content value="built-in" class="mt-4 space-y-4 sm:mt-6 sm:space-y-6">
+ <Card.Root>
+ <Card.Header icon={BellIcon}>
+ <div class="flex flex-col space-y-1.5">
+ <Card.Title>{m.notifications_discord_title()}</Card.Title>
+ <Card.Description>{m.notifications_discord_description()}</Card.Description>
</div>
- {/if}
- </Card.Content>
- <Card.Footer class="flex gap-2 px-3 py-4 sm:px-6">
- {#if $formInputs.discordEnabled.value}
- <Button variant="outline" onclick={() => testNotification('discord')} disabled={isReadOnly || isTesting}>
- {#if isTesting}
- <Spinner class="mr-2 h-4 w-4" />
- {:else}
- <SendIcon class="mr-2 h-4 w-4" />
- {/if}
- {m.notifications_discord_test_button()}
- </Button>
- {/if}
- </Card.Footer>
- </Card.Root>
- <!-- Email Notifications -->
- <Card.Root>
- <Card.Header icon={BellIcon}>
- <div class="flex flex-col space-y-1.5">
- <Card.Title>{m.notifications_email_title()}</Card.Title>
- <Card.Description>{m.notifications_email_description()}</Card.Description>
- </div>
- </Card.Header>
- <Card.Content class="space-y-4 px-3 py-4 sm:px-6">
- <SwitchWithLabel
- id="email-enabled"
- bind:checked={$formInputs.emailEnabled.value}
- disabled={isReadOnly}
- label={m.notifications_email_enabled_label()}
- description={m.notifications_email_enabled_description()}
- />
-
- {#if $formInputs.emailEnabled.value}
- <div class="space-y-4 border-l-2 pl-4">
- <div class="grid grid-cols-2 gap-4">
+ </Card.Header>
+ <Card.Content class="space-y-4 px-3 py-4 sm:px-6">
+ <SwitchWithLabel
+ id="discord-enabled"
+ bind:checked={$formInputs.discordEnabled.value}
+ disabled={isReadOnly}
+ label={m.notifications_discord_enabled_label()}
+ description={m.notifications_discord_enabled_description()}
+ />
+
+ {#if $formInputs.discordEnabled.value}
+ <div class="space-y-4 border-l-2 pl-4">
<TextInputWithLabel
- bind:value={$formInputs.emailSmtpHost.value}
+ bind:value={$formInputs.discordWebhookUrl.value}
disabled={isReadOnly}
- label={m.notifications_email_smtp_host_label()}
- placeholder={m.notifications_email_smtp_host_placeholder()}
+ label={m.notifications_discord_webhook_url_label()}
+ placeholder={m.notifications_discord_webhook_url_placeholder()}
type="text"
autocomplete="off"
- helpText={m.notifications_email_smtp_host_help()}
+ helpText={m.notifications_discord_webhook_url_help()}
/>
- {#if $formInputs.emailSmtpHost.error}
- <p class="text-destructive col-span-2 -mt-2 text-sm">{$formInputs.emailSmtpHost.error}</p>
+ {#if $formInputs.discordWebhookUrl.error}
+ <p class="text-destructive -mt-2 text-sm">{$formInputs.discordWebhookUrl.error}</p>
{/if}
- <div class="space-y-2">
- <Label for="smtp-port">{m.notifications_email_smtp_port_label()}</Label>
- <Input
- id="smtp-port"
- type="number"
- bind:value={$formInputs.emailSmtpPort.value}
- disabled={isReadOnly}
- autocomplete="off"
- placeholder={m.notifications_email_smtp_port_placeholder()}
- />
- <p class="text-muted-foreground text-sm">{m.notifications_email_smtp_port_help()}</p>
- </div>
- </div>
-
- <div class="grid grid-cols-2 gap-4">
<TextInputWithLabel
- bind:value={$formInputs.emailSmtpUsername.value}
+ bind:value={$formInputs.discordUsername.value}
disabled={isReadOnly}
- label={m.notifications_email_username_label()}
- placeholder={m.notifications_email_username_placeholder()}
+ label={m.notifications_discord_username_label()}
+ placeholder={m.notifications_discord_username_placeholder()}
type="text"
autocomplete="off"
- helpText={m.notifications_email_username_help()}
+ helpText={m.notifications_discord_username_help()}
/>
<TextInputWithLabel
- bind:value={$formInputs.emailSmtpPassword.value}
+ bind:value={$formInputs.discordAvatarUrl.value}
disabled={isReadOnly}
- label={m.notifications_email_password_label()}
- placeholder={m.notifications_email_password_placeholder()}
- type="password"
- autocomplete="new-password"
- helpText={m.notifications_email_password_help()}
+ label={m.notifications_discord_avatar_url_label()}
+ placeholder={m.notifications_discord_avatar_url_placeholder()}
+ type="text"
+ autocomplete="off"
+ helpText={m.notifications_discord_avatar_url_help()}
/>
+
+ <div class="space-y-3 pt-2">
+ <Label class="text-sm font-medium">{m.notifications_events_title()}</Label>
+ <p class="text-muted-foreground text-xs">{m.notifications_events_description()}</p>
+ <div class="space-y-2">
+ <SwitchWithLabel
+ id="discord-event-image-update"
+ bind:checked={$formInputs.discordEventImageUpdate.value}
+ disabled={isReadOnly}
+ label={m.notifications_event_image_update_label()}
+ description={m.notifications_event_image_update_description()}
+ />
+ <SwitchWithLabel
+ id="discord-event-container-update"
+ bind:checked={$formInputs.discordEventContainerUpdate.value}
+ disabled={isReadOnly}
+ label={m.notifications_event_container_update_label()}
+ description={m.notifications_event_container_update_description()}
+ />
+ </div>
+ </div>
</div>
+ {/if}
+ </Card.Content>
+ <Card.Footer class="flex gap-2 px-3 py-4 sm:px-6">
+ {#if $formInputs.discordEnabled.value}
+ <Button variant="outline" onclick={() => testNotification('discord')} disabled={isReadOnly || isTesting}>
+ {#if isTesting}
+ <Spinner class="mr-2 h-4 w-4" />
+ {:else}
+ <SendIcon class="mr-2 h-4 w-4" />
+ {/if}
+ {m.notifications_discord_test_button()}
+ </Button>
+ {/if}
+ </Card.Footer>
+ </Card.Root>
+ <Card.Root>
+ <Card.Header icon={BellIcon}>
+ <div class="flex flex-col space-y-1.5">
+ <Card.Title>{m.notifications_email_title()}</Card.Title>
+ <Card.Description>{m.notifications_email_description()}</Card.Description>
+ </div>
+ </Card.Header>
+ <Card.Content class="space-y-4 px-3 py-4 sm:px-6">
+ <SwitchWithLabel
+ id="email-enabled"
+ bind:checked={$formInputs.emailEnabled.value}
+ disabled={isReadOnly}
+ label={m.notifications_email_enabled_label()}
+ description={m.notifications_email_enabled_description()}
+ />
+
+ {#if $formInputs.emailEnabled.value}
+ <div class="space-y-4 border-l-2 pl-4">
+ <div class="grid grid-cols-2 gap-4">
+ <TextInputWithLabel
+ bind:value={$formInputs.emailSmtpHost.value}
+ disabled={isReadOnly}
+ label={m.notifications_email_smtp_host_label()}
+ placeholder={m.notifications_email_smtp_host_placeholder()}
+ type="text"
+ autocomplete="off"
+ helpText={m.notifications_email_smtp_host_help()}
+ />
+ {#if $formInputs.emailSmtpHost.error}
+ <p class="text-destructive col-span-2 -mt-2 text-sm">{$formInputs.emailSmtpHost.error}</p>
+ {/if}
- <TextInputWithLabel
- bind:value={$formInputs.emailFromAddress.value}
- disabled={isReadOnly}
- label={m.notifications_email_from_address_label()}
- placeholder={m.notifications_email_from_address_placeholder()}
- type="email"
- autocomplete="off"
- helpText={m.notifications_email_from_address_help()}
- />
- {#if $formInputs.emailFromAddress.error}
- <p class="text-destructive -mt-2 text-sm">{$formInputs.emailFromAddress.error}</p>
- {/if}
-
- <div class="space-y-2">
- <Label for="to-addresses">{m.notifications_email_to_addresses_label()}</Label>
- <Textarea
- id="to-addresses"
- bind:value={$formInputs.emailToAddresses.value}
+ <div class="space-y-2">
+ <Label for="smtp-port">{m.notifications_email_smtp_port_label()}</Label>
+ <Input
+ id="smtp-port"
+ type="number"
+ bind:value={$formInputs.emailSmtpPort.value}
+ disabled={isReadOnly}
+ autocomplete="off"
+ placeholder={m.notifications_email_smtp_port_placeholder()}
+ />
+ <p class="text-muted-foreground text-sm">{m.notifications_email_smtp_port_help()}</p>
+ </div>
+ </div>
+
+ <div class="grid grid-cols-2 gap-4">
+ <TextInputWithLabel
+ bind:value={$formInputs.emailSmtpUsername.value}
+ disabled={isReadOnly}
+ label={m.notifications_email_username_label()}
+ placeholder={m.notifications_email_username_placeholder()}
+ type="text"
+ autocomplete="off"
+ helpText={m.notifications_email_username_help()}
+ />
+
+ <TextInputWithLabel
+ bind:value={$formInputs.emailSmtpPassword.value}
+ disabled={isReadOnly}
+ label={m.notifications_email_password_label()}
+ placeholder={m.notifications_email_password_placeholder()}
+ type="password"
+ autocomplete="new-password"
+ helpText={m.notifications_email_password_help()}
+ />
+ </div>
+
+ <TextInputWithLabel
+ bind:value={$formInputs.emailFromAddress.value}
disabled={isReadOnly}
+ label={m.notifications_email_from_address_label()}
+ placeholder={m.notifications_email_from_address_placeholder()}
+ type="email"
autocomplete="off"
- placeholder={m.notifications_email_to_addresses_placeholder()}
- rows={2}
+ helpText={m.notifications_email_from_address_help()}
/>
- {#if $formInputs.emailToAddresses.error}
- <p class="text-destructive text-sm">{$formInputs.emailToAddresses.error}</p>
- {:else}
- <p class="text-muted-foreground text-sm">{m.notifications_email_to_addresses_help()}</p>
+ {#if $formInputs.emailFromAddress.error}
+ <p class="text-destructive -mt-2 text-sm">{$formInputs.emailFromAddress.error}</p>
{/if}
- </div>
- <SelectWithLabel
- id="email-tls-mode"
- label="TLS Mode"
- bind:value={$formInputs.emailTlsMode.value}
- disabled={isReadOnly}
- placeholder="Select TLS mode"
- options={[
- { value: 'none', label: 'None' },
- { value: 'starttls', label: 'StartTLS' },
- { value: 'ssl', label: 'SSL/TLS' }
- ]}
- description="StartTLS (default) upgrades from plain connection. SSL/TLS uses encryption from start. None uses no encryption."
- />
-
- <div class="space-y-3 pt-2">
- <Label class="text-sm font-medium">{m.notifications_events_title()}</Label>
- <p class="text-muted-foreground text-xs">{m.notifications_events_description()}</p>
<div class="space-y-2">
- <SwitchWithLabel
- id="email-event-image-update"
- bind:checked={$formInputs.emailEventImageUpdate.value}
+ <Label for="to-addresses">{m.notifications_email_to_addresses_label()}</Label>
+ <Textarea
+ id="to-addresses"
+ bind:value={$formInputs.emailToAddresses.value}
disabled={isReadOnly}
- label={m.notifications_event_image_update_label()}
- description={m.notifications_event_image_update_description()}
- />
- <SwitchWithLabel
- id="email-event-container-update"
- bind:checked={$formInputs.emailEventContainerUpdate.value}
- disabled={isReadOnly}
- label={m.notifications_event_container_update_label()}
- description={m.notifications_event_container_update_description()}
+ autocomplete="off"
+ placeholder={m.notifications_email_to_addresses_placeholder()}
+ rows={2}
/>
+ {#if $formInputs.emailToAddresses.error}
+ <p class="text-destructive text-sm">{$formInputs.emailToAddresses.error}</p>
+ {:else}
+ <p class="text-muted-foreground text-sm">{m.notifications_email_to_addresses_help()}</p>
+ {/if}
+ </div>
+
+ <SelectWithLabel
+ id="email-tls-mode"
+ label={m.notifications_email_tls_mode_label()}
+ bind:value={$formInputs.emailTlsMode.value}
+ disabled={isReadOnly}
+ placeholder={m.notifications_email_tls_mode_placeholder()}
+ options={[
+ { value: 'none', label: 'None' },
+ { value: 'starttls', label: 'StartTLS' },
+ { value: 'ssl', label: 'SSL/TLS' }
+ ]}
+ description={m.notifications_email_tls_mode_description()}
+ />
+ <div class="space-y-3 pt-2">
+ <Label class="text-sm font-medium">{m.notifications_events_title()}</Label>
+ <p class="text-muted-foreground text-xs">{m.notifications_events_description()}</p>
+ <div class="space-y-2">
+ <SwitchWithLabel
+ id="email-event-image-update"
+ bind:checked={$formInputs.emailEventImageUpdate.value}
+ disabled={isReadOnly}
+ label={m.notifications_event_image_update_label()}
+ description={m.notifications_event_image_update_description()}
+ />
+ <SwitchWithLabel
+ id="email-event-container-update"
+ bind:checked={$formInputs.emailEventContainerUpdate.value}
+ disabled={isReadOnly}
+ label={m.notifications_event_container_update_label()}
+ description={m.notifications_event_container_update_description()}
+ />
+ </div>
</div>
</div>
- </div>
- {/if}
- </Card.Content>
- <Card.Footer class="flex gap-2 px-3 py-4 sm:px-6">
- {#if $formInputs.emailEnabled.value}
- <DropdownMenu.Root>
- <DropdownMenu.Trigger>
- <Button variant="outline" disabled={isReadOnly || isTesting}>
- {#if isTesting}
- <Spinner class="mr-2 h-4 w-4" />
- {:else}
+ {/if}
+ </Card.Content>
+ <Card.Footer class="flex gap-2 px-3 py-4 sm:px-6">
+ {#if $formInputs.emailEnabled.value}
+ <DropdownMenu.Root>
+ <DropdownMenu.Trigger>
+ <Button variant="outline" disabled={isReadOnly || isTesting}>
+ {#if isTesting}
+ <Spinner class="mr-2 h-4 w-4" />
+ {:else}
+ <SendIcon class="mr-2 h-4 w-4" />
+ {/if}
+ {m.notifications_email_test_button()}
+ <ChevronDownIcon class="ml-2 h-4 w-4" />
+ </Button>
+ </DropdownMenu.Trigger>
+ <DropdownMenu.Content align="start">
+ <DropdownMenu.Item onclick={() => testNotification('email', 'simple')}>
<SendIcon class="mr-2 h-4 w-4" />
- {/if}
- {m.notifications_email_test_button()}
- <ChevronDownIcon class="ml-2 h-4 w-4" />
- </Button>
- </DropdownMenu.Trigger>
- <DropdownMenu.Content align="start">
- <DropdownMenu.Item onclick={() => testNotification('email', 'simple')}>
- <SendIcon class="mr-2 h-4 w-4" />
- Simple Test Email
- </DropdownMenu.Item>
- <DropdownMenu.Item onclick={() => testNotification('email', 'image-update')}>
+ {m.notifications_email_test_simple()}
+ </DropdownMenu.Item>
+ <DropdownMenu.Item onclick={() => testNotification('email', 'image-update')}>
+ <SendIcon class="mr-2 h-4 w-4" />
+ {m.notifications_email_test_image_update()}
+ </DropdownMenu.Item>
+ </DropdownMenu.Content>
+ </DropdownMenu.Root>
+ {/if}
+ </Card.Footer>
+ </Card.Root>
+ </Tabs.Content>
+
+ <Tabs.Content value="apprise" class="mt-4 space-y-4 sm:mt-6 sm:space-y-6">
+ <Card.Root>
+ <Card.Header icon={BellIcon}>
+ <div class="flex flex-col space-y-1.5">
+ <Card.Title>{m.notifications_apprise_title()}</Card.Title>
+ <Card.Description>{m.notifications_apprise_description()}</Card.Description>
+ </div>
+ </Card.Header>
+ <Card.Content class="space-y-4 px-3 py-4 sm:px-6">
+ <SwitchWithLabel
+ id="apprise-enabled"
+ bind:checked={appriseSettings.enabled}
+ disabled={isReadOnly}
+ label={m.notifications_apprise_enabled_label()}
+ description={m.notifications_apprise_enabled_description()}
+ />
+ {#if appriseSettings.enabled}
+ <div class="space-y-4 border-l-2 pl-4">
+ <TextInputWithLabel
+ bind:value={appriseSettings.apiUrl}
+ disabled={isReadOnly}
+ label={m.notifications_apprise_api_url_label()}
+ placeholder={m.notifications_apprise_api_url_placeholder()}
+ type="url"
+ autocomplete="off"
+ helpText={m.notifications_apprise_api_url_help()}
+ />
+ <TextInputWithLabel
+ bind:value={appriseSettings.imageUpdateTag}
+ disabled={isReadOnly}
+ label={m.notifications_apprise_image_tag_label()}
+ placeholder={m.notifications_apprise_image_tag_placeholder()}
+ type="text"
+ autocomplete="off"
+ helpText={m.notifications_apprise_image_tag_help()}
+ />
+ <TextInputWithLabel
+ bind:value={appriseSettings.containerUpdateTag}
+ disabled={isReadOnly}
+ label={m.notifications_apprise_container_tag_label()}
+ placeholder={m.notifications_apprise_container_tag_placeholder()}
+ type="text"
+ autocomplete="off"
+ helpText={m.notifications_apprise_container_tag_help()}
+ />
+ </div>
+ {/if}
+ </Card.Content>
+ <Card.Footer class="flex gap-2 px-3 py-4 sm:px-6">
+ {#if appriseSettings.enabled}
+ <Button variant="outline" onclick={() => testAppriseNotification()} disabled={isReadOnly || isTesting}>
+ {#if isTesting}
+ <Spinner class="mr-2 h-4 w-4" />
+ {:else}
<SendIcon class="mr-2 h-4 w-4" />
- Image Update Email
- </DropdownMenu.Item>
- </DropdownMenu.Content>
- </DropdownMenu.Root>
- {/if}
- </Card.Footer>
- </Card.Root>
- </div>
+ {/if}
+ {m.notifications_apprise_test_button()}
+ </Button>
+ {/if}
+ </Card.Footer>
+ </Card.Root>
+ </Tabs.Content>
+ </Tabs.Root>
</fieldset>
{/snippet}
</SettingsPageLayout>
+
+<Dialog.Root bind:open={showUnsavedDialog}>
+ <Dialog.Content>
+ <Dialog.Header>
+ <Dialog.Title>{m.notifications_unsaved_changes_title()}</Dialog.Title>
+ <Dialog.Description>
+ {m.notifications_unsaved_changes_description()}
+ </Dialog.Description>
+ </Dialog.Header>
+ <Dialog.Footer>
+ <Button variant="outline" onclick={() => (showUnsavedDialog = false)}>
+ {m.common_cancel()}
+ </Button>
+ <Button onclick={handleSaveAndTest}>
+ {m.notifications_unsaved_changes_save_and_test()}
+ </Button>
+ </Dialog.Footer>
+ </Dialog.Content>
+</Dialog.Root>