Skip to content

Commit

Permalink
Squashed commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuergi committed Jan 23, 2025
1 parent 3c3468e commit eb4954c
Show file tree
Hide file tree
Showing 109 changed files with 1,381 additions and 834 deletions.
12 changes: 6 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
<DefineConstants Condition=" '$(CIRun)' == 'true' ">$(DefineConstants);CIRun</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Roslynator.Analyzers" />
<PackageReference Include="Roslynator.Formatting.Analyzers" />
<PackageReference Include="Roslynator.CodeFixes" />
<PackageReference Include="Roslynator.CodeAnalysis.Analyzers" />
<PackageReference Include="Roslynator.Refactorings" />
</ItemGroup>
<PackageReference Include="Roslynator.Analyzers" PrivateAssets="all" />
<PackageReference Include="Roslynator.Formatting.Analyzers" PrivateAssets="all" />
<PackageReference Include="Roslynator.CodeFixes" PrivateAssets="all" />
<PackageReference Include="Roslynator.CodeAnalysis.Analyzers" PrivateAssets="all" />
<PackageReference Include="Roslynator.Refactorings" PrivateAssets="all" />
</ItemGroup>

<Target Name="CopyOutputToNuget" AfterTargets="Build" Condition="$(HasMeshNodes) == 'true'">
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static LayoutDefinition AddAnnualReportSummary(this LayoutDefinition layo
.WithNavMenu((menu, _, _) =>
menu.WithNavLink(
nameof(AnnualReportSummary),
new LayoutAreaReference(nameof(AnnualReportSummary)).ToAppHref(layout.Hub.Address), FluentIcons.Document)
new LayoutAreaReference(nameof(AnnualReportSummary)).ToHref(layout.Hub.Address), FluentIcons.Document)
)

;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static LayoutDefinition AddClientsOverview(this LayoutDefinition layout)
.WithNavMenu((menu, _, _) =>
menu.WithNavLink(
nameof(TopClients),
new LayoutAreaReference(nameof(TopClients)).ToAppHref(layout.Hub.Address), FluentIcons.Document)
new LayoutAreaReference(nameof(TopClients)).ToHref(layout.Hub.Address), FluentIcons.Document)
)
;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reactive.Linq;
using MeshWeaver.Application.Styles;
using MeshWeaver.Application.Styles;
using MeshWeaver.Data;
using MeshWeaver.Layout;
using MeshWeaver.Layout.Composition;
Expand All @@ -25,7 +24,7 @@ public static LayoutDefinition AddCustomerSummary(this LayoutDefinition layout)
.WithNavMenu((menu,_, _) =>
menu.WithNavLink(
nameof(CustomerSummary).Wordify(),
new LayoutAreaReference(nameof(CustomerSummary)).ToAppHref(layout.Hub.Address),
new LayoutAreaReference(nameof(CustomerSummary)).ToHref(layout.Hub.Address),
FluentIcons.Person
)
);
Expand All @@ -38,15 +37,9 @@ public static LayoutDefinition AddCustomerSummary(this LayoutDefinition layout)
/// <returns>A layout stack control representing the customer summary.</returns>
/// <remarks>This method constructs a stack control that includes a pane header titled "Customer Summary". Additional views can be added to the stack to complete the summary display.
/// </remarks>
public static StackControl CustomerSummary(
public static object CustomerSummary(
this LayoutAreaHost layoutArea,
RenderingContext ctx
) =>
Controls.Stack
.WithView(Controls.PaneHeader("Customer Summary"))
.WithView(
(a, _) =>
a.GetDataStream<Toolbar>(nameof(Toolbar))
.Select(tb => $"Year selected: {tb.Year}")
);
Controls.Markdown("TODO");
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static LayoutDefinition AddDiscountPercentage(this LayoutDefinition layou
.WithNavMenu((menu, _, _) =>
menu.WithNavLink(
nameof(DiscountPercentage),
new LayoutAreaReference(nameof(DiscountPercentage)).ToAppHref(layout.Hub.Address), FluentIcons.Document)
new LayoutAreaReference(nameof(DiscountPercentage)).ToHref(layout.Hub.Address), FluentIcons.Document)
)
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static LayoutDefinition AddDiscountSummary(this LayoutDefinition layout)
.WithNavMenu((menu, _, _) =>
menu.WithNavLink(
nameof(DiscountSummary),
new LayoutAreaReference(nameof(DiscountSummary)).ToAppHref(layout.Hub.Address), FluentIcons.Document)
new LayoutAreaReference(nameof(DiscountSummary)).ToHref(layout.Hub.Address), FluentIcons.Document)
)
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static LayoutDefinition AddDiscountVsRevenue(this LayoutDefinition layout
.WithNavMenu((menu, _, _) =>
menu.WithNavLink(
nameof(DiscountVsRevenue),
new LayoutAreaReference(nameof(DiscountVsRevenue)).ToAppHref(layout.Hub.Address), FluentIcons.Document)
new LayoutAreaReference(nameof(DiscountVsRevenue)).ToHref(layout.Hub.Address), FluentIcons.Document)
)
;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
Name: "Northwind Overview"
Description: "This is a sample description of the article."
Thumbnail: "images/thumbnail.jpg"
Published: "2024-09-24"
Authors:
- "Roland Bürgi"
- "Anna Kuleshova"
Tags:
- "Northwind"
- "Conceptual"
---

