Add footer to know what is the current running build

This commit is contained in:
nicolas.dorier 2017-10-27 12:08:18 +09:00
parent b71f9d0a08
commit 59ce3b5fc0
3 changed files with 52 additions and 1 deletions

View File

@ -113,6 +113,7 @@ namespace BTCPayServer.Hosting
runtime.Configure(o.GetRequiredService<BTCPayServerOptions>());
return runtime;
});
services.AddSingleton<BTCPayServerEnvironment>();
services.TryAddSingleton<TokenRepository>();
services.TryAddSingleton(o => o.GetRequiredService<BTCPayServerRuntime>().InvoiceRepository);
services.TryAddSingleton<Network>(o => o.GetRequiredService<BTCPayServerOptions>().Network);

View File

@ -0,0 +1,47 @@
using Microsoft.AspNetCore.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Reflection;
using System.Text;
namespace BTCPayServer.Services
{
public class BTCPayServerEnvironment
{
public BTCPayServerEnvironment(IHostingEnvironment env)
{
Version = typeof(BTCPayServerEnvironment).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;
#if DEBUG
Build = "Debug";
#else
Build = "Release";
#endif
Environment = env;
}
public IHostingEnvironment Environment
{
get; set;
}
public string Version
{
get; set;
}
public string Build
{
get; set;
}
public override string ToString()
{
StringBuilder txt = new StringBuilder();
txt.Append($"@Copyright BTCPayServer v{Version}");
if(!Environment.IsProduction() || Build.Equals("Release", StringComparison.OrdinalIgnoreCase))
{
txt.Append($" Environment: {Environment.EnvironmentName} Build: {Build}");
}
return txt.ToString();
}
}
}

View File

@ -1,6 +1,7 @@
@inject SignInManager<ApplicationUser> SignInManager
@inject UserManager<ApplicationUser> UserManager
@inject RoleManager<IdentityRole> RoleManager
@inject BTCPayServer.Services.BTCPayServerEnvironment env
<!DOCTYPE html>
<html lang="en">
@ -75,7 +76,9 @@
</div>
</nav>
@RenderBody()
<footer class="bg-dark">
<div class="container" style="text-align:right;font-size:10px; ">@env.ToString()</div>
</footer>
<!-- Bootstrap core JavaScript -->
<script src="~/vendor/jquery/jquery.min.js"></script>
<script src="~/vendor/popper/popper.min.js"></script>