1
0
mirror of https://github.com/fspc/BikeShed-1.git synced 2025-04-04 05:33:22 -04:00
BikeShed-1/app/components/user_stats.rb
John N. Milner 55fbd06305 Closes #1
2013-04-04 22:27:54 -04:00

33 lines
747 B
Ruby

class UserStats < Netzke::Base
def body_content(user)
bike = user.bike
%Q(
<div id="user_stats_page">
<p>Total Hours Worked: #{user.total_hours}</p>
<p>Hours worked in #{Time.now.strftime('%B')}: #{user.current_month_hours}</p>
<p>Current bike Shop ID: #{bike.shop_id if bike}</p>
<p>Current bike S/N: #{bike.serial_number if bike}</p>
</div>
)
end
js_configure do |c|
c.body_padding = 15
c.title = "User Stats"
c.mixin :user_stats
end
endpoint :server_update do |params, this|
# updateBodyHtml is a JS-side method we inherit from Netkze::Basepack::Panel
this[:update] = [body_content(user)]
end
private
def user
controller.current_user
end
end