pull/13/head
Evan Chen 2021-10-20 22:02:10 +08:00
parent b36c7b79ff
commit 025861446b
6 changed files with 29 additions and 6 deletions

View File

@ -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
View File

@ -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 {

View File

@ -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")

View File

@ -26,6 +26,7 @@ async function FileSave(){
'Content-Type': 'application/json'
})
})
if (res.ok) window.location.reload();
}
else {
const res = await fetch('/api/file', {

View File

@ -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 := ""

View File

@ -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}}