Skip to content

Commit

Permalink
Merge pull request #451 from Blazam-App/Stable-Dev-Common-Code
Browse files Browse the repository at this point in the history
Self Notification Subscription Management
  • Loading branch information
jacobsen9026 authored Jul 27, 2024
2 parents 542d27f + 970ad0f commit a854a23
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 39 deletions.
9 changes: 9 additions & 0 deletions BLAZAMGui/Layouts/AppUserButton.razor
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<MudMenuItem OnClick="@(()=>{profileModal?.Show();})" Icon="@Icons.Material.Filled.Settings">
@AppLocalization["Profile Settings"]
</MudMenuItem>
<MudMenuItem OnClick="@(()=>{notificationsModal?.Show();})" Icon="@Icons.Material.Filled.Notifications">
@AppLocalization["Notification Settings"]
</MudMenuItem>
<MudMenuItem Href="https://docs.blazam.org" Target="_blank" Icon="@Icons.Material.Filled.Book">
@AppLocalization["Documentation"]
</MudMenuItem>
Expand All @@ -58,8 +61,14 @@
<AppUserProfileModalContent />
</CascadingValue>
</AppModal>
<AppModal @ref=notificationsModal Title="Notification Settings" Options="new(){ CloseButton=true, MaxWidth=MaxWidth.ExtraLarge,FullWidth=true}">
<CascadingValue Value="mainLayout">
<NotificaionSubscriptionEditor User="UserState.Preferences"/>
</CascadingValue>
</AppModal>
@code {
AppModal? profileModal;
AppModal? notificationsModal;
/// <summary>
/// Indicates whether the notification panel is open
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

@inject IStringLocalizer<AppLocalization> AppLocalization
<tr>
@foreach (var type in Enum.GetValues(typeof(NotificationType)))
{
Expand All @@ -11,7 +11,6 @@
ValueChanged=@((bool val)=>{ToggleType(originalEnum,val);})
Value="@(Subscription.NotificationTypes.FirstOrDefault(x=>x.NotificationType==originalEnum)!=null)" />


</td>
}
<td>
Expand All @@ -29,9 +28,13 @@
@if (Subscription.Id == 0)
{
<td colspan="2">
<MudFab Color=@Color.Tertiary
StartIcon="@Icons.Material.Filled.Add"
OnClick="@(AddSubscription)" />
<MudButton Color=@Color.Tertiary
Disabled=@((!Subscription.ByEmail&&!Subscription.InApp)||Subscription.NotificationTypes.Count==0)
Style="align-items:center;"
StartIcon="@Icons.Material.Filled.Add"
OnClick="@(AddSubscription)">
@AppLocalization["Create"]
</MudButton>
</td>
}
else
Expand All @@ -40,10 +43,12 @@
<td>
<MudFab Color=@Color.Success
OnClick="@(OnSaved)"
Size="Size.Small"
StartIcon="@Icons.Material.Filled.Save" />
</td>
<td>
<MudFab Color=@Color.Error
Size="Size.Small"
OnClick="@(()=>{OnDeleted.InvokeAsync(Subscription);})"
StartIcon="@Icons.Material.Filled.Delete" />
</td>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<MudCard>
<MudStack Row=true>
<OUTreeView SelectedEntry=_selectedOU
SelectedEntryChanged="ouChanged" />
<MudContainer>
@if (_selectedOU != null)
{
<OUNotificationSubscriptions User="@User"
OU=@_selectedOU />


}
</MudContainer>
</MudStack>
</MudCard>

@code{
[Parameter]
public AppUser User {get;set;}

IDirectoryEntryAdapter? _selectedOU = null;


private async void ouChanged(IDirectoryEntryAdapter entry)
{
var ou = (IADOrganizationalUnit)entry;
if (ou != null)
{
_selectedOU = ou;
await InvokeAsync(StateHasChanged);
}
}

}
29 changes: 3 additions & 26 deletions BLAZAMGui/UI/Settings/Notifications/NotificationSettings.razor
Original file line number Diff line number Diff line change
@@ -1,30 +1,15 @@
@inherits AppComponentBase
<h3>@AppLocalization["Managee Notifications"]</h3>
<h3>@AppLocalization["Manage Notifications"]</h3>
<MudAutocomplete @bind-Value=_selectedUser
MaxItems="50"
SearchFunc="SearchUsers"
T="AppUser"
Label="@AppLocalization["User"]" />
@if (_selectedUser != null)
{
<MudCard>
<MudStack Row=true>
<OUTreeView SelectedEntry=_selectedOU
SelectedEntryChanged="ouChanged" />
<MudContainer>
@if (_selectedOU != null)
{
<OUNotificationSubscriptions User="@_selectedUser"
OU=@_selectedOU />


}
</MudContainer>
</MudStack>
</MudCard>
<NotificaionSubscriptionEditor User=_selectedUser/>
}
@code {
IDirectoryEntryAdapter? _selectedOU = null;
IList<AppUser> Users = new List<AppUser>();
AppUser? _selectedUser = null;
protected override async Task OnInitializedAsync()
Expand All @@ -37,15 +22,7 @@
if (value == null) value = String.Empty;
return Users.Where(x => x.Username.Contains(value));
}
private async void ouChanged(IDirectoryEntryAdapter entry)
{
var ou = (IADOrganizationalUnit)entry;
if (ou != null)
{
_selectedOU = ou;
await InvokeAsync(StateHasChanged);
}
}




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,52 @@
@inject OUNotificationService ouNotificationService
<MudSimpleTable>

<tr>
<th colspan="10" class="mb-6">
<MudText Typo="Typo.h5" Class="pb-6">@(AppLocalization["Notification Settings for "]+_ou.CanonicalName)</MudText>

</th>

</tr>
<tr>

<th style="border-left:solid;border-right:solid;" colspan="5">
@AppLocalization["Events"]
</th>
<th style="border-right:solid;" colspan="2">
@AppLocalization["Delivery"]
</th>
<th style="border-right:solid;">
@AppLocalization[" "]
</th>
<th colpan="2">
@AppLocalization[" "]
</th>
</tr>
<tr>


@{
bool first = true;
}
@foreach (var type in Enum.GetValues(typeof(NotificationType)))
{
var originalEnum = (NotificationType)type;
<th class="align-self-center">
<th style="@(first==true?"border-left:solid;":"")" class="align-self-center">
@originalEnum.ToString()
</th>
first=false;

}
<th>
<th style="border-left:solid;">
@AppLocalization["In App"]
</th>
<th>
@AppLocalization["To Email"]
</th>
<th>
<th style="border-left:solid;">
@AppLocalization["Block"]
</th>
<th>
<th style="border-left:solid;">
@AppLocalization["Save"]
</th>
<th>
Expand All @@ -37,10 +61,24 @@
<EditNotificationSubscriptionRow Subscription="sub"
Context="Context"
OnSaved="SaveExisting"
OnDeleted="DeleteExisting" />
OnDeleted="DeleteExisting" />

}
}
else
{

<tr>
<td colspan="10">
<MudText Align="Align.Center" Class="py-5">@AppLocalization["No subscriptions are set for this OU"]</MudText>
</td>
</tr>
}
<tr>
<td colspan="10">
<MudDivider Class="my-3"/>
</td>
</tr>
<EditNotificationSubscriptionRow @bind-Subscription="newSubscription"
Context="Context"
OnAdded="AddSubscription" />
Expand All @@ -50,10 +88,16 @@
</MudSimpleTable>

<MudSimpleTable>

<tr>
<th colspan="10">
@AppLocalization["Effective Notification Settings"]
<MudDivider Class="my-10"/>
</th>

</tr>
<tr>
<th colspan="10" class="mb-6">
<MudText Typo="Typo.h5" Class="pb-6">@(AppLocalization["Effective Notification Settings for "]+_ou.CanonicalName)</MudText>

</th>

</tr>
Expand Down

0 comments on commit a854a23

Please sign in to comment.