|
6 | 6 | @inject CourseClient CourseClient |
7 | 7 | @inject ExerciseClient ExerciseClient |
8 | 8 | @inject AssignmentClient AssignmentClient |
| 9 | +@inject DashboardClient DashboardClient |
9 | 10 | <PageTitle>AHK Review UI</PageTitle> |
10 | 11 |
|
11 | 12 | <style> |
|
29 | 30 | <LoadingComponent LongTask="@Loading" @ref="loadingRef"> |
30 | 31 |
|
31 | 32 | <MudStack Row="true" Class="mt-6"> |
32 | | - <MudSelect T="Course" Label="Course" @bind-Value="_selectedCourse" @bind-Value:after="CourseChanged" |
| 33 | + <MudSelect T="string" Label="Course" @bind-Value="_selectedCourse" @bind-Value:after="CourseChanged" |
33 | 34 | Dense="true" Variant="Variant.Outlined" AnchorOrigin="Origin.BottomCenter" |
34 | 35 | TransformOrigin="Origin.TopCenter"> |
35 | 36 | @foreach (var course in _courses ?? []) |
36 | 37 | { |
37 | | - <MudSelectItem Value="@course">@course.Name</MudSelectItem> |
| 38 | + <MudSelectItem Value="@course">@course</MudSelectItem> |
38 | 39 | } |
39 | 40 | </MudSelect> |
40 | 41 | <MudSpacer/> |
41 | | - <MudSelect T="Exercise" Label="Exercise" @bind-Value="_selectedTask" @bind-Value:after="ExerciseChanged" |
| 42 | + <MudSelect T="string" Label="Exercise" @bind-Value="_selectedExercise" @bind-Value:after="ExerciseChanged" |
42 | 43 | Dense="true" Variant="Variant.Outlined" AnchorOrigin="Origin.BottomCenter" |
43 | 44 | TransformOrigin="Origin.TopCenter"> |
44 | 45 | @foreach (var task in _tasks ?? []) |
45 | 46 | { |
46 | | - <MudSelectItem Value="@task">@task.Name</MudSelectItem> |
| 47 | + <MudSelectItem Value="@task">@task</MudSelectItem> |
47 | 48 | } |
48 | 49 | </MudSelect> |
49 | 50 | <MudSpacer/> |
50 | 51 |
|
51 | 52 | <MudIconButton Icon="@Icons.Material.Filled.Download" Color="Color.Inherit" Edge="Edge.End" Size="Size.Large"/> |
52 | 53 | </MudStack> |
53 | | - <MudDataGrid Items="@_assignmentsData" T="Assignment" Class="custom-grid"> |
| 54 | + <MudDataGrid Items="@_filteredData" T="Dashboard" Class="custom-grid"> |
54 | 55 | <Columns> |
55 | | - <PropertyColumn Property="x => x.Id" Title="Id"/> |
56 | | - <PropertyColumn Property="x => x.GithubRepoName" Title="Repository name"/> |
57 | | - @* <PropertyColumn Property="x => x.Student.NeptunCode" Title="Neptun"/> *@ |
58 | | - @* <PropertyColumn Property="x => JoinPullRequests(x)" Title="PRs"/> *@ |
| 56 | + <PropertyColumn Property="x => x.GithubRepoUrl" Title="Repo URL"/> |
| 57 | + <PropertyColumn Property="x => x.StudentNeptun" Title="Neptun"/> |
| 58 | + <TemplateColumn Title="PRs"> |
| 59 | + <CellTemplate> |
| 60 | + <MudTooltip Text="@PrTooltip(context.Item)"> |
| 61 | + @JoinPullRequests(context.Item) |
| 62 | + </MudTooltip> |
| 63 | + </CellTemplate> |
| 64 | + </TemplateColumn> |
59 | 65 | @* <PropertyColumn Property="x => JoinCiWorkflows(x)" Title="Workflows"/> *@ |
60 | | - @* <PropertyColumn Property="x => JoinScore(x)" Title="Pontok"/> *@ |
| 66 | + <PropertyColumn Property="x => JoinScore(x)" Title="Score"/> |
| 67 | + <TemplateColumn Title="" T="Dashboard"> |
| 68 | + <CellTemplate> |
| 69 | + @if (MergedEntry(context.Item)) |
| 70 | + { |
| 71 | + <MudIcon Icon="@Icons.Material.Filled.Verified" Color="Color.Success"/> |
| 72 | + } |
| 73 | + else if (CheckedEntry(context.Item)) |
| 74 | + { |
| 75 | + <MudIcon Icon="@Icons.Material.Filled.Check" Color="Color.Success"/> |
| 76 | + } |
| 77 | + else if (CiRunOnEntry(context.Item)) |
| 78 | + { |
| 79 | + <MudIcon Icon="@Icons.Material.Filled.Warning" Color="Color.Warning"/> |
| 80 | + } |
| 81 | + else |
| 82 | + { |
| 83 | + <MudIcon Icon="@Icons.Material.Filled.Warning" Color="Color.Error"/> |
| 84 | + } |
| 85 | + </CellTemplate> |
| 86 | + </TemplateColumn> |
61 | 87 | </Columns> |
62 | 88 | <PagerContent> |
63 | 89 | <MudDataGridPager T="Assignment"/> |
|
70 | 96 |
|
71 | 97 | #region Data Grid helpers |
72 | 98 |
|
73 | | -// private string JoinPullRequests(Assignment data) |
74 | | -// { |
75 | | -// //Kéne menteni a branch nevét is? |
76 | | -// return string.Join(", ", data.PullRequests.Select(x => x.Url)); |
77 | | -// } |
78 | | -// |
79 | | -// private string JoinCiWorkflows(Assignment data) |
80 | | -// { |
81 | | -// var filtered = data.AssignmentEvents?.Where(IsCicdWorkflow) ?? []; |
82 | | -// var assignmentEvents = filtered as AssignmentEvent[] ?? filtered.ToArray(); |
83 | | -// string run = assignmentEvents.Length == 1 ? "run" : "runs"; |
84 | | -// return $"{assignmentEvents.Length} {run}, last: {assignmentEvents.LastOrDefault()?.Description}"; |
85 | | -// } |
86 | | -// |
87 | | -// private bool IsCicdWorkflow(AssignmentEvent data) |
88 | | -// { |
89 | | -// return true; |
90 | | -// } |
91 | | -// |
92 | | -// private string JoinScore(Assignment data) |
93 | | -// { |
94 | | -// return string.Join(".", data.Scores.Select(x => x.Value)); |
95 | | -// } |
| 99 | + private string JoinPullRequests(Dashboard data) |
| 100 | + { |
| 101 | + //Kéne menteni a branch nevét is? |
| 102 | + return data.PullRequests?.FirstOrDefault()?.Url ?? ""; |
| 103 | + } |
| 104 | + |
| 105 | + private string PrTooltip(Dashboard data) |
| 106 | + { |
| 107 | + return data.PullRequests?.FirstOrDefault()?.OpeningDate.ToString() ?? ""; |
| 108 | + } |
| 109 | + |
| 110 | + private string JoinScore(Dashboard data) |
| 111 | + { |
| 112 | + return string.Join(", ", data.PullRequests?.FirstOrDefault()?.Scores.Select(x => x.Value) ?? []); |
| 113 | + } |
| 114 | + |
| 115 | + private bool MergedEntry(Dashboard data) |
| 116 | + { |
| 117 | + return data.PullRequests?.FirstOrDefault()?.Status == PullRequestStatus.Merged; |
| 118 | + } |
| 119 | + |
| 120 | + private bool CheckedEntry(Dashboard data) |
| 121 | + { |
| 122 | + var scores = data.PullRequests?.FirstOrDefault()?.Scores; |
| 123 | + return scores?.Count > 0 && scores.All(x => x.IsApproved); |
| 124 | + } |
| 125 | + |
| 126 | + private bool CiRunOnEntry(Dashboard data) |
| 127 | + { |
| 128 | + return data.PullRequests?.FirstOrDefault()?.Scores.Count > 0; |
| 129 | + } |
96 | 130 |
|
97 | 131 | #endregion |
| 132 | + |
98 | 133 | //Van e assignolt teacher? |
99 | 134 | //Mikor pontoztak? Tooltip |
100 | 135 | //PR status - closed szűrve |
101 | 136 | private LoadingComponent loadingRef; |
102 | 137 |
|
103 | 138 | private Subject? _selectedSubject = null; |
104 | | - private Course? _selectedCourse = null; |
105 | | - private Exercise? _selectedTask = null; |
106 | | - private IEnumerable<Course>? _courses = new List<Course>(); |
107 | | - private IEnumerable<Exercise>? _tasks = new List<Exercise>(); |
108 | | - private IEnumerable<Assignment> _assignmentsData = new List<Assignment>(); |
| 139 | + private string? _selectedCourse = null; |
| 140 | + private string? _selectedExercise = null; |
| 141 | + private IEnumerable<string>? _courses = new List<string>(); |
| 142 | + private IEnumerable<string>? _tasks = new List<string>(); |
| 143 | + private ICollection<Dashboard> _dashboardData = new List<Dashboard>(); |
| 144 | + private ICollection<Dashboard> _filteredData = new List<Dashboard>(); |
109 | 145 |
|
110 | 146 |
|
111 | 147 | private async Task Loading() |
112 | 148 | { |
113 | 149 | _selectedSubject = SubjectService.CurrentSubject; |
114 | | - _courses = await SubjectClient.GetAllCoursesByIdAsync(_selectedSubject.Id); |
| 150 | + _dashboardData = await DashboardClient.GetDashboardAsync(_selectedSubject.Id); |
| 151 | + _filteredData = _dashboardData.ToList(); |
| 152 | + _courses = _dashboardData?.Select(x => x.CourseName).Distinct(); |
| 153 | + _tasks = _dashboardData?.Select(x => x.ExerciseName).Distinct(); |
| 154 | + } |
| 155 | + |
| 156 | + private void CourseChanged() |
| 157 | + { |
| 158 | + _filteredData = _dashboardData.Where(x => (_selectedCourse == null || x.CourseName == _selectedCourse) && (_selectedExercise == null || x.ExerciseName == _selectedExercise)).ToList(); |
| 159 | + _courses = _dashboardData?.Select(x => x.CourseName).Distinct(); |
| 160 | + _tasks = _dashboardData?.Select(x => x.ExerciseName).Distinct(); |
| 161 | + } |
| 162 | + |
| 163 | + private void ExerciseChanged() |
| 164 | + { |
| 165 | + _filteredData = _dashboardData.Where(x => (_selectedCourse == null || x.CourseName == _selectedCourse) && (_selectedExercise == null || x.ExerciseName == _selectedExercise)).ToList(); |
| 166 | + _courses = _dashboardData?.Select(x => x.CourseName).Distinct(); |
| 167 | + _tasks = _dashboardData?.Select(x => x.ExerciseName).Distinct(); |
115 | 168 | } |
116 | 169 |
|
117 | | - private async Task CourseChanged() |
| 170 | + private void OnSubjectChanged() |
118 | 171 | { |
119 | | - _tasks = await CourseClient.GetAllExercisesByIdAsync(_selectedCourse.Id); |
| 172 | + loadingRef.StartLoading(); |
120 | 173 | } |
121 | 174 |
|
122 | | - private async Task ExerciseChanged() |
| 175 | + protected override void OnInitialized() |
123 | 176 | { |
124 | | - _assignmentsData = await ExerciseClient.GetAssignmentsByIdAsync(_selectedTask.Id); |
| 177 | + SubjectService.OnChange += OnSubjectChanged; |
125 | 178 | } |
126 | 179 | } |
0 commit comments