after refactor cleanup
This commit is contained in:
112
DiunaBI.UI.Shared/Pages/LayerDetailPage.razor
Normal file
112
DiunaBI.UI.Shared/Pages/LayerDetailPage.razor
Normal file
@@ -0,0 +1,112 @@
|
||||
@page "/layers/{id:guid}"
|
||||
@using DiunaBI.UI.Shared.Services
|
||||
@using DiunaBI.Application.DTOModels
|
||||
@using MudBlazor
|
||||
@inject LayerService LayerService
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<MudCard>
|
||||
<MudCardHeader>
|
||||
<CardHeaderContent>
|
||||
<MudText Typo="Typo.h5">Layer Details</MudText>
|
||||
</CardHeaderContent>
|
||||
<CardHeaderActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="Export">Export</MudButton>
|
||||
@if (layer != null && layer.Type == LayerType.Administration)
|
||||
{
|
||||
<MudButton Variant="Variant.Text" Href="@($"/layers/edit/{layer.Id}/duplicate")">Duplicate</MudButton>
|
||||
<MudButton Variant="Variant.Text" Href="@($"/layers/edit/{layer.Id}")">Edit</MudButton>
|
||||
}
|
||||
@if (layer != null && layer.Type == LayerType.Processed)
|
||||
{
|
||||
<MudButton Variant="Variant.Text" OnClick="ProcessLayer">Process Layer</MudButton>
|
||||
}
|
||||
</CardHeaderActions>
|
||||
</MudCardHeader>
|
||||
<MudCardContent>
|
||||
@if (isLoading)
|
||||
{
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" />
|
||||
}
|
||||
else if (layer == null)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error">Layer not found</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudGrid>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField @bind-Value="layer.Name"
|
||||
Label="Name"
|
||||
Variant="Variant.Outlined"
|
||||
ReadOnly="true"
|
||||
FullWidth="true"/>
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
@if (layer.IsCancelled)
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Dense="true">
|
||||
This layer is cancelled. Will not be used in any further processing.
|
||||
</MudAlert>
|
||||
}
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField Value="@layer.CreatedAt.ToString("g")"
|
||||
Label="Created"
|
||||
Variant="Variant.Outlined"
|
||||
ReadOnly="true"
|
||||
FullWidth="true"
|
||||
Adornment="Adornment.End"
|
||||
AdornmentText="@(layer.CreatedBy?.Username ?? "")"/>
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField Value="@layer.ModifiedAt.ToString("g")"
|
||||
Label="Modified"
|
||||
Variant="Variant.Outlined"
|
||||
ReadOnly="true"
|
||||
FullWidth="true"
|
||||
Adornment="Adornment.End"
|
||||
AdornmentText="@(layer.ModifiedBy?.Username ?? "")"/>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<MudDivider Class="my-4"/>
|
||||
|
||||
<MudTable Items="@records"
|
||||
Dense="true"
|
||||
Striped="true"
|
||||
FixedHeader="true"
|
||||
FixedFooter="true"
|
||||
Height="600px">
|
||||
<HeaderContent>
|
||||
<MudTh>Code</MudTh>
|
||||
@foreach (var column in displayedColumns)
|
||||
{
|
||||
<MudTh>@column</MudTh>
|
||||
}
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Code">@context.Code</MudTd>
|
||||
@foreach (var column in displayedColumns)
|
||||
{
|
||||
<MudTd DataLabel="@column">@GetRecordValue(context, column)</MudTd>
|
||||
}
|
||||
</RowTemplate>
|
||||
<FooterContent>
|
||||
<MudTd><b>Value1 sum</b></MudTd>
|
||||
@foreach (var column in displayedColumns)
|
||||
{
|
||||
@if (column == "Value1")
|
||||
{
|
||||
<MudTd><b>@valueSum.ToString("N2")</b></MudTd>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudTd></MudTd>
|
||||
}
|
||||
}
|
||||
</FooterContent>
|
||||
</MudTable>
|
||||
}
|
||||
</MudCardContent>
|
||||
</MudCard>
|
||||
122
DiunaBI.UI.Shared/Pages/LayerDetailPage.razor.cs
Normal file
122
DiunaBI.UI.Shared/Pages/LayerDetailPage.razor.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using DiunaBI.Application.DTOModels;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DiunaBI.UI.Shared.Pages;
|
||||
|
||||
public partial class LayerDetailPage : ComponentBase
|
||||
{
|
||||
[Parameter]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[Inject]
|
||||
private ISnackbar Snackbar { get; set; } = null!;
|
||||
|
||||
private LayerDto? layer;
|
||||
private List<RecordDto> records = new();
|
||||
private List<string> displayedColumns = new();
|
||||
private double valueSum = 0;
|
||||
private bool isLoading = false;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadLayer();
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await LoadLayer();
|
||||
}
|
||||
|
||||
private async Task LoadLayer()
|
||||
{
|
||||
isLoading = true;
|
||||
StateHasChanged();
|
||||
|
||||
try
|
||||
{
|
||||
layer = await LayerService.GetLayerByIdAsync(Id);
|
||||
|
||||
if (layer != null && layer.Records != null)
|
||||
{
|
||||
records = layer.Records;
|
||||
CalculateDisplayedColumns();
|
||||
CalculateValueSum();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine($"Error loading layer: {ex.Message}");
|
||||
Snackbar.Add("Error loading layer", Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
isLoading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void CalculateDisplayedColumns()
|
||||
{
|
||||
displayedColumns.Clear();
|
||||
|
||||
// Check which Value columns have data
|
||||
for (int i = 1; i <= 32; i++)
|
||||
{
|
||||
var columnName = $"Value{i}";
|
||||
var hasData = records.Any(r => GetRecordValueByName(r, columnName) != null);
|
||||
|
||||
if (hasData)
|
||||
{
|
||||
displayedColumns.Add(columnName);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if Desc1 has data
|
||||
if (records.Any(r => !string.IsNullOrEmpty(r.Desc1)))
|
||||
{
|
||||
displayedColumns.Add("Description1");
|
||||
}
|
||||
}
|
||||
|
||||
private void CalculateValueSum()
|
||||
{
|
||||
valueSum = records
|
||||
.Where(r => r.Value1.HasValue)
|
||||
.Sum(r => r.Value1!.Value);
|
||||
}
|
||||
|
||||
private string GetRecordValue(RecordDto record, string columnName)
|
||||
{
|
||||
if (columnName == "Description1")
|
||||
{
|
||||
return record.Desc1 ?? string.Empty;
|
||||
}
|
||||
|
||||
var value = GetRecordValueByName(record, columnName);
|
||||
return value.HasValue ? value.Value.ToString("N2") : string.Empty;
|
||||
}
|
||||
|
||||
private double? GetRecordValueByName(RecordDto record, string columnName)
|
||||
{
|
||||
var property = typeof(RecordDto).GetProperty(columnName, BindingFlags.Public | BindingFlags.Instance);
|
||||
if (property != null && property.PropertyType == typeof(double?))
|
||||
{
|
||||
return property.GetValue(record) as double?;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void Export()
|
||||
{
|
||||
// TODO: Implement export functionality
|
||||
Snackbar.Add("Export functionality coming soon", Severity.Error);
|
||||
}
|
||||
|
||||
private void ProcessLayer()
|
||||
{
|
||||
// TODO: Implement process layer functionality
|
||||
Snackbar.Add("Process layer functionality coming soon", Severity.Error);
|
||||
}
|
||||
}
|
||||
8
DiunaBI.UI.Shared/Pages/LayerListPage.razor
Normal file
8
DiunaBI.UI.Shared/Pages/LayerListPage.razor
Normal file
@@ -0,0 +1,8 @@
|
||||
@page "/layers"
|
||||
@using DiunaBI.UI.Shared.Components
|
||||
|
||||
<PageTitle>Layers</PageTitle>
|
||||
|
||||
<MudContainer MaxWidth="MaxWidth.ExtraExtraLarge">
|
||||
<LayerListComponent />
|
||||
</MudContainer>
|
||||
46
DiunaBI.UI.Shared/Pages/LoginPage.razor
Normal file
46
DiunaBI.UI.Shared/Pages/LoginPage.razor
Normal file
@@ -0,0 +1,46 @@
|
||||
@page "/login"
|
||||
@layout EmptyLayout
|
||||
|
||||
<div class="login-page">
|
||||
<div class="login-container">
|
||||
<LoginCard />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
height: 100% !important;
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
#app {
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
.login-page {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)), url('_content/DiunaBI.UI.Shared/images/login-background.jpg') no-repeat center;
|
||||
background-size: cover;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.login-container {
|
||||
padding: 20px;
|
||||
width: 100%;
|
||||
max-width: 450px;
|
||||
}
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user