Skip to content
75 changes: 46 additions & 29 deletions TarkovMonitor/Blazor/AppLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -173,39 +173,56 @@

private void OnMessageAdded(object? sender, NewLogMessageArgs e)
{
InvokeAsync(StateHasChanged);

if (e.Message.Type == "quest" && GameWatcher.ReadingPastLogs)
_ = InvokeAsync(() =>
{
return;
}
try
{
if (e.IsRepeat)
{
return;
}

var severity = e.Message.Type switch
{
"exception" => Severity.Error,
"warning" => Severity.Warning,
"update" => Severity.Success,
_ => Severity.Info
};

var path = NavigationManager.ToBaseRelativePath(NavigationManager.Uri)
.Split('?', '#')[0]
.Trim('/');
var messagesAreVisible = string.IsNullOrEmpty(path) || path.Equals("app", StringComparison.OrdinalIgnoreCase);
var requiresImmediateAttention = severity is Severity.Error or Severity.Warning;

if (messagesAreVisible && !requiresImmediateAttention)
{
return;
}
StateHasChanged();

Snackbar.Add(e.Message.Message, severity, configuration =>
{
configuration.OnClick = snackbar =>
if (e.Message.Type == "quest" && GameWatcher.ReadingPastLogs)
{
return;
}

var severity = e.Message.Type switch
{
"exception" => Severity.Error,
"warning" => Severity.Warning,
"update" => Severity.Success,
_ => Severity.Info
};

var path = NavigationManager.ToBaseRelativePath(NavigationManager.Uri)
.Split('?', '#')[0]
.Trim('/');
var messagesAreVisible = string.IsNullOrEmpty(path) || path.Equals("app", StringComparison.OrdinalIgnoreCase);
var requiresImmediateAttention = severity is Severity.Error or Severity.Warning;

if (messagesAreVisible && !requiresImmediateAttention)
{
return;
}

Snackbar.Add(e.Message.Message, severity, configuration =>
{
configuration.OnClick = snackbar =>
{
NavigationManager.NavigateTo("/");
return Task.CompletedTask;
};
});
}
catch (Exception exception)
{
NavigationManager.NavigateTo("/");
return Task.CompletedTask;
};
MessageLog.Diagnostics.Capture(
new DiagnosticContext("TM-UI-006", "SnackbarNotification", "UI", "Notification", "A snackbar notification could not be shown."),
exception);
}
});
}

Expand Down
16 changes: 13 additions & 3 deletions TarkovMonitor/Blazor/Components/MessageBoard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@inject MessageLog messageLog
@inject IDialogService DialogService
@inject LocalizationService LocalizationService
@inject ISnackbar Snackbar
<MudPaper Class="app-surface dashboard-notification-surface" Elevation="3">
<MudStack Reverse="true" Justify="Justify.FlexStart" AlignItems="AlignItems.Center" Class="pa-3">
@if (messageLog.Messages.Count == 0)
Expand Down Expand Up @@ -34,7 +35,7 @@
}
@foreach (MonitorMessageButton button in message.Buttons)
{
<MudButton Variant="Variant.Filled" Color="@button.Color" StartIcon="@button.Icon" OnClick="@((e) => MessageButtonClick(button) )">@button.Text</MudButton>
<MudButton Variant="Variant.Filled" Color="@button.Color" StartIcon="@button.Icon" Disabled="@button.Disabled" OnClick="@((e) => MessageButtonClick(button) )">@button.Text</MudButton>
}
</div>
</MudPaper>
Expand Down Expand Up @@ -122,8 +123,16 @@

private async void MessageButtonClick(MonitorMessageButton button)
{
var startedUtc = DateTime.UtcNow;
try
{
if (button.ResultAction != null)
{
var copyResult = button.ResultAction();
Snackbar.Add(copyResult.Message, copyResult.Succeeded ? Severity.Success : Severity.Error);
return;
}

if (button.Confirm == null)
{
button.OnClick?.Invoke();
Expand All @@ -142,19 +151,20 @@
}
catch (Exception ex)
{
messageLog.AddMessage($"Error in message button: ${ex.Message} {ex.StackTrace}", "exception");
messageLog.AddException("A notification action could not be completed.", "TM-UI-ACTION-001", "MessageButton", ex, "UI", "Action", durationMilliseconds: DiagnosticsService.ElapsedMilliseconds(startedUtc));
}
}

private async void MessageSelectChanged(MonitorMessageSelect select, IEnumerable<MonitorMessageSelectOption> selected)
{
var startedUtc = DateTime.UtcNow;
try
{
select.ChangeSelection(selected.First());
}
catch (Exception ex)
{
messageLog.AddMessage($"Error in message select: ${ex.Message} {ex.StackTrace}", "exception");
messageLog.AddException("A notification selection could not be completed.", "TM-UI-ACTION-002", "MessageSelect", ex, "UI", "Action", durationMilliseconds: DiagnosticsService.ElapsedMilliseconds(startedUtc));
}
}
}
8 changes: 5 additions & 3 deletions TarkovMonitor/Blazor/Pages/RawLogs/ForceReadDialog.razor
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
TaskStatuses.Clear();
var totalTasks = 0;
Dictionary<string, TarkovMonitor.TaskStatus> updateTasks = new();
var startedUtc = DateTime.UtcNow;
try
{
//eft.ProcessLogs(selectedPath);
Expand Down Expand Up @@ -173,13 +174,14 @@
}
catch (Exception ex)
{
messageLog.AddMessage($"Error compiling task updates: {ex.Message}", "exception");
messageLog.AddException("Past-log task updates could not be compiled.", "TM-LOG-001", "CompileTaskUpdates", ex, "LogParser", "PastLogs", durationMilliseconds: DiagnosticsService.ElapsedMilliseconds(startedUtc));
return;
}
finally
{
GameWatcher.ReadingPastLogs = false;
}
var updateStartedUtc = DateTime.UtcNow;
try
{
if (updateTasks.Count > 0)
Expand All @@ -191,12 +193,12 @@
}
catch (Exception ex)
{
messageLog.AddMessage($"Error updating tasks: {ex.Message}", "exception");
messageLog.AddException("Past-log task updates could not be sent.", "TM-API-TRACKER-007", "UpdatePastLogTasks", ex, "TarkovTracker", "PastLogs", $"https://{Properties.Settings.Default.tarkovTrackerDomain}", DiagnosticsService.ElapsedMilliseconds(updateStartedUtc));
}
}

