diff --git a/api/types/pipeline.go b/api/types/pipeline.go index 8980885..636b55c 100644 --- a/api/types/pipeline.go +++ b/api/types/pipeline.go @@ -4,7 +4,7 @@ import "github.com/go-playground/validator/v10" type Pipeline struct { Tasks []Task `json:"Tasks" validate:"required"` - Parameters map[string]interface{} `json:"parameters" validate:"required"` + Parameters map[string]interface{} `json:"Parameters" validate:"required"` } func (p *Pipeline) Validate() error { diff --git a/web/modules/editor/editor.go b/web/modules/editor/editor.go index 7a0d461..20b67a6 100644 --- a/web/modules/editor/editor.go +++ b/web/modules/editor/editor.go @@ -1,15 +1,43 @@ package editor import ( + "encoding/json" + "github.com/PiotrFerenc/mash2/api/types" "github.com/labstack/echo/v4" "net/http" ) func CreateEditorHandler() func(c echo.Context) error { return func(c echo.Context) error { + initCommand, err := initCommand() + if err != nil { + return err + } + data := map[string]interface{}{ - "Title": "Edytor", + "Title": "Edytor", + "InitCommand": string(initCommand), } return c.Render(http.StatusOK, "edytor.html", data) } } + +func initCommand() ([]byte, error) { + initCommand := types.Pipeline{ + Parameters: map[string]interface{}{ + "my-console.text": "hallo word", + }, + Tasks: []types.Task{ + types.Task{ + Sequence: 1, + Action: "console", + Name: "my-console", + }, + }, + } + initCommandBytes, err := json.MarshalIndent(initCommand, "", " ") + if err != nil { + return nil, err + } + return initCommandBytes, nil +} diff --git a/web/public/views/edytor.html b/web/public/views/edytor.html index b021db8..4e5d693 100644 --- a/web/public/views/edytor.html +++ b/web/public/views/edytor.html @@ -20,7 +20,7 @@
-
+
             graph TD
             asd[Client qwe] -->|tcp_123| B
             B(Load Balancer)
@@ -32,6 +32,8 @@
     
{{template "scripts" .}} -