# Northwind

This is a model for the [Northwind Database](https://github.com/microsoft/sql-server-samples/blob/master/samples/databases/northwind-pubs/readme.md).
It is a small data domain modelling an e-commerce store. The complexity is moderate, it is more realistic than,
e.g. a TODO application or a blog application. Nevertheless, the complexity is not too big, so that we can
describe the basic principles of data modeling.

## Counter

The counter doesn't really fit here, we should move it to a spearate project.

@("ProductSummary"){ Layout = "Documentation" }

## Interactive Reporting

Make your reports interactive by using the [Interactive Reporting](InteractiveReporting.md) feature. Here an example:

@("OrderSummary"){ Layout = "Documentation" }
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
<!-- Embed source files in the PDB -->
<EmbedAllSources>true</EmbedAllSources>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml">
<LogicalName>$(AssemblyName).xml</LogicalName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static LayoutDefinition AddDashboard(this LayoutDefinition layout)
.WithNavMenu((menu,_, _) =>
menu.WithNavLink(
nameof(Dashboard),
new LayoutAreaReference(nameof(Dashboard)).ToAppHref(layout.Hub.Address), FluentIcons.Grid)
new LayoutAreaReference(nameof(Dashboard)).ToHref(layout.Hub.Address), FluentIcons.Grid)
);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Reactive.Linq;
using MeshWeaver.Application.Styles;
using MeshWeaver.Data;
using MeshWeaver.Domain;
using MeshWeaver.Layout;
using MeshWeaver.Layout.Composition;
using MeshWeaver.Layout.DataGrid;
Expand Down Expand Up @@ -29,7 +30,7 @@ public static LayoutDefinition AddOrdersSummary(this LayoutDefinition layout)
.WithSourcesForType(ctx => ctx.Area == nameof(OrderSummary), typeof(OrdersSummaryArea), typeof(NorthwindViewModels))
.WithEmbeddedDocument(ctx => ctx.Area == nameof(OrderSummary),typeof(OrdersSummaryArea).Assembly, "Readme.md")
.WithNavMenu((menu,_, _) =>menu.WithNavLink(nameof(OrderSummary).Wordify(),
new LayoutAreaReference(nameof(OrderSummary)).ToAppHref(layout.Hub.Address), FluentIcons.Box)
new LayoutAreaReference(nameof(OrderSummary)).ToHref(layout.Hub.Address), FluentIcons.Box)
);

