| | | 1 | | @using Syki.Front.Features.Academic.CreateClass |
| | | 2 | | @using Syki.Front.Features.Academic.CreateTeacher |
| | | 3 | | @using Syki.Front.Features.Academic.BuildClassroomAssignment |
| | | 4 | | @using Syki.Front.Features.Academic.AssignDisciplinesToTeacher |
| | | 5 | | |
| | | 6 | | @namespace Syki.Front.Pages.Academic |
| | | 7 | | |
| | | 8 | | @page "/academic/classrooms/assignment" |
| | | 9 | | @attribute [Authorize(Roles = "Academic")] |
| | | 10 | | |
| | | 11 | | <SykiPageTitle Title="Ensalamento" /> |
| | | 12 | | |
| | | 13 | | <MudContainer Class="my-4 px-4"> |
| | | 14 | | <MudGrid Class="align-center"> |
| | | 15 | | <MudItem xs="12" sm="8" md="8" lg="8"> |
| | | 16 | | <MudStack Row AlignItems="AlignItems.Center"> |
| | | 17 | | <MudIcon Icon="@Icons.Material.Filled.Sort" Class="mb-1" Size="Size.Large"/> |
| | 0 | 18 | | <MudText Typo="@Typo.h5" Style="font-weight: bold">Ensalamento - @_period.Id</MudText> |
| | | 19 | | </MudStack> |
| | | 20 | | </MudItem> |
| | | 21 | | <MudItem xs="12" sm="4" md="4" lg="4"> |
| | | 22 | | <MudSelect |
| | | 23 | | Dense |
| | | 24 | | Label="Campus" |
| | | 25 | | Value="@_campus" |
| | | 26 | | Margin="Margin.Dense" |
| | | 27 | | Variant="Variant.Outlined" |
| | | 28 | | AdornmentColor="Color.Primary" |
| | 0 | 29 | | ValueChanged="(GetCampiItemOut newValue) => HandleCampusChanged(newValue)" |
| | | 30 | | > |
| | 0 | 31 | | @foreach (var item in _campi) |
| | | 32 | | { |
| | 0 | 33 | | <MudSelectItem Value="@item">@item.Name</MudSelectItem> |
| | | 34 | | } |
| | | 35 | | </MudSelect> |
| | | 36 | | </MudItem> |
| | | 37 | | </MudGrid> |
| | | 38 | | |
| | | 39 | | <MudCard Class="my-4 pa-4"> |
| | | 40 | | <MudCardContent> |
| | | 41 | | <MudGrid Spacing="2"> |
| | | 42 | | |
| | | 43 | | <MudItem xs="12" sm="12" md="12" lg="12"> |
| | | 44 | | <MudDataGrid |
| | | 45 | | Dense |
| | | 46 | | Hover |
| | | 47 | | SortMode="SortMode.None" |
| | | 48 | | Items="@_courseOfferings" |
| | | 49 | | > |
| | | 50 | | <Columns> |
| | | 51 | | <PropertyColumn Property="x => x.Course" Title="@($"Ofertas de Curso ({_courseOfferings.Coun |
| | | 52 | | <PropertyColumn Property="x => _students.Count(s => s.CourseOfferingId == x.CourseOfferingId |
| | | 53 | | <PropertyColumn Property="x => x.Disciplines.Count" Title="Disciplinas" /> |
| | | 54 | | </Columns> |
| | | 55 | | <NoRecordsContent> |
| | | 56 | | <MudText Typo="Typo.body2">Nenhuma oferta de curso encontrada</MudText> |
| | | 57 | | </NoRecordsContent> |
| | | 58 | | </MudDataGrid> |
| | | 59 | | </MudItem> |
| | | 60 | | |
| | | 61 | | <MudItem xs="12" sm="12" md="12" lg="12"> |
| | | 62 | | <MudDataGrid |
| | | 63 | | Dense |
| | | 64 | | Hover |
| | | 65 | | SortMode="SortMode.None" |
| | | 66 | | Items="@_teachers" |
| | | 67 | | > |
| | | 68 | | <Columns> |
| | | 69 | | <PropertyColumn Property="x => x.Name" Title="@($"Professores ({_teachers.Count})")" /> |
| | | 70 | | <PropertyColumn Property="x => x.Disciplines.Count(d => _disciplines.Select(y => y.Id).Conta |
| | | 71 | | <TemplateColumn CellClass="d-flex justify-end"> |
| | | 72 | | <CellTemplate> |
| | | 73 | | <MudTooltip Text="Disciplinas" Arrow Placement="Placement.Top" ShowOnFocus="false"> |
| | 0 | 74 | | <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.Apps" OnClick="@( |
| | | 75 | | </MudTooltip> |
| | | 76 | | </CellTemplate> |
| | | 77 | | </TemplateColumn> |
| | | 78 | | </Columns> |
| | | 79 | | <NoRecordsContent> |
| | | 80 | | <MudText Typo="Typo.body2">Nenhum professor encontrado para este campus</MudText> |
| | | 81 | | </NoRecordsContent> |
| | | 82 | | </MudDataGrid> |
| | | 83 | | </MudItem> |
| | | 84 | | |
| | | 85 | | <MudItem xs="12" sm="12" md="12" lg="12"> |
| | | 86 | | <MudDataGrid |
| | | 87 | | Dense |
| | | 88 | | Hover |
| | | 89 | | SortMode="SortMode.None" |
| | | 90 | | Items="@_disciplines" |
| | | 91 | | > |
| | | 92 | | <Columns> |
| | | 93 | | <PropertyColumn Property="x => x.Name" Title="@($"Disciplinas ({_disciplines.Count})")" /> |
| | | 94 | | <PropertyColumn Property="x => _teachers.Count(t => t.Disciplines.Contains(x.Id))" Title="Pr |
| | | 95 | | <PropertyColumn Property="x => _students.Count(s => _courseOfferings.FirstOrDefault(c => c.C |
| | | 96 | | <PropertyColumn Property="x => _classes.Where(c => c.DisciplineId == x.Id).Sum(c => c.Vacanc |
| | | 97 | | |
| | | 98 | | <TemplateColumn CellClass="d-flex justify-end"> |
| | | 99 | | <CellTemplate> |
| | | 100 | | @{ |
| | 0 | 101 | | var (icon, color, message) = GetDisciplineIconData(context.Item.Id); |
| | | 102 | | } |
| | | 103 | | <MudTooltip Text="@message" Arrow Placement="Placement.Top" ShowOnFocus="false"> |
| | | 104 | | <MudIcon Size="@Size.Small" Icon="@icon" Color="@color" /> |
| | | 105 | | </MudTooltip> |
| | | 106 | | </CellTemplate> |
| | | 107 | | </TemplateColumn> |
| | | 108 | | </Columns> |
| | | 109 | | <NoRecordsContent> |
| | | 110 | | <MudText Typo="Typo.body2">Nenhuma disciplina encontrada</MudText> |
| | | 111 | | </NoRecordsContent> |
| | | 112 | | </MudDataGrid> |
| | | 113 | | </MudItem> |
| | | 114 | | |
| | | 115 | | <MudItem xs="12" sm="12" md="12" lg="12"> |
| | | 116 | | <MudDataGrid |
| | | 117 | | Dense |
| | | 118 | | Hover |
| | | 119 | | SortMode="SortMode.None" |
| | | 120 | | Items="@_students" |
| | | 121 | | > |
| | | 122 | | <Columns> |
| | | 123 | | <PropertyColumn Property="x => x.Name" Title="@($"Alunos ({_students.Count})")" /> |
| | | 124 | | <PropertyColumn Property="x => _courseOfferings.FirstOrDefault(c => c.CourseOfferingId == x. |
| | | 125 | | <PropertyColumn Property="x => _disciplines.Count(d => _courseOfferings.FirstOrDefault(c => |
| | | 126 | | </Columns> |
| | | 127 | | <NoRecordsContent> |
| | | 128 | | <MudText Typo="Typo.body2">Nenhum aluno encontrado</MudText> |
| | | 129 | | </NoRecordsContent> |
| | | 130 | | </MudDataGrid> |
| | | 131 | | </MudItem> |
| | | 132 | | |
| | | 133 | | </MudGrid> |
| | | 134 | | </MudCardContent> |
| | | 135 | | </MudCard> |
| | | 136 | | |
| | | 137 | | <MudCard Class="my-4 pa-4"> |
| | | 138 | | <MudCardContent> |
| | | 139 | | <MudGrid> |
| | | 140 | | <MudItem xs="12" sm="12" md="12" lg="12"> |
| | | 141 | | <MudStack Row AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween"> |
| | 0 | 142 | | <MudText Typo="Typo.h6" Style="font-weight: bold">Turmas (@_classes.Count)</MudText> |
| | | 143 | | <MudButton |
| | | 144 | | StartIcon="@Icons.Material.Outlined.Add" |
| | | 145 | | IconSize="Size.Large" |
| | | 146 | | Variant="Variant.Filled" |
| | | 147 | | Size="Size.Medium" |
| | | 148 | | Color="Color.Primary" |
| | | 149 | | OnClick="@OpenNewClassDialog" |
| | | 150 | | > |
| | | 151 | | Nova Turma |
| | | 152 | | </MudButton> |
| | | 153 | | </MudStack> |
| | | 154 | | </MudItem> |
| | | 155 | | |
| | | 156 | | <MudItem xs="12" sm="12" md="12" lg="12"> |
| | | 157 | | <MudDataGrid |
| | | 158 | | Dense |
| | | 159 | | Hover |
| | | 160 | | SortMode="SortMode.None" |
| | | 161 | | Items="@_classes" |
| | | 162 | | > |
| | | 163 | | <Columns> |
| | | 164 | | <PropertyColumn Property="x => x.Discipline" Title="Disciplina" /> |
| | | 165 | | <PropertyColumn Property="x => x.Teacher" Title="Professor" /> |
| | | 166 | | <PropertyColumn Property="x => x.Vacancies" Title="Vagas" /> |
| | | 167 | | </Columns> |
| | | 168 | | <NoRecordsContent> |
| | | 169 | | <MudText Typo="Typo.body2">Nenhuma turma encontrada</MudText> |
| | | 170 | | </NoRecordsContent> |
| | | 171 | | </MudDataGrid> |
| | | 172 | | </MudItem> |
| | | 173 | | </MudGrid> |
| | | 174 | | </MudCardContent> |
| | | 175 | | </MudCard> |
| | | 176 | | |
| | | 177 | | <MudCard Class="my-4 pa-4"> |
| | | 178 | | <MudCardContent> |
| | | 179 | | <MudGrid> |
| | | 180 | | <MudItem xs="12" sm="12" md="12" lg="12"> |
| | 0 | 181 | | <MudText Typo="Typo.h6" Style="font-weight: bold">Salas (@_classrooms.Count)</MudText> |
| | | 182 | | </MudItem> |
| | | 183 | | |
| | | 184 | | <MudItem xs="12" sm="12" md="12" lg="12"> |
| | | 185 | | <MudDataGrid |
| | | 186 | | Dense |
| | | 187 | | Hover |
| | | 188 | | SortMode="SortMode.None" |
| | | 189 | | Items="@_classrooms" |
| | | 190 | | > |
| | | 191 | | <Columns> |
| | | 192 | | <PropertyColumn Property="x => x.Name" Title="Nome" /> |
| | | 193 | | <PropertyColumn Property="x => x.Capacity" Title="Capacidade" /> |
| | | 194 | | <TemplateColumn CellClass="d-flex justify-end"> |
| | | 195 | | <CellTemplate> |
| | | 196 | | <MudTooltip Text="Horários" Arrow Placement="Placement.Top" ShowOnFocus="false"> |
| | 0 | 197 | | <MudIconButton Size="@Size.Small" Icon="@Icons.Material.Filled.VideoLabel" OnCli |
| | | 198 | | </MudTooltip> |
| | | 199 | | </CellTemplate> |
| | | 200 | | </TemplateColumn> |
| | | 201 | | </Columns> |
| | | 202 | | <NoRecordsContent> |
| | | 203 | | <MudText Typo="Typo.body2">Nenhuma sala encontrada</MudText> |
| | | 204 | | </NoRecordsContent> |
| | | 205 | | </MudDataGrid> |
| | | 206 | | </MudItem> |
| | | 207 | | </MudGrid> |
| | | 208 | | </MudCardContent> |
| | | 209 | | </MudCard> |
| | | 210 | | </MudContainer> |
| | | 211 | | |
| | 0 | 212 | | <AssignDisciplinesToTeacherDrawer @ref="@_disciplinesDrawer" AfterSubmit="@LoadData" /> |
| | 0 | 213 | | |
| | 0 | 214 | | @inject IDialogService DialogService |
| | 0 | 215 | | @inject GetCampiClient GetCampiClient |
| | 0 | 216 | | @inject GetClassroomsClient GetClassroomsClient |
| | 0 | 217 | | @inject GetCampusClassesClient GetCampusClassesClient |
| | | 218 | | @inject IBrowserViewportService BrowserViewportService |
| | | 219 | | @inject GetCampusTeachersClient GetCampusTeachersClient |
| | | 220 | | @inject GetCampusStudentsClient GetCampusStudentsClient |
| | | 221 | | @inject GetCurrentAcademicPeriodClient GetCurrentAcademicPeriodClient |
| | | 222 | | @inject GetCampusCourseOfferingsClient GetCampusCourseOfferingsClient |
| | | 223 | | |
| | | 224 | | @code |
| | | 225 | | { |
| | 0 | 226 | | private AcademicPeriodOut _period = new(); |
| | 0 | 227 | | private GetCampiItemOut _campus = new(); |
| | 0 | 228 | | private List<GetCampiItemOut> _campi = []; |
| | | 229 | | |
| | 0 | 230 | | private List<GetClassroomsOut> _classrooms = []; |
| | 0 | 231 | | private List<GetCampusClassesOut> _classes = []; |
| | 0 | 232 | | private List<GetCampusTeachersOut> _teachers = []; |
| | 0 | 233 | | private List<GetCampusStudentsOut> _students = []; |
| | 0 | 234 | | private List<GetCampusCourseOfferingsOut> _courseOfferings = []; |
| | 0 | 235 | | private List<GetCampusCourseOfferingsDisciplineOut> _disciplines = []; |
| | | 236 | | |
| | | 237 | | private AssignDisciplinesToTeacherDrawer _disciplinesDrawer = default!; |
| | | 238 | | |
| | | 239 | | protected override async Task OnInitializedAsync() |
| | | 240 | | { |
| | 0 | 241 | | var periodResponse = await GetCurrentAcademicPeriodClient.Get(); |
| | 0 | 242 | | if (periodResponse.IsError) return; |
| | 0 | 243 | | _period = periodResponse.Success; |
| | | 244 | | |
| | 0 | 245 | | _campi = (await GetCampiClient.Get()).Items; |
| | 0 | 246 | | _campus = _campi.FirstOrDefault() ?? new(); |
| | | 247 | | |
| | 0 | 248 | | await LoadData(); |
| | 0 | 249 | | } |
| | | 250 | | |
| | | 251 | | private async Task LoadData() |
| | | 252 | | { |
| | 0 | 253 | | _teachers = await GetCampusTeachersClient.Get(_campus.Id); |
| | 0 | 254 | | _students = await GetCampusStudentsClient.Get(_campus.Id); |
| | 0 | 255 | | _courseOfferings = await GetCampusCourseOfferingsClient.Get(_campus.Id); |
| | 0 | 256 | | _disciplines = _courseOfferings.SelectMany(x => x.Disciplines).OrderBy(x => x.Name).ToList(); |
| | 0 | 257 | | _classes = await GetCampusClassesClient.Get(_campus.Id); |
| | 0 | 258 | | _classrooms = (await GetClassroomsClient.Get()).Where(x => x.CampusId == _campus.Id).ToList(); |
| | 0 | 259 | | } |
| | | 260 | | |
| | | 261 | | private async Task HandleCampusChanged(GetCampiItemOut newValue) |
| | | 262 | | { |
| | 0 | 263 | | _campus = newValue; |
| | 0 | 264 | | await LoadData(); |
| | 0 | 265 | | } |
| | | 266 | | |
| | | 267 | | private async Task OpenDisciplinesDrawer(Guid teacherId) |
| | | 268 | | { |
| | 0 | 269 | | await _disciplinesDrawer.Open(teacherId); |
| | 0 | 270 | | } |
| | | 271 | | |
| | | 272 | | private (string icon, Color color, string message) GetDisciplineIconData(Guid disciplineId) |
| | | 273 | | { |
| | 0 | 274 | | var teachers = _teachers.Count(t => t.Disciplines.Contains(disciplineId)); |
| | 0 | 275 | | if (teachers == 0) return (Icons.Material.Filled.Error, Color.Error, "Disciplina sem professor"); |
| | | 276 | | |
| | 0 | 277 | | var students = _students.Count(s => _courseOfferings.FirstOrDefault(c => c.CourseOfferingId == s.CourseOfferingI |
| | 0 | 278 | | var vacancies = _classes.Where(c => c.DisciplineId == disciplineId).Sum(c => c.Vacancies); |
| | | 279 | | |
| | 0 | 280 | | if (vacancies < students) return (Icons.Material.Filled.WarningAmber, Color.Warning, "Disciplina sem vagas sufic |
| | | 281 | | |
| | 0 | 282 | | return (Icons.Material.Filled.CheckCircle, Color.Success, "Disciplina ok"); |
| | | 283 | | } |
| | | 284 | | |
| | | 285 | | private async Task OpenNewClassDialog() |
| | | 286 | | { |
| | 0 | 287 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| | 0 | 288 | | var options = new DialogOptions { |
| | 0 | 289 | | MaxWidth = MaxWidth.Small, |
| | 0 | 290 | | FullWidth = true, |
| | 0 | 291 | | FullScreen = breakpoint == Breakpoint.Xs, |
| | 0 | 292 | | }; |
| | | 293 | | |
| | 0 | 294 | | var parameters = new DialogParameters<CreateCampusClassDialog>(); |
| | 0 | 295 | | parameters.Add(x => x.Period, _period.Id); |
| | 0 | 296 | | parameters.Add(x => x.CampusId, _campus.Id); |
| | 0 | 297 | | parameters.Add(x => x.Teachers, _teachers); |
| | 0 | 298 | | parameters.Add(x => x.Disciplines, _disciplines.Where(d => _teachers.Any(t => t.Disciplines.Contains(d.Id))).ToL |
| | | 299 | | |
| | 0 | 300 | | var dialog = await DialogService.ShowAsync<CreateCampusClassDialog>("", parameters, options); |
| | | 301 | | |
| | 0 | 302 | | var result = await dialog.Result; |
| | | 303 | | |
| | 0 | 304 | | if (result!.Canceled) return; |
| | | 305 | | |
| | 0 | 306 | | _classes = await GetCampusClassesClient.Get(_campus.Id); |
| | 0 | 307 | | } |
| | | 308 | | |
| | | 309 | | private async Task OpenAssignClassToClassroomDialog(GetClassroomsOut classroom) |
| | | 310 | | { |
| | 0 | 311 | | var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync(); |
| | 0 | 312 | | var options = new DialogOptions { |
| | 0 | 313 | | FullWidth = true, |
| | 0 | 314 | | MaxWidth = MaxWidth.Large, |
| | 0 | 315 | | FullScreen = breakpoint == Breakpoint.Xs, |
| | 0 | 316 | | }; |
| | | 317 | | |
| | 0 | 318 | | var parameters = new DialogParameters<AssignClassToClassroomDialog>(); |
| | 0 | 319 | | parameters.Add(x => x.Classroom, classroom); |
| | 0 | 320 | | parameters.Add(x => x.Classes, _classes); |
| | | 321 | | |
| | 0 | 322 | | var dialog = await DialogService.ShowAsync<AssignClassToClassroomDialog>("", parameters, options); |
| | | 323 | | |
| | 0 | 324 | | var result = await dialog.Result; |
| | | 325 | | |
| | 0 | 326 | | if (result!.Canceled) return; |
| | | 327 | | |
| | 0 | 328 | | _classes = await GetCampusClassesClient.Get(_campus.Id); |
| | 0 | 329 | | _classrooms = (await GetClassroomsClient.Get()).Where(x => x.CampusId == _campus.Id).ToList(); |
| | 0 | 330 | | } |
| | | 331 | | } |