diff --git a/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml b/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml index 1841365..02cbd46 100644 --- a/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml +++ b/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml @@ -102,6 +102,7 @@ + diff --git a/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs b/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs index a05ef88..218e151 100644 --- a/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs +++ b/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs @@ -13,6 +13,7 @@ using Microsoft.Data.SqlClient; using PlanViewer.Core.Interfaces; using PlanViewer.Core.Models; +using PlanViewer.App.Dialogs; using PlanViewer.Core.Services; namespace PlanViewer.App.Controls; @@ -218,6 +219,26 @@ private void LoadHighlightedPlan_Click(object? sender, RoutedEventArgs e) PlansSelected?.Invoke(this, new List { row.Plan }); } + private async void ViewHistory_Click(object? sender, RoutedEventArgs e) + { + if (ResultsGrid.SelectedItem is not QueryStoreRow row) return; + + var hoursBack = (int)(HoursBackBox.Value ?? 24); + + var window = new QueryStoreHistoryWindow( + _connectionString, + row.QueryId, + row.FullQueryText, + _database, + hoursBack); + + var topLevel = Avalonia.Controls.TopLevel.GetTopLevel(this); + if (topLevel is Window parentWindow) + await window.ShowDialog(parentWindow); + else + window.Show(); + } + // ── Context menu ──────────────────────────────────────────────────────── private void ContextMenu_Opening(object? sender, System.ComponentModel.CancelEventArgs e) @@ -225,6 +246,7 @@ private void ContextMenu_Opening(object? sender, System.ComponentModel.CancelEve var row = ResultsGrid.SelectedItem as QueryStoreRow; var hasRow = row != null; + ViewHistoryItem.IsEnabled = hasRow; CopyQueryIdItem.IsEnabled = hasRow; CopyPlanIdItem.IsEnabled = hasRow; CopyQueryHashItem.IsEnabled = hasRow && !string.IsNullOrEmpty(row!.QueryHash); diff --git a/src/PlanViewer.App/Dialogs/QueryStoreHistoryWindow.axaml b/src/PlanViewer.App/Dialogs/QueryStoreHistoryWindow.axaml new file mode 100644 index 0000000..08e58fb --- /dev/null +++ b/src/PlanViewer.App/Dialogs/QueryStoreHistoryWindow.axaml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +