Compare commits

..

No commits in common. "a0e526662bfe5d0c5ed58c02006c6e6b52edee1e" and "9b57b7a6462752b9f539d0d0a0172bd793127a8d" have entirely different histories.

9 changed files with 139 additions and 167 deletions

View File

@ -6,20 +6,12 @@
@apply rounded bg-indigo-600 px-2 py-1 font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600; @apply rounded bg-indigo-600 px-2 py-1 font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600;
} }
.today-table-grid { /*
display: grid;
}
@media (min-width: 640px) { @layer components {
.today-table-grid { .btn-primary {
grid-template-columns: 2fr repeat(3, 1fr); @apply py-2 px-4 bg-blue-200;
} }
} }
@media (min-width: 480px) and (max-width: 639px) { */
.today-table-grid {
grid-template-rows: 1fr 1fr;
grid-template-columns: 1fr 1fr;
grid-auto-flow: column;
}
}

View File

@ -1,39 +1,16 @@
class AttendanceTrackerController < ApplicationController class AttendanceTrackerController < ApplicationController
def index def index
@courses = Course.all.sort_by(&:title) @courses = Course.all.sort_by(&:title)
@current_lecture = get_current_lecture
end end
def today def today
@courses = Course.all.sort_by(&:title) @courses = Course.all.sort_by(&:title)
@date = Date.today @date = Date.today
@current_lecture = get_current_lecture
@lectures = @courses.flat_map { |course| course.lectures.filter { |a| a.start_time.today? } }.sort_by { |l| l.start_time } @lectures = @courses.flat_map { |course| course.lectures.filter { |a| a.start_time.today? } }.sort_by { |l| l.start_time }
end end
def course_focus def course_focus
@course = Course.find(params[:id]) @course = Course.find(params[:id])
@current_lecture = get_current_lecture
end
private
def get_current_lecture
current_time_entry = Toggl.current_time_entry
return nil if current_time_entry.nil?
lecture = Lecture
.joins(:course)
.find_by(title: current_time_entry['description'], course: { toggl_project: current_time_entry['project_id'] })
return lecture if lecture.present?
start_time = Time.new(current_time_entry['start'])
lecture = Lecture.joins(:course)
.find_by(start_time: (start_time - 10.minutes)..(start_time + 10.minutes), course: { toggl_project: current_time_entry['project_id'] })
return lecture if lecture.present?
nil
end end
end end

View File

