mirror of
https://github.com/StarFleetCPTN/GoMFT.git
synced 2026-09-08 15:41:20 +02:00
feat: Enhance notification services with delete confirmation dialog
- Added a confirmation dialog for deleting notification services to prevent accidental deletions. - Updated the notifications management interface to include improved delete button functionality. - Enhanced JavaScript event handling for delete requests, providing user feedback on success and error scenarios. - Refactored notification service deletion logic to ensure accurate tracking and messaging during deletion operations.
This commit is contained in:
@@ -1579,12 +1579,23 @@ func (s *Scheduler) sendServiceWebhookNotification(service *db.NotificationServi
|
||||
|
||||
// generateDefaultPayload creates a standard webhook payload
|
||||
func generateDefaultPayload(job *db.Job, history *db.JobHistory, config *db.TransferConfig, eventType string) map[string]interface{} {
|
||||
// get event type
|
||||
switch eventType {
|
||||
case "job_start":
|
||||
eventType = "Job Started"
|
||||
case "job_complete":
|
||||
eventType = "Job Completed"
|
||||
case "job_fail":
|
||||
eventType = "Job Failed"
|
||||
}
|
||||
|
||||
payload := map[string]interface{}{
|
||||
"event": eventType,
|
||||
"job": map[string]interface{}{
|
||||
"id": job.ID,
|
||||
"name": job.Name,
|
||||
"status": history.Status,
|
||||
"event": eventType,
|
||||
"message": history.ErrorMessage,
|
||||
"started_at": history.StartTime.Format(time.RFC3339),
|
||||
"config_id": config.ID,
|
||||
@@ -2400,6 +2411,8 @@ func (s *Scheduler) sendNtfyNotification(service *db.NotificationService, job *d
|
||||
func (s *Scheduler) sendGotifyNotification(service *db.NotificationService, job *db.Job, history *db.JobHistory, config *db.TransferConfig, eventType string) error {
|
||||
s.log.LogDebug("Sending Gotify notification for job %d", job.ID)
|
||||
|
||||
// pretty print job
|
||||
fmt.Printf("Job: %+v\n", job)
|
||||
// Get Gotify server URL and token from service config
|
||||
serverURL, ok := service.Config["url"]
|
||||
if !ok || serverURL == "" {
|
||||
|
||||
@@ -74,12 +74,6 @@ func (h *Handlers) HandleCreateNotificationService(c *gin.Context) {
|
||||
description := c.PostForm("description")
|
||||
isEnabled := c.PostForm("is_enabled") == "on"
|
||||
|
||||
// print the form data
|
||||
fmt.Println("name", name)
|
||||
fmt.Println("serviceType", serviceType)
|
||||
fmt.Println("description", description)
|
||||
fmt.Println("isEnabled", isEnabled)
|
||||
|
||||
// Validate required fields
|
||||
if name == "" || serviceType == "" {
|
||||
// Return to notifications page with error message
|
||||
@@ -727,6 +721,8 @@ func (h *Handlers) HandleTestNotification(c *gin.Context) {
|
||||
config["priority"] = c.PostForm("gotify_priority")
|
||||
config["title"] = c.PostForm("gotify_title_template")
|
||||
|
||||
fmt.Println("config", config)
|
||||
|
||||
// Validate required fields
|
||||
if config["url"] == "" || config["token"] == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"success": false, "message": "Gotify Server URL and Application Token are required"})
|
||||
|
||||
Reference in New Issue
Block a user