Skip to content

Commit

Permalink
Improve history presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cezarypiatek committed Sep 21, 2024
1 parent e53983d commit 6ca7b1d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Controls.Documents;
using Avalonia.Input;
using Avalonia.Input.Platform;
using Avalonia.Media;
using Avalonia.Threading;
using CliWrap;
using DynamicData;
Expand Down Expand Up @@ -919,7 +921,25 @@ private static string[] SplitCommand(string command)
public record ExecutionLogAction(DateTime Timestamp, string Source, string Name, Dictionary<string, string> Parameters)
{
[JsonIgnore]
public string Description => $"{Timestamp:s} - [{string.Join(", ", Parameters.Select(x => $"{x.Key} = {x.Value}"))}]";
public InlineCollection ParametersDescription => new InlineCollection()
{
new Run("["),

Parameters.SelectMany((x,i) =>
{
var value = x.Value.StartsWith("!!vault:") ? "*****" : x.Value;
return new[]
{
new Run($"{x.Key} = "),
new Run(value)
{
Foreground = Brushes.LightGreen,
},
new Run( i< Parameters.Count -1?", ":"")
};
}),
new Run("]"),
};
};

public record RecentAction(ActionId ActionId, DateTime Timestamp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</TextBlock>

</StackPanel>
<SelectableTextBlock TextWrapping="Wrap" Classes="consoleOutput" Text="{Binding CurrentRunOutputBuffered, Mode=OneWay}" Inlines="{Binding SelectedAction.CommandFormatted}" ></SelectableTextBlock>
<SelectableTextBlock TextWrapping="Wrap" Classes="consoleOutput" Inlines="{Binding SelectedAction.CommandFormatted}" ></SelectableTextBlock>
</StackPanel>
</Expander>

Expand Down Expand Up @@ -131,7 +131,7 @@
</Border>
</StackPanel>
<DockPanel Margin="0, 20, 0 , 5" HorizontalAlignment="Stretch" >
<Button DockPanel.Dock="Right" HorizontalAlignment="Center" Width="100" HorizontalContentAlignment="Center" Command="{Binding RunScript}">Run</Button>
<Button DockPanel.Dock="Right" HorizontalAlignment="Center" Width="200" HorizontalContentAlignment="Center" Command="{Binding RunScript}">Run</Button>
</DockPanel>
</StackPanel>
</StackPanel>
Expand Down Expand Up @@ -183,14 +183,10 @@


<DataTemplate x:DataType="viewModels:ExecutionLogAction">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<Grid ColumnDefinitions="Auto, *" RowDefinitions="Auto, *">
<avalonia:Icon Value="fas fa-clock" Margin="0,5,0,0" VerticalAlignment="Top"/>
<TextBlock Grid.Column="1" VerticalAlignment="Top" TextWrapping="Wrap" Margin="10,0" Text="{Binding Description}"></TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" TextWrapping="Wrap" Margin="10,0" Text="{Binding Timestamp, StringFormat={}{0:s}}"></TextBlock>
<SelectableTextBlock Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Padding="0, 5" Inlines="{Binding ParametersDescription}" TextWrapping="Wrap"></SelectableTextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
Expand Down

0 comments on commit 6ca7b1d

Please sign in to comment.