diff options
Diffstat (limited to 'Pages/Component/AclDialog.razor')
| -rw-r--r-- | Pages/Component/AclDialog.razor | 97 |
1 files changed, 73 insertions, 24 deletions
diff --git a/Pages/Component/AclDialog.razor b/Pages/Component/AclDialog.razor index 7c3267d..6df9320 100644 --- a/Pages/Component/AclDialog.razor +++ b/Pages/Component/AclDialog.razor @@ -2,37 +2,81 @@ @inject IDbContextFactory<HBContext> dbFactory; @implements IDialog -<Dialog Title="Edit permissions" @ref=dialog> - @if(obj?.Acl is not null) { - <table class="data-table"> - <tr> - <th>Action</th> - <th>Subject</th> - <th>Permissions</th> - </tr> - @foreach(var rule in Object.Acl.Rules) { - <tr> - <td style="font-family:'lucida console';font-size:10pt;">@rule.Action.ToString()</td> - <td style="font-family:'lucida console';font-size:10pt;">@rule.Principal.ToString()</td> - <td style="font-family:'lucida console';font-size:10pt;">@GetActivePermissions(rule)</td> - </tr> - } - </table> - <ButtonContainer> - <button class="secondary" @onclick=Hide>Cancel</button> - </ButtonContainer> - } else { - <center><i>This item does not have any permissions set!</i></center> +<Dialog HeightPixels=500 WidthPixels=900 Title="Edit permissions" @ref=dialog> + <div class="vcontainer"> + <div class="hcontainer"> + <div> + @if(obj?.Acl is not null) { + <label> + Owner + <input type="text" autocomplete="off"/> + </label> + <table class="data-table"> + <tr> + <th>Action</th> + <th>Subject</th> + <th colspan="2">Permissions</th> + </tr> + @foreach(var rule in obj.Acl.Rules.OrderByDescending(r => r.Action)) { + <tr> + <td><div><AclActionSwitch InitialValue=@(rule.Action == AclRuleAction.Allow)/></div></td> + <td> + @(WellKnownSid.TranslateSid(rule.Principal) ?? rule.Principal.ToString()) + </td> + <td>@GetActivePermissions(rule)</td> + <td> + <a title="Edit" href="javascript:;">🖉</a> + <a title="Delete" href="javascript:;">✖</a> + </td> + </tr> + } + </table> + <br/> + <center><a href="javascript:;">Add new</a></center> + } else { + <p><i>This item does not have any permissions set!</i></p> + } + </div> + <div> + @if(obj?.Acl is not null) { + <div class="principal-select"> + <label> + Subject + <input type="text" autocomplete="off"/> + </label> + <button>Submit</button> + </div> + var permissions = Acl.GetPermissionDescriptions(obj) + .OrderByDescending(kv => BitOperations.PopCount(kv.Value)) + .ThenBy(kv => kv.Value); + foreach(var kv in permissions) { + <label> + <input type="checkbox"/> + @kv.Key + </label> + } + } else { + <p><i>Click Edit next to an ACL to edit it's permissions</i></p> + } + </div> + </div> <ButtonContainer> <button class="secondary" @onclick=Hide>Cancel</button> + @if(obj?.Acl is not null) { + <button data-keyboard-shortcut="a" @onclick=Hide><u>A</u>pply</button> + } </ButtonContainer> - } + </div> </Dialog> @code { public bool Visible { get => dialog.Visible; - set => dialog.Visible = value; + set { + dialog.Visible = value; + if(value) + StateHasChanged(); + } } private HBObject? obj; @@ -42,6 +86,11 @@ public void Show() => Visible = true; public void Hide() => Visible = false; + public void Show(HBObject obj) { + Object = obj; + Show(); + } + public HBObject? Object { get => obj; set { @@ -81,7 +130,7 @@ return string.Join(", ", perms .OrderByDescending(kv => BitOperations.PopCount(kv.Value)) - .ThenByDescending(kv => kv.Value) + .ThenBy(kv => kv.Value) .Select(kv => kv.Key)); } }
\ No newline at end of file |
