diff --git a/README.md b/README.md index 2aeb3e5..de9d73d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Config UI -a web app to edit and action on update +a web app to edit and action on update powered by [ACE](https://ace.c9.io/#nav=howto&api=edit_session) ``` Usage: configui [options] diff --git a/api.go b/api.go index 2a2f00e..df91853 100644 --- a/api.go +++ b/api.go @@ -92,6 +92,10 @@ func Download(w http.ResponseWriter, r *http.Request) { } func LoadConfig(w http.ResponseWriter, r *http.Request) { + if flagNoReconfig { + AbortError(w, "system reconfig is disabled") + return + } data, err := ioutil.ReadAll(r.Body) r.Body.Close() if err != nil { diff --git a/main.go b/main.go index ae9d1bc..bd3758b 100644 --- a/main.go +++ b/main.go @@ -25,10 +25,11 @@ var ( flagAlias string flagConfigPath string - flagBind string - flagLogFile string - flagAllow string - flagVer bool + flagBind string + flagNoReconfig bool + flagLogFile string + flagAllow string + flagVer bool ) var Version = "0.0.0" @@ -45,6 +46,7 @@ func init() { flag.StringVar(&flagLogFile, "log", "", "log to file") flag.StringVar(&flagAllow, "allow", "", "IPs to allow, blank to allow all") flag.StringVar(&flagBind, "bind", "localhost:8000", "address to bind") + flag.BoolVar(&flagNoReconfig, "static", false, "disable config api") flag.BoolVar(&flagVer, "v", false, "show version") flag.Usage = func() { fmt.Fprintf(os.Stderr, "Usage: configui [options]\n") diff --git a/public/js/main.js b/public/js/main.js index c1947e3..cc84d10 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -26,6 +26,7 @@ async function FileSave(){ 'Content-Type': 'application/json' }) }) + if (res.ok) window.location.reload(); } else { const res = await fetch('/api/file', { diff --git a/route.go b/route.go index b1a4c7d..d9f179c 100644 --- a/route.go +++ b/route.go @@ -26,6 +26,7 @@ type Page struct { Error string File OnPageFile Editor Editor + Static bool } func setRoutes(mux *http.ServeMux) { @@ -54,6 +55,7 @@ func setRoutes(mux *http.ServeMux) { Editor: Editor{ Platform: plat, }, + Static: flagNoReconfig, } content := "" diff --git a/templates/components/error.tmpl b/templates/components/error.tmpl index 260b5b6..8a12552 100644 --- a/templates/components/error.tmpl +++ b/templates/components/error.tmpl @@ -1,3 +1,17 @@ {{define "components/error"}} - +