Enhance MeetingSchedule component to support student exclusion management
This commit introduces functionality in the MeetingSchedule feature to manage student exclusions during scheduling. The Index.razor component has been updated to include methods for saving and loading excluded students, as well as UI elements for toggling exclusions. Additionally, the TeamScheduler logic has been modified to account for excluded students when calculating overlaps and scheduling teams. These changes improve the flexibility and accuracy of the scheduling process, enhancing the overall user experience.
This commit is contained in:
@@ -147,6 +147,49 @@ public sealed class LocalStorageService
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a JSON-serialized object from localStorage.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type to deserialize to.</typeparam>
|
||||
/// <param name="key">The storage key.</param>
|
||||
/// <returns>The deserialized object or default value if not found.</returns>
|
||||
public async Task<T?> GetJsonAsync<T>(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
var json = await _jsRuntime.InvokeAsync<string?>("localStorage.getItem", key);
|
||||
if (!string.IsNullOrEmpty(json))
|
||||
{
|
||||
return JsonSerializer.Deserialize<T>(json);
|
||||
}
|
||||
return default;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to load JSON from localStorage [{Key}]", key);
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a JSON-serialized object in localStorage.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type to serialize.</typeparam>
|
||||
/// <param name="key">The storage key.</param>
|
||||
/// <param name="value">The object to store.</param>
|
||||
public async Task SetJsonAsync<T>(string key, T value)
|
||||
{
|
||||
try
|
||||
{
|
||||
var json = JsonSerializer.Serialize(value);
|
||||
await _jsRuntime.InvokeVoidAsync("localStorage.setItem", key, json);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Failed to save JSON to localStorage [{Key}]", key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all items from localStorage.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user