From ebf6c512bf26fbe0e689b00fa17223b501013853 Mon Sep 17 00:00:00 2001 From: Abhishek Singla Date: Tue, 14 Jun 2022 18:54:06 +0000 Subject: [PATCH 1/2] to convert seconds to ms --- .../public/javascripts/countly.models.js | 21 ++++++++++++++++++- .../templates/helpers/drawer/period.html | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/plugins/dashboards/frontend/public/javascripts/countly.models.js b/plugins/dashboards/frontend/public/javascripts/countly.models.js index e5c4da7ea15..fbd6cef3ec0 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.models.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.models.js @@ -317,7 +317,16 @@ create: function(context, widget) { var dashboardId = context.rootGetters["countlyDashboards/selected"].id; var settings = widget.settings || {}; - + if (widget.settings.custom_period && typeof widget.settings.custom_period === "object") { + if (Array.isArray(widget.settings.custom_period)) { + if (widget.settings.custom_period[0] && widget.settings.custom_period[0].toString().length === 13) { + widget.settings.custom_period[0] = Math.floor(widget.settings.custom_period[0] / 1000); + } + if (widget.settings.custom_period[1] && widget.settings.custom_period[1].toString().length === 13) { + widget.settings.custom_period[1] = Math.floor(widget.settings.custom_period[1] / 1000); + } + } + } return countlyDashboards.service.widgets.create(dashboardId, settings).then(function(id) { return id; }).catch(function(e) { @@ -334,6 +343,16 @@ var dashboardId = context.rootGetters["countlyDashboards/selected"].id; var widgetId = widget.id; var settings = widget.settings; + if (widget.settings.custom_period && typeof widget.settings.custom_period === "object") { + if (Array.isArray(widget.settings.custom_period)) { + if (widget.settings.custom_period[0] && widget.settings.custom_period[0].toString().length === 13) { + widget.settings.custom_period[0] = Math.floor(widget.settings.custom_period[0] / 1000); + } + if (widget.settings.custom_period[1] && widget.settings.custom_period[1].toString().length === 13) { + widget.settings.custom_period[1] = Math.floor(widget.settings.custom_period[1] / 1000); + } + } + } return countlyDashboards.service.widgets.update(dashboardId, widgetId, settings).then(function() { return widgetId; diff --git a/plugins/dashboards/frontend/public/templates/helpers/drawer/period.html b/plugins/dashboards/frontend/public/templates/helpers/drawer/period.html index efeb3c9cae6..4f21893aebc 100644 --- a/plugins/dashboards/frontend/public/templates/helpers/drawer/period.html +++ b/plugins/dashboards/frontend/public/templates/helpers/drawer/period.html @@ -4,6 +4,6 @@ v-if="checkbox" name="title" :rules="checkbox ? 'required' : ''"> - + From ef5088a6aa940234397eb96a742ba030c2bebaea Mon Sep 17 00:00:00 2001 From: Abhishek Singla Date: Tue, 14 Jun 2022 19:04:42 +0000 Subject: [PATCH 2/2] to convert seconds to ms --- .../dashboards/frontend/public/javascripts/countly.models.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/dashboards/frontend/public/javascripts/countly.models.js b/plugins/dashboards/frontend/public/javascripts/countly.models.js index fbd6cef3ec0..44265df67a7 100644 --- a/plugins/dashboards/frontend/public/javascripts/countly.models.js +++ b/plugins/dashboards/frontend/public/javascripts/countly.models.js @@ -317,7 +317,7 @@ create: function(context, widget) { var dashboardId = context.rootGetters["countlyDashboards/selected"].id; var settings = widget.settings || {}; - if (widget.settings.custom_period && typeof widget.settings.custom_period === "object") { + if (widget.settings && widget.settings.custom_period && typeof widget.settings.custom_period === "object") { if (Array.isArray(widget.settings.custom_period)) { if (widget.settings.custom_period[0] && widget.settings.custom_period[0].toString().length === 13) { widget.settings.custom_period[0] = Math.floor(widget.settings.custom_period[0] / 1000); @@ -343,7 +343,7 @@ var dashboardId = context.rootGetters["countlyDashboards/selected"].id; var widgetId = widget.id; var settings = widget.settings; - if (widget.settings.custom_period && typeof widget.settings.custom_period === "object") { + if (widget.settings && widget.settings.custom_period && typeof widget.settings.custom_period === "object") { if (Array.isArray(widget.settings.custom_period)) { if (widget.settings.custom_period[0] && widget.settings.custom_period[0].toString().length === 13) { widget.settings.custom_period[0] = Math.floor(widget.settings.custom_period[0] / 1000);