feat(tui): expose HTTP method and accepted status codes #7
@@ -24,6 +24,8 @@ type siteFormData struct {
|
|||||||
Name string
|
Name string
|
||||||
SiteType string
|
SiteType string
|
||||||
URL string
|
URL string
|
||||||
|
Method string
|
||||||
|
AcceptedCodes string
|
||||||
Interval string
|
Interval string
|
||||||
AlertID string
|
AlertID string
|
||||||
CheckSSL bool
|
CheckSSL bool
|
||||||
@@ -278,6 +280,8 @@ func (m Model) viewSitesTab() string {
|
|||||||
func (m *Model) initSiteHuhForm() tea.Cmd {
|
func (m *Model) initSiteHuhForm() tea.Cmd {
|
||||||
m.siteFormData = &siteFormData{
|
m.siteFormData = &siteFormData{
|
||||||
SiteType: "http",
|
SiteType: "http",
|
||||||
|
Method: "GET",
|
||||||
|
AcceptedCodes: "200-299",
|
||||||
Interval: "60",
|
Interval: "60",
|
||||||
Threshold: "7",
|
Threshold: "7",
|
||||||
Retries: "0",
|
Retries: "0",
|
||||||
@@ -303,6 +307,8 @@ func (m *Model) initSiteHuhForm() tea.Cmd {
|
|||||||
m.siteFormData.Description = site.Description
|
m.siteFormData.Description = site.Description
|
||||||
m.siteFormData.IgnoreTLS = site.IgnoreTLS
|
m.siteFormData.IgnoreTLS = site.IgnoreTLS
|
||||||
m.siteFormData.GroupID = strconv.Itoa(site.ParentID)
|
m.siteFormData.GroupID = strconv.Itoa(site.ParentID)
|
||||||
|
m.siteFormData.Method = site.Method
|
||||||
|
m.siteFormData.AcceptedCodes = site.AcceptedCodes
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -432,6 +438,24 @@ func (m *Model) initSiteHuhForm() tea.Cmd {
|
|||||||
).Title("Connection").WithHideFunc(func() bool {
|
).Title("Connection").WithHideFunc(func() bool {
|
||||||
return m.siteFormData.SiteType == "group"
|
return m.siteFormData.SiteType == "group"
|
||||||
}),
|
}),
|
||||||
|
huh.NewGroup(
|
||||||
|
huh.NewSelect[string]().Title("HTTP Method").
|
||||||
|
Options(
|
||||||
|
huh.NewOption("GET", "GET"),
|
||||||
|
huh.NewOption("POST", "POST"),
|
||||||
|
huh.NewOption("PUT", "PUT"),
|
||||||
|
huh.NewOption("PATCH", "PATCH"),
|
||||||
|
huh.NewOption("DELETE", "DELETE"),
|
||||||
|
huh.NewOption("HEAD", "HEAD"),
|
||||||
|
huh.NewOption("OPTIONS", "OPTIONS"),
|
||||||
|
).Value(&m.siteFormData.Method),
|
||||||
|
huh.NewInput().Title("Accepted Status Codes").
|
||||||
|
Placeholder("200-299").
|
||||||
|
Description("Ranges (200-299) and singles (301) separated by commas").
|
||||||
|
Value(&m.siteFormData.AcceptedCodes),
|
||||||
|
).Title("HTTP Settings").WithHideFunc(func() bool {
|
||||||
|
return m.siteFormData.SiteType != "http"
|
||||||
|
}),
|
||||||
huh.NewGroup(
|
huh.NewGroup(
|
||||||
huh.NewConfirm().Title("Monitor SSL Certificate?").
|
huh.NewConfirm().Title("Monitor SSL Certificate?").
|
||||||
Value(&m.siteFormData.CheckSSL),
|
Value(&m.siteFormData.CheckSSL),
|
||||||
@@ -503,6 +527,8 @@ func (m *Model) submitSiteForm() {
|
|||||||
Description: d.Description,
|
Description: d.Description,
|
||||||
IgnoreTLS: d.IgnoreTLS,
|
IgnoreTLS: d.IgnoreTLS,
|
||||||
ParentID: groupID,
|
ParentID: groupID,
|
||||||
|
Method: d.Method,
|
||||||
|
AcceptedCodes: d.AcceptedCodes,
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.editID > 0 {
|
if m.editID > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user