Skip to content

Commit

Permalink
Admin UI: Show number of Identities in Clients overview page (#312)
Browse files Browse the repository at this point in the history
* feat: add ClientOverview DTO

* feat: use ClientOverview in Clients controller

* feat: add NumberOfIdentities field to ClientOverview in the AdminUi

* test: add integration tests for ClientOverview

* fix: merge fix

* fix: add missing DefaultTier property to ClientOverview

* chore: create SqlServer migrations for ClientOverviews

* chore: create Postgres migrations for ClientOverviews

* fix: add missing DROP to ClientOverviews migrations

* chore: move ClientOverviews variable in the AdminUiDbContext

* refactor: improve Client List responsiveness in the AdminUi

* Upgrade Helm chart for Consumer API and Admin UI (#316)

* feat: set consumer api version to 3.0.0

* feat: set admin ui version to 2.0.0

* fix: merge fix

* refactor: improve AdminUi client overview responsiveness

* refactor: improve ClientsOverview migrations

* fix: add missing link to the Client Details in the Clients Overview page

* ci: trigger pipelines

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Daniel Almeida <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2023
1 parent 1fbd662 commit a9111fb
Show file tree
Hide file tree
Showing 19 changed files with 430 additions and 35 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace AdminUi.Infrastructure.Database.Postgres.Migrations
{
/// <inheritdoc />
public partial class ClientsOverview : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("""
CREATE VIEW "ClientOverviews" AS
SELECT
CLIENTS."ClientId" AS "ClientId",
CLIENTS."DisplayName" AS "DisplayName",
CLIENTS."DefaultTier" AS "DefaultTier",
CLIENTS."CreatedAt" AS "CreatedAt",
(
SELECT COUNT("ClientId")
FROM "Devices"."Identities"
WHERE "ClientId" = CLIENTS."ClientId"
) AS "NumberOfIdentities"
FROM "Devices"."OpenIddictApplications" CLIENTS
""");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(""" DROP VIEW "ClientOverviews" """);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ protected override void BuildModel(ModelBuilder modelBuilder)

NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);

modelBuilder.Entity("AdminUi.Infrastructure.DTOs.ClientOverview", b =>
{
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("text");

b.Property<string>("DefaultTier")
.IsRequired()
.HasColumnType("text");

b.Property<string>("DisplayName")
.IsRequired()
.HasColumnType("text");

b.Property<int>("NumberOfIdentities")
.HasColumnType("integer");

b.ToTable((string)null);

b.ToView("ClientOverviews", (string)null);
});

modelBuilder.Entity("AdminUi.Infrastructure.DTOs.IdentityOverview", b =>
{
b.Property<string>("Address")
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace AdminUi.Infrastructure.Database.SqlServer.Migrations
{
/// <inheritdoc />
public partial class ClientsOverview : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("""
CREATE VIEW ClientOverviews AS
SELECT
CLIENTS.ClientId,
CLIENTS.DisplayName,
CLIENTS.DefaultTier,
CLIENTS.CreatedAt,
(
SELECT COUNT(ClientId)
FROM Devices.Identities
WHERE ClientId = CLIENTS.ClientId
) AS NumberOfIdentities
FROM Devices.OpenIddictApplications CLIENTS
""");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql(""" DROP VIEW ClientOverviews """);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ protected override void BuildModel(ModelBuilder modelBuilder)

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);

modelBuilder.Entity("AdminUi.Infrastructure.DTOs.ClientOverview", b =>
{
b.Property<string>("ClientId")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("DefaultTier")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("DisplayName")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<int>("NumberOfIdentities")
.HasColumnType("int");

b.ToTable((string)null);

b.ToView("ClientOverviews", (string)null);
});

modelBuilder.Entity("AdminUi.Infrastructure.DTOs.IdentityOverview", b =>
{
b.Property<string>("Address")
Expand Down
9 changes: 9 additions & 0 deletions AdminUi/src/AdminUi.Infrastructure/DTOs/ClientOverview.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace AdminUi.Infrastructure.DTOs;
public class ClientOverview
{
public string ClientId { get; set; }
public string DisplayName { get; set; }
public string DefaultTier { get; set; }
public DateTime CreatedAt { get; set; }
public int NumberOfIdentities { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public AdminUiDbContext(DbContextOptions<AdminUiDbContext> options, IServiceProv

public DbSet<TierOverview> TierOverviews { get; set; }

public DbSet<ClientOverview> ClientOverviews { get; set; }

protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using AdminUi.Infrastructure.DTOs;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace AdminUi.Infrastructure.Persistence.Database.EntityTypeConfigurations;
public class ClientOverviewEntityTypeConfiguration : IEntityTypeConfiguration<ClientOverview>
{
public void Configure(EntityTypeBuilder<ClientOverview> builder)
{
builder.ToView("ClientOverviews");
builder.HasNoKey();
}
}
Loading

0 comments on commit a9111fb

Please sign in to comment.