Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init of editing hosts #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions actions/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func App() *buffalo.App {
app.GET("/hosts/create", HostsCreate)
app.GET("/hosts/show", HostsShow)
app.POST("/hosts/new", HostsNew)
app.GET("/hosts/{id}/edit", HostsEdit)
app.ServeFiles("/assets", assetsPath())
}

Expand Down
36 changes: 36 additions & 0 deletions actions/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package actions
import (
"github.com/gobuffalo/buffalo"
"github.com/bscott/rancher-wrangler/models"

)

// HostsShow default implementation.
Expand Down Expand Up @@ -34,4 +35,39 @@ import (
return c.Render(200, r.String("Host Created"))

}

// HostEdit implements the edit of an Host entry
func HostsEdit(c buffalo.Context) error {
var hh models.Host
//models.DB.All(&hh)
var id = c.Param("id")

err := models.DB.Find(&hh, id)

if err != nil {
return c.Error(500, err)
}


c.Set("host", hh)
return c.Render(200, r.HTML("hosts/_edit.html"))
}

// HostUpdate implements the update of an Host entry
func HostsUpdate(c buffalo.Context) error {
var hh models.Host
//models.DB.All(&hh)
var id = c.Param("id")

err := models.DB.Find(&hh, id)

if err != nil {
return c.Error(500, err)
}


c.Set("host", hh)
return c.Render(200, r.HTML("hosts/_edit.html"))
}


15 changes: 15 additions & 0 deletions templates/hosts/_edit.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="row">
</div>
<div class="col-md-10">
</div>
<h1>Wrangler - Edit host to inventory</h1>

<hr>

<form class="host-edit-form" action="/hosts/update" method="put">

Name for Host (e.g. My Rancher Server): <input type="text" name="name" value="{{ host.Name }}" />
<br/>
Description of Host (e.g. Rancher Server in AWS US West 2): <input type="text" name="description" value="{{ host.Description }}" />
<br/>
Rancher Server URL (e.g. https://rancher.domain.com:8080/): <input type="text" name="url" value="{{ host.Url }}" />

<br/>

Rancher API Access Key: <input type="text" name="access_key" value="{{ host.AccessKey }}" />

<br/>

Rancher API Secret Key: <input type="text" name="secret_key" value="{{ host.SecretKey }}" />

<br/>

<br/>

<input type="submit" name="update" value="Update" />

</form>