Integrate TeamMeetingHistoryService into Calendar component for enhanced meeting management
This commit updates the Calendar component to include the ITeamMeetingHistoryService, allowing for the loading and display of meeting histories alongside event occurrences. The calendar items are now wrapped in CalendarItemWrapper to accommodate both events and meetings. Additionally, error handling and logging are implemented to ensure robustness during the loading process. This enhancement improves the overall functionality and user experience of the calendar feature by providing a comprehensive view of both events and meetings.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
@using WebApp.Authentication
|
||||
@using Core.Utility
|
||||
@inject IEventOccurrenceService EventOccurrenceService
|
||||
@inject ITeamMeetingHistoryService TeamMeetingHistoryService
|
||||
@inject ILogger<Index> Logger
|
||||
@inject IDialogService DialogService
|
||||
|
||||
@@ -44,7 +45,7 @@
|
||||
</MudButton>
|
||||
</MudButtonGroup>
|
||||
|
||||
<MudCalendar T="CalendarEventItem"
|
||||
<MudCalendar T="CalendarItemWrapper"
|
||||
Items="_calendarItems"
|
||||
View="_currentView"
|
||||
CurrentDay="@_calendarDate"
|
||||
@@ -76,7 +77,7 @@
|
||||
</MudPaper>
|
||||
|
||||
@code {
|
||||
private List<CalendarEventItem>? _calendarItems;
|
||||
private List<CalendarItemWrapper>? _calendarItems;
|
||||
private DateTime _calendarDate = DateTime.Today;
|
||||
private CalendarView _currentView = CalendarView.Month;
|
||||
|
||||
@@ -105,7 +106,9 @@
|
||||
// Load teams for all event definitions
|
||||
var teamsByEventId = await EventOccurrenceService.GetTeamsByEventDefinitionIdsAsync(eventDefinitionIds);
|
||||
|
||||
List<CalendarEventItem> items = [];
|
||||
List<CalendarItemWrapper> items = [];
|
||||
|
||||
// Add event occurrences
|
||||
foreach (var occ in eventOccurrences)
|
||||
{
|
||||
try
|
||||
@@ -127,8 +130,8 @@
|
||||
})
|
||||
: [];
|
||||
|
||||
var calendarItem = new CalendarEventItem(occ, studentFirstNames);
|
||||
items.Add(calendarItem);
|
||||
var calendarEventItem = new CalendarEventItem(occ, studentFirstNames);
|
||||
items.Add(new CalendarItemWrapper(calendarEventItem));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -138,8 +141,37 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Load and add meeting histories
|
||||
try
|
||||
{
|
||||
Logger.LogInformation("Loading meeting histories");
|
||||
var meetingHistories = await TeamMeetingHistoryService.GetMeetingHistoriesAsync();
|
||||
|
||||
foreach (var meetingHistory in meetingHistories)
|
||||
{
|
||||
try
|
||||
{
|
||||
var calendarMeetingItem = new CalendarMeetingItem(meetingHistory);
|
||||
items.Add(new CalendarItemWrapper(calendarMeetingItem));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error creating CalendarMeetingItem for meeting history Id={Id}, Date={Date}",
|
||||
meetingHistory?.Id, meetingHistory?.MeetingDate);
|
||||
// Continue processing other items
|
||||
}
|
||||
}
|
||||
|
||||
Logger.LogInformation("Added {Count} meeting histories to calendar", meetingHistories.Count());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error loading meeting histories");
|
||||
// Continue - don't fail the entire calendar load if meetings fail
|
||||
}
|
||||
|
||||
_calendarItems = items;
|
||||
Logger.LogInformation("Created {Count} calendar items from {OccurrenceCount} occurrences",
|
||||
Logger.LogInformation("Created {Count} calendar items from {OccurrenceCount} occurrences and meetings",
|
||||
_calendarItems.Count, eventOccurrences.Count());
|
||||
|
||||
// Find the next date with events
|
||||
@@ -168,7 +200,7 @@
|
||||
}
|
||||
|
||||
var today = DateTime.Today;
|
||||
var nextEvent = _calendarItems
|
||||
var nextItem = _calendarItems
|
||||
.Where(item =>
|
||||
{
|
||||
try
|
||||
@@ -184,17 +216,17 @@
|
||||
.OrderBy(item => item.Start)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (nextEvent != null)
|
||||
if (nextItem != null)
|
||||
{
|
||||
return nextEvent.Start.Date;
|
||||
return nextItem.Start.Date;
|
||||
}
|
||||
|
||||
// Fallback to first event if no future events
|
||||
var firstEvent = _calendarItems
|
||||
// Fallback to first item if no future items
|
||||
var firstItem = _calendarItems
|
||||
.OrderBy(item => item.Start)
|
||||
.FirstOrDefault();
|
||||
|
||||
return firstEvent != null ? firstEvent.Start.Date : DateTime.Today;
|
||||
return firstItem != null ? firstItem.Start.Date : DateTime.Today;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -235,12 +267,19 @@
|
||||
return string.Join("\n", parts);
|
||||
}
|
||||
|
||||
private async Task OnItemClicked(CalendarEventItem calendarEventItem)
|
||||
private async Task OnItemClicked(CalendarItemWrapper wrapper)
|
||||
{
|
||||
if (_calendarItems == null)
|
||||
return;
|
||||
|
||||
await ShowEventDetails(calendarEventItem);
|
||||
if (wrapper.ItemType == CalendarItemType.Event && wrapper.EventItem != null)
|
||||
{
|
||||
await ShowEventDetails(wrapper.EventItem);
|
||||
}
|
||||
else if (wrapper.ItemType == CalendarItemType.Meeting && wrapper.MeetingItem != null)
|
||||
{
|
||||
await ShowMeetingDetails(wrapper.MeetingItem);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ShowEventDetails(CalendarEventItem item)
|
||||
@@ -264,5 +303,25 @@
|
||||
|
||||
await DialogService.ShowAsync<EventOccurrenceDetailsDialog>("Event Details", parameters, options);
|
||||
}
|
||||
|
||||
private async Task ShowMeetingDetails(CalendarMeetingItem item)
|
||||
{
|
||||
if (item.MeetingHistoryData == null) return;
|
||||
|
||||
var parameters = new DialogParameters
|
||||
{
|
||||
["MeetingHistoryId"] = item.MeetingHistoryData.Id
|
||||
};
|
||||
|
||||
var options = new DialogOptions
|
||||
{
|
||||
CloseOnEscapeKey = true,
|
||||
CloseButton = true,
|
||||
MaxWidth = MaxWidth.Large,
|
||||
FullWidth = true
|
||||
};
|
||||
|
||||
await DialogService.ShowAsync<MeetingHistoryDetailDialog>("Meeting Details", parameters, options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user