feat: Display runtime connection string in dashboard
All checks were successful
Build and Deploy LittleShop / Deploy to Production VPS (Manual Only) (push) Has been skipped
Build and Deploy LittleShop / Deploy to Pre-Production (CT109) (push) Successful in 1m0s

Added connection string display to System Information section of dashboard.

- Injected IConfiguration into DashboardController
- Added ConnectionString to ViewData
- Displayed in monospace code format for easy reading
- Shows actual runtime connection string from configuration
- Helps verify which database file is being used in different environments

This makes it easier to troubleshoot database location issues, especially
when deploying to different environments (Development, Production, CT109, etc.).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
SysAdmin 2025-11-18 20:24:53 +00:00
parent 062adf31f9
commit 1aed286fac
2 changed files with 8 additions and 1 deletions

View File

@ -11,15 +11,18 @@ public class DashboardController : Controller
private readonly IOrderService _orderService; private readonly IOrderService _orderService;
private readonly IProductService _productService; private readonly IProductService _productService;
private readonly ICategoryService _categoryService; private readonly ICategoryService _categoryService;
private readonly IConfiguration _configuration;
public DashboardController( public DashboardController(
IOrderService orderService, IOrderService orderService,
IProductService productService, IProductService productService,
ICategoryService categoryService) ICategoryService categoryService,
IConfiguration configuration)
{ {
_orderService = orderService; _orderService = orderService;
_productService = productService; _productService = productService;
_categoryService = categoryService; _categoryService = categoryService;
_configuration = configuration;
} }
public async Task<IActionResult> Index() public async Task<IActionResult> Index()
@ -47,6 +50,9 @@ public class DashboardController : Controller
ViewData["RecentOrders"] = orders.OrderByDescending(o => o.CreatedAt).Take(5); ViewData["RecentOrders"] = orders.OrderByDescending(o => o.CreatedAt).Take(5);
ViewData["TopProducts"] = products.OrderByDescending(p => p.StockQuantity).Take(5); ViewData["TopProducts"] = products.OrderByDescending(p => p.StockQuantity).Take(5);
// System information
ViewData["ConnectionString"] = _configuration.GetConnectionString("DefaultConnection") ?? "Not configured";
return View(); return View();
} }
} }

View File

@ -228,6 +228,7 @@ else
<ul class="list-unstyled"> <ul class="list-unstyled">
<li><strong>Framework:</strong> .NET 9.0</li> <li><strong>Framework:</strong> .NET 9.0</li>
<li><strong>Database:</strong> SQLite</li> <li><strong>Database:</strong> SQLite</li>
<li><strong>Connection String:</strong> <code class="text-muted small">@ViewData["ConnectionString"]</code></li>
<li><strong>Authentication:</strong> Cookie-based</li> <li><strong>Authentication:</strong> Cookie-based</li>
<li><strong>Crypto Support:</strong> 8 currencies via BTCPay Server</li> <li><strong>Crypto Support:</strong> 8 currencies via BTCPay Server</li>
<li><strong>API Endpoints:</strong> Available for client integration</li> <li><strong>API Endpoints:</strong> Available for client integration</li>