Improve readability and styling of last refresh timestamp. Closes #190

This commit is contained in:
Herman Schaaf
2017-09-26 19:42:56 +01:00
parent 2a5c3d2a9d
commit 391133d3ba
3 changed files with 17 additions and 5 deletions

View File

@@ -1,3 +1,8 @@
time {
border-bottom: 1px dashed;
line-height: 1.5em;
cursor: pointer;
}
.header .is-active {
font-weight: bold;
}

View File

@@ -49,7 +49,8 @@ func getFromCache(repo string) (checksResp, error) {
}
resp.LastRefresh = resp.LastRefresh.UTC()
resp.HumanizedLastRefresh = humanize.Time(resp.LastRefresh.UTC())
resp.LastRefreshFormatted = resp.LastRefresh.Format(time.UnixDate)
resp.LastRefreshHumanized = humanize.Time(resp.LastRefresh.UTC())
return resp, nil
}
@@ -72,7 +73,8 @@ type checksResp struct {
Repo string `json:"repo"`
ResolvedRepo string `json:"resolvedRepo"`
LastRefresh time.Time `json:"last_refresh"`
HumanizedLastRefresh string `json:"humanized_last_refresh"`
LastRefreshFormatted string `json:"formatted_last_refresh"`
LastRefreshHumanized string `json:"humanized_last_refresh"`
}
func newChecksResp(repo string, forceRefresh bool) (checksResp, error) {
@@ -142,12 +144,14 @@ func newChecksResp(repo string, forceRefresh bool) (checksResp, error) {
}(c)
}
t := time.Now().UTC()
resp := checksResp{
Repo: repo,
ResolvedRepo: repoRoot.Repo,
Files: len(filenames),
LastRefresh: time.Now().UTC(),
HumanizedLastRefresh: humanize.Time(time.Now().UTC()),
LastRefresh: t,
LastRefreshFormatted: t.Format(time.UnixDate),
LastRefreshHumanized: humanize.Time(t),
}
var total, totalWeight float64

View File

@@ -159,7 +159,10 @@
<hr>
</script>
<script id="template-lastrefresh" type="text/x-handlebars-template">
<p>Last refresh: <span title={{last_refresh}}>{{humanized_last_refresh}}</span></p>
<div title="{{formatted_last_refresh}}">
Last refresh:
<time datetime="{{last_refresh}}" class="label-align">{{humanized_last_refresh}}</time>
</div>
<br>
<p><a class="refresh-button button" href=""><strong>Refresh now</strong></a></p>
</script>