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
4 changes: 4 additions & 0 deletions Dashboard/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@
TextAlignment="Center"/>
<TextBlock Text="x historical average" VerticalAlignment="Center"/>
</StackPanel>
<TextBlock x:Name="AlertPreviewText" FontSize="11" FontStyle="Italic" Foreground="Gray"
TextWrapping="Wrap" Margin="0,12,0,0"/>
</StackPanel>
</StackPanel>
</ScrollViewer>
Expand Down Expand Up @@ -322,6 +324,8 @@
<StackPanel Grid.Row="6" Grid.Column="1" Orientation="Horizontal" Margin="0,4,0,0">
<Button x:Name="TestEmailButton" Content="Send Test Email" Padding="10,3"
Click="TestEmailButton_Click"/>
<Button x:Name="ValidateSmtpButton" Content="Validate Settings" Padding="10,3" Margin="8,0,0,0"
Click="ValidateSmtpButton_Click"/>
<TextBlock x:Name="TestEmailStatusText" FontStyle="Italic" Foreground="Gray"
VerticalAlignment="Center" Margin="10,0,0,0" FontSize="11"/>
</StackPanel>
Expand Down
55 changes: 55 additions & 0 deletions Dashboard/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,31 @@ private void RestoreAlertDefaultsButton_Click(object sender, RoutedEventArgs e)
LongRunningQueryThresholdTextBox.Text = "30";
TempDbSpaceThresholdTextBox.Text = "80";
LongRunningJobMultiplierTextBox.Text = "3";
UpdateAlertPreviewText();
}

private void UpdateAlertPreviewText()
{
var parts = new System.Collections.Generic.List<string>();

if (NotifyOnBlockingCheckBox.IsChecked == true)
parts.Add($"blocking > {BlockingThresholdTextBox.Text}s");
if (NotifyOnDeadlockCheckBox.IsChecked == true)
parts.Add($"deadlocks >= {DeadlockThresholdTextBox.Text}");
if (NotifyOnHighCpuCheckBox.IsChecked == true)
parts.Add($"CPU > {CpuThresholdTextBox.Text}%");
if (NotifyOnPoisonWaitsCheckBox.IsChecked == true)
parts.Add($"poison waits >= {PoisonWaitThresholdTextBox.Text}ms avg");
if (NotifyOnLongRunningQueriesCheckBox.IsChecked == true)
parts.Add($"queries > {LongRunningQueryThresholdTextBox.Text}min");
if (NotifyOnTempDbSpaceCheckBox.IsChecked == true)
parts.Add($"TempDB > {TempDbSpaceThresholdTextBox.Text}%");
if (NotifyOnLongRunningJobsCheckBox.IsChecked == true)
parts.Add($"jobs > {LongRunningJobMultiplierTextBox.Text}x avg");

AlertPreviewText.Text = parts.Count > 0
? $"Will alert when: {string.Join(", ", parts)}"
: "No alerts enabled";
}

private void UpdateAlertNotificationStates()
Expand All @@ -275,6 +300,7 @@ private void UpdateAlertNotificationStates()
TempDbSpaceThresholdTextBox.IsEnabled = notificationsEnabled && NotifyOnTempDbSpaceCheckBox.IsChecked == true;
NotifyOnLongRunningJobsCheckBox.IsEnabled = notificationsEnabled;
LongRunningJobMultiplierTextBox.IsEnabled = notificationsEnabled && NotifyOnLongRunningJobsCheckBox.IsChecked == true;
UpdateAlertPreviewText();
}

private void UpdateNotificationCheckboxStates()
Expand Down Expand Up @@ -561,6 +587,35 @@ private void UpdateSmtpControlStates()
SmtpFromTextBox.IsEnabled = enabled;
SmtpRecipientsTextBox.IsEnabled = enabled;
TestEmailButton.IsEnabled = enabled;
ValidateSmtpButton.IsEnabled = enabled;
}

