Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Dashboard/ServerTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<StackPanel Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Orientation="Vertical" Margin="15,0,0,0">
<StackPanel Orientation="Horizontal">
<Button x:Name="ApplyToAllButton" Content="Apply to All Tabs" Click="ApplyToAllTabs_Click" Margin="2,0" Padding="12,5" Style="{DynamicResource AccentButton}"/>
<Button x:Name="RefreshButton" Content="Refresh Tab" Click="RefreshButton_Click" Margin="2,0" Padding="12,5" Style="{DynamicResource SuccessButton}"/>
<Button x:Name="RefreshButton" Content="Refresh Tab" Click="RefreshButton_Click" Margin="2,0" Padding="12,5" Style="{DynamicResource SuccessButton}" ToolTip="Refresh the current tab. Ctrl+Click to refresh all tabs."/>
<ToggleButton x:Name="AutoRefreshToggle" Content="Auto-Refresh: Off" Click="AutoRefreshToggle_Click" Margin="8,0,2,0" Padding="12,5" MinWidth="130" ToolTip="Toggle auto-refresh on/off. Configure interval in Settings."/>
<Button Content="Edit Schedules" Click="EditSchedules_Click" Margin="8,0,2,0" Padding="12,5" Style="{DynamicResource AccentButton}" ToolTip="Edit collector schedules (frequency, retention, enabled/disabled)"/>
<TextBlock Text="|" VerticalAlignment="Center" Margin="8,0,4,0" Foreground="{DynamicResource ForegroundBrush}"/>
Expand Down
23 changes: 15 additions & 8 deletions Dashboard/ServerTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public partial class ServerTab : UserControl
private bool _isRefreshing;
private DateTime _refreshStartedUtc;
private bool _suppressPickerUpdates;
private readonly HashSet<string> _initializedTabs = new();

// Filter state dictionaries for each DataGrid

Expand Down Expand Up @@ -424,6 +425,7 @@ public void CleanupOnClose()
_autoRefreshCts?.Cancel();
_autoRefreshTimer?.Stop();
_autoRefreshTimer = null;
_initializedTabs.Clear();

Helpers.ThemeManager.ThemeChanged -= OnThemeChanged;
Loaded -= ServerTab_Loaded;
Expand Down Expand Up @@ -549,7 +551,8 @@ private async void ServerTab_KeyDown(object sender, System.Windows.Input.KeyEven
if (e.Key == System.Windows.Input.Key.F5)
{
e.Handled = true;
await LoadDataAsync();
bool fullRefresh = System.Windows.Input.Keyboard.Modifiers.HasFlag(System.Windows.Input.ModifierKeys.Control);
await LoadDataAsync(fullRefresh);
}
else if (e.Key == System.Windows.Input.Key.V &&
System.Windows.Input.Keyboard.Modifiers == System.Windows.Input.ModifierKeys.Control &&
Expand Down Expand Up @@ -640,7 +643,7 @@ private async void ServerTab_Loaded(object sender, RoutedEventArgs e)
CriticalIssuesTab.SetTimeRange(_globalHoursBack, _globalFromDate, _globalToDate);
DefaultTraceTab.SetTimeRange(_globalHoursBack, _globalFromDate, _globalToDate);

await LoadDataAsync();
await LoadDataAsync(fullRefresh: false);
SetupAutoRefresh();
}
catch (Exception ex)
Expand All @@ -654,7 +657,8 @@ private async void RefreshButton_Click(object sender, RoutedEventArgs e)
{
try
{
await LoadDataAsync();
bool fullRefresh = System.Windows.Input.Keyboard.Modifiers.HasFlag(System.Windows.Input.ModifierKeys.Control);
await LoadDataAsync(fullRefresh);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -1271,34 +1275,37 @@ private async Task RefreshAllTabsAsync()
}

/// <summary>
/// Refreshes only the currently visible tab — used on auto-refresh timer tick.
/// Refreshes only the currently visible tab. On first visit to a tab,
/// does a full refresh so all sub-tabs are populated. Subsequent visits
/// only refresh the active sub-tab for speed.
/// </summary>
private async Task RefreshVisibleTabAsync()
{
var selectedTab = DataTabControl.SelectedItem as TabItem;
if (selectedTab == null) return;

var tabHeader = GetTabHeaderText(selectedTab);
bool firstVisit = _initializedTabs.Add(tabHeader);

switch (tabHeader)
{
case "Overview":
await RefreshOverviewTabAsync();
break;
case "Queries":
await RefreshQueriesTabAsync(fullRefresh: false);
await RefreshQueriesTabAsync(fullRefresh: firstVisit);
break;
case "Resource Metrics":
await RefreshResourceMetricsTabAsync(fullRefresh: false);
await RefreshResourceMetricsTabAsync(fullRefresh: firstVisit);
break;
case "Memory":
await RefreshMemoryTabAsync(fullRefresh: false);
await RefreshMemoryTabAsync(fullRefresh: firstVisit);
break;
case "Locking":
await RefreshLockingTabAsync();
break;
case "System Events":
await RefreshSystemEventsTabAsync(fullRefresh: false);
await RefreshSystemEventsTabAsync(fullRefresh: firstVisit);
break;
// Plan Viewer has no data to refresh
}
Expand Down
6 changes: 3 additions & 3 deletions Dashboard/Services/DatabaseService.QueryPerformance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ GROUP BY
qs.query_hash,
qs.creation_time
)
SELECT
SELECT TOP (500)
database_name = pl.database_name,
query_hash = CONVERT(nvarchar(20), pl.query_hash, 1),
object_type = MAX(pl.object_type),
Expand Down Expand Up @@ -1345,7 +1345,7 @@ GROUP BY
ps.object_name,
ps.cached_time
)
SELECT
SELECT TOP (500)
database_name = pl.database_name,
object_id = MAX(pl.object_id),
object_name = QUOTENAME(pl.schema_name) + N'.' + QUOTENAME(pl.object_name),
Expand Down Expand Up @@ -1520,7 +1520,7 @@ public async Task<List<QueryStoreItem>> GetQueryStoreDataAsync(int hoursBack = 2
string query = @"
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

SELECT
SELECT TOP (500)
database_name = qsd.database_name,
query_id = qsd.query_id,
execution_type_desc = MAX(qsd.execution_type_desc),
Expand Down
Loading