Skip to content

Commit

Permalink
Merge pull request #724 from bcgov/DIAM-56-admin
Browse files Browse the repository at this point in the history
Diam 56 admin
  • Loading branch information
leewrigh authored Dec 3, 2024
2 parents d927da8 + 4c807a6 commit bf36c39
Show file tree
Hide file tree
Showing 162 changed files with 2,078 additions and 8,942 deletions.
8 changes: 6 additions & 2 deletions backend/ApprovalFlow/ApprovalFlow.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.1.8</Version>
<Version>1.1.9</Version>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

Expand All @@ -19,6 +19,10 @@
<Folder Include="API\v1\" />
<Folder Include="Data\Migrations\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.0" />
</ItemGroup>
<!--<Target Name="OpenAPI" AfterTargets="Build" Condition="$(Configuration)=='Debug'">
<Exec Command="dotnet swagger tofile -o ./API/v1/$(AssemblyName).yaml -y $(OutputPath)$(AssemblyName).dll v1" WorkingDirectory="$(ProjectDir)" />
<Exec Command="dotnet swagger tofile -o ./API/v1/$(AssemblyName).json $(OutputPath)$(AssemblyName).dll v1" WorkingDirectory="$(ProjectDir)" />
Expand Down
4 changes: 2 additions & 2 deletions backend/CommonConstants/CommonConstants.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>1.1.8</Version>
<Version>1.1.9</Version>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>DIAM-Common-Constants</Title>
<Description>Common constants for DIAM services</Description>
Expand Down
4 changes: 2 additions & 2 deletions backend/CommonModels/CommonModels.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>1.1.9.2</Version>
<Version>1.1.9.31</Version>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>DIAM-Common-Models</Title>
<Description>Common models for DIAM services</Description>
Expand Down
25 changes: 25 additions & 0 deletions backend/CommonModels/Models/DIAMAdmin/AdminCommandSet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace CommonModels.Models.DIAMAdmin;

public enum AdminCommandSet
{
PING,
PARTY_REMOVE_REQUEST,
PARTY_ACCESS_REQUEST_RESET,
PARTY_ACCESS_REQUEST_REMOVE,
SSO_USER_GROUP_ADD,
SSO_USER_GROUP_REMOVE,
SSO_GROUP_ADD,
SSO_GROUP_DELETE,
SSO_GROUP_CHILD_ADD,
SSO_GROUP_CLIENT_ROLES_ADD,
SSO_GROUP_CLIENT_ROLES_REMOVE,
SSO_CLIENT_ADD,
SSO_CLIENT_UPDATE


}

public static class AdminCommandSetExtensions
{
public static string ToSnakeCase(this AdminCommandSet commandSet) => commandSet.ToString().ToLower().Replace('_', '-');
}
24 changes: 24 additions & 0 deletions backend/CommonModels/Models/DIAMAdmin/AdminRequestModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace CommonModels.Models.DIAMAdmin;

/// <summary>
/// Represents a request for a service to take an admin action
/// For instance this could represent a request to remove a users access to a service
/// </summary>
public class AdminRequestModel
{
public string? TargetKafkaInstance { get; set; }
public required string TargetEnvironment { get; set; }
public required AdminCommandSet RequestType { get; set; }
public required string Requestor { get; set; }
public string? RequestorIPAddress { get; set; }
public Dictionary<string, string> RequestData { get; set; } = [];
public DateTime RequestDateTime { get; set; }

}

public class AdminRequestKey
{
public required string Key { get; set; }
public List<string> TargetServices { get; set; } = [];
}

22 changes: 22 additions & 0 deletions backend/CommonModels/Models/DIAMAdmin/AdminRequestStatusModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace CommonModels.Models.DIAMAdmin;


public class AdminRequestStatusModel
{
public int RequestId { get; set; }
public string? Instance { get; set; }
public string? KafkaInstance { get; set; }
public required Guid MessageId { get; set; }
public required string Requestor { get; set; }
public required string RequestIPAddress { get; set; }
public DateTime RequestTime { get; set; } = DateTime.UtcNow;
public DateTime? DeliveredTime { get; set; }
public DateTime? CompletedTime { get; set; }
public string? Errors { get; set; }
public required AdminCommandSet RequestType { get; set; }
public string? Status { get; set; }
public string? RequestData { get; set; }
public string? ResponseData { get; set; }


}
17 changes: 17 additions & 0 deletions backend/CommonModels/Models/DIAMAdmin/AdminResponseModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace CommonModels.Models.DIAMAdmin;

/// <summary>
/// When a service has picked up and processed an AdminRequest a response
/// should be generated that contains response data
/// </summary>
public class AdminResponseModel
{
public required Guid RequestId { get; set; }
public DateTime RequestProcessDateTime { get; set; }
public required string Hostname { get; set; }
public AdminCommandSet RequestType { get; set; }
public string? Errors { get; set; }
public bool Success { get; set; }
public Dictionary<string, string> ResponseData { get; set; } = [];

}
9 changes: 9 additions & 0 deletions backend/CommonModels/Models/DIAMAdmin/AdminSignal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace CommonModels.Models.DIAMAdmin;


public class AdminSignal
{
public string Msg { get; set; }
public AdminCommandSet Command { get; set; }
public string UserId { get; set; }
}
46 changes: 40 additions & 6 deletions backend/CommonModels/Models/DIAMAdmin/AdminUserModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,48 @@ namespace CommonModels.Models.DIAMAdmin;

