class UserStats < Netzke::Base
def body_content(user)
bike = user.bike
%Q(
Total Hours Worked: #{user.total_hours}
Hours worked in #{Time.now.strftime('%B')}: #{user.current_month_hours}
Current bike ID: #{bike.id if bike}
Current bike S/N: #{bike.serial_number if bike}
)
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