mirror of
https://github.com/writefreely/writefreely
synced 2024-11-24 09:33:11 +00:00
Tell admin that automated check failed when necessary
This keeps track when automated update check fails, and displays a relevant message to the admin on /admin/updates Ref T572
This commit is contained in:
parent
c2ece926e0
commit
37b7755c08
4 changed files with 15 additions and 2 deletions
2
admin.go
2
admin.go
|
@ -612,6 +612,7 @@ func handleViewAdminUpdates(app *App, u *User, w http.ResponseWriter, r *http.Re
|
|||
LatestVersion string
|
||||
LatestReleaseURL string
|
||||
LatestReleaseNotesURL string
|
||||
CheckFailed bool
|
||||
}{
|
||||
UserPage: NewUserPage(app, r, u, "Updates", nil),
|
||||
AdminPage: NewAdminPage(app),
|
||||
|
@ -624,6 +625,7 @@ func handleViewAdminUpdates(app *App, u *User, w http.ResponseWriter, r *http.Re
|
|||
p.LatestReleaseURL = app.updates.ReleaseURL()
|
||||
p.LatestReleaseNotesURL = app.updates.ReleaseNotesURL()
|
||||
p.UpdateAvailable = app.updates.AreAvailable()
|
||||
p.CheckFailed = app.updates.checkError != nil
|
||||
}
|
||||
|
||||
showUserPage(w, "app-updates", p)
|
||||
|
|
|
@ -1350,6 +1350,11 @@ div.row {
|
|||
color: #71D571;
|
||||
}
|
||||
|
||||
.ex.failure {
|
||||
font-weight: bold;
|
||||
color: @dangerCol;
|
||||
}
|
||||
|
||||
@media all and (max-width: 450px) {
|
||||
body#post {
|
||||
header {
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
{{template "admin-header" .}}
|
||||
|
||||
{{ if .UpdateChecks }}
|
||||
{{if not .UpdateAvailable}}
|
||||
{{if .CheckFailed}}
|
||||
<p class="intro"><span class="ex failure">×</span> Automated update check failed.</p>
|
||||
<p>Installed version: <strong>{{.Version}}</strong> (<a href="{{.CurReleaseNotesURL}}" target="changelog-wf">release notes</a>).</p>
|
||||
<p>Learn about latest releases on the <a href="https://blog.writefreely.org/tag:release" target="changelog-wf">WriteFreely blog</a> or <a href="https://discuss.write.as/c/writefreely/updates" target="forum-wf">forum</a>.</p>
|
||||
{{else if not .UpdateAvailable}}
|
||||
<p class="intro"><span class="check">✓</span> WriteFreely is <strong>up to date</strong>.</p>
|
||||
<p>Installed version: <strong>{{.Version}}</strong> (<a href="{{.LatestReleaseNotesURL}}" target="changelog-wf">release notes</a>).</p>
|
||||
{{else}}
|
||||
|
|
|
@ -30,6 +30,7 @@ type updatesCache struct {
|
|||
lastCheck time.Time
|
||||
latestVersion string
|
||||
currentVersion string
|
||||
checkError error
|
||||
}
|
||||
|
||||
// CheckNow asks for the latest released version of writefreely and updates
|
||||
|
@ -38,11 +39,12 @@ type updatesCache struct {
|
|||
func (uc *updatesCache) CheckNow() error {
|
||||
uc.mu.Lock()
|
||||
defer uc.mu.Unlock()
|
||||
uc.lastCheck = time.Now()
|
||||
latestRemote, err := newVersionCheck()
|
||||
if err != nil {
|
||||
uc.checkError = err
|
||||
return err
|
||||
}
|
||||
uc.lastCheck = time.Now()
|
||||
if CompareSemver(latestRemote, uc.latestVersion) == 1 {
|
||||
uc.latestVersion = latestRemote
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue