@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.
Files changed (197) hide show
  1. package/Models/AnalyticsModels/ExceptionInstance.ts +488 -0
  2. package/Models/AnalyticsModels/Index.ts +2 -0
  3. package/Models/AnalyticsModels/Span.ts +2 -2
  4. package/Models/DatabaseModels/Index.ts +4 -0
  5. package/Models/DatabaseModels/TelemetryException.ts +978 -0
  6. package/Server/API/StatusAPI.ts +63 -51
  7. package/Server/EnvironmentConfig.ts +3 -0
  8. package/Server/Infrastructure/Postgres/SchemaMigrations/1724610006927-MigrationName.ts +93 -0
  9. package/Server/Infrastructure/Postgres/SchemaMigrations/1724613666632-MigrationName.ts +60 -0
  10. package/Server/Infrastructure/Postgres/SchemaMigrations/1724659071843-MigrationName.ts +17 -0
  11. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
  12. package/Server/Infrastructure/Queue.ts +36 -1
  13. package/Server/Infrastructure/QueueWorker.ts +2 -2
  14. package/Server/Services/DatabaseService.ts +4 -5
  15. package/Server/Services/ExceptionInstanceService.ts +11 -0
  16. package/Server/Services/Index.ts +5 -0
  17. package/Server/Services/StatusPageDomainService.ts +118 -59
  18. package/Server/Services/TelemetryExceptionService.ts +10 -0
  19. package/Server/Types/Database/Permissions/Index.ts +1 -1
  20. package/Server/Types/Database/UpdateByID.ts +1 -1
  21. package/Server/Utils/Greenlock/Greenlock.ts +331 -204
  22. package/Server/Utils/Logger.ts +8 -2
  23. package/Server/Utils/Telemetry.ts +109 -25
  24. package/Types/Code/CodeType.ts +1 -0
  25. package/Types/Database/PartialEntity.ts +14 -1
  26. package/Types/Date.ts +9 -1
  27. package/Types/Icon/IconProp.ts +2 -0
  28. package/Types/Permission.ts +39 -0
  29. package/UI/Components/ActionCard/ActionCard.tsx +66 -0
  30. package/UI/Components/Alerts/Alert.tsx +69 -60
  31. package/UI/Components/Card/Card.tsx +1 -0
  32. package/UI/Components/Charts/ChartGroup/ChartGroup.tsx +4 -17
  33. package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +1005 -0
  34. package/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.ts +3 -0
  35. package/UI/Components/Charts/ChartLibrary/Utils/ChartColors.ts +117 -0
  36. package/UI/Components/Charts/ChartLibrary/Utils/Cx.ts +8 -0
  37. package/UI/Components/Charts/ChartLibrary/Utils/GetYAxisDomain.ts +15 -0
  38. package/UI/Components/Charts/ChartLibrary/Utils/HasOnlyOneValueForKey.ts +19 -0
  39. package/UI/Components/Charts/ChartLibrary/Utils/UseWindowOnResize.ts +17 -0
  40. package/UI/Components/Charts/Line/LineChart.tsx +58 -225
  41. package/UI/Components/Charts/Types/ChartCurve.ts +7 -0
  42. package/UI/Components/Charts/Types/DataPoint.ts +7 -0
  43. package/UI/Components/Charts/Types/SeriesPoint.ts +7 -0
  44. package/UI/Components/Charts/Types/SeriesPoints.ts +6 -0
  45. package/UI/Components/Charts/Types/XAxis/XAxis.ts +21 -0
  46. package/UI/Components/Charts/Types/XAxis/XAxisMaxMin.ts +3 -0
  47. package/UI/Components/Charts/Types/XAxis/XAxisPrecision.ts +26 -0
  48. package/UI/Components/Charts/Types/XAxis/XAxisType.ts +6 -0
  49. package/UI/Components/Charts/Types/XValue.ts +3 -0
  50. package/UI/Components/Charts/Types/YAxis/YAxis.ts +22 -0
  51. package/UI/Components/Charts/Types/YAxis/YAxisMaxMin.ts +3 -0
  52. package/UI/Components/Charts/Types/YAxis/YAxisType.ts +5 -0
  53. package/UI/Components/Charts/Types/YValue.ts +3 -0
  54. package/UI/Components/Charts/Utils/DataPoint.ts +188 -0
  55. package/UI/Components/Charts/Utils/XAxis.ts +267 -0
  56. package/UI/Components/Detail/Detail.tsx +6 -1
  57. package/UI/Components/GanttChart/Row/Row.tsx +4 -2
  58. package/UI/Components/GanttChart/Row/RowLabel.tsx +7 -3
  59. package/UI/Components/Icon/Icon.tsx +16 -0
  60. package/UI/Components/LogsViewer/LogsViewer.tsx +1 -1
  61. package/UI/Components/Types/FieldType.ts +1 -0
  62. package/UI/Config.ts +2 -0
  63. package/UI/Utils/Telemetry.ts +7 -2
  64. package/Utils/Crypto.ts +11 -0
  65. package/build/dist/Models/AnalyticsModels/ExceptionInstance.js +445 -0
  66. package/build/dist/Models/AnalyticsModels/ExceptionInstance.js.map +1 -0
  67. package/build/dist/Models/AnalyticsModels/Index.js +2 -0
  68. package/build/dist/Models/AnalyticsModels/Index.js.map +1 -1
  69. package/build/dist/Models/AnalyticsModels/Span.js +2 -2
  70. package/build/dist/Models/DatabaseModels/Index.js +2 -0
  71. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  72. package/build/dist/Models/DatabaseModels/TelemetryException.js +1010 -0
  73. package/build/dist/Models/DatabaseModels/TelemetryException.js.map +1 -0
  74. package/build/dist/Server/API/StatusAPI.js +52 -44
  75. package/build/dist/Server/API/StatusAPI.js.map +1 -1
  76. package/build/dist/Server/EnvironmentConfig.js +1 -0
  77. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  78. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724610006927-MigrationName.js +38 -0
  79. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724610006927-MigrationName.js.map +1 -0
  80. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724613666632-MigrationName.js +26 -0
  81. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724613666632-MigrationName.js.map +1 -0
  82. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724659071843-MigrationName.js +12 -0
  83. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1724659071843-MigrationName.js.map +1 -0
  84. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
  85. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  86. package/build/dist/Server/Infrastructure/Queue.js +20 -1
  87. package/build/dist/Server/Infrastructure/Queue.js.map +1 -1
  88. package/build/dist/Server/Infrastructure/QueueWorker.js +2 -2
  89. package/build/dist/Server/Infrastructure/QueueWorker.js.map +1 -1
  90. package/build/dist/Server/Services/DatabaseService.js.map +1 -1
  91. package/build/dist/Server/Services/ExceptionInstanceService.js +9 -0
  92. package/build/dist/Server/Services/ExceptionInstanceService.js.map +1 -0
  93. package/build/dist/Server/Services/Index.js +4 -0
  94. package/build/dist/Server/Services/Index.js.map +1 -1
  95. package/build/dist/Server/Services/StatusPageDomainService.js +101 -53
  96. package/build/dist/Server/Services/StatusPageDomainService.js.map +1 -1
  97. package/build/dist/Server/Services/TelemetryExceptionService.js +9 -0
  98. package/build/dist/Server/Services/TelemetryExceptionService.js.map +1 -0
  99. package/build/dist/Server/Types/Database/Permissions/Index.js.map +1 -1
  100. package/build/dist/Server/Utils/Greenlock/Greenlock.js +234 -157
  101. package/build/dist/Server/Utils/Greenlock/Greenlock.js.map +1 -1
  102. package/build/dist/Server/Utils/Logger.js +5 -1
  103. package/build/dist/Server/Utils/Logger.js.map +1 -1
  104. package/build/dist/Server/Utils/Telemetry.js +63 -22
  105. package/build/dist/Server/Utils/Telemetry.js.map +1 -1
  106. package/build/dist/Types/Code/CodeType.js +1 -0
  107. package/build/dist/Types/Code/CodeType.js.map +1 -1
  108. package/build/dist/Types/Database/PartialEntity.js +3 -0
  109. package/build/dist/Types/Database/PartialEntity.js.map +1 -1
  110. package/build/dist/Types/Date.js +7 -1
  111. package/build/dist/Types/Date.js.map +1 -1
  112. package/build/dist/Types/Icon/IconProp.js +2 -0
  113. package/build/dist/Types/Icon/IconProp.js.map +1 -1
  114. package/build/dist/Types/Permission.js +33 -0
  115. package/build/dist/Types/Permission.js.map +1 -1
  116. package/build/dist/UI/Components/ActionCard/ActionCard.js +27 -0
  117. package/build/dist/UI/Components/ActionCard/ActionCard.js.map +1 -0
  118. package/build/dist/UI/Components/Alerts/Alert.js +36 -45
  119. package/build/dist/UI/Components/Alerts/Alert.js.map +1 -1
  120. package/build/dist/UI/Components/Card/Card.js +1 -1
  121. package/build/dist/UI/Components/Card/Card.js.map +1 -1
  122. package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js +4 -9
  123. package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js.map +1 -1
  124. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +388 -0
  125. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -0
  126. package/build/dist/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.js +2 -0
  127. package/build/dist/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.js.map +1 -0
  128. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/ChartColors.js +88 -0
  129. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/ChartColors.js.map +1 -0
  130. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/Cx.js +7 -0
  131. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/Cx.js.map +1 -0
  132. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/GetYAxisDomain.js +7 -0
  133. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/GetYAxisDomain.js.map +1 -0
  134. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/HasOnlyOneValueForKey.js +14 -0
  135. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/HasOnlyOneValueForKey.js.map +1 -0
  136. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/UseWindowOnResize.js +14 -0
  137. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/UseWindowOnResize.js.map +1 -0
  138. package/build/dist/UI/Components/Charts/Line/LineChart.js +30 -136
  139. package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
  140. package/build/dist/UI/Components/Charts/Types/ChartCurve.js +8 -0
  141. package/build/dist/UI/Components/Charts/Types/ChartCurve.js.map +1 -0
  142. package/build/dist/UI/Components/Charts/Types/DataPoint.js +2 -0
  143. package/build/dist/UI/Components/Charts/Types/DataPoint.js.map +1 -0
  144. package/build/dist/UI/Components/Charts/Types/SeriesPoint.js +2 -0
  145. package/build/dist/UI/Components/Charts/Types/SeriesPoint.js.map +1 -0
  146. package/build/dist/UI/Components/Charts/Types/SeriesPoints.js +2 -0
  147. package/build/dist/UI/Components/Charts/Types/SeriesPoints.js.map +1 -0
  148. package/build/dist/UI/Components/Charts/Types/XAxis/XAxis.js +8 -0
  149. package/build/dist/UI/Components/Charts/Types/XAxis/XAxis.js.map +1 -0
  150. package/build/dist/UI/Components/Charts/Types/XAxis/XAxisMaxMin.js +2 -0
  151. package/build/dist/UI/Components/Charts/Types/XAxis/XAxisMaxMin.js.map +1 -0
  152. package/build/dist/UI/Components/Charts/Types/XAxis/XAxisPrecision.js +27 -0
  153. package/build/dist/UI/Components/Charts/Types/XAxis/XAxisPrecision.js.map +1 -0
  154. package/build/dist/UI/Components/Charts/Types/XAxis/XAxisType.js +7 -0
  155. package/build/dist/UI/Components/Charts/Types/XAxis/XAxisType.js.map +1 -0
  156. package/build/dist/UI/Components/Charts/Types/XValue.js +2 -0
  157. package/build/dist/UI/Components/Charts/Types/XValue.js.map +1 -0
  158. package/build/dist/UI/Components/Charts/Types/YAxis/YAxis.js +8 -0
  159. package/build/dist/UI/Components/Charts/Types/YAxis/YAxis.js.map +1 -0
  160. package/build/dist/UI/Components/Charts/Types/YAxis/YAxisMaxMin.js +2 -0
  161. package/build/dist/UI/Components/Charts/Types/YAxis/YAxisMaxMin.js.map +1 -0
  162. package/build/dist/UI/Components/Charts/Types/YAxis/YAxisType.js +6 -0
  163. package/build/dist/UI/Components/Charts/Types/YAxis/YAxisType.js.map +1 -0
  164. package/build/dist/UI/Components/Charts/Types/YValue.js +2 -0
  165. package/build/dist/UI/Components/Charts/Types/YValue.js.map +1 -0
  166. package/build/dist/UI/Components/Charts/Utils/DataPoint.js +109 -0
  167. package/build/dist/UI/Components/Charts/Utils/DataPoint.js.map +1 -0
  168. package/build/dist/UI/Components/Charts/Utils/XAxis.js +241 -0
  169. package/build/dist/UI/Components/Charts/Utils/XAxis.js.map +1 -0
  170. package/build/dist/UI/Components/Detail/Detail.js +5 -1
  171. package/build/dist/UI/Components/Detail/Detail.js.map +1 -1
  172. package/build/dist/UI/Components/GanttChart/Row/Row.js +2 -2
  173. package/build/dist/UI/Components/GanttChart/Row/Row.js.map +1 -1
  174. package/build/dist/UI/Components/GanttChart/Row/RowLabel.js +3 -3
  175. package/build/dist/UI/Components/GanttChart/Row/RowLabel.js.map +1 -1
  176. package/build/dist/UI/Components/Icon/Icon.js +6 -0
  177. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  178. package/build/dist/UI/Components/LogsViewer/LogsViewer.js +1 -1
  179. package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
  180. package/build/dist/UI/Components/Types/FieldType.js +1 -0
  181. package/build/dist/UI/Components/Types/FieldType.js.map +1 -1
  182. package/build/dist/UI/Config.js +1 -0
  183. package/build/dist/UI/Config.js.map +1 -1
  184. package/build/dist/UI/Utils/Telemetry.js +6 -3
  185. package/build/dist/UI/Utils/Telemetry.js.map +1 -1
  186. package/build/dist/Utils/Crypto.js +10 -0
  187. package/build/dist/Utils/Crypto.js.map +1 -0
  188. package/package.json +15 -13
  189. package/UI/Components/Charts/Bar/Bar.tsx +0 -0
  190. package/UI/Components/Charts/Base/BaseChart.tsx +0 -0
  191. package/UI/Components/Charts/Tooltip/Tooltip.tsx +0 -84
  192. package/build/dist/UI/Components/Charts/Bar/Bar.js +0 -2
  193. package/build/dist/UI/Components/Charts/Bar/Bar.js.map +0 -1
  194. package/build/dist/UI/Components/Charts/Base/BaseChart.js +0 -2
  195. package/build/dist/UI/Components/Charts/Base/BaseChart.js.map +0 -1
  196. package/build/dist/UI/Components/Charts/Tooltip/Tooltip.js +0 -34
  197. package/build/dist/UI/Components/Charts/Tooltip/Tooltip.js.map +0 -1
@@ -0,0 +1,188 @@
1
+ /// ChartDataPoint is in the format of:
2
+ // {
3
+ // date: "Feb 22",
4
+ // SolarPanels: 2756,
5
+ // Inverters: 2103,
6
+ // }
7
+
8
+ import BadDataException from "../../../../Types/Exception/BadDataException";
9
+ import ChartDataPoint from "../ChartLibrary/Types/ChartDataPoint";
10
+ import SeriesPoints from "../Types/SeriesPoints";
11
+ import { XAxis, XAxisAggregateType } from "../Types/XAxis/XAxis";
12
+ import XAxisMaxMin from "../Types/XAxis/XAxisMaxMin";
13
+ import YAxis, { YAxisPrecision } from "../Types/YAxis/YAxis";
14
+ import XAxisUtil from "./XAxis";
15
+
16
+ interface SeriesData {
17
+ sum: number;
18
+ count: number;
19
+ max: number;
20
+ min: number;
21
+ }
22
+
23
+ export default class DataPointUtil {
24
+ public static getChartDataPoints(data: {
25
+ seriesPoints: Array<SeriesPoints>;
26
+ xAxis: XAxis;
27
+ yAxis: YAxis;
28
+ }): Array<ChartDataPoint> {
29
+ const { xAxisLegend, intervals, formatter } = this.initializeXAxisData(
30
+ data.xAxis,
31
+ );
32
+ const arrayOfData: ChartDataPoint[] = this.initializeArrayOfData(
33
+ intervals,
34
+ xAxisLegend,
35
+ formatter,
36
+ );
37
+ const seriesDataMap: {
38
+ [key: string]: SeriesData;
39
+ } = this.processSeriesData(
40
+ data.seriesPoints,
41
+ arrayOfData,
42
+ xAxisLegend,
43
+ formatter,
44
+ data.xAxis.options.aggregateType,
45
+ );
46
+ this.formatSeriesData(
47
+ arrayOfData,
48
+ seriesDataMap,
49
+ data.yAxis.options.precision,
50
+ );
51
+ return arrayOfData;
52
+ }
53
+
54
+ private static initializeXAxisData(xAxis: XAxis): {
55
+ xAxisMax: XAxisMaxMin;
56
+ xAxisMin: XAxisMaxMin;
57
+ xAxisLegend: string;
58
+ intervals: Array<Date>;
59
+ formatter: (value: Date) => string;
60
+ } {
61
+ const xAxisMax: XAxisMaxMin = xAxis.options.max;
62
+ const xAxisMin: XAxisMaxMin = xAxis.options.min;
63
+ const xAxisLegend: string = xAxis.legend;
64
+ const intervals: Array<Date> = XAxisUtil.getPrecisionIntervals({
65
+ xAxisMax,
66
+ xAxisMin,
67
+ });
68
+ const formatter: (value: Date) => string = XAxisUtil.getFormatter({
69
+ xAxisMax,
70
+ xAxisMin,
71
+ });
72
+ return { xAxisMax, xAxisMin, xAxisLegend, intervals, formatter };
73
+ }
74
+
75
+ private static initializeArrayOfData(
76
+ intervals: Array<Date>,
77
+ xAxisLegend: string,
78
+ formatter: (value: Date) => string,
79
+ ): Array<ChartDataPoint> {
80
+ const arrayOfData: Array<ChartDataPoint> = [];
81
+ for (const interval of intervals) {
82
+ const dataPoint: ChartDataPoint = {};
83
+ dataPoint[xAxisLegend] = formatter(interval);
84
+ arrayOfData.push(dataPoint);
85
+ }
86
+ return arrayOfData;
87
+ }
88
+
89
+ private static processSeriesData(
90
+ seriesPoints: Array<SeriesPoints>,
91
+ arrayOfData: Array<ChartDataPoint>,
92
+ xAxisLegend: string,
93
+ formatter: (value: Date) => string,
94
+ aggregateType: XAxisAggregateType,
95
+ ): { [key: string]: SeriesData } {
96
+ const seriesDataMap: { [key: string]: SeriesData } = {};
97
+ for (const series of seriesPoints) {
98
+ for (const dataPoint of series.data) {
99
+ const date: Date = dataPoint.x;
100
+ const value: number = dataPoint.y;
101
+ const formattedDate: string = formatter(date);
102
+ for (const chartDataPoint of arrayOfData) {
103
+ if (chartDataPoint[xAxisLegend] === formattedDate) {
104
+ if (!seriesDataMap[series.seriesName]) {
105
+ seriesDataMap[series.seriesName] = {
106
+ sum: 0,
107
+ count: 0,
108
+ max: Number.NEGATIVE_INFINITY,
109
+ min: Number.POSITIVE_INFINITY,
110
+ };
111
+ }
112
+ seriesDataMap[series.seriesName]!.sum += value;
113
+ seriesDataMap[series.seriesName]!.count += 1;
114
+ seriesDataMap[series.seriesName]!.max = Math.max(
115
+ seriesDataMap[series.seriesName]!.max,
116
+ value,
117
+ );
118
+ seriesDataMap[series.seriesName]!.min = Math.min(
119
+ seriesDataMap[series.seriesName]!.min,
120
+ value,
121
+ );
122
+ chartDataPoint[series.seriesName] = this.calculateAggregate(
123
+ seriesDataMap[series.seriesName]!,
124
+ aggregateType,
125
+ );
126
+ }
127
+ }
128
+ }
129
+ }
130
+ return seriesDataMap;
131
+ }
132
+
133
+ private static calculateAggregate(
134
+ seriesData: SeriesData,
135
+ aggregateType: XAxisAggregateType,
136
+ ): number {
137
+ switch (aggregateType) {
138
+ case XAxisAggregateType.Average:
139
+ return seriesData.sum / seriesData.count;
140
+ case XAxisAggregateType.Sum:
141
+ return seriesData.sum;
142
+ case XAxisAggregateType.Max:
143
+ return seriesData.max;
144
+ case XAxisAggregateType.Min:
145
+ return seriesData.min;
146
+ default:
147
+ throw new BadDataException("Aggregate type not supported.");
148
+ }
149
+ }
150
+
151
+ private static formatSeriesData(
152
+ arrayOfData: Array<ChartDataPoint>,
153
+ seriesDataMap: { [key: string]: SeriesData },
154
+ yAxisPrecision: YAxisPrecision,
155
+ ): void {
156
+ for (const chartDataPoint of arrayOfData) {
157
+ for (const seriesName in seriesDataMap) {
158
+ if (
159
+ chartDataPoint[seriesName] &&
160
+ typeof chartDataPoint[seriesName] === "number"
161
+ ) {
162
+ chartDataPoint[seriesName] = this.formatValue(
163
+ chartDataPoint[seriesName] as number,
164
+ yAxisPrecision,
165
+ );
166
+ }
167
+ }
168
+ }
169
+ }
170
+
171
+ private static formatValue(
172
+ value: number,
173
+ yAxisPrecision: YAxisPrecision,
174
+ ): number {
175
+ switch (yAxisPrecision) {
176
+ case YAxisPrecision.NoDecimals:
177
+ return parseFloat(value.toFixed(0));
178
+ case YAxisPrecision.OneDecimal:
179
+ return parseFloat(value.toFixed(1));
180
+ case YAxisPrecision.TwoDecimals:
181
+ return parseFloat(value.toFixed(2));
182
+ case YAxisPrecision.ThreeDecimals:
183
+ return parseFloat(value.toFixed(3));
184
+ default:
185
+ throw new BadDataException("YAxis precision not supported.");
186
+ }
187
+ }
188
+ }
@@ -0,0 +1,267 @@
1
+ import NotImplementedException from "../../../../Types/Exception/NotImplementedException";
2
+ import XAxisMaxMin from "../Types/XAxis/XAxisMaxMin";
3
+ import XAxisPrecision from "../Types/XAxis/XAxisPrecision";
4
+
5
+ export default class XAxisUtil {
6
+ public static getPrecision(data: {
7
+ xAxisMin: XAxisMaxMin;
8
+ xAxisMax: XAxisMaxMin;
9
+ }): XAxisPrecision {
10
+ if (
11
+ typeof data.xAxisMax === "number" ||
12
+ typeof data.xAxisMin === "number"
13
+ ) {
14
+ // number not yet supported.
15
+ throw new NotImplementedException();
16
+ }
17
+
18
+ const startDate: Date = data.xAxisMin as Date;
19
+ const endDate: Date = data.xAxisMax as Date;
20
+
21
+ const totalMilliseconds: number = endDate.getTime() - startDate.getTime();
22
+ const totalSeconds: number = totalMilliseconds / 1000;
23
+ const totalMinutes: number = totalSeconds / 60;
24
+ const totalHours: number = totalMinutes / 60;
25
+ const totalDays: number = totalHours / 24;
26
+ const totalWeeks: number = totalDays / 7;
27
+ const totalMonths: number = totalDays / 30;
28
+
29
+ if (totalSeconds <= 100) {
30
+ return XAxisPrecision.EVERY_SECOND;
31
+ }
32
+ if (totalSeconds <= 500) {
33
+ return XAxisPrecision.EVERY_FIVE_SECONDS;
34
+ }
35
+ if (totalSeconds <= 1000) {
36
+ return XAxisPrecision.EVERY_TEN_SECONDS;
37
+ }
38
+ if (totalSeconds <= 3000) {
39
+ return XAxisPrecision.EVERY_THIRTY_SECONDS;
40
+ }
41
+ if (totalMinutes <= 100) {
42
+ return XAxisPrecision.EVERY_MINUTE;
43
+ }
44
+ if (totalMinutes <= 500) {
45
+ return XAxisPrecision.EVERY_FIVE_MINUTES;
46
+ }
47
+ if (totalMinutes <= 1000) {
48
+ return XAxisPrecision.EVERY_TEN_MINUTES;
49
+ }
50
+ if (totalMinutes <= 3000) {
51
+ return XAxisPrecision.EVERY_THIRTY_MINUTES;
52
+ }
53
+ if (totalHours <= 100) {
54
+ return XAxisPrecision.EVERY_HOUR;
55
+ }
56
+ if (totalHours <= 200) {
57
+ return XAxisPrecision.EVERY_TWO_HOURS;
58
+ }
59
+ if (totalHours <= 300) {
60
+ return XAxisPrecision.EVERY_THREE_HOURS;
61
+ }
62
+ if (totalHours <= 600) {
63
+ return XAxisPrecision.EVERY_SIX_HOURS;
64
+ }
65
+ if (totalHours <= 1200) {
66
+ return XAxisPrecision.EVERY_TWELVE_HOURS;
67
+ }
68
+ if (totalDays <= 100) {
69
+ return XAxisPrecision.EVERY_DAY;
70
+ }
71
+ if (totalDays <= 200) {
72
+ return XAxisPrecision.EVERY_TWO_DAYS;
73
+ }
74
+ if (totalWeeks <= 100) {
75
+ return XAxisPrecision.EVERY_WEEK;
76
+ }
77
+ if (totalWeeks <= 200) {
78
+ return XAxisPrecision.EVERY_TWO_WEEKS;
79
+ }
80
+ if (totalMonths <= 100) {
81
+ return XAxisPrecision.EVERY_MONTH;
82
+ }
83
+ if (totalMonths <= 200) {
84
+ return XAxisPrecision.EVERY_TWO_MONTHS;
85
+ }
86
+ if (totalMonths <= 300) {
87
+ return XAxisPrecision.EVERY_THREE_MONTHS;
88
+ }
89
+ if (totalMonths <= 600) {
90
+ return XAxisPrecision.EVERY_SIX_MONTHS;
91
+ }
92
+ return XAxisPrecision.EVERY_YEAR;
93
+ }
94
+
95
+ public static getPrecisionIntervals(data: {
96
+ xAxisMin: XAxisMaxMin;
97
+ xAxisMax: XAxisMaxMin;
98
+ }): Array<Date> {
99
+ const precision: XAxisPrecision = XAxisUtil.getPrecision(data);
100
+
101
+ if (
102
+ typeof data.xAxisMax === "number" ||
103
+ typeof data.xAxisMin === "number"
104
+ ) {
105
+ // number not yet supported.
106
+ throw new NotImplementedException();
107
+ }
108
+
109
+ const startDate: Date = new Date(data.xAxisMin as Date);
110
+ const endDate: Date = new Date(data.xAxisMax as Date);
111
+ const intervals: Array<Date> = [];
112
+
113
+ const currentDate: Date = new Date(startDate);
114
+
115
+ while (currentDate <= endDate) {
116
+ intervals.push(new Date(currentDate));
117
+
118
+ switch (precision) {
119
+ case XAxisPrecision.EVERY_SECOND:
120
+ currentDate.setSeconds(currentDate.getSeconds() + 1);
121
+ break;
122
+ case XAxisPrecision.EVERY_FIVE_SECONDS:
123
+ currentDate.setSeconds(currentDate.getSeconds() + 5);
124
+ break;
125
+ case XAxisPrecision.EVERY_TEN_SECONDS:
126
+ currentDate.setSeconds(currentDate.getSeconds() + 10);
127
+ break;
128
+ case XAxisPrecision.EVERY_THIRTY_SECONDS:
129
+ currentDate.setSeconds(currentDate.getSeconds() + 30);
130
+ break;
131
+ case XAxisPrecision.EVERY_MINUTE:
132
+ currentDate.setMinutes(currentDate.getMinutes() + 1);
133
+ break;
134
+ case XAxisPrecision.EVERY_FIVE_MINUTES:
135
+ currentDate.setMinutes(currentDate.getMinutes() + 5);
136
+ break;
137
+ case XAxisPrecision.EVERY_TEN_MINUTES:
138
+ currentDate.setMinutes(currentDate.getMinutes() + 10);
139
+ break;
140
+ case XAxisPrecision.EVERY_THIRTY_MINUTES:
141
+ currentDate.setMinutes(currentDate.getMinutes() + 30);
142
+ break;
143
+ case XAxisPrecision.EVERY_HOUR:
144
+ currentDate.setHours(currentDate.getHours() + 1);
145
+ break;
146
+ case XAxisPrecision.EVERY_TWO_HOURS:
147
+ currentDate.setHours(currentDate.getHours() + 2);
148
+ break;
149
+ case XAxisPrecision.EVERY_THREE_HOURS:
150
+ currentDate.setHours(currentDate.getHours() + 3);
151
+ break;
152
+ case XAxisPrecision.EVERY_SIX_HOURS:
153
+ currentDate.setHours(currentDate.getHours() + 6);
154
+ break;
155
+ case XAxisPrecision.EVERY_TWELVE_HOURS:
156
+ currentDate.setHours(currentDate.getHours() + 12);
157
+ break;
158
+ case XAxisPrecision.EVERY_DAY:
159
+ currentDate.setDate(currentDate.getDate() + 1);
160
+ break;
161
+ case XAxisPrecision.EVERY_TWO_DAYS:
162
+ currentDate.setDate(currentDate.getDate() + 2);
163
+ break;
164
+ case XAxisPrecision.EVERY_WEEK:
165
+ currentDate.setDate(currentDate.getDate() + 7);
166
+ break;
167
+ case XAxisPrecision.EVERY_TWO_WEEKS:
168
+ currentDate.setDate(currentDate.getDate() + 14);
169
+ break;
170
+ case XAxisPrecision.EVERY_MONTH:
171
+ currentDate.setMonth(currentDate.getMonth() + 1);
172
+ break;
173
+ case XAxisPrecision.EVERY_TWO_MONTHS:
174
+ currentDate.setMonth(currentDate.getMonth() + 2);
175
+ break;
176
+ case XAxisPrecision.EVERY_THREE_MONTHS:
177
+ currentDate.setMonth(currentDate.getMonth() + 3);
178
+ break;
179
+ case XAxisPrecision.EVERY_SIX_MONTHS:
180
+ currentDate.setMonth(currentDate.getMonth() + 6);
181
+ break;
182
+ case XAxisPrecision.EVERY_YEAR:
183
+ currentDate.setFullYear(currentDate.getFullYear() + 1);
184
+ break;
185
+ }
186
+ }
187
+
188
+ return intervals;
189
+ }
190
+
191
+ public static getFormatter(data: {
192
+ xAxisMin: XAxisMaxMin;
193
+ xAxisMax: XAxisMaxMin;
194
+ }): (value: Date) => string {
195
+ const precision: XAxisPrecision = XAxisUtil.getPrecision(data);
196
+
197
+ switch (precision) {
198
+ case XAxisPrecision.EVERY_SECOND:
199
+ case XAxisPrecision.EVERY_FIVE_SECONDS:
200
+ case XAxisPrecision.EVERY_TEN_SECONDS:
201
+ case XAxisPrecision.EVERY_THIRTY_SECONDS:
202
+ return (value: Date) => {
203
+ return value.toISOString().substring(11, 19);
204
+ }; // HH:mm:ss
205
+ case XAxisPrecision.EVERY_MINUTE:
206
+ case XAxisPrecision.EVERY_FIVE_MINUTES:
207
+ case XAxisPrecision.EVERY_TEN_MINUTES:
208
+ case XAxisPrecision.EVERY_THIRTY_MINUTES:
209
+ return (value: Date) => {
210
+ return value.toISOString().substring(11, 16);
211
+ }; // HH:mm
212
+ case XAxisPrecision.EVERY_HOUR:
213
+ case XAxisPrecision.EVERY_TWO_HOURS:
214
+ case XAxisPrecision.EVERY_THREE_HOURS:
215
+ case XAxisPrecision.EVERY_SIX_HOURS:
216
+ case XAxisPrecision.EVERY_TWELVE_HOURS:
217
+ return (value: Date) => {
218
+ const dateString: string = value.toISOString();
219
+ const day: string = dateString.substring(8, 10);
220
+ const month: string = value.toLocaleString("default", {
221
+ month: "short",
222
+ });
223
+ const hour: string = dateString.substring(11, 13);
224
+ return `${day} ${month}, ${hour}:00`;
225
+ }; // DD MMM, HH:00
226
+ case XAxisPrecision.EVERY_DAY:
227
+ case XAxisPrecision.EVERY_TWO_DAYS:
228
+ return (value: Date) => {
229
+ const dateString: string = value.toISOString();
230
+ const day: string = dateString.substring(8, 10);
231
+ const month: string = value.toLocaleString("default", {
232
+ month: "short",
233
+ });
234
+ return `${day} ${month}`;
235
+ }; // DD MMM
236
+ case XAxisPrecision.EVERY_WEEK:
237
+ case XAxisPrecision.EVERY_TWO_WEEKS:
238
+ return (value: Date) => {
239
+ const dateString: string = value.toISOString();
240
+ const day: string = dateString.substring(8, 10);
241
+ const month: string = value.toLocaleString("default", {
242
+ month: "short",
243
+ });
244
+ return `${day} ${month}`;
245
+ }; // DD MMM
246
+ case XAxisPrecision.EVERY_MONTH:
247
+ case XAxisPrecision.EVERY_TWO_MONTHS:
248
+ case XAxisPrecision.EVERY_THREE_MONTHS:
249
+ case XAxisPrecision.EVERY_SIX_MONTHS:
250
+ return (value: Date) => {
251
+ const dateString: string = value.toISOString();
252
+ const day: string = dateString.substring(8, 10);
253
+ const year: string = dateString.substring(0, 4);
254
+ const month: string = value.toLocaleString("default", {
255
+ month: "short",
256
+ });
257
+ return `${day} ${month} ${year}`;
258
+ }; // DD MMM
259
+ case XAxisPrecision.EVERY_YEAR:
260
+ return (value: Date) => {
261
+ return value.toISOString().substring(0, 4);
262
+ }; // YYYY
263
+ default:
264
+ throw new Error("Unsupported precision");
265
+ }
266
+ }
267
+ }
@@ -283,7 +283,8 @@ const Detail: DetailFunction = <T extends GenericObject>(
283
283
  (field.fieldType === FieldType.HTML ||
284
284
  field.fieldType === FieldType.CSS ||
285
285
  field.fieldType === FieldType.JSON ||
286
- field.fieldType === FieldType.JavaScript)
286
+ field.fieldType === FieldType.JavaScript ||
287
+ field.fieldType === FieldType.Code)
287
288
  ) {
288
289
  let codeType: CodeType = CodeType.HTML;
289
290
 
@@ -315,6 +316,10 @@ const Detail: DetailFunction = <T extends GenericObject>(
315
316
  codeType = CodeType.JavaScript;
316
317
  }
317
318
 
319
+ if (field.fieldType === FieldType.Code) {
320
+ codeType = CodeType.Text;
321
+ }
322
+
318
323
  data = (
319
324
  <CodeEditor
320
325
  type={codeType}
@@ -50,8 +50,10 @@ const Row: FunctionComponent<ComponentProps> = (
50
50
  <div
51
51
  className={`flex w-full border-b-2 border-gray-200 border-l-2 border-l-gray-400 border-r-2 border-r-gray-400`}
52
52
  >
53
- <div className="flex w-1/4 border-r-2 border-gray-300">
54
- <div className={`pl-${paddingCount} pt-2 pb-2 pr-2 flex`}>
53
+ <div className="flex w-1/4 border-r-2 border-gray-300 overflow-hidden">
54
+ <div
55
+ className={`pl-${paddingCount} pt-2 pb-2 pr-2 flex overflow-hidden`}
56
+ >
55
57
  <div className="w-5 h-5 ml-3 mt-1">
56
58
  {hasChildRows && (
57
59
  <Icon
@@ -11,9 +11,13 @@ const RowLabel: FunctionComponent<ComponentProps> = (
11
11
  return (
12
12
  // rectangle div with curved corners and text inside in tailwindcss
13
13
 
14
- <div>
15
- <div className="text-sm text-gray-600">{props.title}</div>
16
- <div className="text-xs text-gray-500">{props.description}</div>
14
+ <div className="overflow-hidden">
15
+ <div className="text-sm text-gray-600 truncate overflow-hidden">
16
+ {props.title}
17
+ </div>
18
+ <div className="text-xs text-gray-500 truncate overflow-hidden">
19
+ {props.description}
20
+ </div>
17
21
  </div>
18
22
  );
19
23
  };
@@ -138,6 +138,14 @@ const Icon: FunctionComponent<ComponentProps> = ({
138
138
  d="m3 3 8.735 8.735m0 0a.374.374 0 1 1 .53.53m-.53-.53.53.53m0 0L21 21M14.652 9.348a3.75 3.75 0 0 1 0 5.304m2.121-7.425a6.75 6.75 0 0 1 0 9.546m2.121-11.667c3.808 3.807 3.808 9.98 0 13.788m-9.546-4.242a3.733 3.733 0 0 1-1.06-2.122m-1.061 4.243a6.75 6.75 0 0 1-1.625-6.929m-.496 9.05c-3.068-3.067-3.664-7.67-1.79-11.334M12 12h.008v.008H12V12Z"
139
139
  />,
140
140
  );
141
+ } else if (icon === IconProp.Archive) {
142
+ return getSvgWrapper(
143
+ <path
144
+ strokeLinecap="round"
145
+ strokeLinejoin="round"
146
+ d="m20.25 7.5-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5M10 11.25h4M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z"
147
+ />,
148
+ );
141
149
  } else if (icon === IconProp.ShieldCheck) {
142
150
  return getSvgWrapper(
143
151
  <path
@@ -370,6 +378,14 @@ const Icon: FunctionComponent<ComponentProps> = ({
370
378
  d="M7.5 21L3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"
371
379
  />,
372
380
  );
381
+ } else if (icon === IconProp.Unarchive) {
382
+ return getSvgWrapper(
383
+ <path
384
+ strokeLinecap="round"
385
+ strokeLinejoin="round"
386
+ d="m20.25 7.5-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5m6 4.125 2.25 2.25m0 0 2.25 2.25M12 13.875l2.25-2.25M12 13.875l-2.25 2.25M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z"
387
+ />,
388
+ );
373
389
  } else if (icon === IconProp.JSON) {
374
390
  return getSvgWrapper(
375
391
  <path
@@ -239,7 +239,7 @@ const LogsViewer: FunctionComponent<ComponentProps> = (
239
239
 
240
240
  {props.logs.length === 0 && (
241
241
  <div className={`text-slate-200 courier-prime`}>
242
- {props.noLogsMessage || "No logs found for this service."}
242
+ {props.noLogsMessage || "No logs found."}
243
243
  </div>
244
244
  )}
245
245
  </div>
@@ -34,6 +34,7 @@ enum FieldType {
34
34
  Element = "Element",
35
35
  Minutes = "Minutes",
36
36
  ArrayOfText = "ArrayOfText",
37
+ Code = "Code",
37
38
  }
38
39
 
39
40
  export default FieldType;
package/UI/Config.ts CHANGED
@@ -209,3 +209,5 @@ const getOpenTelemetryExporterOtlpHeaders: GetOpenTelemetryExporterOtlpHeadersFu
209
209
 
210
210
  export const OpenTelemetryExporterOtlpHeaders: Dictionary<string> =
211
211
  getOpenTelemetryExporterOtlpHeaders();
212
+
213
+ export const DisableTelemetry: boolean = env("DISABLE_TELEMETRY") === "true";
@@ -1,4 +1,5 @@
1
1
  import {
2
+ DisableTelemetry,
2
3
  OpenTelemetryExporterOtlpEndpoint,
3
4
  OpenTelemetryExporterOtlpHeaders,
4
5
  } from "../Config";
@@ -13,18 +14,22 @@ import {
13
14
  TracerConfig,
14
15
  WebTracerProvider,
15
16
  } from "@opentelemetry/sdk-trace-web";
16
- import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
17
+ import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
17
18
  import URL from "Common/Types/API/URL";
18
19
 
19
20
  export default class Telemetry {
20
21
  public static init(data: { serviceName: string }): void {
22
+ if (DisableTelemetry) {
23
+ return;
24
+ }
25
+
21
26
  const hasHeaders: boolean =
22
27
  Object.keys(OpenTelemetryExporterOtlpHeaders).length > 0;
23
28
 
24
29
  if (OpenTelemetryExporterOtlpEndpoint && hasHeaders) {
25
30
  const providerConfig: TracerConfig = {
26
31
  resource: new Resource({
27
- [SemanticResourceAttributes.SERVICE_NAME]: data.serviceName,
32
+ [ATTR_SERVICE_NAME]: data.serviceName,
28
33
  }),
29
34
  };
30
35
 
@@ -0,0 +1,11 @@
1
+ import CryptoJS from "crypto-js";
2
+
3
+ export default class Crypto {
4
+ public static getMd5Hash(text: string): string {
5
+ return CryptoJS.MD5(text).toString();
6
+ }
7
+
8
+ public static getSha256Hash(text: string): string {
9
+ return CryptoJS.SHA256(text).toString();
10
+ }
11
+ }