added FIP Cooldown before start
This commit is contained in:
1 parent
291eea3eb8
commit
f22ad569b6
36 files changed
+1182
-25
No files matched your search
@@ -0,0 +1,46 @@
|
||||
package dashboard
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type settingsPageData struct {
|
||||
PageData
|
||||
Settings orchestratorSettingsDTO
|
||||
}
|
||||
|
||||
func (s *Server) handleSettingsPage(w http.ResponseWriter, r *http.Request) {
|
||||
settings, err := s.CA.GetOrchestratorSettings(r.Context())
|
||||
data := settingsPageData{Settings: settings}
|
||||
data.ActiveNav = "settings"
|
||||
data.Banner = bannerFor(err)
|
||||
s.renderPage(w, "settings_page", data)
|
||||
}
|
||||
|
||||
// renderSettingsForm re-fetches the current settings and renders the
|
||||
// settings_form fragment, tagging actionErr (if any) on the shared error
|
||||
// banner — same pattern as renderIPsTable: always reflect true current
|
||||
// state regardless of whether the mutation itself succeeded.
|
||||
func (s *Server) renderSettingsForm(w http.ResponseWriter, r *http.Request, actionErr error) {
|
||||
settings, getErr := s.CA.GetOrchestratorSettings(r.Context())
|
||||
if actionErr == nil {
|
||||
actionErr = getErr
|
||||
}
|
||||
s.renderFragment(w, "settings_form", settingsPageData{Settings: settings}, actionErr)
|
||||
}
|
||||
|
||||
func (s *Server) handleSettingsPut(w http.ResponseWriter, r *http.Request) {
|
||||
if err := r.ParseForm(); err != nil {
|
||||
s.renderSettingsForm(w, r, fmt.Errorf("invalid form: %w", err))
|
||||
return
|
||||
}
|
||||
seconds, err := strconv.Atoi(r.PostFormValue("fip_settle_seconds"))
|
||||
if err != nil {
|
||||
s.renderSettingsForm(w, r, &apiErr{Status: http.StatusBadRequest, Message: "пауза должна быть целым числом секунд"})
|
||||
return
|
||||
}
|
||||
_, err = s.CA.PutOrchestratorSettings(r.Context(), seconds)
|
||||
s.renderSettingsForm(w, r, err)
|
||||
}
|
||||
Reference in new issue
Block a user