diff --git a/web/modules/editor/editor.go b/web/modules/editor/editor.go index 20b67a6..7070665 100644 --- a/web/modules/editor/editor.go +++ b/web/modules/editor/editor.go @@ -2,7 +2,10 @@ package editor import ( "encoding/json" + "fmt" "github.com/PiotrFerenc/mash2/api/types" + "github.com/PiotrFerenc/mash2/internal/configuration" + "github.com/PiotrFerenc/mash2/internal/executor" "github.com/labstack/echo/v4" "net/http" ) @@ -13,14 +16,36 @@ func CreateEditorHandler() func(c echo.Context) error { if err != nil { return err } - + initActions, err := initActions() + if err != nil { + return err + } data := map[string]interface{}{ "Title": "Edytor", "InitCommand": string(initCommand), + "Actions": initActions, } return c.Render(http.StatusOK, "edytor.html", data) } } +func initActions() (map[string]string, error) { + actions := executor.CreateActionMap(&configuration.Config{}) + result := make(map[string]string, len(actions)) + + for name, _ := range actions { + jsonString, err := json.MarshalIndent(types.Task{ + Sequence: 0, + Action: name, + Name: fmt.Sprintf("my-%s", name), + }, "", " ") + if err != nil { + return nil, err + } + result[name] = string(jsonString) + + } + return result, nil +} func initCommand() ([]byte, error) { initCommand := types.Pipeline{ diff --git a/web/public/views/edytor.html b/web/public/views/edytor.html index 4e5d693..578adf0 100644 --- a/web/public/views/edytor.html +++ b/web/public/views/edytor.html @@ -21,16 +21,24 @@
-            graph TD
-            asd[Client qwe] -->|tcp_123| B
-            B(Load Balancer)
-            B --> C[Server1]
-            B -->|tcp_456| D[Server2]
+
     
+ {{template "scripts" .}} -