mirror of
https://github.com/rickbarrette/stopwatch.git
synced 2026-11-17 19:50:36 -05:00
Running timers page with view/stop permissions
- New top-menu page listing running timers: owner, issue, project, activity, start time, time on this run and entry total, oldest first; refreshes every minute - Role permissions "View running timers" and "Stop other users' timers", checked against each timer's project; users can always stop their own - A timer can be stopped at an earlier time (when the person left): hours logged after it are taken off the entry, and the comment notes who stopped it and when - Timers now record when they were started (session_started_at); timers running from before show "unknown" until restarted - Integration tests for permissions, project scoping and stopping; unit tests for Timer#stop_for Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
11 files changed
+399
-1
No files matched your search
@@ -0,0 +1,77 @@
|
||||
<div class="contextual">
|
||||
<%= link_to sprite_icon(:reload, l(:label_stopwatch_refresh)), stopwatch_running_timers_path, class: 'icon icon-reload' %>
|
||||
</div>
|
||||
|
||||
<h2><%= l(:label_stopwatch_running_timers) %></h2>
|
||||
|
||||
<% if @rows.empty? %>
|
||||
<p class="nodata"><%= l(:label_stopwatch_no_running_timers) %></p>
|
||||
<% else %>
|
||||
<div class="autoscroll">
|
||||
<table class="list stopwatch-running-timers">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= l(:field_user) %></th>
|
||||
<th><%= l(:field_issue) %></th>
|
||||
<th><%= l(:field_project) %></th>
|
||||
<th><%= l(:field_activity) %></th>
|
||||
<th><%= l(:label_stopwatch_started_at) %></th>
|
||||
<th><%= l(:label_stopwatch_running_for) %></th>
|
||||
<th><%= l(:label_stopwatch_entry_total) %></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @rows.each do |row| %>
|
||||
<% entry = row.time_entry %>
|
||||
<tr class="<%= cycle('odd', 'even') %>" id="stopwatch-running-timer-<%= row.user.id %>">
|
||||
<td class="user"><%= avatar(row.user, size: 16) %> <%= link_to_user row.user %></td>
|
||||
<td class="issue">
|
||||
<% if row.issue %>
|
||||
<%= row.issue.visible? ? link_to_issue(row.issue, truncate: 60) : "##{row.issue.id}" %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="project"><%= link_to_project(row.project) if row.project %></td>
|
||||
<td class="activity"><%= entry&.activity %></td>
|
||||
<td class="started">
|
||||
<%= row.started_at ? format_time(row.started_at) : content_tag(:span, l(:label_stopwatch_unknown_start), class: 'stopwatch-unknown', title: l(:text_stopwatch_unknown_start)) %>
|
||||
</td>
|
||||
<td class="hours running"><%= html_hours(format_hours(row.timer.session_hours)) %></td>
|
||||
<td class="hours"><%= html_hours(format_hours(row.timer.time_spent)) %></td>
|
||||
<td class="buttons">
|
||||
<% if row.stoppable_by?(User.current) %>
|
||||
<%= form_tag stop_stopwatch_running_timer_path(row.user), method: :post, class: 'stopwatch-stop-form',
|
||||
data: { confirm: l(:text_stopwatch_confirm_stop, name: row.user.name) } do %>
|
||||
<% if row.started_at %>
|
||||
<%# Optional: when the person actually stopped working; blank = now %>
|
||||
<%= datetime_local_field_tag :stopped_at, nil,
|
||||
min: row.started_at.in_time_zone(User.current.time_zone || Time.zone).strftime('%Y-%m-%dT%H:%M'),
|
||||
max: Time.now.in_time_zone(User.current.time_zone || Time.zone).strftime('%Y-%m-%dT%H:%M'),
|
||||
title: l(:text_stopwatch_stopped_at), 'aria-label': l(:label_stopwatch_stopped_at),
|
||||
id: "stopped_at_#{row.user.id}" %>
|
||||
<% end %>
|
||||
<%= submit_tag l(:label_stopwatch_stop_timer), name: nil, class: 'small' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<p class="stopwatch-running-timers-help"><em class="info"><%= l(:text_stopwatch_running_timers_help) %></em></p>
|
||||
<% end %>
|
||||
|
||||
<%= javascript_tag do %>
|
||||
// Refresh every minute, unless someone is filling in a stop time
|
||||
(function () {
|
||||
setInterval(function () {
|
||||
var busy = Array.prototype.some.call(document.querySelectorAll('.stopwatch-stop-form input[name="stopped_at"]'), function (el) {
|
||||
return el.value !== '' || el === document.activeElement;
|
||||
});
|
||||
if (!busy) window.location.reload();
|
||||
}, 60000);
|
||||
})();
|
||||
<% end %>
|
||||
|
||||
<% html_title(l(:label_stopwatch_running_timers)) -%>
|
||||
Reference in new issue
Block a user