157 lines
7.6 KiB
Plaintext
157 lines
7.6 KiB
Plaintext
@page "/securitygroups"
|
|
@using UserService.Infrastructure.DataModels
|
|
@inherits SecurityGroupsBase
|
|
|
|
<h1>Table of all security groups</h1>
|
|
|
|
@if (Members is null)
|
|
{
|
|
<p>
|
|
<em>Loading...</em>
|
|
</p>
|
|
}
|
|
else
|
|
{
|
|
<TextEdit Placeholder="Search" Size="Size.Large" @bind-Text="@CustomFilterValue" />
|
|
<DataGrid
|
|
TItem="SecurityGroup"
|
|
RowSelectable="@(u => false)"
|
|
CustomFilter="@OnCustomFilter"
|
|
Sortable="true"
|
|
Editable="true"
|
|
EditMode="DataGridEditMode.Inline"
|
|
RowRemoving="RowDeletingCallback"
|
|
Data="@Members"
|
|
RowInserted="RowInsertedCallback"
|
|
RowInserting="RowInsertingCallback"
|
|
RowUpdating="RowUpdatingCallback">
|
|
<DataGridCommandColumn TItem="SecurityGroup">
|
|
<NewCommandTemplate>
|
|
<Button Color="Color.Success" Clicked="@context.Clicked" title="Create security group">
|
|
<i class="fas fa-users"></i>
|
|
</Button>
|
|
</NewCommandTemplate>
|
|
<EditCommandTemplate>
|
|
<Button Color="Color.Primary" Clicked="@context.Clicked" title="Edit security group">
|
|
<i class="fa fa-user-edit"></i>
|
|
</Button>
|
|
</EditCommandTemplate>
|
|
<DeleteCommandTemplate>
|
|
<Button Color="Color.Danger" Clicked="@context.Clicked" title="Delete security group">
|
|
<i class="fa fa-user-minus"></i>
|
|
</Button>
|
|
</DeleteCommandTemplate>
|
|
<SaveCommandTemplate>
|
|
<Button Color="Color.Success" Clicked="@context.Clicked" title="Save security group">
|
|
<i class="fas fa-save"></i>
|
|
</Button>
|
|
</SaveCommandTemplate>
|
|
<CancelCommandTemplate>
|
|
<Button Color="Color.Secondary" Clicked="@context.Clicked" title="Cancel editing">
|
|
<i class="far fa-times-circle"></i>
|
|
</Button>
|
|
</CancelCommandTemplate>
|
|
</DataGridCommandColumn>
|
|
<DataGridColumn TItem="SecurityGroup" Field="@nameof(SecurityGroup.Id)" Caption="#" Sortable="false" />
|
|
|
|
<DataGridColumn TItem="SecurityGroup" Field="@nameof(SecurityGroup.CommonName)" Caption="CN" CellsEditableOnEditCommand="false" Editable="true">
|
|
<EditTemplate>
|
|
<Validation Validator="@ValidateCommonName">
|
|
<TextEdit Placeholder="Enter common name" Text="@((string)(((CellEditContext)context).CellValue))" TextChanged="@(v=>((CellEditContext)context).CellValue=v)">
|
|
<Feedback>
|
|
<ValidationSuccess></ValidationSuccess>
|
|
<ValidationError>Please enter a valid common name!</ValidationError>
|
|
</Feedback>
|
|
</TextEdit>
|
|
</Validation>
|
|
</EditTemplate>
|
|
</DataGridColumn>
|
|
<DataGridSelectColumn TItem="SecurityGroup" Field="@nameof(SecurityGroup.ParentId)" Caption="Parent" Editable="true">
|
|
<DisplayTemplate>
|
|
@{
|
|
var name = ((SecurityGroup) context ).Parent?.CommonName ?? "-";
|
|
@name
|
|
}
|
|
</DisplayTemplate>
|
|
<EditTemplate>
|
|
<Select TValue="Guid?" SelectedValue="@((Guid?)(context.CellValue))" SelectedValueChanged="@(v => context.CellValue = v)" >
|
|
@foreach (var item in OrganizationUnits ?? Enumerable.Empty<OrganizationUnit>())
|
|
{
|
|
<SelectItem TValue="Guid" Value="@(item.Id)">@item.CommonName</SelectItem>
|
|
}
|
|
</Select>
|
|
</EditTemplate>
|
|
</DataGridSelectColumn>
|
|
<DataGridColumn TItem="SecurityGroup" Field="@nameof(SecurityGroup.Members)" Caption="Members" Editable="false">
|
|
<DisplayTemplate>
|
|
<Button Color="Color.Success" Block="true" Clicked="@(() => OnButtonClicked((SecurityGroup) context ))">Edit</Button>
|
|
</DisplayTemplate>
|
|
</DataGridColumn>
|
|
</DataGrid>
|
|
|
|
<Modal @ref="ModalRef">
|
|
<ModalBackdrop/>
|
|
<ModalContent IsCentered="true">
|
|
@if (SelectedSecurityGroup != null)
|
|
{
|
|
<ModalHeader>
|
|
<ModalTitle>Members of @SelectedSecurityGroup.CommonName group</ModalTitle>
|
|
<CloseButton Clicked="@(async () => await HideModalAsync(false))"/>
|
|
</ModalHeader>
|
|
<ModalBody>
|
|
<Row>
|
|
<Column ColumnSize="ColumnSize.Is12">
|
|
<Addons >
|
|
<Addon AddonType="AddonType.Start">
|
|
<AddonLabel>@@</AddonLabel>
|
|
</Addon>
|
|
<Addon AddonType="AddonType.Body">
|
|
<Autocomplete Data="@AvailableMembers" TItem="Member"
|
|
TextField="@((item) => item.CommonName)"
|
|
ValueField="@((item) => item)"
|
|
SearchChanged="@OnSearchChanged"
|
|
Placeholder="Username"
|
|
SelectedValueChanged="@MySearchHandler"
|
|
SelectedValue="@SelectedMember" />
|
|
</Addon>
|
|
<Addon AddonType="AddonType.End">
|
|
<Button Clicked="@AddToListAsync" Color="Color.Primary">Ok</Button>
|
|
</Addon>
|
|
</Addons>
|
|
</Column>
|
|
</Row>
|
|
<Row>
|
|
<Column ColumnSize="ColumnSize.Is12">
|
|
<Table Narrow="true" FullWidth="true">
|
|
<TableHeader>
|
|
<TableRow>
|
|
<TableHeaderCell>#</TableHeaderCell>
|
|
<TableHeaderCell>Common Name</TableHeaderCell>
|
|
<TableHeaderCell></TableHeaderCell>
|
|
</TableRow>
|
|
</TableHeader>
|
|
<TableBody>
|
|
@foreach (var member in SelectedSecurityGroup?.Members ?? Enumerable.Empty<MembersMember>())
|
|
{
|
|
<TableRow>
|
|
<TableRowHeader>@member.MemberId</TableRowHeader>
|
|
<TableRowCell>@member.AttachedMember?.CommonName</TableRowCell>
|
|
<TableRowCell>
|
|
<Button Color="Color.Danger">Delete</Button>
|
|
</TableRowCell>
|
|
</TableRow>
|
|
}
|
|
</TableBody>
|
|
</Table>
|
|
</Column>
|
|
</Row>
|
|
|
|
</ModalBody>
|
|
<ModalFooter>
|
|
<Button Color="Color.Primary" Clicked="@(async () => await HideModalAsync(true))">OK</Button>
|
|
<Button Color="Color.Primary" Clicked="@(async () => await HideModalAsync(false))">Cancel</Button>
|
|
</ModalFooter>
|
|
}
|
|
</ModalContent>
|
|
</Modal>
|
|
} |