Transition entirely to div version
This commit is contained in:
parent
ab43d0f7a0
commit
c1c7342497
@ -1,11 +1,6 @@
|
||||
class AttendanceTrackerController < ApplicationController
|
||||
before_action :refresh_toggl
|
||||
|
||||
def index
|
||||
@courses = Course.active.sort_by(&:title)
|
||||
@current_lecture = get_current_lecture
|
||||
end
|
||||
|
||||
def overview
|
||||
@courses = Course.active.sort_by(&:title)
|
||||
@current_lecture = get_current_lecture
|
||||
@ -13,9 +8,9 @@ class AttendanceTrackerController < ApplicationController
|
||||
|
||||
def today
|
||||
@courses = Course.active.sort_by(&:title)
|
||||
@date = Date.today
|
||||
@date = Date.tomorrow
|
||||
@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.to_date == @date } }.sort_by { |l| l.start_time }
|
||||
end
|
||||
|
||||
def course_focus
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
</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 flex flex-row justify-between">
|
||||
<div class="py-2 bg-gray-50 text-left text-sm font-semibold text-gray-900 px-6 flex flex-row justify-between">
|
||||
Week <%= week_number %>
|
||||
|
||||
<div>
|
||||
|
||||
@ -1,63 +0,0 @@
|
||||
<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.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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@ -2,10 +2,10 @@
|
||||
<h1 class="text-3xl font-medium">Overview</h1>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row flex-wrap gap-4 justify-around">
|
||||
<div class="flex flex-row flex-wrap gap-4 justify-around items-start">
|
||||
<% @courses.each do |course| %>
|
||||
<div class="min-w-[350px] sm:min-w-[500px] flex-grow max-w-lg">
|
||||
<div class="flex flex-row gap-2 items-center">
|
||||
<div class="min-w-[350px] sm:min-w-[500px] flex-grow max-w-lg mt-4 shadow ring-1 ring-black ring-opacity-5 rounded-lg">
|
||||
<div class="flex flex-row gap-2 items-center px-4 p-2 justify-between">
|
||||
<h1 class="text-xl font-medium"><%= course.title %></h1>
|
||||
|
||||
<% if course.homepage.present? %>
|
||||
@ -15,7 +15,7 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 shadow ring-1 ring-black ring-opacity-5 rounded-lg">
|
||||
<div class="border-t-2 divide-y divide-gray-300 w-full">
|
||||
<%= render partial: 'course_table', locals: { course: course, current_lecture: @current_lecture } %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -10,31 +10,7 @@
|
||||
<div>Action</div>
|
||||
</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="px-6 py-4 flex justify-between items-center grid today-table-grid gap-2 <%= status_classes %>">
|
||||
<div class="whitespace-nowrap text-sm font-medium text-gray-900">
|
||||
<%= lecture.course.title %>
|
||||
</div>
|
||||
|
||||
<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: 'lectures/lecture_status_icons', locals: { lecture: } %>
|
||||
</div>
|
||||
|
||||
<div class="whitespace-nowrap text-sm font-medium text-gray-900">
|
||||
<%= render partial: 'lectures/lecture_action', locals: { lecture: } %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<%= render @lectures, { div: true, today_view: true } %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -19,13 +19,17 @@
|
||||
data-controller="popover"
|
||||
data-action="mouseenter->popover#show mouseleave->popover#hide"
|
||||
>
|
||||
<%= lecture.start_time.to_fs(:dmy) %>
|
||||
<% if local_assigns[:today_view] %>
|
||||
<%= lecture.start_time.to_fs(:time) %> ‐ <%= lecture.end_time.to_fs(:time) %>
|
||||
<% else %>
|
||||
<%= lecture.start_time.to_fs(:dmy) %>
|
||||
|
||||
<template data-popover-target="content">
|
||||
<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">
|
||||
<%= lecture.start_time.to_fs(:time) %> ‐ <%= lecture.end_time.to_fs(:time) %>
|
||||
</div>
|
||||
</template>
|
||||
<template data-popover-target="content">
|
||||
<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">
|
||||
<%= lecture.start_time.to_fs(:time) %> ‐ <%= lecture.end_time.to_fs(:time) %>
|
||||
</div>
|
||||
</template>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="whitespace-nowrap text-sm font-medium text-gray-900" data-controller="popover" data-action="mouseenter->popover#show mouseleave->popover#hide">
|
||||
|
||||
@ -12,7 +12,7 @@ Rails.application.routes.draw do
|
||||
get '/courses/:id/fill_in_default_live_video_url', to: 'courses#fill_in_default_live_video_url', as: :course_fill_in_default_live_video_url
|
||||
end
|
||||
|
||||
root controller: :attendance_tracker, action: :index
|
||||
root controller: :attendance_tracker, action: :overview
|
||||
get '/today', controller: :attendance_tracker, action: :today
|
||||
get '/overview', controller: :attendance_tracker, action: :overview
|
||||
get '/courses/:id', controller: :attendance_tracker, action: :course_focus
|
||||
|
||||
Loading…
Reference in New Issue
Block a user