diff --git a/client/app/config.go b/client/app/config.go index f2aadbc687..b6da7eb515 100644 --- a/client/app/config.go +++ b/client/app/config.go @@ -143,6 +143,7 @@ type Config struct { WebConfig LogConfig MMConfig + AppVersion string // AppData and ConfigPath should be parsed from the command-line, // as it makes no sense to set these in the config file itself. If no values // are assigned, defaults will be used. @@ -195,6 +196,7 @@ func (cfg *Config) Web(c *core.Core, mm *mm.MarketMaker, log dex.Logger, utc boo KeyFile: keyFile, NoEmbed: cfg.NoEmbedSite, HttpProf: cfg.HTTPProfile, + AppVersion: cfg.AppVersion, Language: cfg.Language, } } @@ -348,9 +350,17 @@ func ResolveConfig(appData string, cfg *Config) error { if cfg.MMConfig.EventLogDBPath == "" { cfg.MMConfig.EventLogDBPath = defaultMMEventLogDBPath } + + cfg.AppVersion = userAppVersion(Version) return nil } +// userAppVersion returns a simple user-facing version: maj.min.patch. +func userAppVersion(fullVersion string) string { + parts := strings.Split(fullVersion, "-") + return parts[0] +} + // setNet sets the filepath for the network directory and some network specific // files. It returns a suggested path for the database file and a log file. If // using a file rotator, the directory of the log filepath as parsed by diff --git a/client/webserver/http.go b/client/webserver/http.go index 45ca372e66..c0ddbe6d40 100644 --- a/client/webserver/http.go +++ b/client/webserver/http.go @@ -58,6 +58,7 @@ type CommonArguments struct { UserInfo *userInfo Title string UseDEXBranding bool + Version string } // Create the CommonArguments for the request. @@ -66,6 +67,7 @@ func (s *WebServer) commonArgs(r *http.Request, title string) *CommonArguments { UserInfo: extractUserInfo(r), Title: title, UseDEXBranding: s.useDEXBranding, + Version: s.appVersion, } } @@ -260,6 +262,7 @@ func (s *WebServer) handleSettings(w http.ResponseWriter, r *http.Request) { FiatCurrency string Exchanges map[string]*core.Exchange IsInitialized bool + AppVersion string }{ CommonArguments: *common, KnownExchanges: s.knownUnregisteredExchanges(xcs), @@ -267,6 +270,7 @@ func (s *WebServer) handleSettings(w http.ResponseWriter, r *http.Request) { FiatRateSources: s.core.FiatRateSources(), Exchanges: xcs, IsInitialized: s.core.IsInitialized(), + AppVersion: s.appVersion, } s.sendTemplate(w, "settings", data) } diff --git a/client/webserver/locales/ar.go b/client/webserver/locales/ar.go index 27f7c264ac..b36fc2bc3f 100644 --- a/client/webserver/locales/ar.go +++ b/client/webserver/locales/ar.go @@ -137,6 +137,7 @@ var Ar = map[string]*intl.Translation{ "Export Account": {T: "تصدير الحساب"}, "simultaneous_servers_msg": {T: "يدعم عميل منصة المبادلات اللامركزية لديكريد الاستخدام المتزامن لأي عدد من خوادم منصة المبادلات اللامركزية DEX."}, "Change App Password": {T: "تغيير كلمة مرور التطبيق"}, + "Version": {T: "إصدار"}, "Build ID": {T: "معرف البنية"}, "Connect": {T: "اتصل"}, "Send": {T: "ارسال"}, diff --git a/client/webserver/locales/de-de.go b/client/webserver/locales/de-de.go index ecd2becfea..e7d6e03493 100644 --- a/client/webserver/locales/de-de.go +++ b/client/webserver/locales/de-de.go @@ -135,6 +135,7 @@ var DeDE = map[string]*intl.Translation{ "Export Account": {T: "Account exportieren"}, "simultaneous_servers_msg": {T: "Der unterstützt die gleichzeitige Nutzung einer beliebigen Anzahl von DEX-Servern."}, "Change App Password": {T: "App-Passwort ändern"}, + "Version": {T: "Version"}, "Build ID": {T: "Build ID"}, "Connect": {T: "Verbinden"}, "Send": {T: "Senden"}, diff --git a/client/webserver/locales/en-us.go b/client/webserver/locales/en-us.go index 8d15eef0cc..6b7e7efad2 100644 --- a/client/webserver/locales/en-us.go +++ b/client/webserver/locales/en-us.go @@ -167,6 +167,7 @@ var EnUS = map[string]*intl.Translation{ "browser_ntfn_blocked": {T: "Browser notifications are currently blocked. Please unblock this site in your browser to receive notifications."}, "enable_browser_ntfn_info": {T: "Desktop notifications appear even when this window is not active. When you have other applications open this can be helpful as you will be notified on DCRDEX events. Customize below the types of notifications you would like to receive."}, "Save Notifications": {T: "Save Notifications"}, + "Version": {T: "Version"}, "Build ID": {T: "Build ID"}, "Connect": {T: "Connect"}, "Send": {T: "Send"}, diff --git a/client/webserver/locales/pl-pl.go b/client/webserver/locales/pl-pl.go index c1f7be9a99..147fa170fe 100644 --- a/client/webserver/locales/pl-pl.go +++ b/client/webserver/locales/pl-pl.go @@ -133,6 +133,7 @@ var PlPL = map[string]*intl.Translation{ "Export Account": {T: "Eksportuj konto"}, "simultaneous_servers_msg": {T: "Klient Decred DEX wspiera jednoczesne korzystanie z wielu serwerów DEX."}, "Change App Password": {T: "Zmień hasło aplikacji"}, + "Version": {T: "Wersja"}, "Build ID": {T: "ID builda"}, "Connect": {T: "Połącz"}, "Withdraw": {T: "Wypłać"}, diff --git a/client/webserver/locales/pt-br.go b/client/webserver/locales/pt-br.go index 38187ed0b2..b77f4ed314 100644 --- a/client/webserver/locales/pt-br.go +++ b/client/webserver/locales/pt-br.go @@ -133,6 +133,7 @@ var PtBr = map[string]*intl.Translation{ "Export Account": {T: "Exportar Conta"}, "simultaneous_servers_msg": {T: "O cliente da DEX suporta simultâneos números de servidores DEX."}, "Change App Password": {T: "Trocar Senha do aplicativo"}, + "Version": {T: "Versão"}, "Build ID": {T: "ID da Build"}, "Connect": {T: "Conectar"}, "Withdraw": {T: "Retirar"}, diff --git a/client/webserver/locales/zh-cn.go b/client/webserver/locales/zh-cn.go index 0b68f012b7..87cf3f0006 100644 --- a/client/webserver/locales/zh-cn.go +++ b/client/webserver/locales/zh-cn.go @@ -135,6 +135,7 @@ var ZhCN = map[string]*intl.Translation{ "Export Account": {T: "退出账户"}, "simultaneous_servers_msg": {T: "Decred DEX 客户端支持同时使用任意数量的 DEX 服务器。"}, "Change App Password": {T: "更改应用程序密码"}, + "Version": {T: "版本"}, "Build ID": {T: "构建 ID"}, "Connect": {T: "连接"}, "Send": {T: "发送"}, diff --git a/client/webserver/site/src/html/bodybuilder.tmpl b/client/webserver/site/src/html/bodybuilder.tmpl index fb0fca5e3d..6b2d399706 100644 --- a/client/webserver/site/src/html/bodybuilder.tmpl +++ b/client/webserver/site/src/html/bodybuilder.tmpl @@ -97,7 +97,7 @@ [[[Market Making]]] - + [[[Settings]]] @@ -118,8 +118,15 @@ [[[Sign Out]]] +
+
+
+ [[[Version]]] {{.Version}} +
+
+ {{end}} diff --git a/client/webserver/webserver.go b/client/webserver/webserver.go index 1ea09fa6fe..dc81aaf5ad 100644 --- a/client/webserver/webserver.go +++ b/client/webserver/webserver.go @@ -229,7 +229,8 @@ type Config struct { CustomSiteDir string Language string Logger dex.Logger - UTC bool // for stdout http request logging + UTC bool // for stdout http request logging + AppVersion string // user app version for UI CertFile string KeyFile string // NoEmbed indicates to serve files from the system disk rather than the @@ -270,6 +271,8 @@ type WebServer struct { bondBufMtx sync.Mutex bondBuf map[uint32]valStamp + appVersion string + useDEXBranding bool } @@ -391,6 +394,7 @@ func New(cfg *Config) (*WebServer, error) { authTokens: make(map[string]bool), cachedPasswords: make(map[string]*cachedPassword), bondBuf: map[uint32]valStamp{}, + appVersion: cfg.AppVersion, useDEXBranding: useDEXBranding, } s.lang.Store(lang)