/// <summary>
Expand All @@ -41,62 +42,53 @@ public static LayoutDefinition AddOrdersSummary(this LayoutDefinition layout)
/// <remarks>
/// This method constructs the Orders Summary view, incorporating a data grid to display aggregated order data. The specific contents and layout of the view are determined at runtime based on the rendering context.
/// </remarks>
public static StackControl OrderSummary(
public static UiControl OrderSummary(
this LayoutAreaHost layoutArea,
RenderingContext ctx
)
{
var years = layoutArea
.Workspace
.GetObservable<Order>()
.DistinctUntilChanged()
.Select(x =>
x.Select(y => y.OrderDate.Year)
.Distinct()
.OrderByDescending(year => year)
.Select(year => new Option<int>(year, year.ToString()))
.Prepend(new Option<int>(0, "All Time"))
.ToArray()
)
.DistinctUntilChanged(x => string.Join(',', x.Select(y => y.Item)));

return Controls.Stack
.WithClass("order-summary")
.WithView(ToolbarArea.Toolbar(years))
.WithView(
(area, _) =>
area.Workspace.GetStream(typeof(Order), typeof(Customer), typeof(OrderDetails))
.CombineLatest(
area.GetDataStream<Toolbar>(nameof(Toolbar)),
(changeItem, tb) => (changeItem, tb))
.DistinctUntilChanged()
.Select(tuple =>
area.ToDataGrid(
tuple.changeItem.Value.GetData<Order>()
.Where(x => tuple.tb.Year == 0 || x.OrderDate.Year == tuple.tb.Year)
.Select(order => new OrderSummaryItem(
tuple.changeItem.Value.GetData<Customer>(
order.CustomerId
)?.CompanyName,
tuple.changeItem.Value.GetData<OrderDetails>()
.Where(d => d.OrderId == order.OrderId)
.Sum(d => d.UnitPrice * d.Quantity),
order.OrderDate
))
.OrderByDescending(y => y.Amount)
.Take(5)
.ToArray(),
config =>
config.WithColumn(o => o.Customer)
.WithColumn(o => o.Amount, column => column.WithFormat("N0"))
.WithColumn(
o => o.Purchased,
column => column.WithFormat("yyyy-MM-dd")
)
)
layoutArea.SubscribeToDataStream(OrderSummaryToolbar.Years, layoutArea.GetAllYearsOfOrders());
return layoutArea.Toolbar(new OrderSummaryToolbar(), (tb, area, _) =>
area.Workspace.GetStream(typeof(Order), typeof(Customer), typeof(OrderDetails))
.DistinctUntilChanged()
.Select(tuple =>
area.ToDataGrid(
tuple.Value.GetData<Order>()
.Where(x => tb.Year == 0 || x.OrderDate.Year == tb.Year)
.Select(order => new OrderSummaryItem(
tuple.Value.GetData<Customer>(
order.CustomerId
)?.CompanyName,
tuple.Value.GetData<OrderDetails>()
.Where(d => d.OrderId == order.OrderId)
.Sum(d => d.UnitPrice * d.Quantity),
order.OrderDate
))
.OrderByDescending(y => y.Amount)
.Take(5)
.ToArray(),
config =>
config.WithColumn(o => o.Customer)
.WithColumn(o => o.Amount, column => column.WithFormat("N0"))
.WithColumn(
o => o.Purchased,
column => column.WithFormat("yyyy-MM-dd")
)
)
);

)
)
;
}
/// <summary>
/// Represents a simple toolbar entry that captures a specific year.
/// </summary>
public record OrderSummaryToolbar
{
internal const string Years = "years";
/// <summary>
/// The year selected in the toolbar.
/// </summary>
[Dimension<int>(Options = Years)] public int Year { get; init; }

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static LayoutDefinition AddProductOverview(this LayoutDefinition layout)
.WithNavMenu((menu, _, _) =>
menu.WithNavLink(
nameof(ProductOverview),
new LayoutAreaReference(nameof(ProductOverview)).ToAppHref(layout.Hub.Address), FluentIcons.Document)
new LayoutAreaReference(nameof(ProductOverview)).ToHref(layout.Hub.Address), FluentIcons.Document)
)
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ public static object ProductOverviewToolbar(this LayoutAreaHost layoutArea, Rend
.Select(categories =>
Template.Bind(new ProductOverviewToolbar(0),
tb =>
Controls.Select(tb.Category)
.WithOptions(
Enumerable.Select<Category, Option<int>>(categories, c => new Option<int>(c.CategoryId, c.CategoryName))
.Prepend(new Option<int>(0, "All Categories"))
.Cast<Option>()
.ToArray()
), nameof(ProductOverviewToolbar))
Controls.Select(
tb.Category,
Enumerable.Select<Category, Option<int>>(categories, c => new Option<int>(c.CategoryId, c.CategoryName))
.Prepend(new Option<int>(0, "All Categories"))
.Cast<Option>()
.ToArray()
),
nameof(ProductOverviewToolbar))
)
)
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static class ProductSummaryArea
public static LayoutDefinition AddProductsSummary(this LayoutDefinition layout)
=> layout.WithView(nameof(ProductSummary), ProductSummary)
.WithNavMenu((menu, _, _) => menu.WithNavLink("Product Summary",
new LayoutAreaReference(nameof(ProductSummary)).ToAppHref(layout.Hub.Address), FluentIcons.Box)
new LayoutAreaReference(nameof(ProductSummary)).ToHref(layout.Hub.Address), FluentIcons.Box)
);


Expand Down
Loading

0 comments on commit eb4954c

Please sign in to comment.