mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-23 01:20:11 +00:00
setup: report errors when saving config
This commit is contained in:
parent
9395165916
commit
cebde9d4c0
4
api.go
4
api.go
@ -2095,7 +2095,7 @@ func (app *appContext) GetConfig(gc *gin.Context) {
|
|||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param appConfig body configDTO true "Config split into sections as in config.ini, all values as strings."
|
// @Param appConfig body configDTO true "Config split into sections as in config.ini, all values as strings."
|
||||||
// @Success 200 {object} boolResponse
|
// @Success 200 {object} boolResponse
|
||||||
// @Failure 500 {object} boolResponse
|
// @Failure 500 {object} stringResponse
|
||||||
// @Router /config [post]
|
// @Router /config [post]
|
||||||
// @Security Bearer
|
// @Security Bearer
|
||||||
// @tags Configuration
|
// @tags Configuration
|
||||||
@ -2126,7 +2126,7 @@ func (app *appContext) ModifyConfig(gc *gin.Context) {
|
|||||||
tempConfig.Section("").Key("first_run").SetValue("false")
|
tempConfig.Section("").Key("first_run").SetValue("false")
|
||||||
if err := tempConfig.SaveTo(app.configPath); err != nil {
|
if err := tempConfig.SaveTo(app.configPath); err != nil {
|
||||||
app.err.Printf("Failed to save config to \"%s\": %v", app.configPath, err)
|
app.err.Printf("Failed to save config to \"%s\": %v", app.configPath, err)
|
||||||
respondBool(500, false, gc)
|
respond(500, err.Error(), gc)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.debug.Println("Config saved")
|
app.debug.Println("Config saved")
|
||||||
|
14
ts/setup.ts
14
ts/setup.ts
@ -340,6 +340,20 @@ const serialize = () => {
|
|||||||
_post("/config", config, (req: XMLHttpRequest) => {
|
_post("/config", config, (req: XMLHttpRequest) => {
|
||||||
if (req.readyState == 4) {
|
if (req.readyState == 4) {
|
||||||
toggleLoader(restartButton);
|
toggleLoader(restartButton);
|
||||||
|
if (req.status == 500) {
|
||||||
|
if (req.response["error"] as string) {
|
||||||
|
const old = restartButton.textContent;
|
||||||
|
restartButton.classList.add("~critical");
|
||||||
|
restartButton.classList.remove("~urge");
|
||||||
|
restartButton.textContent = req.response["error"];
|
||||||
|
setTimeout(() => {
|
||||||
|
restartButton.classList.add("~urge");
|
||||||
|
restartButton.classList.remove("~critical");
|
||||||
|
restartButton.textContent = old;
|
||||||
|
}, 5000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
restartButton.parentElement.querySelector("span.back").classList.add("unfocused");
|
restartButton.parentElement.querySelector("span.back").classList.add("unfocused");
|
||||||
restartButton.classList.add("unfocused");
|
restartButton.classList.add("unfocused");
|
||||||
const refresh = document.getElementById("refresh") as HTMLSpanElement;
|
const refresh = document.getElementById("refresh") as HTMLSpanElement;
|
||||||
|
Loading…
Reference in New Issue
Block a user