update
parent
b36c7b79ff
commit
025861446b
|
@ -1,6 +1,6 @@
|
||||||
# Config UI
|
# 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]
|
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) {
|
func LoadConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if flagNoReconfig {
|
||||||
|
AbortError(w, "system reconfig is disabled")
|
||||||
|
return
|
||||||
|
}
|
||||||
data, err := ioutil.ReadAll(r.Body)
|
data, err := ioutil.ReadAll(r.Body)
|
||||||
r.Body.Close()
|
r.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
10
main.go
10
main.go
|
@ -25,10 +25,11 @@ var (
|
||||||
flagAlias string
|
flagAlias string
|
||||||
flagConfigPath string
|
flagConfigPath string
|
||||||
|
|
||||||
flagBind string
|
flagBind string
|
||||||
flagLogFile string
|
flagNoReconfig bool
|
||||||
flagAllow string
|
flagLogFile string
|
||||||
flagVer bool
|
flagAllow string
|
||||||
|
flagVer bool
|
||||||
)
|
)
|
||||||
|
|
||||||
var Version = "0.0.0"
|
var Version = "0.0.0"
|
||||||
|
@ -45,6 +46,7 @@ func init() {
|
||||||
flag.StringVar(&flagLogFile, "log", "", "log to file")
|
flag.StringVar(&flagLogFile, "log", "", "log to file")
|
||||||
flag.StringVar(&flagAllow, "allow", "", "IPs to allow, blank to allow all")
|
flag.StringVar(&flagAllow, "allow", "", "IPs to allow, blank to allow all")
|
||||||
flag.StringVar(&flagBind, "bind", "localhost:8000", "address to bind")
|
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.BoolVar(&flagVer, "v", false, "show version")
|
||||||
flag.Usage = func() {
|
flag.Usage = func() {
|
||||||
fmt.Fprintf(os.Stderr, "Usage: configui [options]\n")
|
fmt.Fprintf(os.Stderr, "Usage: configui [options]\n")
|
||||||
|
|
|
@ -26,6 +26,7 @@ async function FileSave(){
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
if (res.ok) window.location.reload();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const res = await fetch('/api/file', {
|
const res = await fetch('/api/file', {
|
||||||
|
|
2
route.go
2
route.go
|
@ -26,6 +26,7 @@ type Page struct {
|
||||||
Error string
|
Error string
|
||||||
File OnPageFile
|
File OnPageFile
|
||||||
Editor Editor
|
Editor Editor
|
||||||
|
Static bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func setRoutes(mux *http.ServeMux) {
|
func setRoutes(mux *http.ServeMux) {
|
||||||
|
@ -54,6 +55,7 @@ func setRoutes(mux *http.ServeMux) {
|
||||||
Editor: Editor{
|
Editor: Editor{
|
||||||
Platform: plat,
|
Platform: plat,
|
||||||
},
|
},
|
||||||
|
Static: flagNoReconfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
content := ""
|
content := ""
|
||||||
|
|
|
@ -1,3 +1,17 @@
|
||||||
{{define "components/error"}}
|
{{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}}
|
{{end}}
|
Loading…
Reference in New Issue