diff --git a/api.go b/api.go index 0f6982c..3885c44 100644 --- a/api.go +++ b/api.go @@ -1330,6 +1330,14 @@ func (app *appContext) GetLanguages(gc *gin.Context) { gc.JSON(200, resp) } +func (app *appContext) restart(gc *gin.Context) { + app.info.Println("Restarting...") + err := app.Restart() + if err != nil { + app.err.Printf("Couldn't restart, try restarting manually. (%s)", err) + } +} + func (app *appContext) ServeLang(gc *gin.Context) { page := gc.Param("page") lang := strings.Replace(gc.Param("file"), ".json", "", 1) diff --git a/html/admin.html b/html/admin.html index 7e40774..7cdce79 100644 --- a/html/admin.html +++ b/html/admin.html @@ -278,7 +278,8 @@
{{ .strings.settings }}
- {{ .strings.settingsSave }} + {{ .strings.settingsRestart }} + {{ .strings.settingsSave }}
diff --git a/lang/admin/en-us.json b/lang/admin/en-us.json index 3fcdd6f..ada917e 100644 --- a/lang/admin/en-us.json +++ b/lang/admin/en-us.json @@ -35,12 +35,14 @@ "applyHomescreenLayout": "Apply homescreen layout", "sendDeleteNotificationEmail": "Send notification email", "sendDeleteNotifiationExample": "Your account has been deleted.", + "settingsRestart": "Restart", + "settingsRestarting": "Restarting...", "settingsRestartRequired": "Restart needed", "settingsRestartRequiredDescription": "A restart is necessary to apply some settings you changed. Restart now or later?", "settingsApplyRestartLater": "Apply, restart later", "settingsApplyRestartNow": "Apply & restart", "settingsApplied": "Settings applied.", - "settingsRefreshPage": "Refresh the page in a few seconds", + "settingsRefreshPage": "Refresh the page in a few seconds.", "settingsRequiredOrRestartMessage": "Note: {n} indicates a required field, {n} indicates changes require a restart.", "settingsSave": "Save", "ombiUserDefaults": "Ombi user defaults", diff --git a/main.go b/main.go index a305c0b..50205af 100644 --- a/main.go +++ b/main.go @@ -619,6 +619,7 @@ func start(asDaemon, firstCall bool) { api.POST("/users/settings", app.ApplySettings) api.GET("/config", app.GetConfig) api.POST("/config", app.ModifyConfig) + api.POST("/restart", app.restart) if app.config.Section("ombi").Key("enabled").MustBool(false) { api.GET("/ombi/users", app.OmbiUsers) api.POST("/ombi/defaults", app.SetOmbiDefaults) diff --git a/ts/modules/settings.ts b/ts/modules/settings.ts index 3a4bc7f..fba0522 100644 --- a/ts/modules/settings.ts +++ b/ts/modules/settings.ts @@ -556,6 +556,11 @@ export class settingsList { this._sections = {}; this._buttons = {}; document.addEventListener("settings-section-changed", () => this._saveButton.classList.remove("unfocused")); + document.getElementById("settings-restart").onclick = () => { + _post("/restart", null, () => {}); + window.modals.settingsRefresh.modal.querySelector("span.heading").textContent = window.lang.strings("settingsRestarting"); + window.modals.settingsRefresh.show(); + }; this._saveButton.onclick = this._save; document.addEventListener("settings-requires-restart", () => { this._needsRestart = true; });