From 80ddad70389fa83399ba30d95544cf6596fb0282 Mon Sep 17 00:00:00 2001 From: Halil ibrahim Kalkan Date: Mon, 20 May 2019 13:00:29 +0300 Subject: [PATCH] Improve dashboard definition --- .../Mvc/UI/Dashboards/DashboardDefinition.cs | 42 +++++++++++++++++++ .../DashboardWidgetConfiguration.cs | 23 ++++++++++ .../Mvc/UI/Dashboards/WidgetOptions.cs | 14 +++++++ .../Mvc/UI/Widgets/WidgetDefinition.cs | 8 +++- .../Mvc/UI/Widgets/WidgetDimensions.cs | 15 +++++++ 5 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/DashboardDefinition.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/DashboardWidgetConfiguration.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/WidgetOptions.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetDimensions.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/DashboardDefinition.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/DashboardDefinition.cs new file mode 100644 index 0000000000..7006fc6e24 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/DashboardDefinition.cs @@ -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 + { + /// + /// Unique name of the dashboard. + /// + [NotNull] + public string Name { get; } + + /// + /// A list of Widgets available for this dashboard. + /// + public List AvailableWidgets { get; } + + /// + /// Display name of the widget. + /// + [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(); + } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/DashboardWidgetConfiguration.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/DashboardWidgetConfiguration.cs new file mode 100644 index 0000000000..ab6f8d2884 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/DashboardWidgetConfiguration.cs @@ -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; + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/WidgetOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/WidgetOptions.cs new file mode 100644 index 0000000000..fc3ca09b74 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Dashboards/Volo/Abp/AspNetCore/Mvc/UI/Dashboards/WidgetOptions.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Dashboards +{ + public class DashboardOptions + { + public List Dashboards { get; } + + public DashboardOptions() + { + Dashboards = new List(); + } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetDefinition.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetDefinition.cs index d164e3a50c..0b74fa9e07 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetDefinition.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetDefinition.cs @@ -23,13 +23,19 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets } private ILocalizableString _displayName; + [NotNull] public Type ViewComponentType { get; set; } + [CanBeNull] + public WidgetDimensions DefaultDimensions { get; set; } + public WidgetDefinition( [NotNull] string name, [NotNull] Type viewComponentType, - [CanBeNull] ILocalizableString displayName) + [CanBeNull] ILocalizableString displayName, + [CanBeNull] WidgetDimensions defaultDimensions = null) { + DefaultDimensions = defaultDimensions; Name = Check.NotNullOrWhiteSpace(name, nameof(name)); ViewComponentType = Check.NotNull(viewComponentType, nameof(viewComponentType)); DisplayName = displayName ?? new FixedLocalizableString(name); diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetDimensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetDimensions.cs new file mode 100644 index 0000000000..eb24d208b4 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetDimensions.cs @@ -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; + } + } +} \ No newline at end of file