UI: add problem reporting (GitHub discussion/issue) (#23707)

This commit is contained in:
Michael Geers 2025-09-21 12:46:54 +02:00 • committed by GitHub
parent a3af19a023
commit b7a4e309ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 1753 additions and 59 deletions

View file

@ -221,7 +221,7 @@ func (s *HTTPd) RegisterSiteHandlers(site site.API, valueChan chan<- util.Param)
}
// RegisterSystemHandler provides system level handlers
func (s *HTTPd) RegisterSystemHandler(site *core.Site, valueChan chan<- util.Param, cache *util.ParamCache, auth auth.Auth, shutdown func()) {
func (s *HTTPd) RegisterSystemHandler(site *core.Site, valueChan chan<- util.Param, cache *util.ParamCache, auth auth.Auth, shutdown func(), configFile string) {
router := s.Server.Handler.(*mux.Router)
// api
@ -280,6 +280,7 @@ func (s *HTTPd) RegisterSystemHandler(site *core.Site, valueChan chan<- util.Par
"device": {"GET", "/devices/{class:[a-z]+}/{id:[0-9.]+}", deviceConfigHandler},
"devicestatus": {"GET", "/devices/{class:[a-z]+}/{name:[a-zA-Z0-9_.:-]+}/status", deviceStatusHandler},
"dirty": {"GET", "/dirty", getHandler(ConfigDirty)},
"evccyaml": {"GET", "/evcc.yaml", configYamlHandler(configFile)},
"newdevice": {"POST", "/devices/{class:[a-z]+}", newDeviceHandler},
"updatedevice": {"PUT", "/devices/{class:[a-z]+}/{id:[0-9.]+}", updateDeviceHandler},
"deletedevice": {"DELETE", "/devices/{class:[a-z]+}/{id:[0-9.]+}", deleteDeviceHandler(site)},

View file

@ -0,0 +1,34 @@
package server
import (
"fmt"
"net/http"
"os"
"github.com/evcc-io/evcc/util"
)
// configYamlHandler returns the redacted evcc.yaml configuration file
func configYamlHandler(configFilePath string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Use the provided config file path
if configFilePath == "" {
jsonError(w, http.StatusNotFound, fmt.Errorf("no config file found"))
return
}
// Read the config file
src, err := os.ReadFile(configFilePath)
if err != nil {
jsonError(w, http.StatusInternalServerError, fmt.Errorf("failed to read config file: %w", err))
return
}
// Redact sensitive information
redacted := util.RedactConfigString(string(src))
// Return the redacted content as plain text
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
w.Write([]byte(redacted))
}
}