private void UpdateTaskStatus(object? sender, LogContentEventArgs<TaskStatusMessageLogContent> e)
{
TaskStatuses[e.LogContent.TaskId] = e.LogContent.Status;
}
}
}
48 changes: 35 additions & 13 deletions TarkovMonitor/Blazor/Pages/Settings/Settings.razor
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
</div>
</MudPaper>
</MudItem>

</MudGrid>

@code {
Expand All @@ -195,6 +196,7 @@

private Dictionary<int, string> PlaybackDevices;
private List<(string Code, string Name)> AvailableLanguages = new();
private string resolvedCustomLogsFolder = "";
private TarkovDev.Trader? TraderFence
{
get
Expand Down Expand Up @@ -229,6 +231,7 @@
PlaybackDevices = Sound.GetPlaybackDevices();
AvailableLanguages = LocalizationService.GetAvailableLanguages();
LocalizationService.LanguageChanged += OnLanguageChanged;
ResolveCustomLogsFolder();
UpdateProfileName();
}

Expand Down Expand Up @@ -604,13 +607,14 @@
return;
}

var startedUtc = DateTime.UtcNow;
try
{
await TarkovTracker.SetProfile(GameWatcher.CurrentProfile.Id);
}
catch (Exception ex)
{
messageLog.AddMessage(ex.Message, "exception");
messageLog.AddException("Tarkov Tracker profile could not be loaded.", "TM-API-TRACKER-005", "SetProfile", ex, "TarkovTracker", "Profile", $"https://{TarkovTrackerDomain}", DiagnosticsService.ElapsedMilliseconds(startedUtc));
}
}

Expand Down Expand Up @@ -645,6 +649,7 @@
messageLog.AddMessage("Enter a PVE_, PVP_, or SZN_ TarkovTracker.org key followed by its 18-character hexadecimal identifier.", "warning");
return;
} else {
var startedUtc = DateTime.UtcNow;
try
{
var tokenResponse = await TarkovTracker.TestToken(TarkovTrackerToken);
Expand All @@ -656,7 +661,7 @@
}
catch (Exception ex)
{
messageLog.AddMessage(ex.Message, "exception");
messageLog.AddException("The Tarkov Tracker key test failed.", "TM-API-TRACKER-006", "TestToken", ex, "TarkovTracker", "TokenTest", $"https://{TarkovTrackerDomain}", DiagnosticsService.ElapsedMilliseconds(startedUtc));

}
}
Expand Down Expand Up @@ -764,25 +769,42 @@
{
return Properties.Settings.Default.customLogsPath;
}
try
{
return GameWatcher.GetDefaultLogsFolder();
}
catch (Exception ex)
{
messageLog.AddMessage($"Error getting default logs folder: {ex.Message}", "exception");
}
return "";
return resolvedCustomLogsFolder;
}
set
{
Properties.Settings.Default.customLogsPath = value;
Properties.Settings.Default.customLogsPath = value ?? "";
Properties.Settings.Default.Save();
if (string.IsNullOrWhiteSpace(Properties.Settings.Default.customLogsPath))
{
ResolveCustomLogsFolder();
}
}
}

private void ResolveCustomLogsFolder()
{
if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.customLogsPath))
{
resolvedCustomLogsFolder = Properties.Settings.Default.customLogsPath;
return;
}

var startedUtc = DateTime.UtcNow;
try
{
resolvedCustomLogsFolder = GameWatcher.GetDefaultLogsFolder();
}
catch (Exception ex)
{
resolvedCustomLogsFolder = "";
messageLog.AddException("The default EFT logs folder could not be located.", "TM-FILES-002", "GetDefaultLogsFolder", ex, "Filesystem", "Settings", durationMilliseconds: DiagnosticsService.ElapsedMilliseconds(startedUtc));
}
}

void CustomLogsFolderClick()
{
var startedUtc = DateTime.UtcNow;
try
{
var currentFolder = CustomLogsFolder;
Expand All @@ -801,7 +823,7 @@
}
catch (Exception ex)
{
messageLog.AddMessage($"Error opening logs folder picker: {ex.Message}", "exception");
messageLog.AddException("The EFT logs folder picker could not be opened.", "TM-UI-004", "OpenLogsFolderPicker", ex, "UI", "Settings", durationMilliseconds: DiagnosticsService.ElapsedMilliseconds(startedUtc));
}
}

Expand Down
3 changes: 2 additions & 1 deletion TarkovMonitor/Blazor/Pages/Sounds/Sounds.razor
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,14 @@
}
else
{
var startedUtc = DateTime.UtcNow;
try
{
Sound.RemoveCustomSound(key);
}
catch (Exception ex)
{
Debug.WriteLine(ex);
messageLog.AddException("The custom sound could not be removed.", "TM-FILES-003", "RemoveCustomSound", ex, "Filesystem", "Sounds", durationMilliseconds: DiagnosticsService.ElapsedMilliseconds(startedUtc));
}
}
}
Expand Down
Loading
Loading