-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update editor interface and capitalize JSON field
The editor interface update includes initialization of the command on creation of the editor handler. A function to initialize the command with pre-filled details (Pipeline, Parameters and Tasks) has been added. In "pipeline.go", the json annotation of the 'parameters' field has been corrected to 'Parameters' for consistency.
- Loading branch information
1 parent
d1f98bc
commit 19f409b
Showing
3 changed files
with
34 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters