mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
started merging module and calendar pages
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
@page "/calendar"
|
||||
@using CanvasModel.EnrollmentTerms
|
||||
@using Management.Web.Shared.Module
|
||||
@using Management.Web.Shared.Semester
|
||||
|
||||
@inject IConfigurationManagement configurationManagement
|
||||
@@ -10,17 +11,26 @@
|
||||
private SemesterPlanner? semester { get; set; }
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (configurationManagement.Configuration != null)
|
||||
semester = new SemesterPlanner(configurationManagement.Configuration);
|
||||
if (configurationManagement.SemesterCalendar != null)
|
||||
semester = new SemesterPlanner(configurationManagement.SemesterCalendar);
|
||||
}
|
||||
|
||||
}
|
||||
<br>
|
||||
@if (semester != null)
|
||||
{
|
||||
@foreach (var month in semester.Months)
|
||||
{
|
||||
<MonthDetail Month="month" Semester="semester" />
|
||||
<hr />
|
||||
}
|
||||
}
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
|
||||
@if (semester != null)
|
||||
{
|
||||
@foreach (var month in semester.Months)
|
||||
{
|
||||
<MonthDetail Month="month" Semester="semester" />
|
||||
<hr />
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<div class="col">
|
||||
<Modules />
|
||||
</div>
|
||||
</div>
|
||||
@@ -5,10 +5,13 @@
|
||||
|
||||
@inject ICanvasService canvasService
|
||||
@inject IConfigurationManagement configurationManagement
|
||||
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||
@inject ProtectedLocalStorage BrowserStorage
|
||||
|
||||
|
||||
|
||||
@code
|
||||
{
|
||||
private string semesterConfigurationKey = "semesterCalendarConfiguration";
|
||||
private IEnumerable<EnrollmentTermModel>? terms { get; set; } = null;
|
||||
private ulong? selectedTermId { get; set; }
|
||||
private EnrollmentTermModel? selectedTerm
|
||||
@@ -25,12 +28,27 @@
|
||||
readDaysFromConfig();
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if(firstRender)
|
||||
{
|
||||
var storedConfiguration = await BrowserStorage.GetAsync<SemesterCalendarConfig>(semesterConfigurationKey);
|
||||
if (storedConfiguration.Success) {
|
||||
Console.WriteLine(JsonSerializer.Serialize(storedConfiguration.Value));
|
||||
configurationManagement.SemesterCalendar = storedConfiguration.Value;
|
||||
} else {
|
||||
Console.WriteLine("no stored configuration");
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void readTermFromConfig()
|
||||
{
|
||||
if (terms == null || configurationManagement.Configuration == null) return;
|
||||
if (terms == null || configurationManagement.SemesterCalendar == null) return;
|
||||
foreach (var term in terms)
|
||||
{
|
||||
var termInConfiguration = configurationManagement.Configuration.StartDate == term.StartAt;
|
||||
var termInConfiguration = configurationManagement.SemesterCalendar.StartDate == term.StartAt;
|
||||
if (termInConfiguration)
|
||||
{
|
||||
selectedTermId = term.Id;
|
||||
@@ -40,17 +58,24 @@
|
||||
|
||||
private void readDaysFromConfig()
|
||||
{
|
||||
if (terms == null || configurationManagement.Configuration == null) return;
|
||||
if (terms == null || configurationManagement.SemesterCalendar == null) return;
|
||||
|
||||
days = configurationManagement.Configuration.Days.ToList();
|
||||
days = configurationManagement.SemesterCalendar.Days.ToList();
|
||||
}
|
||||
|
||||
|
||||
public async void HandleSave()
|
||||
{
|
||||
saved = true;
|
||||
configurationManagement.SetConfiguration(selectedTerm, days.ToArray());
|
||||
await ProtectedSessionStore.SetAsync("configuration", configurationManagement.Configuration);
|
||||
configurationManagement.SetConfiguration(
|
||||
selectedTerm ?? throw new Exception("cannot save configuration without selecting term"),
|
||||
days.ToArray()
|
||||
);
|
||||
await BrowserStorage.SetAsync(
|
||||
semesterConfigurationKey,
|
||||
configurationManagement.SemesterCalendar ?? throw new Exception("Semester Calendar configuration not properly configured")
|
||||
);
|
||||
|
||||
Console.WriteLine(JsonSerializer.Serialize(await BrowserStorage.GetAsync<SemesterCalendarConfig>(semesterConfigurationKey)));
|
||||
}
|
||||
}
|
||||
<PageTitle>Index</PageTitle>
|
||||
@@ -61,7 +86,7 @@
|
||||
<div class="col-auto">
|
||||
|
||||
<form>
|
||||
<lablel for="termselect">Select Term:</lablel>
|
||||
<label for="termselect">Select Term:</label>
|
||||
<select id="termselect" class="form-select" @bind="selectedTermId">
|
||||
@foreach (var term in terms)
|
||||
{
|
||||
@@ -103,7 +128,7 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (configurationManagement.Configuration is not null)
|
||||
@if (configurationManagement.SemesterCalendar is not null)
|
||||
{
|
||||
<div>Config complete</div>
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
@page "/modules"
|
||||
@using Management.Web.Shared.Module
|
||||
@using System.Linq
|
||||
@inject IModuleManager moduleManager
|
||||
|
||||
@code {
|
||||
private bool showNewModule { get; set; } = false;
|
||||
|
||||
}
|
||||
|
||||
<PageTitle>Weather forecast</PageTitle>
|
||||
|
||||
@if (!showNewModule)
|
||||
{
|
||||
<button class="btn btn-secondary" @onclick="() => showNewModule = true">New Module</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-secondary" @onclick="() => showNewModule = false">Hide New Module</button>
|
||||
}
|
||||
|
||||
@if (showNewModule)
|
||||
{
|
||||
<NewModule OnSubmit="() => showNewModule = false" />
|
||||
}
|
||||
|
||||
@foreach (var i in moduleManager.Modules.Select((_value, i) => i))
|
||||
{
|
||||
<hr>
|
||||
<ModuleDetail ModuleIndex="i" />
|
||||
}
|
||||
@@ -25,16 +25,27 @@
|
||||
@if (showAddAssignment)
|
||||
{
|
||||
<div class="ms-5 ">
|
||||
<div class="bg-light border rounded m-3 p-3">
|
||||
<NewAssignment ModuleIndex="ModuleIndex" OnSubmit="() => showAddAssignment = false" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-light border rounded m-3 p-3">
|
||||
<NewAssignment ModuleIndex="ModuleIndex" OnSubmit="() => showAddAssignment = false" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<h5>Assignments</h5>
|
||||
<div class="row">
|
||||
|
||||
@foreach (var assignment in module.Assignments)
|
||||
{
|
||||
<div>@assignment.name</div>
|
||||
<div class="col-2">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="card-title">
|
||||
@assignment.name
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
}
|
||||
60
Management.Web/Shared/Module/Modules.razor
Normal file
60
Management.Web/Shared/Module/Modules.razor
Normal file
@@ -0,0 +1,60 @@
|
||||
@using Management.Web.Shared.Module
|
||||
@using System.Linq
|
||||
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||
|
||||
@inject IModuleManager moduleManager
|
||||
@inject ProtectedLocalStorage BrowserStorage
|
||||
|
||||
@code {
|
||||
private bool showNewModule { get; set; } = false;
|
||||
private string moduleStorageKey = "module storage key";
|
||||
|
||||
private async Task Save()
|
||||
{
|
||||
await BrowserStorage.SetAsync(moduleStorageKey, moduleManager.Modules);
|
||||
|
||||
}
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if(firstRender)
|
||||
{
|
||||
var storedModules = await BrowserStorage.GetAsync<IEnumerable<CourseModule>>(moduleStorageKey);
|
||||
if (storedModules.Success) {
|
||||
moduleManager.Modules = storedModules.Value ?? throw new Exception("stored modules was null, it shouldn't have been");
|
||||
} else {
|
||||
Console.WriteLine("no stored modules");
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@if (!showNewModule)
|
||||
{
|
||||
<button class="btn btn-secondary" @onclick="() => showNewModule = true">New Module</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-secondary" @onclick="() => showNewModule = false">Hide New Module</button>
|
||||
}
|
||||
|
||||
@if (showNewModule)
|
||||
{
|
||||
<NewModule OnSubmit="() => showNewModule = false" />
|
||||
}
|
||||
|
||||
@foreach (var i in moduleManager.Modules.Select((_value, i) => i))
|
||||
{
|
||||
<hr>
|
||||
<ModuleDetail ModuleIndex="i" />
|
||||
}
|
||||
|
||||
<hr>
|
||||
<div class="text-center">
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
@onclick="Save"
|
||||
>
|
||||
Save Modules
|
||||
</button>
|
||||
</div>
|
||||
@@ -14,11 +14,6 @@
|
||||
<span class="oi oi-home" aria-hidden="true"></span> Home
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="/modules">
|
||||
<span class="oi oi-list-rich" aria-hidden="true"></span> Module Management
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="/calendar">
|
||||
<span class="oi oi-plus" aria-hidden="true"></span> Calendar
|
||||
|
||||
Reference in New Issue
Block a user