Skip to content

Commit 6efda35

Browse files
authored
Merge pull request #6 from HeikoStudt/SearchEnter
Search enter
2 parents 8bce964 + 17acd71 commit 6efda35

File tree

4 files changed

+44
-18
lines changed

4 files changed

+44
-18
lines changed

Backend/Model/LogLevel.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ public static LoggingLevel FromName(string name) {
2828
return Levels.FirstOrDefault(m => m.Name == name);
2929
}
3030

31+
public static IEnumerable<LoggingLevel> GetAllLoggingLevels() {
32+
yield return LoggingLevel.TRACE;
33+
yield return LoggingLevel.DEBUG;
34+
yield return LoggingLevel.INFO;
35+
yield return LoggingLevel.WARN;
36+
yield return LoggingLevel.ERROR;
37+
yield return LoggingLevel.FATAL;
38+
}
39+
3140
public static bool IsLogLevelAboveMin(LoggingLevel level, LoggingLevel minLevel) {
3241
if (level == null || minLevel == null) {
3342
return false;

Loginator/MainWindow.xaml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,23 @@
1919
<StackPanel Orientation="Vertical">
2020
<DockPanel>
2121
<CheckBox Content="Is active" IsChecked="{Binding IsActive}"></CheckBox>
22-
<TextBox Text="{Binding NumberOfLogsPerLevel}" ToolTip="Enter limit per application per log level" Width="100" Margin="16,0,0,0"></TextBox>
23-
<Button Content="Limit" Width="80" Margin="2,0,0,0" Command="{Binding UpdateNumberOfLogsPerLevelCommand}"></Button>
24-
<TextBox Text="{Binding SearchCriteria}" ToolTip="Enter search query" Width="100" Margin="16,0,0,0"></TextBox>
25-
<Button Content="Search" Width="80" Margin="2,0,0,0" Command="{Binding UpdateSearchCriteriaCommand}"></Button>
22+
<TextBox Text="{Binding NumberOfLogsPerLevel}" ToolTip="Enter limit per application per log level" Width="100" Margin="16,0,0,0">
23+
<TextBox.InputBindings>
24+
<KeyBinding Key="Enter" Command="{Binding UpdateNumberOfLogsPerLevelCommand}"/>
25+
</TextBox.InputBindings>
26+
</TextBox>
27+
<Button Content="Limit" Width="60" Margin="2,0,0,0" Command="{Binding UpdateNumberOfLogsPerLevelCommand}"></Button>
28+
<TextBox Text="{Binding SearchCriteria, UpdateSourceTrigger=PropertyChanged}" ToolTip="Enter search query" Width="100" Margin="16,0,0,0"></TextBox>
29+
<Button Content="Search" Width="60" Margin="2,0,0,0" Command="{Binding UpdateSearchCriteriaCommand}"></Button>
2630
<CheckBox Content="Invert" IsChecked="{Binding IsInverted}" Margin="2,2,0,0"></CheckBox>
2731
<Grid>
28-
<Button Content="Configure..." Width="80" Margin="0,0,164,0" Command="{Binding OpenConfigurationCommand}" HorizontalAlignment="Right"></Button>
29-
<Button Content="Clear Logs" Width="80" Margin="0,0,82,0" Command="{Binding ClearLogsCommand}" HorizontalAlignment="Right"></Button>
30-
<Button Content="Clear All" Width="80" Margin="16,0,0,0" Command="{Binding ClearAllCommand}" HorizontalAlignment="Right"></Button>
32+
<Button Content="Configure..." Width="80" Margin="0,0,249,0" Command="{Binding OpenConfigurationCommand}" HorizontalAlignment="Right"></Button>
33+
<Button Content="Clear Logs" Width="80" Margin="0,0,166,0" Command="{Binding ClearLogsCommand}" HorizontalAlignment="Right"></Button>
34+
<Button Content="Clear All" Width="80" Margin="0,0,83,0" Command="{Binding ClearAllCommand}" HorizontalAlignment="Right"></Button>
35+
<ComboBox ItemsSource="{Binding Path=LogLevels}" DisplayMemberPath="Name" SelectedValue="{Binding SelectedInitialLogLevel}" Width="70" Margin="2,0,2,0" HorizontalAlignment="Right"/>
3136
</Grid>
3237

38+
3339
</DockPanel>
3440
</StackPanel>
3541
</Grid>

Loginator/ViewModels/ApplicationViewModel.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace LogApplication.ViewModels {
2222
public class ApplicationViewModel : INotifyPropertyChanged {
2323

2424
public string Name { get; set; }
25-
public IList<LoggingLevel> LogLevels { get; set; }
25+
public IList<LoggingLevel> LogLevels { get; } = LoggingLevel.GetAllLoggingLevels().OrderBy(x => x.Id).ToList();
2626

2727
private int MaxNumberOfLogsPerLevel { get; set; }
2828
private string SearchCriteria { get; set; }
@@ -65,17 +65,14 @@ public bool IsActive {
6565
}
6666
}
6767

68-
public ApplicationViewModel(string name, OrderedObservableCollection logs, ObservableCollection<NamespaceViewModel> namespaces) {
68+
public ApplicationViewModel(string name, OrderedObservableCollection logs, ObservableCollection<NamespaceViewModel> namespaces,
69+
LoggingLevel initialLogLevel)
70+
{
6971
Name = name;
7072
IsActive = true;
71-
LogLevels = new List<LoggingLevel>();
72-
LogLevels.Add(LoggingLevel.TRACE);
73-
LogLevels.Add(LoggingLevel.DEBUG);
74-
LogLevels.Add(LoggingLevel.INFO);
75-
LogLevels.Add(LoggingLevel.WARN);
76-
LogLevels.Add(LoggingLevel.ERROR);
77-
LogLevels.Add(LoggingLevel.FATAL);
78-
SelectedMinLogLevel = LogLevels.ElementAt(0);
73+
74+
//SelectedMinLogLevel = LogLevels.ElementAt(0);
75+
SelectedMinLogLevel = initialLogLevel;
7976
Logs = logs;
8077
LogsTrace = new List<LogViewModel>();
8178
LogsDebug = new List<LogViewModel>();

Loginator/ViewModels/LoginatorViewModel.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public string SearchCriteria {
6464
set {
6565
searchCriteria = value;
6666
OnPropertyChanged(nameof(SearchCriteria));
67+
UpdateSearchCriteria(this);
6768
}
6869
}
6970

@@ -76,6 +77,18 @@ public bool IsInverted {
7677
}
7778
}
7879

80+
public IList<LoggingLevel> LogLevels { get; } = LoggingLevel.GetAllLoggingLevels().OrderBy(x => x.Id).ToList();
81+
82+
private LoggingLevel selectedInitialLogLevel;
83+
84+
public LoggingLevel SelectedInitialLogLevel {
85+
get { return selectedInitialLogLevel; }
86+
set {
87+
selectedInitialLogLevel = value;
88+
OnPropertyChanged(nameof(SelectedInitialLogLevel));
89+
}
90+
}
91+
7992
private LogViewModel selectedLog;
8093
public LogViewModel SelectedLog {
8194
get { return selectedLog; }
@@ -111,6 +124,7 @@ public LoginatorViewModel(IApplicationConfiguration applicationConfiguration, IC
111124
ApplicationConfiguration = applicationConfiguration;
112125
ConfigurationDao = configurationDao;
113126
IsActive = true;
127+
SelectedInitialLogLevel = LoggingLevel.TRACE;
114128
NumberOfLogsPerLevel = Constants.DEFAULT_MAX_NUMBER_OF_LOGS_PER_LEVEL;
115129
Logger = LogManager.GetCurrentClassLogger();
116130
Logs = new OrderedObservableCollection();
@@ -259,7 +273,7 @@ private void UpdateApplications(IEnumerable<LogViewModel> logsToInsert) {
259273
foreach (var log in logsToInsert) {
260274
var application = Applications.FirstOrDefault(m => m.Name == log.Application);
261275
if (application == null) {
262-
application = new ApplicationViewModel(log.Application, Logs, Namespaces);
276+
application = new ApplicationViewModel(log.Application, Logs, Namespaces, SelectedInitialLogLevel);
263277
Applications.Add(application);
264278
}
265279
}

0 commit comments

Comments
 (0)