Skip to content

Commit

Permalink
[fix] unexpected error when select time range
Browse files Browse the repository at this point in the history
  • Loading branch information
takkaO committed Jun 2, 2022
1 parent 9426750 commit c057890
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@types/grafana": "github:CorpGlory/types-grafana.git",
"@types/lodash": "^4.14.182",
"dayjs": "^1.11.2",
"moment": "^2.22.1",
"jquery": "^3.2.1",
"lodash": "^4.17.10"
},
Expand Down
4 changes: 2 additions & 2 deletions src/canvas-metric.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MetricsPanelCtrl } from 'grafana/app/plugins/sdk';

/* eslint-disable id-blacklist, no-restricted-imports, @typescript-eslint/ban-types */
//import moment from 'moment';
import moment from 'moment';
import dayjs, { extend } from 'dayjs';
import duration from 'dayjs/plugin/duration';
import relativeTime from 'dayjs/plugin/relativeTime';
Expand Down Expand Up @@ -244,7 +244,7 @@ export class CanvasPanelCtrl extends MetricsPanelCtrl {
} else {
const min = Math.min(this.mouse.down.ts, up.ts);
const max = Math.max(this.mouse.down.ts, up.ts);
const range = { from: dayjs.utc(min), to: dayjs.utc(max) };
const range = { from: moment.utc(min), to: moment.utc(max) };
this.mouse.position = up;
this.onMouseSelectedRange(range, evt);
}
Expand Down
4 changes: 2 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import kbn from 'grafana/app/core/utils/kbn';
import appEvents from 'grafana/app/core/app_events';

/* eslint-disable id-blacklist, no-restricted-imports, @typescript-eslint/ban-types */
//import moment from 'moment';
import moment from 'moment';
import dayjs, { extend } from 'dayjs';
import duration from 'dayjs/plugin/duration';
import relativeTime from 'dayjs/plugin/relativeTime';
Expand Down Expand Up @@ -740,7 +740,7 @@ class DiscretePanelCtrl extends CanvasPanelCtrl {

const pt = this.hoverPoint;
if (pt && pt.start) {
const range = { from: dayjs.utc(pt.start), to: dayjs.utc(pt.start + pt.ms) };
const range = { from: moment.utc(pt.start), to: moment.utc(pt.start + pt.ms) };
this.timeSrv.setTime(range);
this.clear();
}
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8124,6 +8124,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3"
integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==

moment@^2.22.1:
version "2.29.3"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.3.tgz#edd47411c322413999f7a5940d526de183c031f3"
integrity sha512-c6YRvhEo//6T2Jz/vVtYzqBzwvPT95JBQ+smCytzf7c50oMZRsR/a4w88aD34I+/QVSfnoAnSBFPJHItlOMJVw==

monaco-editor@*:
version "0.21.2"
resolved "https://registry.yarnpkg.com/monaco-editor/-/monaco-editor-0.21.2.tgz#37054e63e480d51a2dd17d609dcfb192304d5605"
Expand Down

0 comments on commit c057890

Please sign in to comment.