@oneuptime/common 7.0.2990 → 7.0.3010
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Models/AnalyticsModels/ExceptionInstance.ts +488 -0
- package/Models/AnalyticsModels/Index.ts +2 -0
- package/Models/AnalyticsModels/Span.ts +2 -2
- package/Models/DatabaseModels/Index.ts +4 -0
- package/Models/DatabaseModels/TelemetryException.ts +978 -0
- package/Server/API/StatusAPI.ts +63 -51
- package/Server/EnvironmentConfig.ts +3 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1724610006927-MigrationName.ts +93 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1724613666632-MigrationName.ts +60 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1724659071843-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
- package/Server/Infrastructure/Queue.ts +36 -1
- package/Server/Infrastructure/QueueWorker.ts +2 -2
- package/Server/Services/DatabaseService.ts +4 -5
- package/Server/Services/ExceptionInstanceService.ts +11 -0
- package/Server/Services/Index.ts +5 -0
- package/Server/Services/StatusPageDomainService.ts +118 -59
- package/Server/Services/TelemetryExceptionService.ts +10 -0
- package/Server/Types/Database/Permissions/Index.ts +1 -1
- package/Server/Types/Database/UpdateByID.ts +1 -1
- package/Server/Utils/Greenlock/Greenlock.ts +331 -204
- package/Server/Utils/Logger.ts +8 -2
- package/Server/Utils/Telemetry.ts +109 -25
- package/Types/Code/CodeType.ts +1 -0
- package/Types/Database/PartialEntity.ts +14 -1
- package/Types/Date.ts +9 -1
- package/Types/Icon/IconProp.ts +2 -0
- package/Types/Permission.ts +39 -0
- package/UI/Components/ActionCard/ActionCard.tsx +66 -0
- package/UI/Components/Alerts/Alert.tsx +69 -60
- package/UI/Components/Card/Card.tsx +1 -0
- package/UI/Components/Charts/ChartGroup/ChartGroup.tsx +4 -17
- package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +1005 -0
- package/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.ts +3 -0
- package/UI/Components/Charts/ChartLibrary/Utils/ChartColors.ts +117 -0
- package/UI/Components/Charts/ChartLibrary/Utils/Cx.ts +8 -0
- package/UI/Components/Charts/ChartLibrary/Utils/GetYAxisDomain.ts +15 -0
- package/UI/Components/Charts/ChartLibrary/Utils/HasOnlyOneValueForKey.ts +19 -0
- package/UI/Components/Charts/ChartLibrary/Utils/UseWindowOnResize.ts +17 -0
- package/UI/Components/Charts/Line/LineChart.tsx +58 -225
- package/UI/Components/Charts/Types/ChartCurve.ts +7 -0
- package/UI/Components/Charts/Types/DataPoint.ts +7 -0
- package/UI/Components/Charts/Types/SeriesPoint.ts +7 -0
- package/UI/Components/Charts/Types/SeriesPoints.ts +6 -0
- package/UI/Components/Charts/Types/XAxis/XAxis.ts +21 -0
- package/UI/Components/Charts/Types/XAxis/XAxisMaxMin.ts +3 -0
- package/UI/Components/Charts/Types/XAxis/XAxisPrecision.ts +26 -0
- package/UI/Components/Charts/Types/XAxis/XAxisType.ts +6 -0
- package/UI/Components/Charts/Types/XValue.ts +3 -0
- package/UI/Components/Charts/Types/YAxis/YAxis.ts +22 -0
- package/UI/Components/Charts/Types/YAxis/YAxisMaxMin.ts +3 -0
- package/UI/Components/Charts/Types/YAxis/YAxisType.ts +5 -0
- package/UI/Components/Charts/Types/YValue.ts +3 -0
- package/UI/Components/Charts/Utils/DataPoint.ts +188 -0
- package/UI/Components/Charts/Utils/XAxis.ts +267 -0
- package/UI/Components/Detail/Detail.tsx +6 -1
- package/UI/Components/GanttChart/Row/Row.tsx +4 -2
- package/UI/Components/GanttChart/Row/RowLabel.tsx +7 -3
- package/UI/Components/Icon/Icon.tsx +16 -0
- package/UI/Components/LogsViewer/LogsViewer.tsx +1 -1
- package/UI/Components/Types/FieldType.ts +1 -0
- package/UI/Config.ts +2 -0
- package/UI/Utils/Telemetry.ts +7 -2
- package/Utils/Crypto.ts +11 -0
- package/build/dist/Models/AnalyticsModels/ExceptionInstance.js +445 -0
- package/build/dist/Models/AnalyticsModels/ExceptionInstance.js.map +1 -0
- package/build/dist/Models/AnalyticsModels/Index.js +2 -0
- package/build/dist/Models/AnalyticsModels/Index.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/Span.js +2 -2
- package/build/dist/Models/DatabaseModels/Index.js +2 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/TelemetryException.js +1010 -0
- package/build/dist/Models/DatabaseModels/TelemetryException.js.map +1 -0
- package/build/dist/Server/API/StatusAPI.js +52 -44
- package/build/dist/Server/API/StatusAPI.js.map +1 -1
- package/build/dist/Server/EnvironmentConfig.js +1 -0
- package/build/dist/Server/EnvironmentConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724610006927-MigrationName.js +38 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724610006927-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724613666632-MigrationName.js +26 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724613666632-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724659071843-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724659071843-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Infrastructure/Queue.js +20 -1
- package/build/dist/Server/Infrastructure/Queue.js.map +1 -1
- package/build/dist/Server/Infrastructure/QueueWorker.js +2 -2
- package/build/dist/Server/Infrastructure/QueueWorker.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/ExceptionInstanceService.js +9 -0
- package/build/dist/Server/Services/ExceptionInstanceService.js.map +1 -0
- package/build/dist/Server/Services/Index.js +4 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/StatusPageDomainService.js +101 -53
- package/build/dist/Server/Services/StatusPageDomainService.js.map +1 -1
- package/build/dist/Server/Services/TelemetryExceptionService.js +9 -0
- package/build/dist/Server/Services/TelemetryExceptionService.js.map +1 -0
- package/build/dist/Server/Types/Database/Permissions/Index.js.map +1 -1
- package/build/dist/Server/Utils/Greenlock/Greenlock.js +234 -157
- package/build/dist/Server/Utils/Greenlock/Greenlock.js.map +1 -1
- package/build/dist/Server/Utils/Logger.js +5 -1
- package/build/dist/Server/Utils/Logger.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry.js +63 -22
- package/build/dist/Server/Utils/Telemetry.js.map +1 -1
- package/build/dist/Types/Code/CodeType.js +1 -0
- package/build/dist/Types/Code/CodeType.js.map +1 -1
- package/build/dist/Types/Database/PartialEntity.js +3 -0
- package/build/dist/Types/Database/PartialEntity.js.map +1 -1
- package/build/dist/Types/Date.js +7 -1
- package/build/dist/Types/Date.js.map +1 -1
- package/build/dist/Types/Icon/IconProp.js +2 -0
- package/build/dist/Types/Icon/IconProp.js.map +1 -1
- package/build/dist/Types/Permission.js +33 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/UI/Components/ActionCard/ActionCard.js +27 -0
- package/build/dist/UI/Components/ActionCard/ActionCard.js.map +1 -0
- package/build/dist/UI/Components/Alerts/Alert.js +36 -45
- package/build/dist/UI/Components/Alerts/Alert.js.map +1 -1
- package/build/dist/UI/Components/Card/Card.js +1 -1
- package/build/dist/UI/Components/Card/Card.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js +4 -9
- package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +388 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.js +2 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.js.map +1 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Utils/ChartColors.js +88 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Utils/ChartColors.js.map +1 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Utils/Cx.js +7 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Utils/Cx.js.map +1 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Utils/GetYAxisDomain.js +7 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Utils/GetYAxisDomain.js.map +1 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Utils/HasOnlyOneValueForKey.js +14 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Utils/HasOnlyOneValueForKey.js.map +1 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Utils/UseWindowOnResize.js +14 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Utils/UseWindowOnResize.js.map +1 -0
- package/build/dist/UI/Components/Charts/Line/LineChart.js +30 -136
- package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/Types/ChartCurve.js +8 -0
- package/build/dist/UI/Components/Charts/Types/ChartCurve.js.map +1 -0
- package/build/dist/UI/Components/Charts/Types/DataPoint.js +2 -0
- package/build/dist/UI/Components/Charts/Types/DataPoint.js.map +1 -0
- package/build/dist/UI/Components/Charts/Types/SeriesPoint.js +2 -0
- package/build/dist/UI/Components/Charts/Types/SeriesPoint.js.map +1 -0
- package/build/dist/UI/Components/Charts/Types/SeriesPoints.js +2 -0
- package/build/dist/UI/Components/Charts/Types/SeriesPoints.js.map +1 -0
- package/build/dist/UI/Components/Charts/Types/XAxis/XAxis.js +8 -0
- package/build/dist/UI/Components/Charts/Types/XAxis/XAxis.js.map +1 -0
- package/build/dist/UI/Components/Charts/Types/XAxis/XAxisMaxMin.js +2 -0
- package/build/dist/UI/Components/Charts/Types/XAxis/XAxisMaxMin.js.map +1 -0
- package/build/dist/UI/Components/Charts/Types/XAxis/XAxisPrecision.js +27 -0
- package/build/dist/UI/Components/Charts/Types/XAxis/XAxisPrecision.js.map +1 -0
- package/build/dist/UI/Components/Charts/Types/XAxis/XAxisType.js +7 -0
- package/build/dist/UI/Components/Charts/Types/XAxis/XAxisType.js.map +1 -0
- package/build/dist/UI/Components/Charts/Types/XValue.js +2 -0
- package/build/dist/UI/Components/Charts/Types/XValue.js.map +1 -0
- package/build/dist/UI/Components/Charts/Types/YAxis/YAxis.js +8 -0
- package/build/dist/UI/Components/Charts/Types/YAxis/YAxis.js.map +1 -0
- package/build/dist/UI/Components/Charts/Types/YAxis/YAxisMaxMin.js +2 -0
- package/build/dist/UI/Components/Charts/Types/YAxis/YAxisMaxMin.js.map +1 -0
- package/build/dist/UI/Components/Charts/Types/YAxis/YAxisType.js +6 -0
- package/build/dist/UI/Components/Charts/Types/YAxis/YAxisType.js.map +1 -0
- package/build/dist/UI/Components/Charts/Types/YValue.js +2 -0
- package/build/dist/UI/Components/Charts/Types/YValue.js.map +1 -0
- package/build/dist/UI/Components/Charts/Utils/DataPoint.js +109 -0
- package/build/dist/UI/Components/Charts/Utils/DataPoint.js.map +1 -0
- package/build/dist/UI/Components/Charts/Utils/XAxis.js +241 -0
- package/build/dist/UI/Components/Charts/Utils/XAxis.js.map +1 -0
- package/build/dist/UI/Components/Detail/Detail.js +5 -1
- package/build/dist/UI/Components/Detail/Detail.js.map +1 -1
- package/build/dist/UI/Components/GanttChart/Row/Row.js +2 -2
- package/build/dist/UI/Components/GanttChart/Row/Row.js.map +1 -1
- package/build/dist/UI/Components/GanttChart/Row/RowLabel.js +3 -3
- package/build/dist/UI/Components/GanttChart/Row/RowLabel.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +6 -0
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js +1 -1
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
- package/build/dist/UI/Components/Types/FieldType.js +1 -0
- package/build/dist/UI/Components/Types/FieldType.js.map +1 -1
- package/build/dist/UI/Config.js +1 -0
- package/build/dist/UI/Config.js.map +1 -1
- package/build/dist/UI/Utils/Telemetry.js +6 -3
- package/build/dist/UI/Utils/Telemetry.js.map +1 -1
- package/build/dist/Utils/Crypto.js +10 -0
- package/build/dist/Utils/Crypto.js.map +1 -0
- package/package.json +15 -13
- package/UI/Components/Charts/Bar/Bar.tsx +0 -0
- package/UI/Components/Charts/Base/BaseChart.tsx +0 -0
- package/UI/Components/Charts/Tooltip/Tooltip.tsx +0 -84
- package/build/dist/UI/Components/Charts/Bar/Bar.js +0 -2
- package/build/dist/UI/Components/Charts/Bar/Bar.js.map +0 -1
- package/build/dist/UI/Components/Charts/Base/BaseChart.js +0 -2
- package/build/dist/UI/Components/Charts/Base/BaseChart.js.map +0 -1
- package/build/dist/UI/Components/Charts/Tooltip/Tooltip.js +0 -34
- package/build/dist/UI/Components/Charts/Tooltip/Tooltip.js.map +0 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Tremor Raw chartColors [v0.1.0]
|
|
2
|
+
|
|
3
|
+
export type ColorUtility = "bg" | "stroke" | "fill" | "text";
|
|
4
|
+
|
|
5
|
+
export const chartColors: {
|
|
6
|
+
[color: string]: {
|
|
7
|
+
[key in ColorUtility]: string;
|
|
8
|
+
};
|
|
9
|
+
} = {
|
|
10
|
+
blue: {
|
|
11
|
+
bg: "bg-blue-500",
|
|
12
|
+
stroke: "stroke-blue-500",
|
|
13
|
+
fill: "fill-blue-500",
|
|
14
|
+
text: "text-blue-500",
|
|
15
|
+
},
|
|
16
|
+
emerald: {
|
|
17
|
+
bg: "bg-emerald-500",
|
|
18
|
+
stroke: "stroke-emerald-500",
|
|
19
|
+
fill: "fill-emerald-500",
|
|
20
|
+
text: "text-emerald-500",
|
|
21
|
+
},
|
|
22
|
+
violet: {
|
|
23
|
+
bg: "bg-violet-500",
|
|
24
|
+
stroke: "stroke-violet-500",
|
|
25
|
+
fill: "fill-violet-500",
|
|
26
|
+
text: "text-violet-500",
|
|
27
|
+
},
|
|
28
|
+
amber: {
|
|
29
|
+
bg: "bg-amber-500",
|
|
30
|
+
stroke: "stroke-amber-500",
|
|
31
|
+
fill: "fill-amber-500",
|
|
32
|
+
text: "text-amber-500",
|
|
33
|
+
},
|
|
34
|
+
gray: {
|
|
35
|
+
bg: "bg-gray-500",
|
|
36
|
+
stroke: "stroke-gray-500",
|
|
37
|
+
fill: "fill-gray-500",
|
|
38
|
+
text: "text-gray-500",
|
|
39
|
+
},
|
|
40
|
+
cyan: {
|
|
41
|
+
bg: "bg-cyan-500",
|
|
42
|
+
stroke: "stroke-cyan-500",
|
|
43
|
+
fill: "fill-cyan-500",
|
|
44
|
+
text: "text-cyan-500",
|
|
45
|
+
},
|
|
46
|
+
pink: {
|
|
47
|
+
bg: "bg-pink-500",
|
|
48
|
+
stroke: "stroke-pink-500",
|
|
49
|
+
fill: "fill-pink-500",
|
|
50
|
+
text: "text-pink-500",
|
|
51
|
+
},
|
|
52
|
+
lime: {
|
|
53
|
+
bg: "bg-lime-500",
|
|
54
|
+
stroke: "stroke-lime-500",
|
|
55
|
+
fill: "fill-lime-500",
|
|
56
|
+
text: "text-lime-500",
|
|
57
|
+
},
|
|
58
|
+
fuchsia: {
|
|
59
|
+
bg: "bg-fuchsia-500",
|
|
60
|
+
stroke: "stroke-fuchsia-500",
|
|
61
|
+
fill: "fill-fuchsia-500",
|
|
62
|
+
text: "text-fuchsia-500",
|
|
63
|
+
},
|
|
64
|
+
indigo: {
|
|
65
|
+
bg: "bg-indigo-500",
|
|
66
|
+
stroke: "stroke-indigo-500",
|
|
67
|
+
fill: "fill-indigo-500",
|
|
68
|
+
text: "text-indigo-500",
|
|
69
|
+
},
|
|
70
|
+
rose: {
|
|
71
|
+
bg: "bg-rose-500",
|
|
72
|
+
stroke: "stroke-rose-500",
|
|
73
|
+
fill: "fill-rose-500",
|
|
74
|
+
text: "text-rose-500",
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type AvailableChartColorsKeys = keyof typeof chartColors;
|
|
79
|
+
|
|
80
|
+
export const AvailableChartColors: AvailableChartColorsKeys[] = Object.keys(
|
|
81
|
+
chartColors,
|
|
82
|
+
) as Array<AvailableChartColorsKeys>;
|
|
83
|
+
|
|
84
|
+
export const constructCategoryColors: (
|
|
85
|
+
categories: string[],
|
|
86
|
+
colors: AvailableChartColorsKeys[],
|
|
87
|
+
) => Map<string, AvailableChartColorsKeys> = (
|
|
88
|
+
categories: string[],
|
|
89
|
+
colors: AvailableChartColorsKeys[],
|
|
90
|
+
): Map<string, AvailableChartColorsKeys> => {
|
|
91
|
+
const categoryColors: Map<string, AvailableChartColorsKeys> = new Map<
|
|
92
|
+
string,
|
|
93
|
+
AvailableChartColorsKeys
|
|
94
|
+
>();
|
|
95
|
+
categories.forEach((category: string, index: number) => {
|
|
96
|
+
categoryColors.set(category, colors[index % colors.length]!);
|
|
97
|
+
});
|
|
98
|
+
return categoryColors;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const getColorClassName: (
|
|
102
|
+
color: AvailableChartColorsKeys,
|
|
103
|
+
type: ColorUtility,
|
|
104
|
+
) => string = (color: AvailableChartColorsKeys, type: ColorUtility): string => {
|
|
105
|
+
const fallbackColor: {
|
|
106
|
+
bg: string;
|
|
107
|
+
stroke: string;
|
|
108
|
+
fill: string;
|
|
109
|
+
text: string;
|
|
110
|
+
} = {
|
|
111
|
+
bg: "bg-gray-500",
|
|
112
|
+
stroke: "stroke-gray-500",
|
|
113
|
+
fill: "fill-gray-500",
|
|
114
|
+
text: "text-gray-500",
|
|
115
|
+
};
|
|
116
|
+
return chartColors[color]?.[type] ?? fallbackColor[type];
|
|
117
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Tremor Raw getYAxisDomain [v0.0.0]
|
|
2
|
+
|
|
3
|
+
export const getYAxisDomain: (
|
|
4
|
+
autoMinValue: boolean,
|
|
5
|
+
minValue: number | undefined,
|
|
6
|
+
maxValue: number | undefined,
|
|
7
|
+
) => (number | "auto")[] = (
|
|
8
|
+
autoMinValue: boolean,
|
|
9
|
+
minValue: number | undefined,
|
|
10
|
+
maxValue: number | undefined,
|
|
11
|
+
): (number | "auto")[] => {
|
|
12
|
+
const minDomain: number | "auto" = autoMinValue ? "auto" : minValue ?? 0;
|
|
13
|
+
const maxDomain: number | "auto" = maxValue ?? "auto";
|
|
14
|
+
return [minDomain, maxDomain];
|
|
15
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Tremor Raw hasOnlyOneValueForKey [v0.1.0]
|
|
2
|
+
|
|
3
|
+
export function hasOnlyOneValueForKey(
|
|
4
|
+
array: any[],
|
|
5
|
+
keyToCheck: string,
|
|
6
|
+
): boolean {
|
|
7
|
+
const val: any[] = [];
|
|
8
|
+
|
|
9
|
+
for (const obj of array) {
|
|
10
|
+
if (Object.prototype.hasOwnProperty.call(obj, keyToCheck)) {
|
|
11
|
+
val.push(obj[keyToCheck]);
|
|
12
|
+
if (val.length > 1) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
export const useOnWindowResize: (handler: () => void) => void = (
|
|
4
|
+
handler: () => void,
|
|
5
|
+
): void => {
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
const handleResize: () => void = () => {
|
|
8
|
+
handler();
|
|
9
|
+
};
|
|
10
|
+
handleResize();
|
|
11
|
+
window.addEventListener("resize", handleResize);
|
|
12
|
+
|
|
13
|
+
return () => {
|
|
14
|
+
window.removeEventListener("resize", handleResize);
|
|
15
|
+
};
|
|
16
|
+
}, [handler]);
|
|
17
|
+
};
|
|
@@ -1,240 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
1
|
+
import { LineChart } from "../ChartLibrary/LineChart/LineChart";
|
|
2
|
+
import React, { FunctionComponent, ReactElement, useEffect } from "react";
|
|
3
|
+
import SeriesPoint from "../Types/SeriesPoints";
|
|
4
|
+
import { XAxis } from "../Types/XAxis/XAxis";
|
|
5
|
+
import YAxis from "../Types/YAxis/YAxis";
|
|
6
|
+
import ChartCurve from "../Types/ChartCurve";
|
|
7
|
+
import ChartDataPoint from "../ChartLibrary/Types/ChartDataPoint";
|
|
8
|
+
import DataPointUtil from "../Utils/DataPoint";
|
|
8
9
|
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export enum ChartCurve {
|
|
18
|
-
LINEAR = "linear",
|
|
19
|
-
MONOTONE_X = "monotoneX",
|
|
20
|
-
STEP = "step",
|
|
21
|
-
STEP_BEFORE = "stepBefore",
|
|
22
|
-
STEP_AFTER = "stepAfter",
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export enum XScaleType {
|
|
26
|
-
TIME = "time",
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export enum XScalePrecision {
|
|
30
|
-
SECOND = "second",
|
|
31
|
-
MINUTE = "minute",
|
|
32
|
-
HOUR = "hour",
|
|
33
|
-
DAY = "day",
|
|
34
|
-
MONTH = "month",
|
|
35
|
-
YEAR = "year",
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type XScaleMaxMin = "auto" | number | Date;
|
|
39
|
-
export type YScaleMaxMin = "auto" | number;
|
|
40
|
-
|
|
41
|
-
export interface XScale {
|
|
42
|
-
type: XScaleType;
|
|
43
|
-
min: XScaleMaxMin;
|
|
44
|
-
max: XScaleMaxMin;
|
|
45
|
-
precision: XScalePrecision;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface LineChartData {
|
|
49
|
-
seriesName: string;
|
|
50
|
-
data: Array<LineChartDataItem>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export enum YScaleType {
|
|
54
|
-
LINEAR = "linear",
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface YScale {
|
|
58
|
-
type: YScaleType;
|
|
59
|
-
min: YScaleMaxMin;
|
|
60
|
-
max: YScaleMaxMin;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export enum AxisType {
|
|
64
|
-
Date = "date",
|
|
65
|
-
Time = "time",
|
|
66
|
-
Number = "number",
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface AxisBottom {
|
|
70
|
-
legend: string;
|
|
71
|
-
type: AxisType;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface AxisLeft {
|
|
75
|
-
legend: string;
|
|
76
|
-
type: AxisType;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export interface LineChartPoint {
|
|
80
|
-
x: XValue;
|
|
81
|
-
y: YValue;
|
|
82
|
-
seriesName: string;
|
|
83
|
-
seriesColor: Color;
|
|
10
|
+
export interface ComponentProps {
|
|
11
|
+
data: Array<SeriesPoint>;
|
|
12
|
+
xAxis: XAxis;
|
|
13
|
+
yAxis: YAxis;
|
|
14
|
+
curve: ChartCurve;
|
|
15
|
+
sync: boolean;
|
|
84
16
|
}
|
|
85
17
|
|
|
86
|
-
export interface ComponentProps {
|
|
87
|
-
|
|
88
|
-
curve?: ChartCurve;
|
|
89
|
-
xScale: XScale;
|
|
90
|
-
yScale: YScale;
|
|
91
|
-
axisBottom: AxisBottom;
|
|
92
|
-
axisLeft: AxisLeft;
|
|
93
|
-
onHoverXAxis?: (x: XValue) => void;
|
|
94
|
-
xAxisMarker?: {
|
|
95
|
-
value: XValue | undefined;
|
|
96
|
-
};
|
|
97
|
-
getHoverTooltip?: (data: { points: Array<LineChartPoint> }) => ReactElement;
|
|
18
|
+
export interface LineInternalProps extends ComponentProps {
|
|
19
|
+
syncId: string;
|
|
98
20
|
}
|
|
99
21
|
|
|
100
|
-
const
|
|
101
|
-
props:
|
|
22
|
+
const LineChartElement: FunctionComponent<LineInternalProps> = (
|
|
23
|
+
props: LineInternalProps,
|
|
102
24
|
): ReactElement => {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
if (props.xAxisMarker && props.xAxisMarker.value) {
|
|
106
|
-
markers.push({
|
|
107
|
-
axis: "x",
|
|
108
|
-
legend: "",
|
|
109
|
-
lineStyle: {
|
|
110
|
-
stroke: "#cbd5e1",
|
|
111
|
-
strokeWidth: 2,
|
|
112
|
-
},
|
|
113
|
-
value: props.xAxisMarker.value,
|
|
114
|
-
});
|
|
115
|
-
}
|
|
25
|
+
const [records, setRecords] = React.useState<Array<ChartDataPoint>>([]);
|
|
116
26
|
|
|
117
|
-
|
|
27
|
+
const categories: Array<string> = props.data.map((item: SeriesPoint) => {
|
|
28
|
+
return item.seriesName;
|
|
29
|
+
});
|
|
118
30
|
|
|
119
|
-
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!props.data || props.data.length === 0) {
|
|
33
|
+
setRecords([]);
|
|
34
|
+
}
|
|
120
35
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
36
|
+
const records: Array<ChartDataPoint> = DataPointUtil.getChartDataPoints({
|
|
37
|
+
seriesPoints: props.data,
|
|
38
|
+
xAxis: props.xAxis,
|
|
39
|
+
yAxis: props.yAxis,
|
|
40
|
+
});
|
|
125
41
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
anchor: "bottom-right",
|
|
129
|
-
direction: "column",
|
|
130
|
-
justify: false,
|
|
131
|
-
translateX: 100,
|
|
132
|
-
translateY: 0,
|
|
133
|
-
itemsSpacing: 0,
|
|
134
|
-
itemDirection: "left-to-right",
|
|
135
|
-
itemWidth: 80,
|
|
136
|
-
itemHeight: 20,
|
|
137
|
-
itemOpacity: 0.75,
|
|
138
|
-
symbolSize: 12,
|
|
139
|
-
symbolShape: "circle",
|
|
140
|
-
symbolBorderColor: "rgba(0, 0, 0, .5)",
|
|
141
|
-
effects: [
|
|
142
|
-
{
|
|
143
|
-
on: "hover",
|
|
144
|
-
style: {
|
|
145
|
-
itemBackground: "rgba(0, 0, 0, .03)",
|
|
146
|
-
itemOpacity: 1,
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
],
|
|
150
|
-
},
|
|
151
|
-
];
|
|
152
|
-
}
|
|
42
|
+
setRecords(records);
|
|
43
|
+
}, [props.data]);
|
|
153
44
|
|
|
154
45
|
return (
|
|
155
|
-
<
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
yScale={{
|
|
180
|
-
type: props.yScale.type,
|
|
181
|
-
min: props.yScale.min,
|
|
182
|
-
max: props.yScale.max,
|
|
183
|
-
}}
|
|
184
|
-
axisTop={null}
|
|
185
|
-
axisRight={null}
|
|
186
|
-
axisBottom={{
|
|
187
|
-
legend: props.axisBottom.legend,
|
|
188
|
-
format: (value: XValue) => {
|
|
189
|
-
let strLabel: string = "";
|
|
190
|
-
if (props.axisBottom.type === AxisType.Date) {
|
|
191
|
-
strLabel = OneUptimeDate.getDateAsLocalFormattedString(
|
|
192
|
-
value as Date,
|
|
193
|
-
true,
|
|
194
|
-
);
|
|
195
|
-
} else if (props.axisBottom.type === AxisType.Time) {
|
|
196
|
-
strLabel = OneUptimeDate.getLocalHourAndMinuteFromDate(
|
|
197
|
-
value as Date,
|
|
198
|
-
);
|
|
199
|
-
} else {
|
|
200
|
-
strLabel = value.toString();
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return strLabel;
|
|
204
|
-
},
|
|
205
|
-
}}
|
|
206
|
-
useMesh={true}
|
|
207
|
-
axisLeft={{
|
|
208
|
-
legend: props.axisLeft.legend,
|
|
209
|
-
}}
|
|
210
|
-
enableSlices="x"
|
|
211
|
-
sliceTooltip={(data: {
|
|
212
|
-
slice: {
|
|
213
|
-
points: readonly Point[];
|
|
214
|
-
};
|
|
215
|
-
}) => {
|
|
216
|
-
if (!props.getHoverTooltip) {
|
|
217
|
-
return <></>;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
return props.getHoverTooltip({
|
|
221
|
-
points: data.slice.points.map((point: Point) => {
|
|
222
|
-
return {
|
|
223
|
-
x: point.data.x as XValue,
|
|
224
|
-
y: point.data.y as YValue,
|
|
225
|
-
seriesName: point.serieId.toString(),
|
|
226
|
-
seriesColor: new Color(point.color),
|
|
227
|
-
};
|
|
228
|
-
}),
|
|
229
|
-
});
|
|
230
|
-
}}
|
|
231
|
-
colors={ChartColors.map((item: Color) => {
|
|
232
|
-
return item.toString();
|
|
233
|
-
})}
|
|
234
|
-
legends={legends}
|
|
235
|
-
/>
|
|
236
|
-
</div>
|
|
46
|
+
<LineChart
|
|
47
|
+
className="h-80"
|
|
48
|
+
data={records}
|
|
49
|
+
tickGap={1}
|
|
50
|
+
index={"Time"}
|
|
51
|
+
categories={categories}
|
|
52
|
+
colors={[
|
|
53
|
+
"indigo",
|
|
54
|
+
"rose",
|
|
55
|
+
"emerald",
|
|
56
|
+
"amber",
|
|
57
|
+
"cyan",
|
|
58
|
+
"gray",
|
|
59
|
+
"pink",
|
|
60
|
+
"lime",
|
|
61
|
+
"fuchsia",
|
|
62
|
+
]}
|
|
63
|
+
valueFormatter={props.yAxis.options.formatter || undefined}
|
|
64
|
+
showTooltip={true}
|
|
65
|
+
connectNulls={true}
|
|
66
|
+
curve={props.curve}
|
|
67
|
+
syncId={props.sync ? props.syncId : undefined}
|
|
68
|
+
yAxisWidth={60}
|
|
69
|
+
/>
|
|
237
70
|
);
|
|
238
71
|
};
|
|
239
72
|
|
|
240
|
-
export default
|
|
73
|
+
export default LineChartElement;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import XAxisMaxMin from "./XAxisMaxMin";
|
|
2
|
+
import XAxisType from "./XAxisType";
|
|
3
|
+
|
|
4
|
+
export enum XAxisAggregateType {
|
|
5
|
+
Average = "Average",
|
|
6
|
+
Sum = "Sum",
|
|
7
|
+
Max = "Max",
|
|
8
|
+
Min = "Min",
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface XAxisOptions {
|
|
12
|
+
type: XAxisType;
|
|
13
|
+
min: XAxisMaxMin;
|
|
14
|
+
max: XAxisMaxMin;
|
|
15
|
+
aggregateType: XAxisAggregateType;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface XAxis {
|
|
19
|
+
legend: string;
|
|
20
|
+
options: XAxisOptions;
|
|
21
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
enum XAxisPrecision {
|
|
2
|
+
EVERY_SECOND = "second",
|
|
3
|
+
EVERY_FIVE_SECONDS = "fiveSeconds",
|
|
4
|
+
EVERY_TEN_SECONDS = "tenSeconds",
|
|
5
|
+
EVERY_THIRTY_SECONDS = "thirtySeconds",
|
|
6
|
+
EVERY_MINUTE = "minute",
|
|
7
|
+
EVERY_FIVE_MINUTES = "fiveMinutes",
|
|
8
|
+
EVERY_TEN_MINUTES = "tenMinutes",
|
|
9
|
+
EVERY_THIRTY_MINUTES = "thirtyMinutes",
|
|
10
|
+
EVERY_HOUR = "hour",
|
|
11
|
+
EVERY_TWO_HOURS = "twoHours",
|
|
12
|
+
EVERY_THREE_HOURS = "threeHours",
|
|
13
|
+
EVERY_SIX_HOURS = "sixHours",
|
|
14
|
+
EVERY_TWELVE_HOURS = "twelveHours",
|
|
15
|
+
EVERY_DAY = "day",
|
|
16
|
+
EVERY_TWO_DAYS = "twoDays",
|
|
17
|
+
EVERY_WEEK = "week",
|
|
18
|
+
EVERY_TWO_WEEKS = "twoWeeks",
|
|
19
|
+
EVERY_MONTH = "month",
|
|
20
|
+
EVERY_TWO_MONTHS = "twoMonths",
|
|
21
|
+
EVERY_THREE_MONTHS = "threeMonths",
|
|
22
|
+
EVERY_SIX_MONTHS = "sixMonths",
|
|
23
|
+
EVERY_YEAR = "year",
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default XAxisPrecision;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import YAxisMaxMin from "./YAxisMaxMin";
|
|
2
|
+
import YAxisType from "./YAxisType";
|
|
3
|
+
|
|
4
|
+
export enum YAxisPrecision {
|
|
5
|
+
NoDecimals = "NoDecimals",
|
|
6
|
+
OneDecimal = "OneDecimal",
|
|
7
|
+
TwoDecimals = "TwoDecimals",
|
|
8
|
+
ThreeDecimals = "ThreeDecimals",
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface YAxisOptions {
|
|
12
|
+
type: YAxisType;
|
|
13
|
+
min: YAxisMaxMin;
|
|
14
|
+
max: YAxisMaxMin;
|
|
15
|
+
formatter: (value: number) => string;
|
|
16
|
+
precision: YAxisPrecision;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default interface YAxis {
|
|
20
|
+
legend: string;
|
|
21
|
+
options: YAxisOptions;
|
|
22
|
+
}
|