diff --git a/html/func.go b/html/func.go index c857c96a..98919e21 100644 --- a/html/func.go +++ b/html/func.go @@ -20,6 +20,7 @@ import ( func addFuncMap(t *template.Template) { funcMap := template.FuncMap{ "bigNumber": bigNumber, + "hasPassed": hasPassed, "html": unescapeHTML, "json": unescapeJS, "GISStatement": gisStatement, @@ -62,6 +63,10 @@ func timeAsRelativeDate(d time.Time) string { return d.Format("01-02") } +func hasPassed(t time.Time) bool { + return t.Before(time.Now()) +} + // FormatTimeDuration returns a human-readable string representing a time.Duration // as "X units early" or "X units late" func timeDelta(d time.Duration) string { diff --git a/html/template/sync/setting-integration.html b/html/template/sync/setting-integration.html index 8ce34735..d879a122 100644 --- a/html/template/sync/setting-integration.html +++ b/html/template/sync/setting-integration.html @@ -69,13 +69,17 @@ OAuth Token Status - {{ if .ArcGISOAuth.InvalidatedAt.IsNull }} - - Active + {{ if not .ArcGISOAuth.InvalidatedAt.IsNull }} + + Invalidated + + {{ else if hasPassed .ArcGISOAuth.AccessTokenExpires }} + + Expired {{ else }} - - Active + + Active {{ end }} diff --git a/sync/setting.go b/sync/setting.go index 65537dde..d972f9c7 100644 --- a/sync/setting.go +++ b/sync/setting.go @@ -4,7 +4,6 @@ import ( "net/http" "github.com/Gleipnir-Technology/nidus-sync/arcgis" - "github.com/Gleipnir-Technology/nidus-sync/db" "github.com/Gleipnir-Technology/nidus-sync/db/models" "github.com/Gleipnir-Technology/nidus-sync/html" )