Skip to content

Commit

Permalink
add restart button
Browse files Browse the repository at this point in the history
  • Loading branch information
hrfee committed Jan 31, 2021
1 parent 456ef55 commit 90c6cee
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion html/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@
<div class="card ~neutral !low settings overflow">
<span class="heading">{{ .strings.settings }}</span>
<div class="fr">
<span class="button ~neutral !normal unfocused" id="settings-save">{{ .strings.settingsSave }}</span>
<span class="button ~neutral !normal" id="settings-restart">{{ .strings.settingsRestart }}</span>
<span class="button ~urge !normal unfocused" id="settings-save">{{ .strings.settingsSave }}</span>
</div>
<div class="row">
<div class="card ~neutral !normal col" id="settings-sidebar">
Expand Down
4 changes: 3 additions & 1 deletion lang/admin/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions ts/modules/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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; });

Expand Down

0 comments on commit 90c6cee

Please sign in to comment.