From f5f2a0f1904c0077b60dd2969fa57b18539cd0db Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Sat, 5 Sep 2020 21:52:23 +0100 Subject: [PATCH] Add notice about no self-restarts on windows --- data/static/admin.js | 5 ++++- data/templates/admin.html | 10 ++++++++++ data/templates/setup.html | 4 ++++ main.go | 11 ++++++++++- views.go | 5 +++++ 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/data/static/admin.js b/data/static/admin.js index a428f6b..66316e4 100644 --- a/data/static/admin.js +++ b/data/static/admin.js @@ -1120,7 +1120,10 @@ document.getElementById('settingsSave').onclick = function() { } if (restart_setting_changed) { document.getElementById('applyRestarts').onclick = function(){ sendConfig('restartModal'); }; - document.getElementById('applyAndRestart').onclick = function(){ sendConfig('restartModal', restart=true); }; + let restartButton = document.getElementById('applyAndRestart') + if (restartButton) { + restartButton.onclick = function(){ sendConfig('restartModal', restart=true); }; + } settingsModal.hide(); restartModal.show(); } else if (settings_changed) { diff --git a/data/templates/admin.html b/data/templates/admin.html index 344f3e4..0b32df8 100644 --- a/data/templates/admin.html +++ b/data/templates/admin.html @@ -269,6 +269,15 @@ + {{ if .windows }} + + + {{ else }} @@ -277,6 +286,7 @@ + {{ end }} diff --git a/data/templates/setup.html b/data/templates/setup.html index 6117b8f..b346418 100644 --- a/data/templates/setup.html +++ b/data/templates/setup.html @@ -359,7 +359,11 @@
Finished!

+ {{ if .windows }} + Press the button below to submit your settings. Unfortunately you're running on Windows, so jfa-go cannot restart itself. You will manually have to restart. + {{ else }} Press the button below to submit your settings. The program will restart. Once it's done, refresh this page. + {{ end }}

diff --git a/main.go b/main.go index de7f771..d1c053c 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,7 @@ import ( "os" "os/signal" "path/filepath" + "runtime" "time" "github.com/gin-contrib/pprof" @@ -95,6 +96,8 @@ func setGinLogger(router *gin.Engine, debugMode bool) { } } +var PLATFORM string = runtime.GOOS + func main() { fmt.Printf("jfa-go version: %s (%s)\n", VERSION, COMMIT) // app encompasses essentially all useful functions. @@ -362,8 +365,14 @@ func main() { } app.info.Printf("Starting router @ %s", address) } else { + windows := false + if PLATFORM == "windows" { + windows = true + } router.GET("/", func(gc *gin.Context) { - gc.HTML(200, "setup.html", gin.H{}) + gc.HTML(200, "setup.html", gin.H{ + "windows": windows, + }) }) router.POST("/testJF", app.TestJF) router.POST("/modifyConfig", app.ModifyConfig) diff --git a/views.go b/views.go index a184fda..0379b5e 100644 --- a/views.go +++ b/views.go @@ -11,6 +11,10 @@ func (app *appContext) AdminPage(gc *gin.Context) { emailEnabled, _ := app.config.Section("invite_emails").Key("enabled").Bool() notificationsEnabled, _ := app.config.Section("notifications").Key("enabled").Bool() ombiEnabled := app.config.Section("ombi").Key("enabled").MustBool(false) + windows := false + if PLATFORM == "windows" { + windows = true + } gc.HTML(http.StatusOK, "admin.html", gin.H{ "bs5": bs5, "cssFile": app.cssFile, @@ -20,6 +24,7 @@ func (app *appContext) AdminPage(gc *gin.Context) { "version": VERSION, "commit": COMMIT, "ombiEnabled": ombiEnabled, + "windows": windows, }) }