354 lines
19 KiB
XML
354 lines
19 KiB
XML
<UserControl x:Class="ThreadPilot.Views.LogViewerView"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:viewmodels="clr-namespace:ThreadPilot.ViewModels"
|
|
xmlns:local="clr-namespace:ThreadPilot.Views"
|
|
mc:Ignorable="d"
|
|
d:DesignHeight="600" d:DesignWidth="1000"
|
|
d:DataContext="{d:DesignInstance Type=viewmodels:LogViewerViewModel}">
|
|
|
|
<UserControl.Resources>
|
|
<Style x:Key="LogLevelTextStyle" TargetType="TextBlock">
|
|
<Setter Property="FontWeight" Value="Bold"/>
|
|
<Setter Property="Padding" Value="4,2"/>
|
|
<Setter Property="HorizontalAlignment" Value="Center"/>
|
|
</Style>
|
|
|
|
<Style x:Key="LogEntryStyle" TargetType="ListViewItem">
|
|
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
|
<Setter Property="Padding" Value="2"/>
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding Level}" Value="Error">
|
|
<Setter Property="Background" Value="#FFEEEE"/>
|
|
</DataTrigger>
|
|
<DataTrigger Binding="{Binding Level}" Value="Critical">
|
|
<Setter Property="Background" Value="#FFDDDD"/>
|
|
</DataTrigger>
|
|
<DataTrigger Binding="{Binding Level}" Value="Warning">
|
|
<Setter Property="Background" Value="#FFFAEE"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</UserControl.Resources>
|
|
|
|
<Grid Margin="10">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="*"/>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="200"/>
|
|
<RowDefinition Height="Auto"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<!-- Standardized Header -->
|
|
<GroupBox Grid.Row="0" Header="📋 Activity Logs" Margin="0,0,0,10">
|
|
<Grid Margin="5">
|
|
<TextBlock Text="View and filter application logs and system events"
|
|
FontSize="12" Foreground="Gray" VerticalAlignment="Center"/>
|
|
</Grid>
|
|
</GroupBox>
|
|
|
|
<!-- Filter and Control Panel -->
|
|
<Border Grid.Row="1" Background="#F5F5F5" Padding="10" BorderBrush="#CCCCCC" BorderThickness="0,0,0,1">
|
|
<Grid>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
</Grid.RowDefinitions>
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*"/>
|
|
<ColumnDefinition Width="Auto"/>
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<!-- Filters Row 1 -->
|
|
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" Margin="0,0,0,5">
|
|
<TextBlock Text="Search:" VerticalAlignment="Center" Margin="0,0,5,0"/>
|
|
<TextBox Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}"
|
|
Width="200" Margin="0,0,15,0"/>
|
|
|
|
<TextBlock Text="Category:" VerticalAlignment="Center" Margin="0,0,5,0"/>
|
|
<ComboBox ItemsSource="{Binding AvailableCategories}"
|
|
SelectedItem="{Binding SelectedCategory}"
|
|
Width="120" Margin="0,0,15,0"/>
|
|
|
|
<TextBlock Text="Level:" VerticalAlignment="Center" Margin="0,0,5,0"/>
|
|
<ComboBox ItemsSource="{Binding AvailableLogLevels}"
|
|
SelectedItem="{Binding SelectedLogLevel}"
|
|
Width="100" Margin="0,0,15,0"/>
|
|
</StackPanel>
|
|
|
|
<!-- Filters Row 2 -->
|
|
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal">
|
|
<TextBlock Text="From:" VerticalAlignment="Center" Margin="0,0,5,0"/>
|
|
<DatePicker SelectedDate="{Binding FromDate}" Margin="0,0,15,0"/>
|
|
|
|
<TextBlock Text="To:" VerticalAlignment="Center" Margin="0,0,5,0"/>
|
|
<DatePicker SelectedDate="{Binding ToDate}" Margin="0,0,15,0"/>
|
|
</StackPanel>
|
|
|
|
<!-- Action Buttons -->
|
|
<StackPanel Grid.Row="0" Grid.RowSpan="2" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
|
|
<Button Content="Refresh" Command="{Binding RefreshLogsCommand}"
|
|
Margin="5,0" Padding="10,5">
|
|
<Button.IsEnabled>
|
|
<Binding Path="IsLoading">
|
|
<Binding.Converter>
|
|
<local:InverseBooleanConverter/>
|
|
</Binding.Converter>
|
|
</Binding>
|
|
</Button.IsEnabled>
|
|
</Button>
|
|
<Button Content="Clear Display" Command="{Binding ClearLogsCommand}"
|
|
Margin="5,0" Padding="10,5"/>
|
|
<Button Content="Export" Command="{Binding ExportLogsCommand}"
|
|
Margin="5,0" Padding="10,5"/>
|
|
<Button Content="Cleanup Old" Command="{Binding CleanupOldLogsCommand}"
|
|
Margin="5,0" Padding="10,5"/>
|
|
<Button Content="Open Directory" Command="{Binding OpenLogDirectoryCommand}"
|
|
Margin="5,0" Padding="10,5"/>
|
|
</StackPanel>
|
|
</Grid>
|
|
</Border>
|
|
|
|
<!-- Log Entries List -->
|
|
<ListView Grid.Row="2" ItemsSource="{Binding LogEntries}"
|
|
SelectedItem="{Binding SelectedLogEntry}"
|
|
ItemContainerStyle="{StaticResource LogEntryStyle}"
|
|
ScrollViewer.HorizontalScrollBarVisibility="Auto"
|
|
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
|
VirtualizingPanel.IsVirtualizing="True"
|
|
VirtualizingPanel.VirtualizationMode="Recycling"
|
|
VirtualizingPanel.ScrollUnit="Item"
|
|
ScrollViewer.CanContentScroll="True">
|
|
<ListView.View>
|
|
<GridView>
|
|
<GridViewColumn Header="Time" Width="150">
|
|
<GridViewColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<TextBlock Text="{Binding FormattedTimestamp}" FontFamily="Consolas"/>
|
|
</DataTemplate>
|
|
</GridViewColumn.CellTemplate>
|
|
</GridViewColumn>
|
|
|
|
<GridViewColumn Header="Level" Width="80">
|
|
<GridViewColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<TextBlock Text="{Binding Level}"
|
|
Foreground="{Binding LevelColor}"
|
|
Style="{StaticResource LogLevelTextStyle}"/>
|
|
</DataTemplate>
|
|
</GridViewColumn.CellTemplate>
|
|
</GridViewColumn>
|
|
|
|
<GridViewColumn Header="Category" Width="120">
|
|
<GridViewColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<TextBlock Text="{Binding Category}" FontWeight="SemiBold"/>
|
|
</DataTemplate>
|
|
</GridViewColumn.CellTemplate>
|
|
</GridViewColumn>
|
|
|
|
<GridViewColumn Header="Message" Width="500">
|
|
<GridViewColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<TextBlock Text="{Binding ShortMessage}" TextWrapping="NoWrap"/>
|
|
</DataTemplate>
|
|
</GridViewColumn.CellTemplate>
|
|
</GridViewColumn>
|
|
|
|
<GridViewColumn Header="Exception" Width="60">
|
|
<GridViewColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<TextBlock Foreground="Red" FontWeight="Bold">
|
|
<TextBlock.Style>
|
|
<Style TargetType="TextBlock">
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding HasException}" Value="True">
|
|
<Setter Property="Text" Value="⚠"/>
|
|
</DataTrigger>
|
|
<DataTrigger Binding="{Binding HasException}" Value="False">
|
|
<Setter Property="Text" Value=""/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</TextBlock.Style>
|
|
</TextBlock>
|
|
</DataTemplate>
|
|
</GridViewColumn.CellTemplate>
|
|
</GridViewColumn>
|
|
|
|
<GridViewColumn Header="ID" Width="60">
|
|
<GridViewColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<TextBlock Text="{Binding CorrelationId}" FontFamily="Consolas" FontSize="10"/>
|
|
</DataTemplate>
|
|
</GridViewColumn.CellTemplate>
|
|
</GridViewColumn>
|
|
</GridView>
|
|
</ListView.View>
|
|
|
|
<ListView.ContextMenu>
|
|
<ContextMenu>
|
|
<MenuItem Header="Copy Entry" Command="{Binding CopyLogEntryCommand}"
|
|
CommandParameter="{Binding SelectedLogEntry}"/>
|
|
<Separator/>
|
|
<MenuItem Header="Refresh" Command="{Binding RefreshLogsCommand}"/>
|
|
</ContextMenu>
|
|
</ListView.ContextMenu>
|
|
</ListView>
|
|
|
|
<!-- Splitter -->
|
|
<GridSplitter Grid.Row="3" Height="5" HorizontalAlignment="Stretch"
|
|
Background="#CCCCCC" ResizeBehavior="PreviousAndNext"/>
|
|
|
|
<!-- Log Entry Details -->
|
|
<Border Grid.Row="4" Background="White" BorderBrush="#CCCCCC" BorderThickness="0,1,0,0">
|
|
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
|
|
<StackPanel Margin="10" DataContext="{Binding SelectedLogEntry}">
|
|
<TextBlock Text="Log Entry Details" FontWeight="Bold" FontSize="14" Margin="0,0,0,10"/>
|
|
|
|
<Grid>
|
|
<Grid.Style>
|
|
<Style TargetType="Grid">
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding}" Value="{x:Null}">
|
|
<Setter Property="Visibility" Value="Collapsed"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</Grid.Style>
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="Auto"/>
|
|
<ColumnDefinition Width="*"/>
|
|
</Grid.ColumnDefinitions>
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
<RowDefinition Height="Auto"/>
|
|
</Grid.RowDefinitions>
|
|
|
|
<TextBlock Grid.Row="0" Grid.Column="0" Text="Timestamp:" FontWeight="Bold" Margin="0,0,10,5"/>
|
|
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding FormattedTimestamp}" Margin="0,0,0,5"/>
|
|
|
|
<TextBlock Grid.Row="1" Grid.Column="0" Text="Level:" FontWeight="Bold" Margin="0,0,10,5"/>
|
|
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Level}"
|
|
Foreground="{Binding LevelColor}" FontWeight="Bold" Margin="0,0,0,5"/>
|
|
|
|
<TextBlock Grid.Row="2" Grid.Column="0" Text="Category:" FontWeight="Bold" Margin="0,0,10,5"/>
|
|
<TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Category}" Margin="0,0,0,5"/>
|
|
|
|
<TextBlock Grid.Row="3" Grid.Column="0" Text="Message:" FontWeight="Bold" Margin="0,0,10,5" VerticalAlignment="Top"/>
|
|
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Message, Mode=OneWay}"
|
|
IsReadOnly="True" TextWrapping="Wrap" Background="Transparent"
|
|
BorderThickness="0" Margin="0,0,0,10"/>
|
|
|
|
<TextBlock Grid.Row="4" Grid.Column="0" Text="Exception:" FontWeight="Bold" Margin="0,0,10,5"
|
|
VerticalAlignment="Top">
|
|
<TextBlock.Style>
|
|
<Style TargetType="TextBlock">
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding HasException}" Value="False">
|
|
<Setter Property="Visibility" Value="Collapsed"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</TextBlock.Style>
|
|
</TextBlock>
|
|
<TextBox Grid.Row="4" Grid.Column="1" Text="{Binding Exception, Mode=OneWay}"
|
|
IsReadOnly="True" TextWrapping="Wrap" Background="#FFEEEE"
|
|
BorderThickness="1" BorderBrush="#FFCCCC" Margin="0,0,0,10">
|
|
<TextBox.Style>
|
|
<Style TargetType="TextBox">
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding HasException}" Value="False">
|
|
<Setter Property="Visibility" Value="Collapsed"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</TextBox.Style>
|
|
</TextBox>
|
|
|
|
<TextBlock Grid.Row="5" Grid.Column="0" Text="Correlation ID:" FontWeight="Bold" Margin="0,0,10,5"/>
|
|
<TextBlock Grid.Row="5" Grid.Column="1" Text="{Binding CorrelationId}" FontFamily="Consolas"/>
|
|
</Grid>
|
|
|
|
<TextBlock Text="No log entry selected"
|
|
HorizontalAlignment="Center" VerticalAlignment="Center"
|
|
Foreground="Gray" FontStyle="Italic">
|
|
<TextBlock.Style>
|
|
<Style TargetType="TextBlock">
|
|
<Setter Property="Visibility" Value="Collapsed"/>
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding DataContext.SelectedLogEntry, RelativeSource={RelativeSource AncestorType=UserControl}}" Value="{x:Null}">
|
|
<Setter Property="Visibility" Value="Visible"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</TextBlock.Style>
|
|
</TextBlock>
|
|
</StackPanel>
|
|
</ScrollViewer>
|
|
</Border>
|
|
|
|
<!-- Status and Settings Panel -->
|
|
<Border Grid.Row="5" Background="#F5F5F5" Padding="10" BorderBrush="#CCCCCC" BorderThickness="0,1,0,0">
|
|
<Grid>
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*"/>
|
|
<ColumnDefinition Width="Auto"/>
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<!-- Status and Statistics -->
|
|
<StackPanel Grid.Column="0" Orientation="Horizontal">
|
|
<TextBlock Text="{Binding StatusMessage}" VerticalAlignment="Center" Margin="0,0,20,0"/>
|
|
|
|
<TextBlock Text="Files:" VerticalAlignment="Center" Margin="0,0,5,0" FontWeight="Bold"/>
|
|
<TextBlock Text="{Binding LogStatistics.TotalLogFiles}" VerticalAlignment="Center" Margin="0,0,15,0"/>
|
|
|
|
<TextBlock Text="Size:" VerticalAlignment="Center" Margin="0,0,5,0" FontWeight="Bold"/>
|
|
<TextBlock VerticalAlignment="Center" Margin="0,0,15,0">
|
|
<TextBlock.Text>
|
|
<MultiBinding StringFormat="{}{0:F1} MB">
|
|
<Binding Path="LogStatistics.TotalLogSizeBytes" Converter="{x:Static local:BytesToMegabytesConverter.Instance}"/>
|
|
</MultiBinding>
|
|
</TextBlock.Text>
|
|
</TextBlock>
|
|
|
|
<ProgressBar IsIndeterminate="{Binding IsLoading}" Width="100" Height="16">
|
|
<ProgressBar.Style>
|
|
<Style TargetType="ProgressBar">
|
|
<Style.Triggers>
|
|
<DataTrigger Binding="{Binding IsLoading}" Value="False">
|
|
<Setter Property="Visibility" Value="Collapsed"/>
|
|
</DataTrigger>
|
|
</Style.Triggers>
|
|
</Style>
|
|
</ProgressBar.Style>
|
|
</ProgressBar>
|
|
</StackPanel>
|
|
|
|
<!-- Settings Panel -->
|
|
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
|
<CheckBox Content="Debug Logging" IsChecked="{Binding EnableDebugLogging}"
|
|
VerticalAlignment="Center" Margin="0,0,15,0"/>
|
|
|
|
<TextBlock Text="Max Size (MB):" VerticalAlignment="Center" Margin="0,0,5,0"/>
|
|
<TextBox Text="{Binding MaxLogFileSizeMb}" Width="50" Margin="0,0,15,0"/>
|
|
|
|
<TextBlock Text="Retention (Days):" VerticalAlignment="Center" Margin="0,0,5,0"/>
|
|
<TextBox Text="{Binding LogRetentionDays}" Width="50" Margin="0,0,15,0"/>
|
|
|
|
<Button Content="Save Settings" Command="{Binding SaveSettingsCommand}"
|
|
Padding="10,5" Margin="5,0"/>
|
|
</StackPanel>
|
|
</Grid>
|
|
</Border>
|
|
</Grid>
|
|
</UserControl>
|