Class WidgetArea
Represents the WidgetArea class which extends the DashboardWidget class.
Inherited Members
Namespace: DataWeb.Dashboard.Widgets
Assembly: DataWeb.Core.dll
Syntax
public class WidgetArea : DashboardWidget
Constructors
WidgetArea(IServiceProvider)
Represents the WidgetArea class which extends the DashboardWidget class.
Declaration
public WidgetArea(IServiceProvider serviceProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| IServiceProvider | serviceProvider |
Methods
GetDataAsync(DashboardPanel, Dictionary<string, object>, IUser, CancellationToken)
Gets the data for the widget.
Declaration
public override Task<DashboardWidgetContentData> GetDataAsync(DashboardPanel panel, Dictionary<string, object> widgetSettings, IUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DashboardPanel | panel | The DashboardPanel that the widget belongs to. |
| Dictionary<string, object> | widgetSettings | The widget settings containing the area name key. |
| IUser | user | The IUser who is viewing the widget. |
| CancellationToken | cancellationToken | The CancellationToken to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<DashboardWidgetContentData> | The widget data with area info and sections, or empty data if area name is not configured. |
Overrides
Remarks
Returns empty WidgetArea.Data if AreaName setting is missing or null. Safely handles null sections collection to prevent NullReferenceException.
GetDefaultSettingsAsync(DashboardPanel, IUser, CancellationToken)
Gets the default settings for the widget.
Declaration
public override Task<Dictionary<string, object>> GetDefaultSettingsAsync(DashboardPanel panel, IUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DashboardPanel | panel | The DashboardPanel that the widget belongs to. |
| IUser | user | The IUser who is viewing the widget. |
| CancellationToken | cancellationToken | The CancellationToken to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<Dictionary<string, object>> | A dictionary of default settings with the first available area name, or empty if all areas are already used. |
Overrides
Remarks
Uses HashSet<T> for O(1) lookup performance when collecting existing area names. Returns empty dictionary if no areas are available or no areas are found for the user.
GetOptionsAsync(DashboardPanel, Dictionary<string, object>, IUser, CancellationToken)
Gets the options for the widget.
Declaration
public override Task<DashboardWidgetOptions> GetOptionsAsync(DashboardPanel panel, Dictionary<string, object> widgetSettings, IUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DashboardPanel | panel | The DashboardPanel that the widget belongs to. |
| Dictionary<string, object> | widgetSettings | The widget settings. |
| IUser | user | The IUser who is viewing the widget. |
| CancellationToken | cancellationToken | The CancellationToken to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<DashboardWidgetOptions> | The widget options containing available areas for selection. |
Overrides
UpdateSettingsAsync(DashboardPanel, Dictionary<string, object>, Dictionary<string, object>, IUser, CancellationToken)
Updates the widget settings.
Declaration
public override Task UpdateSettingsAsync(DashboardPanel panel, Dictionary<string, object> providedSettings, Dictionary<string, object> widgetSettings, IUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DashboardPanel | panel | The DashboardPanel that the widget belongs to. |
| Dictionary<string, object> | providedSettings | The provided settings to apply. |
| Dictionary<string, object> | widgetSettings | The widget settings to update. |
| IUser | user | The IUser who is viewing the widget. |
| CancellationToken | cancellationToken | The CancellationToken to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task | A task that represents the asynchronous operation. |
Overrides
Remarks
Uses defensive programming: only updates if AreaName is present and non-null. Safely handles missing keys without throwing exceptions.
ValidateSettingsAsync(DashboardPanel, Dictionary<string, object>, Dictionary<string, object>, IUser, CancellationToken)
Validates the widget settings.
Declaration
public override Task<List<ValidationError>> ValidateSettingsAsync(DashboardPanel panel, Dictionary<string, object> providedSettings, Dictionary<string, object> widgetSettings, IUser user, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| DashboardPanel | panel | The DashboardPanel that the widget belongs to. |
| Dictionary<string, object> | providedSettings | The provided settings to validate. |
| Dictionary<string, object> | widgetSettings | The current widget settings. |
| IUser | user | The IUser who is viewing the widget. |
| CancellationToken | cancellationToken | The CancellationToken to cancel the operation. |
Returns
| Type | Description |
|---|---|
| Task<List<ValidationError>> | The list of validation errors; empty if valid. |
Overrides
Remarks
Validates that AreaName is present, non-null, and non-whitespace. Uses null-safe operators to prevent exceptions during validation.