Improve dashboard definition

pull/1140/head
Halil ibrahim Kalkan 6 years ago
parent 4d79878f7e
commit 80ddad7038

@ -0,0 +1,42 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using Volo.Abp.AspNetCore.Mvc.UI.Widgets;
using Volo.Abp.Localization;
namespace Volo.Abp.AspNetCore.Mvc.UI.Dashboards
{
public class DashboardDefinition
{
/// <summary>
/// Unique name of the dashboard.
/// </summary>
[NotNull]
public string Name { get; }
/// <summary>
/// A list of Widgets available for this dashboard.
/// </summary>
public List<DashboardWidgetConfiguration> AvailableWidgets { get; }
/// <summary>
/// Display name of the widget.
/// </summary>
[NotNull]
public ILocalizableString DisplayName
{
get => _displayName;
set => _displayName = Check.NotNull(value, nameof(value));
}
private ILocalizableString _displayName;
public DashboardDefinition(
[NotNull] string name,
[CanBeNull] ILocalizableString displayName)
{
Name = Check.NotNullOrWhiteSpace(name, nameof(name));
DisplayName = displayName ?? new FixedLocalizableString(name);
AvailableWidgets = new List<DashboardWidgetConfiguration>();
}
}
}

@ -0,0 +1,23 @@
using JetBrains.Annotations;
using Volo.Abp.AspNetCore.Mvc.UI.Widgets;
namespace Volo.Abp.AspNetCore.Mvc.UI.Dashboards
{
public class DashboardWidgetConfiguration
{
[NotNull]
public string WidgetName { get; }
[CanBeNull]
public WidgetDimensions Dimensions { get; set; }
public DashboardWidgetConfiguration(
[NotNull] string widgetName,
[CanBeNull] WidgetDimensions dimensions
)
{
WidgetName = Check.NotNullOrWhiteSpace(widgetName, nameof(widgetName));
Dimensions = dimensions;
}
}
}

@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace Volo.Abp.AspNetCore.Mvc.UI.Dashboards
{
public class DashboardOptions
{
public List<DashboardDefinition> Dashboards { get; }
public DashboardOptions()
{
Dashboards = new List<DashboardDefinition>();
}
}
}

@ -23,13 +23,19 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets
} }
private ILocalizableString _displayName; private ILocalizableString _displayName;
[NotNull]
public Type ViewComponentType { get; set; } public Type ViewComponentType { get; set; }
[CanBeNull]
public WidgetDimensions DefaultDimensions { get; set; }
public WidgetDefinition( public WidgetDefinition(
[NotNull] string name, [NotNull] string name,
[NotNull] Type viewComponentType, [NotNull] Type viewComponentType,
[CanBeNull] ILocalizableString displayName) [CanBeNull] ILocalizableString displayName,
[CanBeNull] WidgetDimensions defaultDimensions = null)
{ {
DefaultDimensions = defaultDimensions;
Name = Check.NotNullOrWhiteSpace(name, nameof(name)); Name = Check.NotNullOrWhiteSpace(name, nameof(name));
ViewComponentType = Check.NotNull(viewComponentType, nameof(viewComponentType)); ViewComponentType = Check.NotNull(viewComponentType, nameof(viewComponentType));
DisplayName = displayName ?? new FixedLocalizableString(name); DisplayName = displayName ?? new FixedLocalizableString(name);

@ -0,0 +1,15 @@
namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets
{
public class WidgetDimensions
{
public int Width { get; }
public int Height { get; }
public WidgetDimensions(int width, int height)
{
Width = width;
Height = height;
}
}
}
Loading…
Cancel
Save