Deletion of notification services.
This commit is contained in:
parent
c7ad2aa1b6
commit
a736ae60af
10 changed files with 74 additions and 9 deletions
20
main.go
20
main.go
|
|
@ -155,6 +155,7 @@ func main() { // {{{
|
|||
service.Register("/configuration/timezone", false, false, actionConfigurationTimezone)
|
||||
service.Register("/configuration/notification", false, false, pageConfigurationNotification)
|
||||
service.Register("/configuration/notification/update/{prio}", false, false, actionConfigurationNotificationUpdate)
|
||||
service.Register("/configuration/notification/delete/{prio}", false, false, actionConfigurationNotificationDelete)
|
||||
service.Register("/entry/{datapoint}", false, false, actionEntryDatapoint)
|
||||
|
||||
go nodataLoop()
|
||||
|
|
@ -1085,7 +1086,8 @@ func pageConfigurationNotification(w http.ResponseWriter, r *http.Request, _ *se
|
|||
var service notification.Service
|
||||
if notificationType != "" {
|
||||
// Create a new instance of the selected notification type.
|
||||
service = notification.GetInstance(notificationType)
|
||||
service = notification.NewInstance(notificationType)
|
||||
logger.Info("FOO", "service", fmt.Sprintf("%p %#v\n", service, service))
|
||||
} else {
|
||||
// Find the existing service for editing.
|
||||
prio, err := strconv.Atoi(prioStr)
|
||||
|
|
@ -1138,7 +1140,7 @@ func actionConfigurationNotificationUpdate(w http.ResponseWriter, r *http.Reques
|
|||
// prio -1 means a new service, not existing in database.
|
||||
var svc *notification.Service
|
||||
if prio == -1 {
|
||||
emptyService := notification.GetInstance(r.PostFormValue("type"))
|
||||
emptyService := notification.NewInstance(r.PostFormValue("type"))
|
||||
svc = &emptyService
|
||||
} else {
|
||||
svc = notificationManager.GetService(prio)
|
||||
|
|
@ -1178,3 +1180,17 @@ func actionConfigurationNotificationUpdate(w http.ResponseWriter, r *http.Reques
|
|||
w.Header().Add("Location", "/configuration")
|
||||
w.WriteHeader(302)
|
||||
} // }}}
|
||||
func actionConfigurationNotificationDelete(w http.ResponseWriter, r *http.Request, _ *session.T) { // {{{
|
||||
prioStr := r.PathValue("prio")
|
||||
prio, err := strconv.Atoi(prioStr)
|
||||
if err != nil {
|
||||
pageError(w, "/configuration", werr.Wrap(err).Log())
|
||||
return
|
||||
}
|
||||
|
||||
DeleteNotificationService(prio)
|
||||
notificationManager.RemoveService(prio)
|
||||
|
||||
w.Header().Add("Location", "/configuration")
|
||||
w.WriteHeader(302)
|
||||
} // }}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue