MVP today view
All checks were successful
Build and Publish Docker Container / build (push) Successful in 5m29s
All checks were successful
Build and Publish Docker Container / build (push) Successful in 5m29s
This commit is contained in:
parent
cdd8c963ca
commit
3fb897fc8b
@ -6,5 +6,7 @@ class AttendanceTrackerController < ApplicationController
|
||||
def today
|
||||
@courses = Course.all.sort_by(&:title)
|
||||
@date = Date.today
|
||||
|
||||
@lectures = @courses.flat_map { |course| course.lectures.filter { |a| a.start_time.today? } }.sort_by { |l| l.start_time }
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,63 +1,132 @@
|
||||
<h1 class="text-3xl font-medium">Attendance Tracker</h1>
|
||||
|
||||
<div class="px-4 sm:px-6 lg:px-8 flex flex-col lg:flex-row gap-4">
|
||||
<% @courses.each do |course| %>
|
||||
<div class="mt-8 flow-root">
|
||||
<div class="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
|
||||
<div class="inline-block py-2 align-middle px-6 lg:px-8">
|
||||
<div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 rounded-lg">
|
||||
<div class="flex flex-row justify-between items-center px-4 p-2">
|
||||
<h2 class="text-2xl">
|
||||
<%= course.title %>
|
||||
</h2>
|
||||
|
||||
<% if course.homepage.present? %>
|
||||
<a class="align-middle" href="<%= course.homepage %>">
|
||||
<i class="fa fa-link text-blue-600"></i>
|
||||
</a>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<table class="border-t-2 divide-y divide-gray-300 w-full">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Lecture</th>
|
||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Date</th>
|
||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Status</th>
|
||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Action</th>
|
||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="divide-y divide-gray-200 bg-white">
|
||||
<% course.lectures_and_work_items.group_by { |lecture| lecture.week_number }.each do |(week_number, lectures)| %>
|
||||
<tr class="border-t border-gray-200">
|
||||
<th colspan="5" scope="colgroup" class="bg-gray-50 py-2 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">
|
||||
<div class="flex flex-row justify-between">
|
||||
<div class="">
|
||||
Week <%= week_number %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<% total_for_week = lectures.sum { |lecture| lecture.total_overall_time }.seconds %>
|
||||
<%# TODO: Improve this figure, atm it is for lectures in week, not time spent in week (ie
|
||||
prepping for lecture next week will count in next week not current week) %>
|
||||
<% if total_for_week > 0 %>
|
||||
(Total <%= humanise_duration(lectures.sum { |lecture| lecture.total_overall_time }.seconds) %>
|
||||
)
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<%= render lectures %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="mt-8 flow-root">
|
||||
<div class="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
|
||||
<div class="inline-block py-2 align-middle px-6 lg:px-8">
|
||||
<div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 rounded-lg">
|
||||
<div class="flex flex-row justify-between items-center px-4 p-2">
|
||||
<h2 class="text-2xl">
|
||||
Today
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<table class="border-t-2 divide-y divide-gray-300 w-full">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Course</th>
|
||||
<th scope="col" class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900 sm:pl-6">Lecture</th>
|
||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Date</th>
|
||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Status</th>
|
||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Action</th>
|
||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody class="divide-y divide-gray-200 bg-white">
|
||||
<% @lectures.each do |lecture| %>
|
||||
<tr class="<%= class_names({
|
||||
'lecture-future': lecture.start_time.future?,
|
||||
'bg-green-100': lecture.attended?,
|
||||
}) %>">
|
||||
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">
|
||||
<%= lecture.course.title %>
|
||||
</td>
|
||||
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6">
|
||||
<%= lecture.title %>
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
<%= lecture.start_time.to_fs(:dmy) %>
|
||||
</td>
|
||||
|
||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500" data-controller="popover" data-action="mouseenter->popover#show mouseleave->popover#hide">
|
||||
<div class="flex flex-row gap-2">
|
||||
<% prep_icon_class = if lecture.prepared?
|
||||
'text-green-700'
|
||||
else
|
||||
'text-slate-300'
|
||||
end %>
|
||||
<i class="fa fa-hourglass-start <%= prep_icon_class %>"></i>
|
||||
|
||||
<% if lecture.attended? %>
|
||||
<% if lecture.entirely_attended_in_person? %>
|
||||
<i class="fa fa-chalkboard-user text-green-700"></i>
|
||||
<% else %>
|
||||
<i class="fa fa-video text-green-700"></i>
|
||||
<% end %>
|
||||
<% elsif lecture.is_live? %>
|
||||
<i class="fa fa-video text-blue-700"></i>
|
||||
<% elsif lecture.start_time.past? %>
|
||||
<i class="fa fa-times text-red-700"></i>
|
||||
<% else %>
|
||||
<div class="flex-grow"></div>
|
||||
<% end %>
|
||||
|
||||
<% reviewed_icon_class = if lecture.start_time.future?
|
||||
'invisible'
|
||||
elsif lecture.reviewed?
|
||||
'text-green-700'
|
||||
else
|
||||
'text-slate-300'
|
||||
end %>
|
||||
<i class="fa fa-hourglass-end <%= reviewed_icon_class %>"></i>
|
||||
</div>
|
||||
|
||||
<template data-popover-target="content">
|
||||
<% unless lecture.tracked_time_entries.empty? %>
|
||||
<div class="absolute p-1 w-max whitespace-normal break-words rounded-lg border border-blue-gray-50 bg-white text-blue-gray-500 shadow-lg shadow-blue-gray-500/10 focus:outline-none" data-popover-target="card">
|
||||
<div>
|
||||
Preparation: <%= humanise_duration(lecture.total_preparation_time) %>
|
||||
</div>
|
||||
<div>
|
||||
In lecture: <%= humanise_duration(lecture.total_attendance_time) %>
|
||||
</div>
|
||||
<div>
|
||||
Review: <%= humanise_duration(lecture.total_review_time) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</template>
|
||||
</td>
|
||||
|
||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
<% joinable_time = lecture.start_time - 5.minutes %>
|
||||
<% if joinable_time.future? %>
|
||||
<%= button_to "Prepare",
|
||||
lecture_start_preparation_path(id: lecture.id),
|
||||
class: 'action-button'
|
||||
%>
|
||||
<% elsif joinable_time.past? && !lecture.attended? %>
|
||||
<% start_label = if lecture.is_live? then
|
||||
"Join"
|
||||
else
|
||||
"Start"
|
||||
end %>
|
||||
<%= button_to start_label,
|
||||
lectures_start_path(id: lecture.id),
|
||||
class: 'action-button'
|
||||
%>
|
||||
<% else %>
|
||||
<div class="flex justify-center">
|
||||
<%= button_to "Review",
|
||||
lecture_start_review_path(id: lecture.id),
|
||||
class: 'action-button'
|
||||
%>
|
||||
</div>
|
||||
<% end %>
|
||||
</td>
|
||||
|
||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
<% if lecture.recording %>
|
||||
<%= link_to "Open recording", lecture.recording&.recording_url %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
<div>
|
||||
<h1 class="font-bold text-4xl">Lecture#start</h1>
|
||||
<p>Find me in app/views/lecture/start.html.erb</p>
|
||||
</div>
|
||||
@ -1,4 +0,0 @@
|
||||
<div>
|
||||
<h1 class="font-bold text-4xl">WorkItem#complete</h1>
|
||||
<p>Find me in app/views/work_item/complete.html.erb</p>
|
||||
</div>
|
||||
@ -1,4 +0,0 @@
|
||||
<div>
|
||||
<h1 class="font-bold text-4xl">WorkItem#start_time_entry</h1>
|
||||
<p>Find me in app/views/work_item/start_time_entry.html.erb</p>
|
||||
</div>
|
||||
@ -10,6 +10,7 @@ Rails.application.routes.draw do
|
||||
end
|
||||
|
||||
root controller: :attendance_tracker, action: :index
|
||||
get '/today', controller: :attendance_tracker, action: :today
|
||||
|
||||
post '/lectures/:id/start', to: 'lecture#start', as: :lectures_start
|
||||
post '/lectures/:id/start_preparation', to: 'lecture#start_preparation', as: :lecture_start_preparation
|
||||
|
||||
Loading…
Reference in New Issue
Block a user