brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [40/50] [abbrv] brooklyn-ui git commit: for doubles when displaying, round to thousands place
Date Mon, 01 Feb 2016 17:52:13 GMT
for doubles when displaying, round to thousands place


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/f837ce03
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/f837ce03
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/f837ce03

Branch: refs/heads/0.5.0
Commit: f837ce03871d347c7bca4a7ad30525d249c67712
Parents: 463b64f
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Sat Mar 2 19:41:57 2013 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Tue Mar 5 18:05:31 2013 -0800

----------------------------------------------------------------------
 .../src/main/webapp/assets/js/view/entity-sensors.js    | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/f837ce03/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js b/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js
index 91ee9e2..50b3748 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js
@@ -75,7 +75,17 @@ define([
                 $rows.each(function (index, row) {
                     var key = $(this).find(".sensor-name").text();
                     var v = data[key];
-                    if (v === undefined) v = '';
+                    if (v === undefined || v === null) v = '';
+                    else if (typeof v === 'number') {
+                        if (Math.round(v)!=v) {
+                            // not an integer, check if it needs rounding
+                            var vk = v*1000; 
+                            if (Math.round(vk)!=vk) {
+                                // needs rounding
+                                v = Math.round(vk)/1000;
+                            }
+                        }
+                    }
                     $table.dataTable().fnUpdate(_.escape(v), row, 2, false);
                 });
             });


Mime
View raw message