diff --git a/src/Soloplan.WhatsON.CruiseControl/CruiseControlProject.cs b/src/Soloplan.WhatsON.CruiseControl/CruiseControlProject.cs index 7310cd7..bb623ab 100644 --- a/src/Soloplan.WhatsON.CruiseControl/CruiseControlProject.cs +++ b/src/Soloplan.WhatsON.CruiseControl/CruiseControlProject.cs @@ -18,6 +18,7 @@ namespace Soloplan.WhatsON.CruiseControl [SubjectType("Cruise Control Project Status", Description = "Retrieve the current status of a Cruise Control project.")] [ConfigurationItem(ProjectName, typeof(string), Optional = false, Priority = 300)] + [NotificationConfigurationItem(NotificationsVisbility, typeof(ConnectorNotificationConfiguration), SupportsUnstableNotify = false, Priority = 1600000000)] public class CruiseControlProject : ServerSubject { public const string ProjectName = "ProjectName"; diff --git a/src/Soloplan.WhatsON.GUI/Config/ConfigControlBuilderFactory.cs b/src/Soloplan.WhatsON.GUI/Config/ConfigControlBuilderFactory.cs index f35933c..f7bc6b9 100644 --- a/src/Soloplan.WhatsON.GUI/Config/ConfigControlBuilderFactory.cs +++ b/src/Soloplan.WhatsON.GUI/Config/ConfigControlBuilderFactory.cs @@ -79,6 +79,7 @@ private void RegisterBuiltInTypeSpecificControlBuilders() this.RegisterControlBuilder(typeof(int), new NumericConfigControlBuilder()); this.RegisterControlBuilder(typeof(string), new CategoryComboBoxConfigControlBuilder()); this.RegisterControlBuilder(typeof(bool), new CheckBoxConfigControlBuilder()); + this.RegisterControlBuilder(typeof(ConnectorNotificationConfiguration), new NotificationSettingsControlBuilder()); } /// diff --git a/src/Soloplan.WhatsON.GUI/Config/MainConfigPage.xaml b/src/Soloplan.WhatsON.GUI/Config/MainConfigPage.xaml index 9b6a0f1..4954a79 100644 --- a/src/Soloplan.WhatsON.GUI/Config/MainConfigPage.xaml +++ b/src/Soloplan.WhatsON.GUI/Config/MainConfigPage.xaml @@ -63,5 +63,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Soloplan.WhatsON.GUI/Config/NotificationSettingsControlBuilder.cs b/src/Soloplan.WhatsON.GUI/Config/NotificationSettingsControlBuilder.cs new file mode 100644 index 0000000..56310f2 --- /dev/null +++ b/src/Soloplan.WhatsON.GUI/Config/NotificationSettingsControlBuilder.cs @@ -0,0 +1,322 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) Soloplan GmbH. All rights reserved. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace Soloplan.WhatsON.GUI.Config +{ + using System; + using System.Collections.Generic; + using System.ComponentModel; + using System.Linq; + using System.Runtime.CompilerServices; + using System.Windows; + using System.Windows.Controls; + using System.Windows.Controls.Primitives; + using System.Windows.Data; + using MaterialDesignThemes.Wpf; + using Newtonsoft.Json; + + /// + /// The control builder for the notification settings. + /// + /// + public class NotificationSettingsControlBuilder : ConfigControlBuilder + { + /// + /// Gets the supported configuration items key. + /// + public override string SupportedConfigurationItemsKey => null; + + /// + /// Creates a new control and returns it. + /// + /// The configuration item. + /// The configuration item attribute. + /// + /// Returns the for the . + /// + public override FrameworkElement GetControlInternal(IConfigurationItem configItem, ConfigurationItemAttribute configItemAttribute) + { + var card = new Card(); + card.Margin = new Thickness(4, 0, 4, 0); + card.SetResourceReference(Control.BackgroundProperty, "MaterialDesignBackground"); + var expander = new Expander(); + card.Content = expander; + expander.HorizontalAlignment = HorizontalAlignment.Stretch; + var itemsStackPanel = new StackPanel(); + expander.Content = itemsStackPanel; + + IList notificationStates = new List(); + this.ApplyConfigurationItemToNotificationStateList(notificationStates, configItem, configItemAttribute, expander); + var configItemPropertyChanged = (INotifyPropertyChanged)configItem; + configItemPropertyChanged.PropertyChanged += (s, e) => this.ApplyConfigurationItemToNotificationStateList(notificationStates, configItem, configItemAttribute, expander); + + foreach (var notificationState in notificationStates) + { + var itemStackPanel = new StackPanel(); + itemStackPanel.Orientation = Orientation.Horizontal; + itemStackPanel.Margin = new Thickness(2, 6, 2, 0); + var toggleButton = new ToggleButton(); + var toogleButtonBinding = new Binding(nameof(NotificationState.IsActive)); + toogleButtonBinding.Source = notificationState; + toogleButtonBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; + toggleButton.SetBinding(ToggleButton.IsCheckedProperty, toogleButtonBinding); + itemStackPanel.Children.Add(toggleButton); + var label = new Label(); + label.Content = notificationState.Caption; + + if (!notificationState.IsUseGlobalSettings) + { + var toogleButtonEnabledBinding = new Binding(nameof(NotificationState.IsNotUseGlobalSettingsForParentListActive)); + toogleButtonEnabledBinding.Source = notificationState; + toogleButtonEnabledBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; + toggleButton.SetBinding(UIElement.IsEnabledProperty, toogleButtonEnabledBinding); + } + + itemStackPanel.Children.Add(label); + itemsStackPanel.Children.Add(itemStackPanel); + } + + this.UpdateExpanderHeader(expander, notificationStates); + return card; + } + + /// + /// Removes the unsupported s by plugin. + /// + /// The observation states collection. + /// to check it's support on plugin. + /// Call to support state check. + private void RemoveNotSupportedObservationState(ICollection observationStates, ObservationState observationState, Func supportsState) + { + var observationStateListItem = observationStates.FirstOrDefault(s => s == observationState); + if (observationStateListItem != default(ObservationState) && !supportsState()) + { + observationStates.Remove(observationStateListItem); + } + } + + private void RemoveNotSupportedObservationStates(IList observationStates, NotificationConfigurationItemAttribute attribute) + { + this.RemoveNotSupportedObservationState(observationStates, ObservationState.Failure, () => attribute.SupportsFailureNotify); + this.RemoveNotSupportedObservationState(observationStates, ObservationState.Success, () => attribute.SupportsSuccessNotify); + this.RemoveNotSupportedObservationState(observationStates, ObservationState.Running, () => attribute.SupportsRunningNotify); + this.RemoveNotSupportedObservationState(observationStates, ObservationState.Unstable, () => attribute.SupportsUnstableNotify); + } + + /// + /// Gets the based on using deserialization. + /// + /// The configuration item. + /// The deserialized instance of or a new instance if it does not exists. + private ConnectorNotificationConfiguration GetConnectorNotificationConfiguration(IConfigurationItem configItem) + { + if (string.IsNullOrWhiteSpace(configItem.Value)) + { + return new ConnectorNotificationConfiguration(); + } + + try + { + var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }; + return JsonConvert.DeserializeObject(configItem.Value, settings); + } + catch + { + return new ConnectorNotificationConfiguration(); + } + } + + /// + /// Applies the to list of s. + /// + /// The notification states. + /// The configuration item. + /// The configuration item attribute. + /// The expander control. + private void ApplyConfigurationItemToNotificationStateList(IList notificationStates, IConfigurationItem configItem, ConfigurationItemAttribute configItemAttribute, Expander expander) + { + var configItemValue = this.GetConnectorNotificationConfiguration(configItem); + var observationStates = Enum.GetValues(typeof(ObservationState)).Cast().ToList(); + observationStates.Remove(observationStates.First(i => i == ObservationState.Unknown)); + if (configItemAttribute is NotificationConfigurationItemAttribute notificationConfigurationItemAttribute) + { + this.RemoveNotSupportedObservationStates(observationStates, notificationConfigurationItemAttribute); + } + + var useGlobalNotificationState = notificationStates.FirstOrDefault(n => n.IsUseGlobalSettings); + if (useGlobalNotificationState == null) + { + useGlobalNotificationState = new NotificationState(notificationStates); + useGlobalNotificationState.IsActive = configItemValue.UseGlobalNotificationSettings; + useGlobalNotificationState.Caption = "Use global configuration"; // TODO load from resources + useGlobalNotificationState.PropertyChanged += (s, e) => this.NotificationStateChanged(useGlobalNotificationState, configItem, e.PropertyName); + useGlobalNotificationState.IsUseGlobalSettings = true; + notificationStates.Add(useGlobalNotificationState); + } + else + { + useGlobalNotificationState.IsActive = configItemValue.UseGlobalNotificationSettings; + } + + foreach (var observationState in observationStates) + { + var notificationState = notificationStates.FirstOrDefault(n => n.ObservationState == observationState); + if (notificationState == null) + { + notificationState = new NotificationState(notificationStates); + notificationState.IsActive = configItemValue.AsObservationStateFlag(observationState); + notificationState.ObservationState = observationState; + notificationState.Caption = observationState.ToString(); // TODO load from resources + notificationState.PropertyChanged += (s, e) => this.NotificationStateChanged(notificationState, configItem, e.PropertyName); + notificationState.PropertyChanged += (s, e) => this.UpdateExpanderHeader(expander, notificationStates); + notificationStates.Add(notificationState); + } + else + { + notificationState.IsActive = configItemValue.AsObservationStateFlag(observationState); + } + } + } + + /// + /// Updates the expander header. + /// + /// The expander. + /// The notification states. + private void UpdateExpanderHeader(Expander expander, IList notificationStates) + { + expander.Header = $"Notification settings ({this.GetNotificationsStateTextRepresentation(notificationStates)})"; // TODO resources + } + + /// + /// Gets the notifications state text representation. + /// + /// The notification states. + /// The text representation for list of . + private string GetNotificationsStateTextRepresentation(IList notificationStates) + { + if (notificationStates.First(n => n.IsUseGlobalSettings).IsActive) + { + return "use global settings"; // TODO resource + } + + var result = string.Join(", ", notificationStates.Where(n => n.IsActive && !n.IsUseGlobalSettings).Select(n => n.Caption)); + if (string.IsNullOrWhiteSpace(result)) + { + return "none"; // TODO resource + } + + return result; + } + + /// + /// Handled the changed. + /// Updates the . + /// + /// State of the notification. + /// The configuration item. + /// Name of the property. + private void NotificationStateChanged(NotificationState notificationState, IConfigurationItem configItem, string propertyName) + { + if (propertyName == nameof(NotificationState.IsNotUseGlobalSettingsForParentListActive)) + { + return; + } + + var connectorNotificationConfiguration = new ConnectorNotificationConfiguration(); + connectorNotificationConfiguration.UseGlobalNotificationSettings = notificationState.ParentList.First(i => i.IsUseGlobalSettings).IsActive; + foreach (var item in notificationState.ParentList) + { + if (item.IsUseGlobalSettings) + { + continue; + } + + connectorNotificationConfiguration.AssignFromObeservationStateActivity(item.ObservationState, item.IsActive); + } + + var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto, NullValueHandling = NullValueHandling.Ignore, Formatting = Formatting.None }; + configItem.Value = JsonConvert.SerializeObject(connectorNotificationConfiguration, settings); + } + + /// + /// The helper class for binding and keeping information about the active state of the notification setting. + /// + /// + private class NotificationState : INotifyPropertyChanged + { + /// + /// The is active flag. + /// + private bool isActive; + + /// + /// Initializes a new instance of the class. + /// + /// The parent list. + public NotificationState(IList parentList) + { + this.ParentList = parentList; + } + + /// + /// Occurs when property changed. + /// + public event PropertyChangedEventHandler PropertyChanged; + + /// + /// Gets the parent list. + /// + public IList ParentList { get; } + + /// + /// Gets or sets the - the reference to the enum value. + /// + public ObservationState ObservationState { get; set; } + + /// + /// Gets a value indicating whether global settings for notifications are used.. + /// + public bool IsNotUseGlobalSettingsForParentListActive => !this.ParentList.First(i => i.IsUseGlobalSettings).isActive; + + /// + /// Gets or sets a value indicating whether this notification setting is active. + /// + public bool IsActive + { + get => this.isActive; + set + { + this.isActive = value; + this.OnPropertyChanged(); + foreach (var listItem in this.ParentList) + { + listItem.OnPropertyChanged(nameof(this.IsNotUseGlobalSettingsForParentListActive)); + } + } + } + + /// + /// Gets or sets a value indicating whether this state is flag for use of notification settings from global configurations. + /// s + public bool IsUseGlobalSettings { get; set; } + + /// + /// Gets or sets the caption. + /// + public string Caption { get; set; } + + /// + /// Called when property changed. + /// + /// Name of the property. + protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) + { + this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } + } + } +} \ No newline at end of file diff --git a/src/Soloplan.WhatsON.GUI/Config/TextConfigControlBuilder.cs b/src/Soloplan.WhatsON.GUI/Config/TextConfigControlBuilder.cs index 320d20c..c4bb2f4 100644 --- a/src/Soloplan.WhatsON.GUI/Config/TextConfigControlBuilder.cs +++ b/src/Soloplan.WhatsON.GUI/Config/TextConfigControlBuilder.cs @@ -9,7 +9,6 @@ namespace Soloplan.WhatsON.GUI.Config using System.Windows; using System.Windows.Controls; using MaterialDesignThemes.Wpf; - using Soloplan.WhatsON.GUI.Config.ViewModel; /// /// The control builder for a text edit control. diff --git a/src/Soloplan.WhatsON.GUI/Config/View/SubjectConfigPage.xaml b/src/Soloplan.WhatsON.GUI/Config/View/SubjectConfigPage.xaml index 488cd60..a439d98 100644 --- a/src/Soloplan.WhatsON.GUI/Config/View/SubjectConfigPage.xaml +++ b/src/Soloplan.WhatsON.GUI/Config/View/SubjectConfigPage.xaml @@ -17,7 +17,9 @@ - + + + diff --git a/src/Soloplan.WhatsON.GUI/Config/View/SubjectsConfigPage.xaml b/src/Soloplan.WhatsON.GUI/Config/View/SubjectsConfigPage.xaml index fad4272..8685418 100644 --- a/src/Soloplan.WhatsON.GUI/Config/View/SubjectsConfigPage.xaml +++ b/src/Soloplan.WhatsON.GUI/Config/View/SubjectsConfigPage.xaml @@ -27,7 +27,7 @@ Style="{StaticResource MaterialDesignMultiFloatingActionPopupBox}" PlacementMode="TopAndAlignCentres" ToolTip="Add new subject" - Panel.ZIndex="2" Margin="0,0,10,10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="56"> + Panel.ZIndex="2" Margin="0,0,25,10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="56"> private ViewStyle viewStyle; + /// + /// The unstable observation state. + /// + private bool unstableObservationState; + + /// + /// The failure observation state. + /// + private bool failureObservationState; + + /// + /// The success observation state. + /// + private bool successObservationState; + + /// + /// The running observation state. + /// + private bool runningObservationState; + /// /// Occurs when configuration was applied. /// @@ -97,6 +117,58 @@ public bool ShowInTaskbar } } + /// + /// Gets or sets a value indicating whether unstable observation state is active. + /// + public bool UnstableObservationState + { + get => this.unstableObservationState; + set + { + this.unstableObservationState = value; + this.OnPropertyChanged(); + } + } + + /// + /// Gets or sets a value indicating whether failure observation state is active. + /// + public bool FailureObservationState + { + get => this.failureObservationState; + set + { + this.failureObservationState = value; + this.OnPropertyChanged(); + } + } + + /// + /// Gets or sets a value indicating whether success observation state is active. + /// + public bool SuccessObservationState + { + get => this.successObservationState; + set + { + this.successObservationState = value; + this.OnPropertyChanged(); + } + } + + /// + /// Gets or sets a value indicating whether running observation state is active. + /// + public bool RunningObservationState + { + get => this.runningObservationState; + set + { + this.runningObservationState = value; + this.OnPropertyChanged(); + } + } + /// /// Gets or sets a value indicating whether window should be always on top of other windows. /// @@ -232,6 +304,10 @@ public void Load(ApplicationConfiguration configurationSource) this.DarkThemeEnabled = configurationSource.DarkThemeEnabled; this.ShowInTaskbar = configurationSource.ShowInTaskbar; + this.UnstableObservationState = configurationSource.NotificationConfiguration.UnstableNotificationEnabled; + this.RunningObservationState = configurationSource.NotificationConfiguration.RunningNotificationEnabled; + this.FailureObservationState = configurationSource.NotificationConfiguration.FailureNotificationEnabled; + this.SuccessObservationState = configurationSource.NotificationConfiguration.SuccessNotificationEnabled; this.AlwaysOnTop = configurationSource.AlwaysOnTop; this.OpenMinimized = configurationSource.OpenMinimized; this.ViewStyle = (int)configurationSource.ViewStyle; @@ -360,6 +436,10 @@ private void ApplyMainSettingsToConfiguration(ApplicationConfiguration configura configuration.AlwaysOnTop = this.AlwaysOnTop; configuration.OpenMinimized = this.OpenMinimized; configuration.ViewStyle = (ViewStyle)this.ViewStyle; + configuration.NotificationConfiguration.FailureNotificationEnabled = this.FailureObservationState; + configuration.NotificationConfiguration.RunningNotificationEnabled = this.RunningObservationState; + configuration.NotificationConfiguration.SuccessNotificationEnabled = this.SuccessObservationState; + configuration.NotificationConfiguration.UnstableNotificationEnabled = this.UnstableObservationState; } /// diff --git a/src/Soloplan.WhatsON.GUI/Soloplan.WhatsON.GUI.csproj b/src/Soloplan.WhatsON.GUI/Soloplan.WhatsON.GUI.csproj index 8560774..9334ab1 100644 --- a/src/Soloplan.WhatsON.GUI/Soloplan.WhatsON.GUI.csproj +++ b/src/Soloplan.WhatsON.GUI/Soloplan.WhatsON.GUI.csproj @@ -88,6 +88,7 @@ + ProjectSelectionWizardPage.xaml @@ -273,9 +274,6 @@ 2.0.20525 - - - False diff --git a/src/Soloplan.WhatsON.Jenkins/JenkinsAPI.cs b/src/Soloplan.WhatsON.Jenkins/JenkinsAPI.cs index 17ca56c..e2e7eb1 100644 --- a/src/Soloplan.WhatsON.Jenkins/JenkinsAPI.cs +++ b/src/Soloplan.WhatsON.Jenkins/JenkinsAPI.cs @@ -8,10 +8,8 @@ namespace Soloplan.WhatsON.Jenkins { using System; - using System.Collections.Generic; using System.IO; using System.Net; - using System.Net.Http; using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json; diff --git a/src/Soloplan.WhatsON.Jenkins/JenkinsProject.cs b/src/Soloplan.WhatsON.Jenkins/JenkinsProject.cs index cb6b543..3819c8f 100644 --- a/src/Soloplan.WhatsON.Jenkins/JenkinsProject.cs +++ b/src/Soloplan.WhatsON.Jenkins/JenkinsProject.cs @@ -17,6 +17,7 @@ namespace Soloplan.WhatsON.Jenkins [SubjectType("Jenkins Project Status", Description = "Retrieve the current status of a Jenkins project.")] [ConfigurationItem(ProjectName, typeof(string), Optional = false, Priority = 300)] [ConfigurationItem(RedirectPlugin, typeof(bool), Priority = 400)] // defines use of Display URL API Plugin https://wiki.jenkins.io/display/JENKINS/Display+URL+API+Plugin + [NotificationConfigurationItem(NotificationsVisbility, typeof(ConnectorNotificationConfiguration), Priority = 1600000000)] public class JenkinsProject : ServerSubject { public const string ProjectName = "ProjectName"; diff --git a/src/Soloplan.WhatsON.ServerHealth/ServerHealth.cs b/src/Soloplan.WhatsON.ServerHealth/ServerHealth.cs index 3809d50..e757e72 100644 --- a/src/Soloplan.WhatsON.ServerHealth/ServerHealth.cs +++ b/src/Soloplan.WhatsON.ServerHealth/ServerHealth.cs @@ -8,6 +8,7 @@ using Soloplan.WhatsON.ServerBase; [SubjectType("Server Health Check", Description = "Ping a server and return the state depending on the reply.")] + [NotificationConfigurationItem(NotificationsVisbility, typeof(ConnectorNotificationConfiguration), SupportsRunningNotify = false, SupportsUnstableNotify = false, Priority = 1600000000)] public class ServerHealth : ServerSubject { /// diff --git a/src/Soloplan.WhatsON/ConnectorNotificationConfiguration.cs b/src/Soloplan.WhatsON/ConnectorNotificationConfiguration.cs new file mode 100644 index 0000000..800782f --- /dev/null +++ b/src/Soloplan.WhatsON/ConnectorNotificationConfiguration.cs @@ -0,0 +1,20 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) Soloplan GmbH. All rights reserved. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace Soloplan.WhatsON +{ + /// + /// The notification configuration used for connectors. + /// + /// + public class ConnectorNotificationConfiguration : NotificationConfiguration + { + /// + /// Gets or sets a value indicating whether global settings should be used. + /// + public bool UseGlobalNotificationSettings { get; set; } = true; + } +} \ No newline at end of file diff --git a/src/Soloplan.WhatsON/NotificationConfiguration.cs b/src/Soloplan.WhatsON/NotificationConfiguration.cs new file mode 100644 index 0000000..f94170f --- /dev/null +++ b/src/Soloplan.WhatsON/NotificationConfiguration.cs @@ -0,0 +1,88 @@ +// // -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) Soloplan GmbH. All rights reserved. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace Soloplan.WhatsON +{ + using System; + + /// + /// The notification configuration used for global options and as base type for . + /// + public class NotificationConfiguration + { + /// + /// Gets or sets a value indicating whether unstable notifications are enabled. + /// + public bool UnstableNotificationEnabled { get; set; } = true; + + /// + /// Gets or sets a value indicating whether running notifications are enabled. + /// + public bool RunningNotificationEnabled { get; set; } = true; + + /// + /// Gets or sets a value indicating whether failure notifications are enabled. + /// + public bool FailureNotificationEnabled { get; set; } = true; + + /// + /// Gets or sets a value indicating whether success notifications are enabled. + /// + public bool SuccessNotificationEnabled { get; set; } = true; + + /// + /// RTeturns flag of enabled state in the configuration. + /// + /// State of the observation. + /// True if given is activated in the configuration, otherwise false. + public bool AsObservationStateFlag(ObservationState observationState) + { + switch (observationState) + { + case ObservationState.Unknown: + return false; + case ObservationState.Unstable: + return this.UnstableNotificationEnabled; + case ObservationState.Failure: + return this.FailureNotificationEnabled; + case ObservationState.Success: + return this.SuccessNotificationEnabled; + case ObservationState.Running: + return this.RunningNotificationEnabled; + default: + throw new ArgumentOutOfRangeException(nameof(observationState), observationState, null); + } + } + + /// + /// Assigns from configuration setting based on . + /// + /// The . + /// if set to true setting related to given will be enabled; otherwise disabled. + public void AssignFromObeservationStateActivity(ObservationState observationState, bool isEnabled) + { + switch (observationState) + { + case ObservationState.Failure: + this.FailureNotificationEnabled = isEnabled; + break; + case ObservationState.Running: + this.RunningNotificationEnabled = isEnabled; + break; + case ObservationState.Success: + this.SuccessNotificationEnabled = isEnabled; + break; + case ObservationState.Unstable: + this.UnstableNotificationEnabled = isEnabled; + break; + case ObservationState.Unknown: + break; + default: + throw new ArgumentOutOfRangeException(nameof(observationState), observationState, null); + } + } + } +} \ No newline at end of file diff --git a/src/Soloplan.WhatsON/NotificationConfigurationItemAttribute.cs b/src/Soloplan.WhatsON/NotificationConfigurationItemAttribute.cs new file mode 100644 index 0000000..1add195 --- /dev/null +++ b/src/Soloplan.WhatsON/NotificationConfigurationItemAttribute.cs @@ -0,0 +1,47 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) Soloplan GmbH. All rights reserved. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace Soloplan.WhatsON +{ + using System; + + /// + /// Used for marking notification configuration items for connectors. + /// + [AttributeUsage(AttributeTargets.Class)] + public class NotificationConfigurationItemAttribute : ConfigurationItemAttribute + { + /// + /// Initializes a new instance of the class. + /// + /// The key. + /// The type. + public NotificationConfigurationItemAttribute(string key, Type type) + : base(key, type) + { + } + + /// + /// Gets or sets a value indicating whether connector supports failure notifications. + /// + public bool SupportsFailureNotify { get; set; } = true; + + /// + /// Gets or sets a value indicating whether connector supports unstable notifications. + /// + public bool SupportsUnstableNotify { get; set; } = true; + + /// + /// Gets or sets a value indicating whether connector supports success notifications. + /// + public bool SupportsSuccessNotify { get; set; } = true; + + /// + /// Gets or sets a value indicating whether connector supports running notifications. + /// + public bool SupportsRunningNotify { get; set; } = true; + } +} \ No newline at end of file diff --git a/src/Soloplan.WhatsON/Serialization/ApplicationConfiguration.cs b/src/Soloplan.WhatsON/Serialization/ApplicationConfiguration.cs index aea3d6e..23baacc 100644 --- a/src/Soloplan.WhatsON/Serialization/ApplicationConfiguration.cs +++ b/src/Soloplan.WhatsON/Serialization/ApplicationConfiguration.cs @@ -50,5 +50,10 @@ public ApplicationConfiguration() /// Gets the subjects configuration. /// public IList SubjectsConfiguration { get; } = new List(); + + /// + /// Gets the notification configuration. + /// + public NotificationConfiguration NotificationConfiguration { get; } = new NotificationConfiguration(); } } \ No newline at end of file diff --git a/src/Soloplan.WhatsON/Subject.cs b/src/Soloplan.WhatsON/Subject.cs index bb4ccb9..28e1dba 100644 --- a/src/Soloplan.WhatsON/Subject.cs +++ b/src/Soloplan.WhatsON/Subject.cs @@ -16,9 +16,14 @@ namespace Soloplan.WhatsON /// /// The subject - represent an executable job defined by the plugin. /// - [ConfigurationItem(Category, typeof(string), Priority = 2147483500)] + [ConfigurationItem(Category, typeof(string), Priority = 1000000000)] public abstract class Subject { + /// + /// The redirect plugin tag. + /// + public const string NotificationsVisbility = "NotificationsVisbility"; + /// /// The category tag. /// @@ -51,6 +56,9 @@ protected Subject(SubjectConfiguration configuration) this.SubjectConfiguration = configuration; } + /// + /// Gets or sets the description of the connector. + /// public string Description { get; set; } public Status CurrentStatus { get; set; }