~humaid/workflow-engine unlisted

aebc1ec6292110dc83e4fca12d6d1f9b6446e20d — Humaid AlQassimi 7 months ago aa905ef
Add basic errors structures/page
4 files changed, 35 insertions(+), 0 deletions(-)

M admin.go
M database.go
M routes.go
A templates/errors.tmpl
M admin.go => admin.go +5 -0
@@ 101,10 101,15 @@ func (e *Engine) RunWebInterface() {
			m.Post("/step/:service/:channel/:step", binding.BindIgnErr(newStepForm{}), postEditStepHandler)
		})
		m.Get("/commit", commitHandler)
		m.Get("/errors", errorsHandler)
	}, requireLogin)
	log.Fatal(http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", e.Options.AdminPort), m))
}

func errorsHandler(ctx *macaron.Context) {
	ctx.HTML(http.StatusOK, "errors")
}

func editStepHandler(ctx *macaron.Context, f *session.Flash) {
	e := ctx.Data["Engine"].(*Engine)
	s := e.getStep(ctx.Params("service"), ctx.Params("channel"), ctx.Params("step"))

M database.go => database.go +11 -0
@@ 14,6 14,17 @@ import (
	_ "github.com/mattn/go-sqlite3"    // SQLite driver support
)

type errorLog struct {
	ID                  int64 `xorm:"pk autoincr"`
	CreatedUnix         int64 `xorm:"created"`
	ActualisationID     string
	ActualisationStepID int64
	Stage               string
	Description         string
	RequestURL          string
	RequestData         string
}

type actualisationStatus int

const (

M routes.go => routes.go +3 -0
@@ 151,6 151,9 @@ func stepCompleteHandler(c *gin.Context) {

				// Apply commits
				err = engine.commitStep(tx, act, step)
				if err != nil {
					// TODO implement err here!!!
				}

				tx.ID(s.ID).Cols("status").Update(&actualisationStep{
					Status: stepComplete,

A templates/errors.tmpl => templates/errors.tmpl +16 -0
@@ 0,0 1,16 @@
{{template "base/head" .}}
<div class="content">
	{{template "partials/flash" .}}
	<h2>Errors</h2>
	{{range .Errors}}
	<div class="entry">
		<a href="/s/{{.ServiceID}}">{{.ServiceID}}</a>
		<div class="meta">
			<p><a href="#">{{if .Description}}{{.Description}}{{else}}No
			description{{end}}</a></p>
		</div>
	</div>
	{{end}}
</div>
{{template "base/footer" .}}