private void ValidateSmtpButton_Click(object sender, RoutedEventArgs e)
{
var errors = new System.Collections.Generic.List<string>();

if (string.IsNullOrWhiteSpace(SmtpServerTextBox.Text))
errors.Add("SMTP server is required");
if (!int.TryParse(SmtpPortTextBox.Text, out var port) || port < 1 || port > 65535)
errors.Add("Port must be between 1 and 65535");
if (string.IsNullOrWhiteSpace(SmtpFromTextBox.Text))
errors.Add("From address is required");
else if (!SmtpFromTextBox.Text.Trim().Contains('@'))
errors.Add("From address must be a valid email");
if (string.IsNullOrWhiteSpace(SmtpRecipientsTextBox.Text))
errors.Add("At least one recipient is required");

if (errors.Count == 0)
{
TestEmailStatusText.Text = "Settings look good. Use 'Send Test Email' to verify delivery.";
}
else
{
TestEmailStatusText.Text = "";
MessageBox.Show(
"SMTP configuration has issues:\n\n" + string.Join("\n", errors),
"SMTP Validation", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}

private async void TestEmailButton_Click(object sender, RoutedEventArgs e)
Expand Down
14 changes: 12 additions & 2 deletions Lite/Windows/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@
<TextBox x:Name="AlertCpuThresholdBox" Width="45" Text="80" Margin="6,0,0,0" VerticalAlignment="Center"/>
<TextBlock Text="%" VerticalAlignment="Center" Margin="2,0,0,0"
Foreground="{DynamicResource ForegroundBrush}"/>
<TextBlock Text="(default 80% — Lite collects directly from DMVs so catches spikes faster than Dashboard)"
FontSize="10" FontStyle="Italic" Foreground="{DynamicResource ForegroundMutedBrush}"
VerticalAlignment="Center" Margin="8,0,0,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="20,6,0,0">
<CheckBox x:Name="AlertBlockingCheckBox" Content="Blocking sessions &#x2265;" VerticalAlignment="Center"
Expand Down Expand Up @@ -152,6 +155,8 @@
<TextBlock Text="x historical average" VerticalAlignment="Center" Margin="2,0,0,0"
Foreground="{DynamicResource ForegroundBrush}"/>
</StackPanel>
<TextBlock x:Name="AlertPreviewText" FontSize="11" FontStyle="Italic"
Foreground="{DynamicResource ForegroundMutedBrush}" TextWrapping="Wrap" Margin="20,10,0,0"/>
</StackPanel>
</Border>

Expand Down Expand Up @@ -206,8 +211,13 @@
<TextBox Grid.Row="5" Grid.Column="1" x:Name="SmtpRecipientsBox" Margin="0,0,0,4"
ToolTip="Comma-separated email addresses"/>

<Button Grid.Row="6" Grid.Column="1" x:Name="TestEmailButton" Content="Send Test Email"
Click="TestEmailButton_Click" HorizontalAlignment="Left" Margin="0,4,0,0"/>
<StackPanel Grid.Row="6" Grid.Column="1" Orientation="Horizontal" Margin="0,4,0,0">
<Button x:Name="TestEmailButton" Content="Send Test Email" Click="TestEmailButton_Click"/>
<Button x:Name="ValidateSmtpButton" Content="Validate Settings" Margin="8,0,0,0"
Click="ValidateSmtpButton_Click"/>
<TextBlock x:Name="SmtpStatusText" FontSize="11" FontStyle="Italic"
Foreground="{DynamicResource ForegroundMutedBrush}" VerticalAlignment="Center" Margin="8,0,0,0"/>
</StackPanel>
</Grid>
</StackPanel>
</Border>
Expand Down
55 changes: 55 additions & 0 deletions Lite/Windows/SettingsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,31 @@ private void RestoreAlertDefaultsButton_Click(object sender, RoutedEventArgs e)
AlertLongRunningQueryThresholdBox.Text = "30";
AlertTempDbSpaceThresholdBox.Text = "80";
AlertLongRunningJobMultiplierBox.Text = "3";
UpdateAlertPreviewText();
}

private void UpdateAlertPreviewText()
{
var parts = new System.Collections.Generic.List<string>();

if (AlertCpuCheckBox.IsChecked == true)
parts.Add($"CPU > {AlertCpuThresholdBox.Text}%");
if (AlertBlockingCheckBox.IsChecked == true)
parts.Add($"blocking >= {AlertBlockingThresholdBox.Text}");
if (AlertDeadlockCheckBox.IsChecked == true)
parts.Add($"deadlocks >= {AlertDeadlockThresholdBox.Text}");
if (AlertPoisonWaitCheckBox.IsChecked == true)
parts.Add($"poison waits >= {AlertPoisonWaitThresholdBox.Text}ms avg");
if (AlertLongRunningQueryCheckBox.IsChecked == true)
parts.Add($"queries > {AlertLongRunningQueryThresholdBox.Text}min");
if (AlertTempDbSpaceCheckBox.IsChecked == true)
parts.Add($"TempDB > {AlertTempDbSpaceThresholdBox.Text}%");
if (AlertLongRunningJobCheckBox.IsChecked == true)
parts.Add($"jobs > {AlertLongRunningJobMultiplierBox.Text}x avg");

AlertPreviewText.Text = parts.Count > 0
? $"Will alert when: {string.Join(", ", parts)}"
: "No alerts enabled";
}

private void UpdateAlertControlStates()
Expand All @@ -343,6 +368,7 @@ private void UpdateAlertControlStates()
AlertTempDbSpaceThresholdBox.IsEnabled = enabled;
AlertLongRunningJobCheckBox.IsEnabled = enabled;
AlertLongRunningJobMultiplierBox.IsEnabled = enabled;
UpdateAlertPreviewText();
}

private void LoadSmtpSettings()
Expand Down Expand Up @@ -430,6 +456,35 @@ private void UpdateSmtpControlStates()
SmtpFromBox.IsEnabled = enabled;
SmtpRecipientsBox.IsEnabled = enabled;
TestEmailButton.IsEnabled = enabled;
ValidateSmtpButton.IsEnabled = enabled;
}

private void ValidateSmtpButton_Click(object sender, RoutedEventArgs e)
{
var errors = new System.Collections.Generic.List<string>();

if (string.IsNullOrWhiteSpace(SmtpServerBox.Text))
errors.Add("SMTP server is required");
if (!int.TryParse(SmtpPortBox.Text, out var port) || port < 1 || port > 65535)
errors.Add("Port must be between 1 and 65535");
if (string.IsNullOrWhiteSpace(SmtpFromBox.Text))
errors.Add("From address is required");
else if (!SmtpFromBox.Text.Trim().Contains('@'))
errors.Add("From address must be a valid email");
if (string.IsNullOrWhiteSpace(SmtpRecipientsBox.Text))
errors.Add("At least one recipient is required");

if (errors.Count == 0)
{
SmtpStatusText.Text = "Settings look good. Use 'Send Test Email' to verify delivery.";
}
else
{
SmtpStatusText.Text = "";
MessageBox.Show(
"SMTP configuration has issues:\n\n" + string.Join("\n", errors),
"SMTP Validation", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}

private async void TestEmailButton_Click(object sender, RoutedEventArgs e)
Expand Down