Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions IntelliTrader.Web/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,29 @@ public IActionResult Help(string lang = "en")
return View(model);
}

[HttpGet]
public IActionResult DownloadLog(string type = "general")
{
try
{
string pattern = "general".Equals(type, StringComparison.OrdinalIgnoreCase) ? "*-general.txt" : "*-trades.txt";
string filePath = GetLatestLogFilePath(pattern);

if (string.IsNullOrEmpty(filePath) || !System.IO.File.Exists(filePath))
{
return NotFound("No log file found.");
}

string fileName = Path.GetFileName(filePath);
var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
return File(fileStream, "text/plain", fileName);
}
catch (Exception ex)
{
return BadRequest($"Error downloading log file: {ex.Message}");
}
}

[HttpGet]
public IActionResult PollLogs(string type = "general", int maxLines = 100)
{
Expand Down
1 change: 1 addition & 0 deletions IntelliTrader.Web/Static/Scripts/Views/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ function setLogType(type) {
$("#logTypeGeneralBtn").removeClass("active");
}

$("#downloadLogTopBtn").attr("href", "/Home/DownloadLog?type=" + type);
$("#logTerminal").html('<div class="text-muted">Loading logs...</div>');
pollLiveLogs();
}
Expand Down
19 changes: 16 additions & 3 deletions IntelliTrader.Web/Views/Home/Dashboard.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,14 @@
<div class="card mt-4" style="background-color: var(--card-bg); color: var(--text-color); border-radius: 4px; border: 1px solid var(--card-border); margin-top: 20px;">
<div class="card-header" style="background-color: var(--card-header-bg); border-bottom: 1px solid var(--card-border); padding: 10px 15px; display: flex; align-items: center; justify-content: space-between;">
<h5 class="mb-0" style="color: var(--text-light); font-size: 16px; margin: 0;"><i class="fas fa-terminal mr-2"></i>Live Log Monitor</h5>
<div class="btn-group btn-group-sm" role="group">
<button type="button" class="btn btn-sm btn-outline-light active" id="logTypeGeneralBtn" style="border-color: var(--card-border); margin-right: 5px;" onclick="setLogType('general')">General Log</button>
<button type="button" class="btn btn-sm btn-outline-light" id="logTypeTradesBtn" style="border-color: var(--card-border);" onclick="setLogType('trades')">Trades Log</button>
<div class="d-flex align-items-center">
<a id="downloadLogTopBtn" href="/Home/DownloadLog?type=general" class="btn btn-sm btn-outline-info mr-2" style="border-color: var(--card-border);" download>
<i class="fas fa-download mr-1"></i> Download Log
</a>
<div class="btn-group btn-group-sm" role="group">
<button type="button" class="btn btn-sm btn-outline-light active" id="logTypeGeneralBtn" style="border-color: var(--card-border); margin-right: 5px;" onclick="setLogType('general')">General Log</button>
<button type="button" class="btn btn-sm btn-outline-light" id="logTypeTradesBtn" style="border-color: var(--card-border);" onclick="setLogType('trades')">Trades Log</button>
</div>
</div>
</div>
<div class="card-body p-0">
Expand Down Expand Up @@ -566,6 +571,9 @@
<option value="trades" selected>Trade Logs</option>
<option value="general">General Logs</option>
</select>
<a id="downloadLogTerminalBtn" href="/Home/DownloadLog?type=trades" class="btn btn-sm btn-outline-info mr-2" style="border-color: var(--card-border);" download>
<i class="fas fa-download mr-1"></i> Download
</a>
<button id="clearTerminalBtn" class="btn btn-sm btn-outline-secondary" style="border-color: var(--card-border); color: var(--text-color);">Clear</button>
</div>
</div>
Expand Down Expand Up @@ -636,6 +644,11 @@
logTypeSelect.addEventListener("change", function() {
lastLogContent = "";
logTerminal.innerHTML = '<div class="text-muted">Loading logs...</div>';
const logType = logTypeSelect.value;
const downloadBtn = document.getElementById("downloadLogTerminalBtn");
if (downloadBtn) {
downloadBtn.href = `/Home/DownloadLog?type=${logType}`;
}
fetchLogs();
});

Expand Down
19 changes: 18 additions & 1 deletion magda_agent_system/agent_tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@
},
{
"id": "web-dashboard-log-download",
"status": "todo",
"status": "done",
"area": "web",
"risk": "low",
"title": "Add log file download button on Web Dashboard",
Expand Down Expand Up @@ -505,6 +505,23 @@
"acceptance": [
"Users can click export on the Stats page to download summary statistics."
]
},
{
"id": "web-dashboard-log-filtering",
"status": "todo",
"area": "web",
"risk": "low",
"title": "Add search and log level filter controls for Live Log Monitor",
"description": "Implement search filter input and log level filter buttons (All, Info, Warning, Error) for the live log monitor card.",
"allowed_paths": [
"IntelliTrader.Web/Views/**",
"IntelliTrader.Web/Controllers/**",
"IntelliTrader.Web/Static/**",
"magda_agent_system/agent_tasks.json"
],
"acceptance": [
"Live log monitor terminal supports real-time text filter and log level filtering."
]
}
]
}