]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Fix moment.js deprecation warning 22052/head
authorTiago Melo <tmelo@suse.com>
Mon, 14 May 2018 15:24:58 +0000 (16:24 +0100)
committerTiago Melo <tmelo@suse.com>
Thu, 17 May 2018 09:19:54 +0000 (10:19 +0100)
Fixes: https://tracker.ceph.com/issues/24115
Signed-off-by: Tiago Melo <tmelo@suse.com>
(cherry picked from commit 89ae2577303a6b48b8822cddd3ec4fc255b6ff1f)

src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.ts

index cca1ae2feb92166ec7f25825141e1406bda3430e..39a03890add32ab28d9317aa1c46c283e7c77756 100644 (file)
@@ -28,15 +28,15 @@ export class CephfsChartComponent implements OnChanges, OnInit {
       return;
     }
 
-    const getTitle = title => {
-      return moment(title).format('LTS');
+    const getTitle = (ts) => {
+      return moment(ts, 'x').format('LTS');
     };
 
-    const getStyleTop = tooltip => {
+    const getStyleTop = (tooltip) => {
       return tooltip.caretY - tooltip.height - 15 + 'px';
     };
 
-    const getStyleLeft = tooltip => {
+    const getStyleLeft = (tooltip) => {
       return tooltip.caretX + 'px';
     };
 
@@ -105,7 +105,18 @@ export class CephfsChartComponent implements OnChanges, OnInit {
           mode: 'index',
           intersect: false,
           position: 'nearest',
-          custom: tooltip => {
+          callbacks: {
+            // Pick the Unix timestamp of the first tooltip item.
+            title: function(tooltipItems, data) {
+              let ts = 0;
+              if (tooltipItems.length > 0) {
+                const item = tooltipItems[0];
+                ts = data.datasets[item.datasetIndex].data[item.index].x;
+              }
+              return ts;
+            }
+          },
+          custom: (tooltip) => {
             chartTooltip.customTooltips(tooltip);
           }
         }
@@ -132,7 +143,7 @@ export class CephfsChartComponent implements OnChanges, OnInit {
   // timestamps)
   convert_timeseries(sourceSeries) {
     const data = [];
-    _.each(sourceSeries, dp => {
+    _.each(sourceSeries, (dp) => {
       data.push({
         x: dp[0] * 1000,
         y: dp[1]