Skip to content

Commit

Permalink
Merge pull request #3266 from Countly/fix/dasboard-custom-period
Browse files Browse the repository at this point in the history
[SER-157] to convert seconds to ms
  • Loading branch information
ar2rsawseen authored Jun 15, 2022
2 parents ef7a5d6 + ef5088a commit 76e2a3f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion plugins/dashboards/frontend/public/javascripts/countly.models.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,16 @@
create: function(context, widget) {
var dashboardId = context.rootGetters["countlyDashboards/selected"].id;
var settings = widget.settings || {};

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);
}
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) {
Expand All @@ -334,6 +343,16 @@
var dashboardId = context.rootGetters["countlyDashboards/selected"].id;
var widgetId = widget.id;
var settings = widget.settings;
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);
}
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
v-if="checkbox"
name="title"
:rules="checkbox ? 'required' : ''">
<cly-date-picker v-model="customPeriod" timestampFormat="s"></cly-date-picker>
<cly-date-picker v-model="customPeriod" timestampFormat="ms"></cly-date-picker>
</cly-form-field>
</div>

0 comments on commit 76e2a3f

Please sign in to comment.