Skip to content

Commit

Permalink
Update user page with total hours and join date
Browse files Browse the repository at this point in the history
  • Loading branch information
oahray committed Feb 26, 2019
1 parent 59ddea1 commit aa33e8c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
21 changes: 19 additions & 2 deletions app/assets/stylesheets/_header.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
.title-container {
@include clearfix;

h1 {
float: left;
.user-detail-container {
.user-title {
float: left;
margin-bottom: 0;
}
}
}

.user-stats {
.joined-time {
margin-left: 0.5em;
font-size: 0.8rem
}

.total-hours {
float: right;
margin-right: 1em;
font-weight: bold;
text-align: center;
}
}
1 change: 0 additions & 1 deletion app/assets/stylesheets/_time_span.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

p {
float: right;
// font-size: em;
color: #ccc;
text-transform: uppercase;
letter-spacing: 1px;
Expand Down
1 change: 1 addition & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class UsersController < ApplicationController
def show
@time_series = time_series_for(resource)
@entry_stats = EntryStats.new(@time_series.entries_for_time_span)
end

def index
Expand Down
3 changes: 2 additions & 1 deletion app/views/_header.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.title-container
%h1= title
.user-detail-container
%h1.user-title= title
= render "/time_span" if @time_series
9 changes: 7 additions & 2 deletions app/views/users/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
.outer
.container
= render "/header", title: @user.full_name
%p.user-stats
%span.joined-time Joined: #{@user.created_at.strftime("%B %d, %Y")}
%span.total-hours Total Hours Spent: #{@entry_stats.total_hours}
.charts
= render @time_series.chart, time_series: @time_series
.charts
= render "/charts/pie_chart", title: t("charts.hours_spent_per_project"), data: EntryStats.new(@time_series.entries_for_time_span).hours_for_subject_collection(Project.all).to_json
= render "/charts/pie_chart", title: t("charts.hours_spent_per_category"), data: EntryStats.new(@time_series.entries_for_time_span).hours_for_subject_collection(Category.all).to_json
= render "/charts/pie_chart", title: t("charts.hours_spent_per_project"),
data: @entry_stats.hours_for_subject_collection(Project.all).to_json
= render "/charts/pie_chart", title: t("charts.hours_spent_per_category"),
data: @entry_stats.hours_for_subject_collection(Category.all).to_json
= link_to t("users.show.entries"), user_entries_path(@user)

0 comments on commit aa33e8c

Please sign in to comment.