Added route to view hardware component
This commit is contained in:
parent
4ad9a92306
commit
dcfc6e0115
@ -7,6 +7,12 @@
|
||||
|
||||
<hr>
|
||||
|
||||
<h3>Latest Benchmark Results:</h3>
|
||||
|
||||
<p>There are currently no benchmarks recorded using this hardware component.</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<p><a href="/hardware">Back</a></p>
|
||||
</div>
|
||||
|
||||
|
@ -22,6 +22,8 @@ func RegisterRoutes(f *flamego.Flame) {
|
||||
|
||||
f.Get("/create", routes.HardwareGetCreate)
|
||||
f.Post("/create", binding.Form(forms.HardwareForm{}), routes.HardwarePostCreate)
|
||||
|
||||
f.Get("/{hardware_id}", routes.HardwareGetView)
|
||||
})
|
||||
|
||||
// test routes
|
||||
|
@ -17,13 +17,25 @@ import (
|
||||
func HardwareGetList(t template.Template, data template.Data) {
|
||||
// add hardwares to template
|
||||
var hardware []models.Hardware
|
||||
models.DB.Find(&hardware)
|
||||
models.DB.First(&hardware)
|
||||
data["hardware"] = hardware
|
||||
|
||||
data["title"] = "List of Hardware"
|
||||
t.HTML(http.StatusOK, "hardware/list")
|
||||
}
|
||||
|
||||
func HardwareGetView(c flamego.Context, t template.Template, data template.Data) {
|
||||
// find hardware ID from request
|
||||
var hardwareID := c.Param("hardware_id")
|
||||
|
||||
// find hardware from DB
|
||||
var hardware models.Hardware
|
||||
models.DB.Find(&hardware)
|
||||
data["hardware"] = hardware
|
||||
|
||||
data["title"] = hardware.
|
||||
}
|
||||
|
||||
func HardwareGetCreate(t template.Template, data template.Data) {
|
||||
data["title"] = "Add New Hardware"
|
||||
t.HTML(http.StatusOK, "hardware/create")
|
||||
|
Loading…
Reference in New Issue
Block a user