UI: add problem reporting (GitHub discussion/issue) (#23707)
This commit is contained in:
parent
a3af19a023
commit
b7a4e309ab
27 changed files with 1753 additions and 59 deletions
|
|
@ -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)},
|
||||
|
|
|
|||
34
server/http_config_yaml_handler.go
Normal file
34
server/http_config_yaml_handler.go
Normal 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))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue