|
@@ -12,11 +12,18 @@ namespace CronAlarm.Pages
|
|
|
[Inject]
|
|
[Inject]
|
|
|
private Alerts Config { get; set; }
|
|
private Alerts Config { get; set; }
|
|
|
|
|
|
|
|
|
|
+ [Inject]
|
|
|
|
|
+ private ICrontFragmentHandler CronFragmentHandler { get; set; }
|
|
|
|
|
+
|
|
|
private IDictionary<string, int> SelectedOptions { get; set; } = new Dictionary<string, int>();
|
|
private IDictionary<string, int> SelectedOptions { get; set; } = new Dictionary<string, int>();
|
|
|
|
|
|
|
|
public AlertSelection()
|
|
public AlertSelection()
|
|
|
{
|
|
{
|
|
|
- SelectedOptions["Weekdays"] = 1;
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ protected override void OnInitialized()
|
|
|
|
|
+ {
|
|
|
|
|
+ Reset();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void ToggleOption(string group, int index)
|
|
private void ToggleOption(string group, int index)
|
|
@@ -42,7 +49,12 @@ namespace CronAlarm.Pages
|
|
|
|
|
|
|
|
private void Reset()
|
|
private void Reset()
|
|
|
{
|
|
{
|
|
|
|
|
+ var current = CronFragmentHandler.GetExpressions().ToHashSet();
|
|
|
|
|
|
|
|
|
|
+ foreach (var group in Config.Groups)
|
|
|
|
|
+ {
|
|
|
|
|
+ SelectedOptions[group.Name] = group.IndexedOptions.Select(item => item.ToTuple()).FirstOrDefault(item => current.Contains(item.Item2.Pattern))?.Item1 ?? -1;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|