adjustments

This commit is contained in:
talksik
2023-09-06 13:25:05 -07:00
parent 8720100313
commit 7826fc21d5
3 changed files with 16 additions and 8 deletions
+10 -3
View File
@@ -19,9 +19,16 @@ func getStatusHandler(w http.ResponseWriter, r *http.Request) {
} }
func updateStatusHandler(w http.ResponseWriter, r *http.Request) { func updateStatusHandler(w http.ResponseWriter, r *http.Request) {
// TODO: read request and update statuses // TODO: read request and update statuses
println("changing status") println("changing status")
queryParams := r.URL.Query()
h_status := queryParams.Get("statush")
a_status := queryParams.Get("statusa")
statusOne = h_status
statusTwo = a_status
getStatusHandler(w, r) getStatusHandler(w, r)
} }
@@ -32,8 +39,8 @@ func main() {
component := templates.Hello("John") component := templates.Hello("John")
http.Handle("/hello", templ.Handler(component)) http.Handle("/hello", templ.Handler(component))
http.HandleFunc("/", getStatusHandler)
http.HandleFunc("/changestatus", updateStatusHandler) http.HandleFunc("/changestatus", updateStatusHandler)
http.HandleFunc("/", getStatusHandler)
fmt.Println("Listening on :3000") fmt.Println("Listening on :3000")
http.ListenAndServe(":3000", nil) http.ListenAndServe(":3000", nil)
+4 -3
View File
@@ -9,14 +9,15 @@ templ GetStatus(statusOne string, statusTwo string) {
hx-swap="outerHTML" hx-swap="outerHTML"
> >
<input <input
id="statusH" name="Status H" type="text" id="statusH" name="statush" type="text"
placeholder="Enter status H" placeholder="Enter status H"
value={ statusOne } value={ statusOne }
/> />
<input <input
id="statusA" name="Status A" type="text" id="statusA" name="statusa" type="text"
placeholder="Enter status, A" value={ statusTwo } placeholder="Enter status, A"
value={ statusTwo }
/> />
<button type="submit" class="button is-primary">Update</button> <button type="submit" class="button is-primary">Update</button>
+2 -2
View File
@@ -31,7 +31,7 @@ func GetStatus(statusOne string, statusTwo string) templ.Component {
if err != nil { if err != nil {
return err return err
} }
_, err = templBuffer.WriteString("</script><div id=\"main\" class=\"flex flex-row gap-2\"><form hx-post=\"/changestatus\" hx-target=\"#main\" hx-swap=\"outerHTML\"><input id=\"statusH\" name=\"Status H\" type=\"text\" placeholder=\"Enter status H\" value=\"") _, err = templBuffer.WriteString("</script><div id=\"main\" class=\"flex flex-row gap-2\"><form hx-post=\"/changestatus\" hx-target=\"#main\" hx-swap=\"outerHTML\"><input id=\"statusH\" name=\"statush\" type=\"text\" placeholder=\"Enter status H\" value=\"")
if err != nil { if err != nil {
return err return err
} }
@@ -39,7 +39,7 @@ func GetStatus(statusOne string, statusTwo string) templ.Component {
if err != nil { if err != nil {
return err return err
} }
_, err = templBuffer.WriteString("\"><input id=\"statusA\" name=\"Status A\" type=\"text\" placeholder=\"Enter status, A\" value=\"") _, err = templBuffer.WriteString("\"><input id=\"statusA\" name=\"statusa\" type=\"text\" placeholder=\"Enter status, A\" value=\"")
if err != nil { if err != nil {
return err return err
} }