mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-06-16 14:28:14 +00:00
ui: Replace moment with date-fns. (#460)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import moment from "moment";
|
||||
import { format } from "date-fns";
|
||||
import { JSONTree as JSONTreeOriginal } from "react-json-tree";
|
||||
import fileDownload from "js-file-download";
|
||||
|
||||
@ -25,7 +25,7 @@ function LogTable(props: IProps) {
|
||||
const onDrawerOpen = (time: { seconds: number } | undefined, body: string) => {
|
||||
const ts = new Date(0);
|
||||
ts.setUTCSeconds(time!.seconds);
|
||||
const drawerTitle = moment(ts).format("YYYY-MM-DD HH:mm:ss");
|
||||
const drawerTitle = format(ts, "YYYY-MM-DD HH:mm:ss");
|
||||
|
||||
return () => {
|
||||
setBody(body);
|
||||
@ -106,7 +106,7 @@ function LogTable(props: IProps) {
|
||||
render: (text, obj) => {
|
||||
const ts = new Date(0);
|
||||
ts.setUTCSeconds(obj.time!.seconds);
|
||||
return moment(ts).format("YYYY-MM-DD HH:mm:ss");
|
||||
return format(ts, "YYYY-MM-DD HH:mm:ss");
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -2,7 +2,6 @@ import { Card } from "antd";
|
||||
|
||||
import type { TimeUnit } from "chart.js";
|
||||
import { Bar } from "react-chartjs-2";
|
||||
import moment from "moment";
|
||||
import palette from "google-palette";
|
||||
|
||||
import type { Metric } from "@chirpstack/chirpstack-api-grpc-web/common/common_pb";
|
||||
@ -52,7 +51,7 @@ function MetricBar(props: IProps) {
|
||||
backgroundColor: string;
|
||||
}[];
|
||||
} = {
|
||||
labels: props.metric.getTimestampsList().map(v => moment(v.toDate()).valueOf()),
|
||||
labels: props.metric.getTimestampsList().map(v => v.toDate().getTime()),
|
||||
datasets: [],
|
||||
};
|
||||
|
||||
|
@ -2,7 +2,6 @@ import { Card } from "antd";
|
||||
|
||||
import type { TimeUnit } from "chart.js";
|
||||
import { Line } from "react-chartjs-2";
|
||||
import moment from "moment";
|
||||
import palette from "google-palette";
|
||||
|
||||
import type { Metric } from "@chirpstack/chirpstack-api-grpc-web/common/common_pb";
|
||||
@ -54,7 +53,7 @@ function MetricChart(props: IProps) {
|
||||
|
||||
let prevValue = 0;
|
||||
const data = {
|
||||
labels: props.metric.getTimestampsList().map(v => moment(v.toDate()).valueOf()),
|
||||
labels: props.metric.getTimestampsList().map(v => v.toDate().getTime()),
|
||||
datasets: props.metric
|
||||
.getDatasetsList()
|
||||
.sort((a, b) => a.getLabel().localeCompare(b.getLabel()))
|
||||
|
@ -5,7 +5,6 @@ import { Card } from "antd";
|
||||
import { color } from "chart.js/helpers";
|
||||
import type { TimeUnit } from "chart.js";
|
||||
import { Chart } from "react-chartjs-2";
|
||||
import moment from "moment";
|
||||
|
||||
import type { Metric } from "@chirpstack/chirpstack-api-grpc-web/common/common_pb";
|
||||
import { Aggregation } from "@chirpstack/chirpstack-api-grpc-web/common/common_pb";
|
||||
@ -44,7 +43,7 @@ function MetricHeatmap(props: IProps) {
|
||||
unit: unit,
|
||||
},
|
||||
offset: true,
|
||||
labels: props.metric.getTimestampsList().map(v => moment(v.toDate().valueOf())),
|
||||
labels: props.metric.getTimestampsList().map(v => v.toDate().getTime()),
|
||||
grid: {
|
||||
display: false,
|
||||
},
|
||||
@ -127,7 +126,7 @@ function MetricHeatmap(props: IProps) {
|
||||
}
|
||||
|
||||
data.datasets[0].data.push({
|
||||
x: moment(tsList[i].toDate()).valueOf(),
|
||||
x: tsList[i].toDate().getTime(),
|
||||
y: ds.getLabel(),
|
||||
v: v,
|
||||
});
|
||||
|
Reference in New Issue
Block a user