From 35eac65dd9c5e4f10a5bf22053f99aa2a5528354 Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Mon, 14 May 2018 16:24:58 +0100 Subject: [PATCH] mgr/dashboard: Fix moment.js deprecation warning Fixes: https://tracker.ceph.com/issues/24115 Signed-off-by: Tiago Melo (cherry picked from commit 89ae2577303a6b48b8822cddd3ec4fc255b6ff1f) --- .../cephfs-chart/cephfs-chart.component.ts | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.ts index cca1ae2feb921..39a03890add32 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-chart/cephfs-chart.component.ts @@ -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] -- 2.39.5