diff --git a/public/css/water.css b/public/css/water.css index 58f41ee..53088d6 100755 --- a/public/css/water.css +++ b/public/css/water.css @@ -43,5 +43,6 @@ tbody tr:nth-child(2n+1) { background: inherit; min-width: 40%; display: inline-block; + white-space: pre; } diff --git a/public/index.html b/public/index.html index cbdd4a5..1a359bb 100755 --- a/public/index.html +++ b/public/index.html @@ -3,9 +3,6 @@ -

- Firestormy -

Upsert Job
diff --git a/public/js/js.js b/public/js/js.js index 03ab058..76b1647 100755 --- a/public/js/js.js +++ b/public/js/js.js @@ -164,6 +164,8 @@ function getForm() { return document.getElementById("upsert") } +getForm().reset() + function getField(name) { var form = getForm() var matches = form.elements[name] diff --git a/scheduler/job.go b/scheduler/job.go index 3a5f11d..251c69a 100755 --- a/scheduler/job.go +++ b/scheduler/job.go @@ -67,7 +67,6 @@ func newBashJob(schedule, sh string, title ...string) (*Job, error) { } b, err := j.Encode() if err == nil { - // TODO webpage doenst load post SET despite this returning nil config.Store.Set(j.Name, b, ns.Jobs...) } logger.New().Info("result", fmt.Sprintf("%+v", j)) diff --git a/server/job.go b/server/job.go index ce6fa78..647e194 100644 --- a/server/job.go +++ b/server/job.go @@ -2,7 +2,6 @@ package server import ( "local/firestormy/scheduler" - "strings" "time" ) @@ -21,7 +20,7 @@ func toMap(j *scheduler.Job) map[string]interface{} { out["last"] = map[string]interface{}{ "run": j.LastRun.In(tz).Format(`2006-01-02 15:04:05 MST`), "runtime": j.LastRuntime.String(), - "output": strings.ReplaceAll(j.LastOutput, "\n", "
"), + "output": j.LastOutput, "status": j.LastStatus, } return out diff --git a/server/upsert.go b/server/upsert.go index fe65e39..04e3e43 100755 --- a/server/upsert.go +++ b/server/upsert.go @@ -33,7 +33,6 @@ func newUpsertRequest(r io.Reader) (upsertRequest, error) { func (u *upsertRequest) validate() error { if u.ID == "" { - u.ID = uuid.New().String() } else if _, err := config.Store.Get(u.ID, ns.Jobs...); err != nil { return fmt.Errorf("ID provided but not accessible: %v", err) } @@ -74,7 +73,16 @@ func (s *Server) upsert(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), http.StatusInternalServerError) return } - if err := scheduler.Schedule.Update(job); err != nil { + if job.Name == "" { + job.Name = uuid.New().String() + if job.Title == "" { + job.Title = job.Name + } + if err := scheduler.Schedule.Add(job); err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + } else if err := scheduler.Schedule.Update(job); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return }