From a61c20be2d519591ef64960734b1b2bd70893fbe Mon Sep 17 00:00:00 2001 From: Peter Hamberg Date: Tue, 29 Nov 2016 10:28:19 +0100 Subject: Add data transformation method to widget base in order to make it possible to transform the incoming data before it is sent to batman. --- javascripts/dashing.coffee | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'javascripts') diff --git a/javascripts/dashing.coffee b/javascripts/dashing.coffee index 20a9987..a85d595 100644 --- a/javascripts/dashing.coffee +++ b/javascripts/dashing.coffee @@ -57,16 +57,22 @@ class Dashing.Widget extends Batman.View # In case the events from the server came before the widget was rendered lastData = Dashing.lastEvents[@id] if lastData + lastData = @select(lastData) @mixin(lastData) @onData(lastData) receiveData: (data) => + data = @select(data) @mixin(data) @onData(data) onData: (data) => # Widgets override this to handle incoming data + select: (data) => + # Widgets override this to transform data before it is applied to the model + return data + Dashing.AnimatedValue = get: Batman.Property.defaultAccessor.get set: (k, to) -> -- cgit v1.2.3 From fa7cf47e28a4ac1636e947c269ed83abe49a1491 Mon Sep 17 00:00:00 2001 From: Peter Hamberg Date: Thu, 21 Sep 2017 09:08:21 +0200 Subject: don't multiply the updatedAt timestamp by 1000 The updatedAt timestamp has already been multiplied by 1000 at https://github.com/Smashing/smashing/blob/master/lib/dashing/app.rb#L141 so there is no need to multiply it again. See https://github.com/Smashing/smashing/commit/fce2ae11158aa39d1a3a5572707a997384afc6fc --- javascripts/dashing.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'javascripts') diff --git a/javascripts/dashing.coffee b/javascripts/dashing.coffee index a85d595..58218ae 100644 --- a/javascripts/dashing.coffee +++ b/javascripts/dashing.coffee @@ -46,7 +46,7 @@ class Dashing.Widget extends Batman.View @accessor 'updatedAtMessage', -> if updatedAt = @get('updatedAt') - timestamp = new Date(updatedAt * 1000) + timestamp = new Date(updatedAt) hours = timestamp.getHours() minutes = ("0" + timestamp.getMinutes()).slice(-2) "Last updated at #{hours}:#{minutes}" -- cgit v1.2.3