Implement client side enable, disable, edit
This commit is contained in:
@@ -33,6 +33,7 @@ func (s *Server) list(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
out[i]["disabled"] = j.Disabled
|
||||
out[i]["id"] = j.Name
|
||||
out[i]["title"] = j.Title
|
||||
out[i]["cron"] = j.Schedule
|
||||
|
||||
@@ -13,11 +13,11 @@ func (s *Server) Routes() error {
|
||||
handler http.HandlerFunc
|
||||
}{
|
||||
{
|
||||
path: fmt.Sprintf("/upserts"),
|
||||
handler: s.gzip(s.authenticate(s.upserts)),
|
||||
path: fmt.Sprintf("/api/job/upsert"),
|
||||
handler: s.gzip(s.authenticate(s.upsert)),
|
||||
},
|
||||
{
|
||||
path: fmt.Sprintf("/list"),
|
||||
path: fmt.Sprintf("/api/job/list"),
|
||||
handler: s.gzip(s.authenticate(s.list)),
|
||||
},
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@ type upsertRequest struct {
|
||||
Language string `json:"language"`
|
||||
Cron string `json:"cron"`
|
||||
Script string `json:"script"`
|
||||
Disabled bool `json:"disabled"`
|
||||
}
|
||||
|
||||
func newUpsertRequest(r io.Reader) (upsertRequest, error) {
|
||||
@@ -51,7 +52,7 @@ func (u *upsertRequest) validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) upserts(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) upsert(w http.ResponseWriter, r *http.Request) {
|
||||
upsert, err := newUpsertRequest(r.Body)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
Reference in New Issue
Block a user