diff --git a/core/services.go b/core/services.go index ee3110a3..56aaeffa 100644 --- a/core/services.go +++ b/core/services.go @@ -388,7 +388,7 @@ func (s *Service) UpdateSingle(attr ...interface{}) error { // Update will update a service in the database, the service's checking routine can be restarted by passing true func (s *Service) Update(restart bool) error { - err := servicesDB().Update(s) + err := servicesDB().Update(&s) if err.Error != nil { utils.Log(3, fmt.Sprintf("Failed to update service %v. %v", s.Name, err)) return err.Error @@ -396,7 +396,7 @@ func (s *Service) Update(restart bool) error { // clear the notification queue for a service if !s.AllowNotifications.Bool { for _, n := range CoreApp.Notifications { - notif := n.(*notifier.Notification) + notif := n.(notifier.Notifier).Select() notif.ResetUniqueQueue(s.Id) } } diff --git a/handlers/services.go b/handlers/services.go index f01596a0..aa9971a0 100644 --- a/handlers/services.go +++ b/handlers/services.go @@ -18,7 +18,6 @@ package handlers import ( "encoding/json" "errors" - "fmt" "github.com/gorilla/mux" "github.com/hunterlong/statup/core" "github.com/hunterlong/statup/types" @@ -65,20 +64,17 @@ func reorderServiceHandler(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/", http.StatusSeeOther) return } + r.ParseForm() var newOrder []*serviceOrder decoder := json.NewDecoder(r.Body) - if err := decoder.Decode(&newOrder); err != nil { - utils.Log(3, fmt.Sprint("error decoding reordering services: %v", err.Error())) - } + decoder.Decode(&newOrder) for _, s := range newOrder { service := core.SelectService(s.Id) service.Order = s.Order - if err := service.Update(false); err != nil { - utils.Log(3, fmt.Sprint("error reordering services: %v", err.Error())) - } + service.Update(false) } - w.Write([]byte("ok")) - w.WriteHeader(http.StatusOK) + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(newOrder) } func servicesViewHandler(w http.ResponseWriter, r *http.Request) { diff --git a/handlers/settings.go b/handlers/settings.go index cf190778..e239615b 100644 --- a/handlers/settings.go +++ b/handlers/settings.go @@ -67,9 +67,6 @@ func saveSettingsHandler(w http.ResponseWriter, r *http.Request) { timeFloat, _ := strconv.ParseFloat(timezone, 10) app.Timezone = float32(timeFloat) - utils.Log(1, fmt.Sprintf("timezone: %v", timezone)) - utils.Log(1, fmt.Sprintf("tzone: %f", app.Timezone)) - app.UseCdn = types.NewNullBool(r.PostForm.Get("enable_cdn") == "on") core.CoreApp, err = core.UpdateCore(app) if err != nil { diff --git a/source/tmpl/services.html b/source/tmpl/services.html index 220ddf50..57cb2580 100644 --- a/source/tmpl/services.html +++ b/source/tmpl/services.html @@ -60,8 +60,15 @@ var o = {service: parseInt(dId), order: i}; newOrder.push(o); }); - console.log(JSON.stringify(newOrder)); - $.post("/services/reorder", JSON.stringify(newOrder), function(data, status){ + $.ajax({ + url: "/services/reorder", + type: 'POST', + data: JSON.stringify(newOrder), + contentType: "application/json", + dataType: "json", + success: function(data) { + console.log(data) + } }); }); diff --git a/version.txt b/version.txt index b563764e..b45d36a6 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.79.92 \ No newline at end of file +0.79.93 \ No newline at end of file