MRB webassembly
This commit is contained in:
248
MesaFabApproval.Client/Pages/Dashboard.razor
Normal file
248
MesaFabApproval.Client/Pages/Dashboard.razor
Normal file
@ -0,0 +1,248 @@
|
||||
@page "/"
|
||||
@page "/Dashboard"
|
||||
@inject IConfiguration Configuration
|
||||
@inject MesaFabApprovalAuthStateProvider stateProvider
|
||||
@inject IApprovalService approvalService
|
||||
@inject IMemoryCache cache
|
||||
@inject NavigationManager navigationManager
|
||||
@inject ISnackbar snackbar
|
||||
@inject IMRBService mrbService
|
||||
@inject IECNService ecnService
|
||||
@inject ICAService caService
|
||||
@inject IJSRuntime jsRuntime
|
||||
|
||||
<PageTitle>Dashboard</PageTitle>
|
||||
|
||||
<MudPaper Class="p-2 m-2">
|
||||
<MudText Typo="Typo.h3" Align="Align.Center">Dashboard</MudText>
|
||||
</MudPaper>
|
||||
|
||||
<MudPaper Class="p-2 m-2">
|
||||
<MudTabs Class="p-2" Rounded Centered Color="Color.Info" MinimumTabWidth="50%">
|
||||
<MudTabPanel Text="My Active Approvals" Style="min-width:50%; text-align: center;">
|
||||
@if (stateProvider.CurrentUser is not null && approvalList is not null && !myApprovalsProcessing) {
|
||||
<MudPaper Outlined="true"
|
||||
Class="p-2 m-2 d-flex flex-column justify-center">
|
||||
<MudText Typo="Typo.h4" Align="Align.Center">My Active Approvals</MudText>
|
||||
<MudDivider DividerType="DividerType.Middle" Class="my-2" />
|
||||
<MudTable Items="@approvalList"
|
||||
Class="m-2"
|
||||
Striped
|
||||
SortLabel="Sort by">
|
||||
<HeaderContent>
|
||||
<MudTh>
|
||||
<MudTableSortLabel SortBy="new Func<Approval,object>(x=>x.IssueID)">
|
||||
Issue ID
|
||||
</MudTableSortLabel>
|
||||
</MudTh>
|
||||
<MudTh>
|
||||
<MudTableSortLabel SortBy="new Func<Approval,object>(x=>x.SubRoleCategoryItem)">
|
||||
Role
|
||||
</MudTableSortLabel>
|
||||
</MudTh>
|
||||
<MudTh>
|
||||
<MudTableSortLabel InitialDirection="SortDirection.Descending" SortBy="new Func<Approval,object>(x=>x.AssignedDate)">
|
||||
Assigned Date
|
||||
</MudTableSortLabel>
|
||||
</MudTh>
|
||||
<MudTh>
|
||||
<MudTableSortLabel SortBy="new Func<Approval,object>(x=>x.Step)">
|
||||
Step
|
||||
</MudTableSortLabel>
|
||||
</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Issue ID">
|
||||
@if (context.IssueID > 0) {
|
||||
<MudLink OnClick="@(() => FollowLink(context.IssueID))">@context.IssueID</MudLink>
|
||||
}
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Role">@context.SubRoleCategoryItem</MudTd>
|
||||
<MudTd DataLabel="Assigned Date">@DateTimeUtilities.GetDateAsStringMinDefault(context.AssignedDate)</MudTd>
|
||||
<MudTd DataLabel="Step">@context.Step</MudTd>
|
||||
</RowTemplate>
|
||||
<PagerContent>
|
||||
<MudTablePager />
|
||||
</PagerContent>
|
||||
</MudTable>
|
||||
</MudPaper>
|
||||
} else {
|
||||
<MudOverlay Visible DarkBackground="true" AutoClose="false">
|
||||
<MudText Align="Align.Center" Typo="Typo.h3">Processing</MudText>
|
||||
<MudProgressCircular Color="Color.Info" Size="Size.Large" Indeterminate="true" />
|
||||
</MudOverlay>
|
||||
}
|
||||
</MudTabPanel>
|
||||
<MudTabPanel Text="My MRBs" Style="min-width:50%; text-align: center;">
|
||||
@if (stateProvider.CurrentUser is not null && myMRBs is not null && !myMrbsProcessing) {
|
||||
<MudPaper Outlined="true"
|
||||
Class="p-2 m-2 d-flex flex-column justify-center">
|
||||
<MudText Typo="Typo.h4" Align="Align.Center">My MRBs</MudText>
|
||||
<MudDivider DividerType="DividerType.Middle" Class="my-2" />
|
||||
<MudTable Items="@myMRBs"
|
||||
Class="m-2"
|
||||
Striped
|
||||
SortLabel="Sort by"
|
||||
Filter="new Func<MRB, bool>(FilterFuncForMRBTable)">
|
||||
<ToolBarContent>
|
||||
<MudSpacer />
|
||||
<MudTextField @bind-Value="mrbSearchString"
|
||||
Placeholder="Search"
|
||||
Adornment="Adornment.Start"
|
||||
AdornmentIcon="@Icons.Material.Filled.Search"
|
||||
IconSize="Size.Medium"
|
||||
Class="mt-0" />
|
||||
</ToolBarContent>
|
||||
<HeaderContent>
|
||||
<MudTh>
|
||||
<MudTableSortLabel InitialDirection="SortDirection.Descending" SortBy="new Func<MRB,object>(x=>x.MRBNumber)">
|
||||
MRB#
|
||||
</MudTableSortLabel>
|
||||
</MudTh>
|
||||
<MudTh>
|
||||
<MudTableSortLabel SortBy="new Func<MRB,object>(x=>x.Title)">
|
||||
Title
|
||||
</MudTableSortLabel>
|
||||
</MudTh>
|
||||
<MudTh>
|
||||
<MudTableSortLabel SortBy="new Func<MRB,object>(x=>x.SubmittedDate)">
|
||||
Submitted Date
|
||||
</MudTableSortLabel>
|
||||
</MudTh>
|
||||
<MudTh>
|
||||
<MudTableSortLabel SortBy="new Func<MRB,object>(x=>x.ApprovalDate)">
|
||||
Approval Date
|
||||
</MudTableSortLabel>
|
||||
</MudTh>
|
||||
<MudTh>
|
||||
<MudTableSortLabel SortBy="new Func<MRB,object>(x=>x.CancelDate)">
|
||||
Cancel Date
|
||||
</MudTableSortLabel>
|
||||
</MudTh>
|
||||
<MudTh>
|
||||
<MudTableSortLabel SortBy="new Func<MRB,object>(x=>x.CloseDate)">
|
||||
Completed Date
|
||||
</MudTableSortLabel>
|
||||
</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="MRB#">
|
||||
<MudLink OnClick="@(() => GoTo($"mrb/{context.MRBNumber}"))">@context.MRBNumber</MudLink>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Title">@context.Title</MudTd>
|
||||
<MudTd DataLabel="Submitted Date">@DateTimeUtilities.GetDateAsStringMinDefault(context.SubmittedDate)</MudTd>
|
||||
<MudTd DataLabel="Approval Date">@DateTimeUtilities.GetDateAsStringMaxDefault(context.ApprovalDate)</MudTd>
|
||||
<MudTd DataLabel="Cancel Date">@DateTimeUtilities.GetDateAsStringMaxDefault(context.CancelDate)</MudTd>
|
||||
<MudTd DataLabel="Completed Date">@DateTimeUtilities.GetDateAsStringMaxDefault(context.CloseDate)</MudTd>
|
||||
</RowTemplate>
|
||||
<PagerContent>
|
||||
<MudTablePager />
|
||||
</PagerContent>
|
||||
</MudTable>
|
||||
</MudPaper>
|
||||
} else {
|
||||
<MudOverlay Visible DarkBackground="true" AutoClose="false">
|
||||
<MudText Align="Align.Center" Typo="Typo.h3">Processing</MudText>
|
||||
<MudProgressCircular Color="Color.Info" Size="Size.Large" Indeterminate="true" />
|
||||
</MudOverlay>
|
||||
}
|
||||
</MudTabPanel>
|
||||
</MudTabs>
|
||||
</MudPaper>
|
||||
|
||||
@code {
|
||||
private IEnumerable<Approval> approvalList = new List<Approval>();
|
||||
private IEnumerable<MRB> myMRBs = new List<MRB>();
|
||||
|
||||
private IEnumerable<int> ecnNumbers = new HashSet<int>();
|
||||
private IEnumerable<int> caNumbers = new HashSet<int>();
|
||||
private IEnumerable<int> mrbNumbers = new HashSet<int>();
|
||||
|
||||
private bool myApprovalsProcessing = false;
|
||||
private bool myMrbsProcessing = false;
|
||||
|
||||
private string mrbSearchString = "";
|
||||
|
||||
protected async override Task OnParametersSetAsync() {
|
||||
try {
|
||||
if (stateProvider.CurrentUser is not null) {
|
||||
myApprovalsProcessing = true;
|
||||
approvalList = (await approvalService.GetApprovalsForUserId(stateProvider.CurrentUser.UserID, true))
|
||||
.Where(a => a.CompletedDate > DateTime.Now && a.ItemStatus == 0)
|
||||
.ToList()
|
||||
.OrderByDescending(x => x.AssignedDate);
|
||||
myApprovalsProcessing = false;
|
||||
|
||||
myMrbsProcessing = true;
|
||||
myMRBs = (await mrbService.GetAllMRBs(false)).Where(m => m.OriginatorID == stateProvider.CurrentUser.UserID)
|
||||
.ToList()
|
||||
.OrderByDescending(x => x.SubmittedDate);
|
||||
myMrbsProcessing = false;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
myMrbsProcessing = false;
|
||||
snackbar.Add($"Unable to load the dashboard, because {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task FollowLink(int issueId) {
|
||||
HashSet<Task> tasks = new();
|
||||
|
||||
bool isEcn = false;
|
||||
bool isCa = false;
|
||||
bool isMrb = false;
|
||||
if (ecnNumbers.Contains(issueId))
|
||||
isEcn = true;
|
||||
if (caNumbers.Contains(issueId))
|
||||
isCa = true;
|
||||
if (mrbNumbers.Contains(issueId))
|
||||
isMrb = true;
|
||||
|
||||
if (!isEcn && !isCa && !isMrb) {
|
||||
Task<bool> isEcnTask = ecnService.ECNNumberIsValid(issueId);
|
||||
tasks.Add(isEcnTask);
|
||||
|
||||
Task<bool> isCaTask = caService.CANumberIsValid(issueId);
|
||||
tasks.Add(isCaTask);
|
||||
|
||||
Task<bool> isMrbTask = mrbService.NumberIsValid(issueId);
|
||||
tasks.Add(isMrbTask);
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
|
||||
if (isEcnTask.Result) {
|
||||
isEcn = true;
|
||||
} else if (isCaTask.Result) {
|
||||
isCa = true;
|
||||
} else if (isMrbTask.Result) {
|
||||
isMrb = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isEcn) await GoToExternal($"{Configuration["OldFabApprovalUrl"]}/ECN/Edit?IssueID={issueId}", "");
|
||||
if (isCa) await GoToExternal($"{Configuration["OldFabApprovalUrl"]}/CorrectiveAction/Edit?IssueID={issueId}", "");
|
||||
if (isMrb) GoTo($"mrb/{issueId}");
|
||||
}
|
||||
|
||||
private void GoTo(string page) {
|
||||
cache.Set("redirectUrl", page);
|
||||
navigationManager.NavigateTo("/" + page);
|
||||
}
|
||||
|
||||
private async Task GoToExternal(string url, string content) {
|
||||
IJSObjectReference windowModule = await jsRuntime.InvokeAsync<IJSObjectReference>("import", "./js/OpenInNewWindow.js");
|
||||
await windowModule.InvokeAsync<object>("OpenInNewWindow", url, content);
|
||||
}
|
||||
|
||||
private bool FilterFuncForMRBTable(MRB mrb) => MRBFilterFunc(mrb, mrbSearchString);
|
||||
|
||||
private bool MRBFilterFunc(MRB mrb, string searchString) {
|
||||
if (string.IsNullOrWhiteSpace(searchString))
|
||||
return true;
|
||||
if (mrb.Title.ToLower().Contains(searchString.Trim().ToLower()))
|
||||
return true;
|
||||
if (mrb.MRBNumber.ToString().Contains(searchString.Trim()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user