update
parent
b36c7b79ff
commit
025861446b
|
@ -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]
|
||||
|
|
4
api.go
4
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 {
|
||||
|
|
2
main.go
2
main.go
|
@ -26,6 +26,7 @@ var (
|
|||
flagConfigPath string
|
||||
|
||||
flagBind string
|
||||
flagNoReconfig bool
|
||||
flagLogFile string
|
||||
flagAllow string
|
||||
flagVer bool
|
||||
|
@ -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")
|
||||
|
|
|
@ -26,6 +26,7 @@ async function FileSave(){
|
|||
'Content-Type': 'application/json'
|
||||
})
|
||||
})
|
||||
if (res.ok) window.location.reload();
|
||||
}
|
||||
else {
|
||||
const res = await fetch('/api/file', {
|
||||
|
|
2
route.go
2
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 := ""
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
{{define "components/error"}}
|
||||
|
||||
<div class="notification is-danger is-light" id="error_view">
|
||||
<button class="delete"></button>
|
||||
<p id="err_msg"></p>
|
||||
</div>
|
||||
<script>
|
||||
function ErrorTog(){
|
||||
let el = document.getElementById('error_view');
|
||||
el.classList.toggle('is-active');
|
||||
}
|
||||
function ShowError(msg){
|
||||
let el = document.getElementById('err_msg');
|
||||
el.innerHTML = msg;
|
||||
ErrorTog();
|
||||
}
|
||||
</script>
|
||||
{{end}}
|
Loading…
Reference in New Issue