Initial commit

This commit is contained in:
2026-04-23 21:38:24 -04:00
commit 63e12a9636
1762 changed files with 1672620 additions and 0 deletions
@@ -0,0 +1,189 @@
@model PowderCoating.Web.Controllers.DiagnosticsInfo
@{
ViewData["Title"] = "System Diagnostics";
ViewData["PageIcon"] = "bi-activity";
}
<div class="container mt-4">
<div class="row mt-4">
<div class="col-md-6">
<div class="card">
<div class="card-header bg-primary text-white">
<h5 class="mb-0">Application Information</h5>
</div>
<div class="card-body">
<table class="table table-sm">
<tr>
<th>Current Time:</th>
<td>@Model.CurrentTime.ToString("yyyy-MM-dd HH:mm:ss")</td>
</tr>
<tr>
<th>Environment:</th>
<td><span class="badge bg-info">@Model.EnvironmentName</span></td>
</tr>
<tr>
<th>Application Path:</th>
<td><code>@Model.ApplicationPath</code></td>
</tr>
<tr>
<th>Running As:</th>
<td><code>@Model.UserIdentity</code></td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-header bg-warning">
<h5 class="mb-0">Permissions Check</h5>
</div>
<div class="card-body">
<table class="table table-sm">
<tr>
<th>Can Write to App Path:</th>
<td>
@if (Model.CanWriteToAppPath)
{
<span class="badge bg-success">✓ YES</span>
}
else
{
<span class="badge bg-danger">✗ NO - PERMISSION ISSUE</span>
}
</td>
</tr>
<tr>
<th>Logs Directory Exists:</th>
<td>
@if (Model.LogsDirectoryExists)
{
<span class="badge bg-success">✓ YES</span>
}
else
{
<span class="badge bg-warning">✗ NO</span>
}
</td>
</tr>
<tr>
<th>Can Write to Logs:</th>
<td>
@if (Model.CanWriteToLogsPath)
{
<span class="badge bg-success">✓ YES</span>
}
else
{
<span class="badge bg-danger">✗ NO - PERMISSION ISSUE</span>
}
</td>
</tr>
<tr>
<th>Logs Path:</th>
<td><code>@Model.LogsPath</code></td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-12">
<div class="card">
<div class="card-header @(Model.LoggingTestSuccess ? "bg-success" : "bg-danger") text-white">
<h5 class="mb-0">Logging Test</h5>
</div>
<div class="card-body">
<p><strong>Status:</strong>
@if (Model.LoggingTestSuccess)
{
<span class="badge bg-success">SUCCESS</span>
}
else
{
<span class="badge bg-danger">FAILED</span>
}
</p>
<p><strong>Message:</strong> @Model.LoggingTestMessage</p>
@if (Model.LoggingTestSuccess)
{
<div class="alert alert-info">
<i class="bi bi-info-circle"></i> A test log entry was written. Check the log files below to see if it appears.
</div>
}
</div>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-12">
<div class="card">
<div class="card-header bg-secondary text-white d-flex justify-content-between align-items-center">
<h5 class="mb-0">Log Files</h5>
<a asp-action="ViewLogs" class="btn btn-sm btn-light">
<i class="bi bi-eye"></i> View Logs
</a>
</div>
<div class="card-body">
@if (Model.LogFilesError != null)
{
<div class="alert alert-danger">
<strong>Error reading log files:</strong> @Model.LogFilesError
</div>
}
else if (Model.LogFiles.Any())
{
<table class="table table-striped">
<thead>
<tr>
<th>File Name</th>
<th>Size</th>
<th>Last Modified</th>
<th>Full Path</th>
</tr>
</thead>
<tbody>
@foreach (var file in Model.LogFiles)
{
<tr>
<td><code>@file.Name</code></td>
<td>@(file.Size / 1024.0).ToString("N2") KB</td>
<td>@file.LastModified.ToString("yyyy-MM-dd HH:mm:ss")</td>
<td><small><code>@file.FullPath</code></small></td>
</tr>
}
</tbody>
</table>
}
else
{
<div class="alert alert-warning">
<i class="bi bi-exclamation-triangle"></i> <strong>No log files found!</strong>
<hr>
<p class="mb-0">This means logs are not being written. Check the permissions above.</p>
</div>
}
</div>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-12">
<div class="alert alert-info">
<h6><i class="bi bi-lightbulb"></i> Troubleshooting Tips</h6>
<ul class="mb-0">
<li>If "Can Write to Logs" shows NO, the IIS Application Pool doesn't have write permissions</li>
<li>Grant "Modify" permissions to <code>IIS AppPool\YourAppPoolName</code> on the application folder</li>
<li>After fixing permissions, restart the Application Pool in IIS Manager</li>
<li>Refresh this page to see if log files appear</li>
</ul>
</div>
</div>
</div>
</div>
@@ -0,0 +1,239 @@
@model PowderCoating.Web.Controllers.LogViewerModel
@{
ViewData["Title"] = "Log Viewer";
ViewData["PageIcon"] = "bi-file-text";
}
<div class="container-fluid mt-4">
<div class="row">
<div class="col-12">
<div class="d-flex justify-content-end mb-3">
<a asp-action="Index" class="btn btn-secondary">
<i class="bi bi-arrow-left"></i> Back to Diagnostics
</a>
</div>
@if (TempData["SuccessMessage"] != null)
{
<div class="alert alert-success alert-dismissible fade show">
<i class="bi bi-check-circle"></i> @TempData["SuccessMessage"]
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
}
@if (TempData["ErrorMessage"] != null)
{
<div class="alert alert-danger alert-dismissible fade show">
<i class="bi bi-exclamation-triangle"></i> @TempData["ErrorMessage"]
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
}
@if (!string.IsNullOrEmpty(Model.Error))
{
<div class="alert alert-danger">
<i class="bi bi-exclamation-triangle"></i> @Model.Error
</div>
}
</div>
</div>
@if (Model.AvailableLogFiles.Any())
{
<div class="row mb-3">
<div class="col-12">
<div class="card">
<div class="card-header bg-primary text-white">
<h5 class="mb-0"><i class="bi bi-funnel"></i> Filter & Options</h5>
</div>
<div class="card-body">
<form method="get" asp-action="ViewLogs" id="filterForm">
<div class="row g-3">
<div class="col-md-4">
<label for="fileName" class="form-label">Log File</label>
<select name="fileName" id="fileName" class="form-select" onchange="document.getElementById('filterForm').submit()">
@foreach (var file in Model.AvailableLogFiles)
{
<option value="@file.Name" selected="@(file.Name == Model.SelectedFileName)">
@file.Name (@((file.Size / 1024.0).ToString("N0")) KB)
</option>
}
</select>
</div>
<div class="col-md-3">
<label for="lines" class="form-label">Lines to Show</label>
<select name="lines" id="lines" class="form-select">
<option value="100" selected="@(Model.SelectedLines == 100)">Last 100</option>
<option value="500" selected="@(Model.SelectedLines == 500)">Last 500</option>
<option value="1000" selected="@(Model.SelectedLines == 1000)">Last 1000</option>
<option value="5000" selected="@(Model.SelectedLines == 5000)">Last 5000</option>
<option value="999999" selected="@(Model.SelectedLines >= 999999)">All</option>
</select>
</div>
<div class="col-md-3">
<label for="search" class="form-label">Search</label>
<input type="text" name="search" id="search" class="form-control"
placeholder="Filter log entries..." value="@Model.SearchTerm">
</div>
<div class="col-md-2">
<label class="form-label">&nbsp;</label>
<button type="submit" class="btn btn-primary w-100">
<i class="bi bi-search"></i> Apply
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
@if (!string.IsNullOrEmpty(Model.SelectedFileName))
{
<div class="row mb-3">
<div class="col-12">
<div class="card">
<div class="card-header bg-secondary text-white d-flex justify-content-between align-items-center">
<div>
<h5 class="mb-0">
<i class="bi bi-file-earmark-text"></i> @Model.SelectedFileName
</h5>
<small>
Showing @Model.DisplayedLines of @Model.TotalLines lines
@if (!string.IsNullOrWhiteSpace(Model.SearchTerm))
{
<span>(@Model.FilteredLines matches for "@Model.SearchTerm")</span>
}
</small>
</div>
<div>
<a asp-action="DownloadLog" asp-route-fileName="@Model.SelectedFileName"
class="btn btn-sm btn-light">
<i class="bi bi-download"></i> Download
</a>
<button type="button" class="btn btn-sm btn-light" onclick="refreshLogs()">
<i class="bi bi-arrow-clockwise"></i> Refresh
</button>
</div>
</div>
<div class="card-body p-0">
<div class="log-content-wrapper">
<pre class="log-content mb-0" id="logContent">@Model.LogContent</pre>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header bg-warning">
<h6 class="mb-0"><i class="bi bi-gear"></i> Log Management</h6>
</div>
<div class="card-body">
<p>Delete old log files to free up disk space. This will permanently remove log files.</p>
<form method="post" asp-action="ClearOldLogs" onsubmit="return confirm('Are you sure you want to delete old log files?');">
<div class="row g-3 align-items-end">
<div class="col-md-3">
<label for="daysToKeep" class="form-label">Keep logs from last</label>
<select name="daysToKeep" id="daysToKeep" class="form-select">
<option value="7">7 days</option>
<option value="14">14 days</option>
<option value="30" selected>30 days</option>
<option value="60">60 days</option>
<option value="90">90 days</option>
</select>
</div>
<div class="col-md-3">
<button type="submit" class="btn btn-warning">
<i class="bi bi-trash"></i> Clear Old Logs
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
}
}
else
{
<div class="alert alert-info">
<i class="bi bi-info-circle"></i> No log files found in <code>@Model.LogsPath</code>
</div>
}
</div>
<style>
.log-content-wrapper {
max-height: 600px;
overflow-y: auto;
background-color: #1e1e1e;
color: #d4d4d4;
}
.log-content {
padding: 15px;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
font-size: 13px;
line-height: 1.5;
white-space: pre-wrap;
word-wrap: break-word;
}
/* Color code log levels */
.log-content {
color: #d4d4d4;
}
pre:has(text) {
background-color: #1e1e1e;
}
</style>
<script>
function refreshLogs() {
location.reload();
}
// Auto-scroll to bottom of logs
window.addEventListener('load', function() {
var logContent = document.querySelector('.log-content-wrapper');
if (logContent) {
logContent.scrollTop = logContent.scrollHeight;
}
});
// Highlight search terms
@if (!string.IsNullOrWhiteSpace(Model.SearchTerm))
{
<text>
window.addEventListener('load', function() {
var content = document.getElementById('logContent');
if (content) {
var searchTerm = '@Html.Raw(System.Web.HttpUtility.JavaScriptStringEncode(Model.SearchTerm))';
var regex = new RegExp('(' + searchTerm.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + ')', 'gi');
content.innerHTML = content.textContent.replace(regex, '<mark>$1</mark>');
}
});
</text>
}
// Color code log levels
window.addEventListener('load', function() {
var content = document.getElementById('logContent');
if (content) {
var html = content.textContent;
html = html.replace(/\[ERR\]/g, '<span style="color: #f48771; font-weight: bold;">[ERR]</span>');
html = html.replace(/\[WRN\]/g, '<span style="color: #dcdcaa; font-weight: bold;">[WRN]</span>');
html = html.replace(/\[INF\]/g, '<span style="color: #4ec9b0;">[INF]</span>');
html = html.replace(/\[DBG\]/g, '<span style="color: #808080;">[DBG]</span>');
content.innerHTML = html;
}
});
</script>