Shopify / dashing

The exceptionally handsome dashboard framework in Ruby and Coffeescript.
http://shopify.github.com/dashing/
MIT License
10.98k stars 1.18k forks source link

Ability to add date to 'Last updated at'. #715

Open barodiamansi opened 8 years ago

barodiamansi commented 8 years ago

There is 'Last update at' text at the bottom of every widget which shows the time of when the dashboard was last updated. I would like to show the date as well along with time. I have <p class="updated-at" data-bind="updatedAtMessage"></p> in my html file and I tried setting "updatedAtMessage" along with the data I pass to send_event, but didn't had much luck with it.

Sample example:

event_data = { items: sample_data }
event_data["updatedAtMessage"] = Time.now.strftime("%d/%m/%Y %H:%M")
send_event(widget_id, event_data)

I think one other workaround could be to override the method which displays 'Last updated at' in the widgets I have. But I am using multiple widgets and will have to override in every single widget. I would appreciate if there is an option in the main Dashing widget to display date along with time.

aming commented 8 years ago

See https://github.com/Shopify/dashing/issues/231 for the solution.

kkuderko commented 7 years ago

so edit the below section in dashing.coffee to something like:

if updatedAt = @get('updatedAt')
  timestamp = new Date(updatedAt * 1000)
  year = timestamp.getFullYear()
  month = timestamp.getMonth()
  day = timestamp.getDate()
  hours = timestamp.getHours()
  minutes = ("0" + timestamp.getMinutes()).slice(-2)
  "Last updated at #{day}/#{month+1}/#{year} #{hours}:#{minutes}"`