@ -1,11 +1,4 @@
module Toggl module Toggl
def self.current_time_entry
JSON.parse(HTTParty.get(
"#{TOGGL_PORTAL_URL}/current",
headers: { 'Accept' => 'application/json' }
).body)
end
def self.entries_for_project(toggl_project_id, start_time:, end_time:) def self.entries_for_project(toggl_project_id, start_time:, end_time:)
JSON.parse(HTTParty.post( JSON.parse(HTTParty.post(
"#{TOGGL_PORTAL_URL}/report", "#{TOGGL_PORTAL_URL}/report",

View File

@ -1,42 +0,0 @@
<div class="divide-y divide-gray-300 w-full">
<div class="py-3.5 justify-between bg-gray-50 text-left text-sm font-semibold text-gray-900 px-6 grid grid-cols-4">
<div>Lecture</div>
<div>Status</div>
<div>Action</div>
<div>Recording</div>
</div>
<% course.lectures.sort_by(&:start_time).group_by(&:week_number).each do |(week_number, lectures)| %>
<div class="py-3.5 bg-gray-50 text-left text-sm font-semibold text-gray-900 px-6 grid grid-cols-4">
Week <%= week_number %>
</div>
<% lectures.each do |lecture| %>
<% status_classes = class_names({
'lecture-future': lecture.start_time.future?,
'bg-purple-100': lecture == @current_lecture,
'bg-green-100': lecture.attended?,
}) %>
<div class="<%= status_classes %> px-6 py-4 flex justify-between items-center grid grid-cols-4">
<div class="whitespace-nowrap text-sm font-medium text-gray-900">
<%= lecture.title %>
</div>
<div class="whitespace-nowrap text-sm font-medium text-gray-900" data-controller="popover" data-action="mouseenter->popover#show mouseleave->popover#hide">
<%= render partial: 'lecture_status_icons', locals: { lecture: } %>
</div>
<div class="whitespace-nowrap text-sm font-medium text-gray-900">
<%= render partial: 'lecture_action', locals: { lecture: } %>
</div>
<div class="whitespace-nowrap text-sm font-medium text-gray-900">
<% if lecture.recording %>
<%= link_to "Open recording", lecture.recording&.recording_url %>
<% end %>
</div>
</div>
<% end %>
<% end %>
</div>

View File

@ -1,27 +0,0 @@
<% joinable_time = lecture.start_time - 5.minutes %>
<% if lecture == @current_lecture %>
<div class="py-1">
Started
</div>
<% elsif 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 %>
<%= button_to "Review",
lecture_start_review_path(id: lecture.id),
class: 'action-button'
%>
<% end %>

View File

@ -0,0 +1,75 @@
<h1 class="text-3xl font-medium"><%= @course.title %></h1>
<div class="flex flex-col gap-4">
<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 w-full">
<div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 rounded-lg">
<div class="divide-y divide-gray-300 w-full">
<div class="py-3.5 justify-between bg-gray-50 text-left text-sm font-semibold text-gray-900 px-6 grid grid-cols-4">
<div>Lecture</div>
<div>Status</div>
<div>Action</div>
<div>Recording</div>
</div>
<% @course.lectures.sort_by(&:start_time).group_by(&:week_number).each do |(week_number, lectures)| %>
<div class="py-3.5 bg-gray-50 text-left text-sm font-semibold text-gray-900 px-6 grid grid-cols-4">
Week <%= week_number %>
</div>
<% lectures.each do |lecture| %>
<% status_classes = class_names({
'lecture-future': lecture.start_time.future?,
'bg-green-100': lecture.attended?,
}) %>
<div class="<%= status_classes %> px-6 py-4 flex justify-between bg-white items-center grid grid-cols-4">
<div class="whitespace-nowrap text-sm font-medium text-gray-900">
<%= lecture.title %>
</div>
<div class="whitespace-nowrap text-sm font-medium text-gray-900" data-controller="popover" data-action="mouseenter->popover#show mouseleave->popover#hide">
<%= render partial: 'lecture_status_icons', locals: { lecture: } %>
</div>
<div class="whitespace-nowrap text-sm font-medium text-gray-900">
<% 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 %>
<%= button_to "Review",
lecture_start_review_path(id: lecture.id),
class: 'action-button'
%>
<% end %>
</div>
<div class="whitespace-nowrap text-sm font-medium text-gray-900">
<% if lecture.recording %>
<%= link_to "Open recording", lecture.recording&.recording_url %>
<% end %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,21 +0,0 @@
<div class="flex flex-row gap-2 items-center">
<h1 class="text-3xl font-medium"><%= @course.title %></h1>
<% if @course.homepage.present? %>
<a class="align-middle" href="<%= @course.homepage %>">
<i class="fa fa-link text-blue-600"></i>
</a>
<% end %>
</div>
<div class="flex flex-col gap-4">
<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 w-full">
<div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 rounded-lg">
<%= render partial: 'course_table', locals: { course: @course, current_lecture: @current_lecture } %>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,9 +1,12 @@
<h1 class="text-3xl font-medium">Today</h1> <h1 class="text-3xl font-medium">Today</h1>
<div class="mt-4 py-2 w-full"> <div class="flex flex-col gap-4">
<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 w-full">
<div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 rounded-lg"> <div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 rounded-lg">
<div class="divide-y divide-gray-300 w-full"> <div class="divide-y divide-gray-300 w-full">
<div class="flex py-3.5 justify-between bg-gray-50 text-left text-sm font-semibold text-gray-900 px-6 grid today-table-grid"> <div class="flex py-3.5 justify-between bg-gray-50 text-left text-sm font-semibold text-gray-900 px-6 grid grid-cols-4">
<div>Course</div> <div>Course</div>
<div>Lecture</div> <div>Lecture</div>
<div>Status</div> <div>Status</div>
@ -13,11 +16,10 @@
<% @lectures.each do |lecture| %> <% @lectures.each do |lecture| %>
<% status_classes = class_names({ <% status_classes = class_names({
'lecture-future': lecture.start_time.future?, 'lecture-future': lecture.start_time.future?,
'bg-purple-100': lecture == @current_lecture,
'bg-green-100': lecture.attended?, 'bg-green-100': lecture.attended?,
}) %> }) %>
<div class="px-6 py-4 flex justify-between items-center grid today-table-grid gap-2 <%= status_classes %>"> <div class="<%= status_classes %> px-6 py-4 flex justify-between bg-white items-center grid grid-cols-4">
<div class="whitespace-nowrap text-sm font-medium text-gray-900"> <div class="whitespace-nowrap text-sm font-medium text-gray-900">
<%= lecture.course.title %> <%= lecture.course.title %>
</div> </div>
@ -31,10 +33,36 @@
</div> </div>
<div class="whitespace-nowrap text-sm font-medium text-gray-900"> <div class="whitespace-nowrap text-sm font-medium text-gray-900">
<%= render partial: 'lecture_action', locals: { lecture: } %> <% 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 %>
</div> </div>
</div> </div>
<% end %> <% end %>
</div> </div>
</div> </div>
</div>
</div>
</div>
</div> </div>

View File

@ -9,9 +9,6 @@ module.exports = {
], ],
theme: { theme: {
extend: { extend: {
screens: {
'xs': '320px',
},
fontFamily: { fontFamily: {
sans: ['Inter var', ...defaultTheme.fontFamily.sans], sans: ['Inter var', ...defaultTheme.fontFamily.sans],
}, },