214 lines
8.0 KiB
Plaintext
214 lines
8.0 KiB
Plaintext
@page "/user/properties"
|
|
@using BlazorAnimation
|
|
@using TIAM.Core.Enums
|
|
@using TIAM.Entities.ServiceProviders
|
|
@using TIAM.Resources
|
|
@using TIAM.Services
|
|
@using TIAMSharedUI.Pages.User.SysAdmins
|
|
@using TIAMSharedUI.Shared
|
|
@using TIAMSharedUI.Shared.Components.BaseComponents
|
|
@using TIAMWebApp.Shared.Application.Interfaces
|
|
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
|
@using TIAMWebApp.Shared.Application.Utility
|
|
@using AyCode.Services.Loggers
|
|
@using TIAMWebApp.Shared.Application.Services
|
|
@using AyCode.Core.Helpers
|
|
@using TIAMSharedUI.Shared.Components.Grids
|
|
@using TIAMSharedUI.Pages.User.CardComponents
|
|
@inherits BasePageComponent
|
|
@layout AdminLayout
|
|
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
|
@inject IStringLocalizer<TIAMResources> localizer
|
|
@inject ISessionService SessionService
|
|
@inject IServiceProviderDataService ServiceProviderDataService
|
|
@inject AdminSignalRClient AdminSignalRClient;
|
|
<PageTitle>User permissions</PageTitle>
|
|
|
|
<div class="text-center m-5">
|
|
<h1>My companies</h1>
|
|
<h2 style="font-size:small">Manage your companies here!</h2>
|
|
</div>
|
|
|
|
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class=" col-12">
|
|
|
|
|
|
<DxTabs>
|
|
<DxTabPage Text="Cards">
|
|
|
|
<DxAccordion SizeMode="@SizeMode.Small" ExpandMode="ExpandMode"
|
|
ExpandCollapseAction="ExpandCollapseAction"
|
|
AnimationType="LayoutAnimationType.Slide">
|
|
<Items>
|
|
@foreach (var company in companies)
|
|
{
|
|
|
|
<DxAccordionItem CssClass="" Text=@($"{company.Name}")>
|
|
<ContentTemplate>
|
|
<div class="py-3 px-3">
|
|
<CompanyCardComponent DataChanged="RefreshComponent" Context="@company" />
|
|
</div>
|
|
</ContentTemplate>
|
|
</DxAccordionItem>
|
|
}
|
|
</Items>
|
|
</DxAccordion>
|
|
|
|
</DxTabPage>
|
|
<DxTabPage Text="Grid">
|
|
<CompanyGrid @ref="_gridCompany"
|
|
Logger="_logger"
|
|
SignalRClient="AdminSignalRClient"
|
|
ContextIds="_contextIds.Cast<object>().ToArray()"
|
|
GetAllMessageTag="SignalRTags.GetCompaniesByContextId"
|
|
PageSize="12"
|
|
ValidationEnabled="false"
|
|
DetailRowDisplayMode="GridDetailRowDisplayMode.Auto"
|
|
CustomizeEditModel="Grid_CustomizeEditModel"
|
|
EditMode="GridEditMode.EditRow">
|
|
<Columns>
|
|
<DxGridCommandColumn Width="160px" />
|
|
<DxGridDataColumn FieldName="Id" Visible="false" MinWidth="130" />
|
|
<DxGridDataColumn FieldName="Name" MinWidth="80" />
|
|
<DxGridDataColumn FieldName="AffiliateId" MinWidth="80" />
|
|
<DxGridDataColumn FieldName="Id" Width="130">
|
|
<CellDisplayTemplate>
|
|
<a class="btn btn-primary" href="user/serviceprovider/@context.Value.ToString()">Manage</a>
|
|
</CellDisplayTemplate>
|
|
</DxGridDataColumn>
|
|
<DxGridDataColumn Caption="Address" FieldName="Profile.Address.AddressText" Width="280" />
|
|
|
|
</Columns>
|
|
<DetailRowTemplate>
|
|
@{
|
|
<p>Address: @(((Company)context.DataItem).Profile.Address.AddressText)</p>
|
|
}
|
|
|
|
<DxTabs>
|
|
<DxTabPage Text="Products">
|
|
<ProductDetailGridComponent ShowManageButtons="true" DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" ParentData="(Company)context.DataItem" ContextId="((Company)context.DataItem).Id" />
|
|
</DxTabPage>
|
|
|
|
</DxTabs>
|
|
|
|
</DetailRowTemplate>
|
|
</CompanyGrid>
|
|
</DxTabPage>
|
|
</DxTabs>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@code {
|
|
|
|
AccordionExpandMode ExpandMode { get; set; } = AccordionExpandMode.SingleOrNone;
|
|
AccordionExpandCollapseAction ExpandCollapseAction { get; set; } = AccordionExpandCollapseAction.HeaderClick;
|
|
private LoggerClient<MyServiceProviders> _logger = null!;
|
|
|
|
private CompanyGrid _gridCompany = null!;
|
|
private List<Company> companies = [];
|
|
public List<Company> Companies = [];
|
|
public ServiceProviderWizardModel MyModel = new ServiceProviderWizardModel();
|
|
|
|
bool EulaAccepted { get; set; }
|
|
bool EulaVisible { get; set; }
|
|
|
|
private Guid[] _contextIds = new Guid[0];
|
|
|
|
void CancelCreateClick()
|
|
{
|
|
EulaVisible = false;
|
|
}
|
|
void EulaPopupClosed()
|
|
{
|
|
EulaAccepted = false;
|
|
|
|
}
|
|
void EulaPopupClosing(PopupClosingEventArgs args)
|
|
{
|
|
MyModel = new ServiceProviderWizardModel();
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------------
|
|
|
|
|
|
public void SubmitForm(object result)
|
|
{
|
|
//await WizardProcessor.ProcessWizardAsync(Result.GetType(), Result);
|
|
_logger.Info($"Submitted nested form: {result.GetType().FullName}");
|
|
}
|
|
|
|
|
|
void Grid_CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
|
{
|
|
if (e.IsNew)
|
|
{
|
|
var newEmployee = (Company)e.EditModel;
|
|
newEmployee.Name = "Add a company name";
|
|
newEmployee.OwnerId = SessionService.User!.UserId;
|
|
newEmployee.AffiliateId = Guid.NewGuid();
|
|
}
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await base.OnInitializedAsync();
|
|
_logger = new LoggerClient<MyServiceProviders>(LogWriters.ToArray());
|
|
var myId = SessionService.User!.UserId;
|
|
|
|
_logger.Debug(companies.Count.ToString());
|
|
_contextIds = new Guid[1];
|
|
_contextIds[0] = myId;
|
|
var result = await AdminSignalRClient.GetByIdAsync<List<Company>>(SignalRTags.GetCompaniesByContextId, myId);
|
|
//await AdminSignalRClient.GetAllIntoAsync<Company>(Companies, SignalRTags.GetCompaniesByContextId, new object[] { myId });
|
|
companies = result;
|
|
// ServiceProviderDataService.GetPropertiesByOwnerIdAsync(myId, companyPropertiesByOwner =>
|
|
// {
|
|
// _logger.DetailConditional($"companyPropertiesByOwner count: {companyPropertiesByOwner?.Count.ToString() ?? "NULL"}");
|
|
// }).Forget();
|
|
|
|
|
|
}
|
|
|
|
void ColumnChooserButton_Click()
|
|
{
|
|
_gridCompany.ShowColumnChooser();
|
|
}
|
|
|
|
string GetCustomColor(ProductType productType)
|
|
{
|
|
|
|
var transferStatusByte = (byte)productType;
|
|
|
|
switch (transferStatusByte)
|
|
{
|
|
case 5:
|
|
return "bg-important";
|
|
|
|
case > 5 and < 35:
|
|
return "bg-attention";
|
|
|
|
case 35:
|
|
return "bg-finished";
|
|
|
|
case > 35:
|
|
return "bg-cancel";
|
|
|
|
default:
|
|
return "";
|
|
}
|
|
|
|
}
|
|
|
|
private void RefreshComponent()
|
|
{
|
|
StateHasChanged();
|
|
}
|
|
}
|