mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-09-21 08:49:05 +00:00
Add debug info section to webpage
This commit is contained in:
parent
024d5eff90
commit
2cdd094e00
4 changed files with 57 additions and 5 deletions
|
@ -5,5 +5,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers
|
||||||
public static class TimestampHelper
|
public static class TimestampHelper
|
||||||
{
|
{
|
||||||
public static long Timestamp => (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
public static long Timestamp => (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
|
||||||
|
|
||||||
|
public static long TimestampMillis => (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
@using LBPUnion.ProjectLighthouse.Helpers
|
@using LBPUnion.ProjectLighthouse.Helpers
|
||||||
|
@using LBPUnion.ProjectLighthouse.Helpers.Extensions
|
||||||
@using LBPUnion.ProjectLighthouse.Types
|
@using LBPUnion.ProjectLighthouse.Types
|
||||||
@using LBPUnion.ProjectLighthouse.Types.Settings
|
@using LBPUnion.ProjectLighthouse.Types.Settings
|
||||||
@model LBPUnion.ProjectLighthouse.Pages.Layouts.BaseLayout
|
@model LBPUnion.ProjectLighthouse.Pages.Layouts.BaseLayout
|
||||||
|
@ -26,6 +27,9 @@
|
||||||
}
|
}
|
||||||
Model.NavigationItemsRight.Add(new PageNavigationItem("Log out", "/logout", "user alternate slash")); // should always be last
|
Model.NavigationItemsRight.Add(new PageNavigationItem("Log out", "/logout", "user alternate slash")); // should always be last
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Model.IsMobile = Model.Request.IsMobile();
|
||||||
|
long timeStarted = TimestampHelper.TimestampMillis;
|
||||||
}
|
}
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
@ -151,6 +155,44 @@
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@if (ServerStatics.IsDebug)
|
||||||
|
{
|
||||||
|
<div class="ui red attached inverted segment">
|
||||||
|
<div class="ui container">
|
||||||
|
<button type="button" class="ui inverted button collapsible">
|
||||||
|
<b>Show/Hide Debug Info</b>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div style="display:none">
|
||||||
|
<p>Model.IsMobile: @Model.IsMobile</p>
|
||||||
|
<p>Model.Title: @Model.Title</p>
|
||||||
|
<p>Model.Description: @Model.Description</p>
|
||||||
|
<p>Render time: ~@(TimestampHelper.TimestampMillis - timeStarted)ms</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const collapsible = document.getElementsByClassName("collapsible");
|
||||||
|
|
||||||
|
for (let i = 0; i < collapsible.length; i++)
|
||||||
|
{
|
||||||
|
collapsible[i].addEventListener("click", function()
|
||||||
|
{
|
||||||
|
this.classList.toggle("active");
|
||||||
|
const content = this.nextElementSibling;
|
||||||
|
if (content.style.display === "block")
|
||||||
|
{
|
||||||
|
content.style.display = "none";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
content.style.display = "block";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
}
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -7,6 +7,13 @@ namespace LBPUnion.ProjectLighthouse.Pages.Layouts
|
||||||
{
|
{
|
||||||
public class BaseLayout : PageModel
|
public class BaseLayout : PageModel
|
||||||
{
|
{
|
||||||
|
public BaseLayout(Database database)
|
||||||
|
{
|
||||||
|
this.Database = database;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsMobile;
|
||||||
|
|
||||||
public readonly Database Database;
|
public readonly Database Database;
|
||||||
|
|
||||||
public readonly List<PageNavigationItem> NavigationItems = new()
|
public readonly List<PageNavigationItem> NavigationItems = new()
|
||||||
|
@ -25,11 +32,6 @@ namespace LBPUnion.ProjectLighthouse.Pages.Layouts
|
||||||
|
|
||||||
private User? user;
|
private User? user;
|
||||||
|
|
||||||
public BaseLayout(Database database)
|
|
||||||
{
|
|
||||||
this.Database = database;
|
|
||||||
}
|
|
||||||
|
|
||||||
public new User? User {
|
public new User? User {
|
||||||
get {
|
get {
|
||||||
if (this.user != null) return this.user;
|
if (this.user != null) return this.user;
|
||||||
|
|
|
@ -27,5 +27,11 @@ namespace LBPUnion.ProjectLighthouse.Types.Settings
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsUnitTesting => AppDomain.CurrentDomain.GetAssemblies().Any(assembly => assembly.FullName.StartsWith("xunit"));
|
public static bool IsUnitTesting => AppDomain.CurrentDomain.GetAssemblies().Any(assembly => assembly.FullName.StartsWith("xunit"));
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
public static readonly bool IsDebug = true;
|
||||||
|
#else
|
||||||
|
public static readonly bool IsDebug = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue