mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
better class day highlighting
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
namespace Management.Web.Data;
|
||||
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
namespace Management.Web.Data;
|
||||
|
||||
public class WeatherForecastService
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
public Task<WeatherForecast[]> GetForecastAsync(DateOnly startDate)
|
||||
{
|
||||
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = startDate.AddDays(index),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
}).ToArray());
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,17 @@
|
||||
@page "/calendar"
|
||||
@using CanvasModel.EnrollmentTerms
|
||||
@using Management.Web.Shared.Semester
|
||||
|
||||
@inject IConfigurationManagement configurationManagement
|
||||
|
||||
@code
|
||||
{
|
||||
[Parameter, EditorRequired]
|
||||
public SemesterConfiguration Configuration { get; set; } = default!;
|
||||
|
||||
private SemesterPlanner? semester { get; set; }
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
semester = new SemesterPlanner(Configuration);
|
||||
if (configurationManagement.Configuration != null)
|
||||
semester = new SemesterPlanner(configurationManagement.Configuration);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,25 +1,57 @@
|
||||
@page "/"
|
||||
@using CanvasModel.EnrollmentTerms
|
||||
@using Management.Web.Shared.Semester
|
||||
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
|
||||
|
||||
@inject ICanvasService canvasService
|
||||
@inject IConfigurationManagement configurationManagement
|
||||
@inject ProtectedSessionStorage ProtectedSessionStore
|
||||
|
||||
@code
|
||||
{
|
||||
private IEnumerable<EnrollmentTermModel>? terms { get; set; } = null;
|
||||
private ulong? selectedTermId { get; set; } = null;
|
||||
private ulong? selectedTermId { get; set; }
|
||||
private EnrollmentTermModel? selectedTerm
|
||||
{
|
||||
get => terms?.FirstOrDefault(t => t.Id == selectedTermId);
|
||||
}
|
||||
private List<DayOfWeek> days { get; set; } = new();
|
||||
private bool saved { get; set; } = false;
|
||||
private SemesterConfiguration? configuration { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
terms = await canvasService.GetCurrentTermsFor();
|
||||
readTermFromConfig();
|
||||
readDaysFromConfig();
|
||||
}
|
||||
|
||||
private void readTermFromConfig()
|
||||
{
|
||||
if (terms == null || configurationManagement.Configuration == null) return;
|
||||
foreach (var term in terms)
|
||||
{
|
||||
var termInConfiguration = configurationManagement.Configuration.StartDate == term.StartAt;
|
||||
if (termInConfiguration)
|
||||
{
|
||||
selectedTermId = term.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void readDaysFromConfig()
|
||||
{
|
||||
if (terms == null || configurationManagement.Configuration == null) return;
|
||||
|
||||
days = configurationManagement.Configuration.Days.ToList();
|
||||
}
|
||||
|
||||
|
||||
public async void HandleSave()
|
||||
{
|
||||
saved = true;
|
||||
configurationManagement.SetConfiguration(selectedTerm, days.ToArray());
|
||||
await ProtectedSessionStore.SetAsync("configuration", configurationManagement.Configuration);
|
||||
}
|
||||
}
|
||||
<PageTitle>Index</PageTitle>
|
||||
|
||||
@@ -60,22 +92,18 @@
|
||||
@day
|
||||
</button>
|
||||
</div>
|
||||
|
||||
}
|
||||
</div>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-auto">
|
||||
<button @onclick="() => {
|
||||
saved = true;
|
||||
configuration = ConfigurationManagement.CreateFromTerm(selectedTerm, days.ToArray());
|
||||
}" class="btn btn-primary" disabled="@saved">
|
||||
<button @onclick="@HandleSave" class="btn btn-primary">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (configuration is not null)
|
||||
@if (configurationManagement.Configuration is not null)
|
||||
{
|
||||
<SemesterDetail Configuration="configuration" />
|
||||
<div>Config complete</div>
|
||||
}
|
||||
3
Management.Web/Pages/Modules.razor
Normal file
3
Management.Web/Pages/Modules.razor
Normal file
@@ -0,0 +1,3 @@
|
||||
@page "/modules"
|
||||
|
||||
<PageTitle>Weather forecast</PageTitle>
|
||||
@@ -1,47 +0,0 @@
|
||||
@page "/testing"
|
||||
@using Management.Web.Data
|
||||
@inject WeatherForecastService ForecastService
|
||||
|
||||
<PageTitle>Weather forecast</PageTitle>
|
||||
|
||||
<h1>Weather forecast</h1>
|
||||
|
||||
<p>This component demonstrates fetching data from a service.</p>
|
||||
|
||||
@if (forecasts == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Temp. (C)</th>
|
||||
<th>Temp. (F)</th>
|
||||
<th>Summary</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var forecast in forecasts)
|
||||
{
|
||||
<tr>
|
||||
<td>@forecast.Date.ToShortDateString()</td>
|
||||
<td>@forecast.TemperatureC</td>
|
||||
<td>@forecast.TemperatureF</td>
|
||||
<td>@forecast.Summary</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
@code {
|
||||
private WeatherForecast[]? forecasts;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ global using System.Text.Json;
|
||||
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Management.Web.Data;
|
||||
using dotenv.net;
|
||||
|
||||
DotEnv.Load();
|
||||
@@ -13,9 +12,9 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorPages();
|
||||
builder.Services.AddServerSideBlazor();
|
||||
builder.Services.AddSingleton<WeatherForecastService>();
|
||||
builder.Services.AddSingleton<IWebRequestor, WebRequestor>();
|
||||
builder.Services.AddSingleton<ICanvasService, CanvasService>();
|
||||
builder.Services.AddSingleton<IConfigurationManagement, ConfigurationManagement>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="counter">
|
||||
<span class="oi oi-plus" aria-hidden="true"></span> Counter
|
||||
<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="/testing">
|
||||
<span class="oi oi-list-rich" aria-hidden="true"></span> Testing Page
|
||||
<NavLink class="nav-link" href="/calendar">
|
||||
<span class="oi oi-plus" aria-hidden="true"></span> Calendar
|
||||
</NavLink>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
if (weekDay != null)
|
||||
{
|
||||
DayOfWeek notNullDay = weekDay ?? default;
|
||||
var totalClasses = Semester.Days.Contains(notNullDay) ? $"bg-light {baseClasses}" : baseClasses;
|
||||
var dayInSemester = Semester.Days.Contains(notNullDay) && day < Semester.LastDay && day > Semester.FirstDay;
|
||||
var totalClasses = dayInSemester ? $"bg-light {baseClasses}" : baseClasses;
|
||||
<div class="@totalClasses">@day?.Day</div>
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user