public class AdminUserModel
{
public int Id { get; set; }
public string Username { get; set; } = string.Empty;
public bool Enabled { get; set; }
public string KeycloakId { get; set; } = string.Empty;
public List<UserAccessModel> KeycloakClientAccess { get; set; } = [];
public string Name { get; set; } = string.Empty;
public bool Enabled { get; set; } = true;
public DateTime CreatedAt { get; set; }
public DateTime LastLogin { get; set; }
public List<UserEnvironmentAccessModel> EnvironmentAccessModel { get; set; } = [];

}

public class AdminAuditUserModel
{
public int Id { get; set; }
public string Username { get; set; } = string.Empty;
public List<UserAuditLogModel> AuditLogs { get; set; } = [];

}

public class UserEnvironmentAccessModel
{
public string EnvironmentName { get; set; } = string.Empty;
public List<UserClientAccessModel> ClientAccessList { get; set; } = [];
public List<UserRealmAccessModel> RealmAccess { get; set; } = [];
}

public class UserAuditLogModel
{
public int Id { get; set; }
public string EventType { get; set; } = string.Empty;
public string IPAddress { get; set; } = string.Empty;
public DateTime EventTime { get; set; }
}


public class UserClientAccessModel
{
public int Id { get; set; }
public string ClientId { get; set; } = string.Empty;
}

public class UserAccessModel
public class UserRealmAccessModel
{
public string KeycloakEnvionment { get; set; } = string.Empty;
public List<string> KeycloakClients { get; set; } = [];
public int Id { get; set; }
public string RealmId { get; set; } = string.Empty;
}
34 changes: 34 additions & 0 deletions backend/CommonModels/Models/DIAMAdmin/ChartDataModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace CommonModels.Models.DIAMAdmin;


public class ChartDataModel
{
public string DataName { get; set; } = "No name";
public List<ChartDataInstance> Data { get; set; } = [];


public List<string> GetLabels()
{
if (this.Data == null || this.Data.Count == 0)
{
return [];
}
return [.. this.Data.Select(d => d.Label).Distinct().OrderBy(x => x)];
}

public ChartDataInstance GetDataForLabel(string label)
{
if (this.Data == null || this.Data.Count == 0 || !this.Data.Any(d => d.Label == label))
{
return new ChartDataInstance();
}
return this.Data.FirstOrDefault(d => d.Label == label);
}
}

public class ChartDataInstance
{
public double Value { get; set; }
public string Label { get; set; } = "No label";
public string Colour { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace CommonModels.Models.EDT;


/// <summary>
/// Used to tell EDT Disclosure when a user should be added to a Folio as a result of a merge event
/// </summary>
public class EdtDisclosureUserMergeUpdateModel
{
public string? Id { get; set; }
public string? Key { get; set; }
public string? UserName { get; set; }
public int SourceDisclosureCaseId { get; set; }
public int TargetDisclosureCaseId { get; set; }
}
27 changes: 27 additions & 0 deletions backend/CommonModels/Models/JUSTIN/ParticipantMergeDetailModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace CommonModels.Models.JUSTIN;

using Common.Models.JUSTIN;
using NodaTime;



/// <summary>
/// Represents two JUSTIN records merged together
/// </summary>
public class ParticipantMergeDetailModel
{
public int MergeId { get; set; }
public ParticipantType ParticipantType { get; set; }
public Instant CreatedOn { get; set; } = Instant.FromDateTimeUtc(DateTime.UtcNow);
public ParticipantDetail? SourceParticipant { get; set; }
public ParticipantDetail? TargetParticipant { get; set; }

}

public enum ParticipantType
{
ACCUSED,
LEGALCOUNSEL,
BCPSUSER
}

15 changes: 14 additions & 1 deletion backend/CommonModels/Models/Web/PaginationInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,21 @@ public class PaginationInput
public int PageSize { get; set; }
public string? SearchValue { get; set; }
public Dictionary<string, string> Filters { get; set; } = [];
public Dictionary<string, int> Sorts { get; set; } = [];
public List<Sort> Sorts { get; set; } = [];


public override string ToString() => $"Page: {this.Page}, PageSize: {this.PageSize}, SearchValue: {this.SearchValue}, Filters: {string.Join(", ", this.Filters)}, Sorts: {string.Join(", ", this.Sorts)}";
}

public class Sort
{
public int Order { get; set; }
public required string ColumnName { get; set; }
public SortDirection Direction { get; set; } = SortDirection.ASC;
}

public enum SortDirection
{
ASC,
DESC
}
18 changes: 18 additions & 0 deletions backend/CommonModels/Models/Web/TreeNode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace CommonModels.Models.Web;

using System.Text.Json.Serialization;

public class TreeNode
{
public int Id { get; set; }
public int ParentId { get; set; }
public required string Name { get; set; }
public string? InternalId { get; set; }
public int Level { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Icon { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public List<TreeNode> Children { get; set; } = [];
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? ClassName { get; set; }
}
20 changes: 20 additions & 0 deletions backend/CommonModels/Models/Web/WebTreeView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace CommonModels.Models.Web;

using System.Text.Json.Serialization;

/// <summary>
/// Represents a tree of data
/// </summary>
public class WebTreeView : TreeNode
{
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Path { get; set; }



public bool Selected { get; set; }

public bool Expanded { get; set; }


}
5 changes: 3 additions & 2 deletions backend/DIAMConfiguration/DIAMConfiguration.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.1.8</Version>
<Version>1.1.9</Version>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

Expand All @@ -15,6 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
Expand Down
5 changes: 3 additions & 2 deletions backend/DIAMCornetService/DIAMCornetService.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>1.1.8</Version>
<Version>1.1.9</Version>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>3b005920-7fbb-4ccb-a850-eefca1fadd82</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
</ItemGroup>

Expand Down
Loading

0 comments on commit bf36c39

Please sign in to comment.