@scality/core-ui 0.193.0 → 0.195.0
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/dist/components/UnsuccessfulResult.component.d.ts.map +1 -1
- package/dist/components/accordion/Accordion.component.d.ts.map +1 -1
- package/dist/components/banner/Banner.component.d.ts +6 -1
- package/dist/components/banner/Banner.component.d.ts.map +1 -1
- package/dist/components/banner/Banner.component.js +30 -9
- package/dist/components/breadcrumb/Breadcrumb.component.d.ts.map +1 -1
- package/dist/components/buttonv2/CopyButton.component.d.ts.map +1 -1
- package/dist/components/charts/MetricsTimeSpanProvider.d.ts.map +1 -1
- package/dist/components/charts/barchart/Barchart.d.ts.map +1 -1
- package/dist/components/charts/barchart/Barchart.js +29 -19
- package/dist/components/charts/barchart/Barchart.utils.d.ts.map +1 -1
- package/dist/components/charts/barchart/BarchartTooltip.d.ts.map +1 -1
- package/dist/components/charts/common/ChartTooltip.d.ts.map +1 -1
- package/dist/components/charts/common/SharedComponents.d.ts +6 -6
- package/dist/components/charts/common/SharedComponents.d.ts.map +1 -1
- package/dist/components/charts/common/SharedComponents.js +7 -3
- package/dist/components/charts/common/chartUtils.d.ts +7 -2
- package/dist/components/charts/common/chartUtils.d.ts.map +1 -1
- package/dist/components/charts/common/chartUtils.js +55 -20
- package/dist/components/charts/globalhealthbar/GlobalHealthBar.hooks.d.ts.map +1 -1
- package/dist/components/charts/globalhealthbar/GlobalHealthBar.utils.d.ts +3 -1
- package/dist/components/charts/globalhealthbar/GlobalHealthBar.utils.d.ts.map +1 -1
- package/dist/components/charts/globalhealthbar/GlobalHealthBarTooltip.d.ts.map +1 -1
- package/dist/components/charts/globalhealthbar/HealthBarXAxis.d.ts.map +1 -1
- package/dist/components/charts/index.d.ts +1 -1
- package/dist/components/charts/index.d.ts.map +1 -1
- package/dist/components/charts/legend/ChartLegend.d.ts.map +1 -1
- package/dist/components/charts/legend/ChartLegendWrapper.d.ts.map +1 -1
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.d.ts +12 -47
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.d.ts.map +1 -1
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.js +46 -220
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.types.d.ts +77 -0
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.types.d.ts.map +1 -0
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.types.js +6 -0
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.utils.d.ts.map +1 -1
- package/dist/components/charts/linetimeseries/LineTimeSerieChartTooltip.d.ts +18 -0
- package/dist/components/charts/linetimeseries/LineTimeSerieChartTooltip.d.ts.map +1 -0
- package/dist/components/charts/linetimeseries/LineTimeSerieChartTooltip.js +65 -0
- package/dist/components/charts/linetimeseries/useChartData.d.ts +44 -0
- package/dist/components/charts/linetimeseries/useChartData.d.ts.map +1 -0
- package/dist/components/charts/linetimeseries/useChartData.js +207 -0
- package/dist/components/charts/linetimeseries/useChartHover.d.ts +15 -0
- package/dist/components/charts/linetimeseries/useChartHover.d.ts.map +1 -0
- package/dist/components/charts/linetimeseries/useChartHover.js +29 -0
- package/dist/components/checkbox/Checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox/Checkbox.component.js +15 -7
- package/dist/components/constrainedtext/Constrainedtext.component.d.ts.map +1 -1
- package/dist/components/constrainedtext/Constrainedtext.component.js +3 -2
- package/dist/components/coreuithemeprovider/CoreUiThemeProvider.d.ts.map +1 -1
- package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
- package/dist/components/dropdown/Dropdown.component.d.ts.map +1 -1
- package/dist/components/dropdown/Dropdown.component.js +3 -0
- package/dist/components/error-pages/ErrorPage401.component.js +1 -1
- package/dist/components/error-pages/ErrorPage404.component.js +1 -1
- package/dist/components/error-pages/ErrorPage500.component.js +1 -1
- package/dist/components/form/Form.component.d.ts.map +1 -1
- package/dist/components/form/Form.component.js +3 -3
- package/dist/components/icon/CustomsIcons.d.ts +10 -0
- package/dist/components/icon/CustomsIcons.d.ts.map +1 -1
- package/dist/components/icon/CustomsIcons.js +8 -0
- package/dist/components/icon/Icon.component.d.ts +2 -131
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.js +10 -133
- package/dist/components/icon/iconTable.d.ts +138 -0
- package/dist/components/icon/iconTable.d.ts.map +1 -0
- package/dist/components/icon/iconTable.js +137 -0
- package/dist/components/iconhelper/IconHelper.d.ts.map +1 -1
- package/dist/components/infomessage/InfoMessage.component.d.ts.map +1 -1
- package/dist/components/infomessage/InfoMessage.component.js +1 -1
- package/dist/components/infomessage/InfoMessageUtils.d.ts.map +1 -1
- package/dist/components/inlineinput/InlineInput.d.ts.map +1 -1
- package/dist/components/inputlist/InputButtons.d.ts.map +1 -1
- package/dist/components/inputlist/InputList.component.d.ts +2 -0
- package/dist/components/inputlist/InputList.component.d.ts.map +1 -1
- package/dist/components/inputlist/InputList.component.js +2 -2
- package/dist/components/inputv2/inputv2.d.ts +2 -0
- package/dist/components/inputv2/inputv2.d.ts.map +1 -1
- package/dist/components/inputv2/inputv2.js +6 -2
- package/dist/components/layout/v2/panels.d.ts.map +1 -1
- package/dist/components/modal/Modal.component.d.ts.map +1 -1
- package/dist/components/searchinput/SearchInput.component.d.ts.map +1 -1
- package/dist/components/searchinput/SearchInput.component.js +1 -1
- package/dist/components/statusicon/StatusIcon.component.d.ts.map +1 -1
- package/dist/components/tablev2/MultiSelectableContent.d.ts.map +1 -1
- package/dist/components/tablev2/Search.d.ts.map +1 -1
- package/dist/components/tablev2/TableCommon.d.ts.map +1 -1
- package/dist/components/tablev2/TableUtils.d.ts.map +1 -1
- package/dist/components/tablev2/Tablestyle.d.ts.map +1 -1
- package/dist/components/tablev2/Tablestyle.js +2 -3
- package/dist/components/tablev2/Tablev2.component.d.ts.map +1 -1
- package/dist/components/tabsv2/useScrollingTabs.d.ts.map +1 -1
- package/dist/components/text/Text.component.d.ts +9 -6
- package/dist/components/text/Text.component.d.ts.map +1 -1
- package/dist/components/text/Text.component.js +5 -0
- package/dist/components/toast/Toast.component.d.ts.map +1 -1
- package/dist/components/toast/useMutationsHandler.d.ts.map +1 -1
- package/dist/components/tooltip/Tooltip.component.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/next.d.ts +3 -3
- package/dist/next.d.ts.map +1 -1
- package/dist/organisms/attachments/AttachmentTable.d.ts.map +1 -1
- package/dist/spacing.d.ts.map +1 -1
- package/dist/utils.d.ts +16 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +27 -0
- package/jest.config.js +6 -1
- package/package.json +7 -7
- package/src/lib/components/banner/Banner.component.test.tsx +58 -0
- package/src/lib/components/banner/Banner.component.tsx +57 -10
- package/src/lib/components/charts/barchart/Barchart.test.tsx +3 -1
- package/src/lib/components/charts/barchart/Barchart.tsx +123 -106
- package/src/lib/components/charts/common/SharedComponents.tsx +15 -11
- package/src/lib/components/charts/common/chartUtils.test.ts +27 -12
- package/src/lib/components/charts/common/chartUtils.ts +67 -23
- package/src/lib/components/charts/index.ts +1 -1
- package/src/lib/components/charts/linetimeseries/LineTimeSerieChart.tsx +136 -516
- package/src/lib/components/charts/linetimeseries/LineTimeSerieChart.types.ts +93 -0
- package/src/lib/components/charts/linetimeseries/LineTimeSerieChartTooltip.tsx +137 -0
- package/src/lib/components/charts/linetimeseries/useChartData.ts +322 -0
- package/src/lib/components/charts/linetimeseries/useChartHover.ts +35 -0
- package/src/lib/components/checkbox/Checkbox.component.tsx +19 -20
- package/src/lib/components/constrainedtext/Constrainedtext.component.tsx +3 -2
- package/src/lib/components/dropdown/Dropdown.component.tsx +3 -0
- package/src/lib/components/error-pages/ErrorPage401.component.tsx +1 -1
- package/src/lib/components/error-pages/ErrorPage404.component.tsx +1 -1
- package/src/lib/components/error-pages/ErrorPage500.component.tsx +1 -1
- package/src/lib/components/form/Form.component.tsx +5 -19
- package/src/lib/components/icon/CustomsIcons.tsx +36 -0
- package/src/lib/components/icon/Icon.component.tsx +17 -137
- package/src/lib/components/icon/iconTable.ts +137 -0
- package/src/lib/components/iconhelper/IconHelper.test.tsx +2 -2
- package/src/lib/components/infomessage/InfoMessage.component.tsx +1 -1
- package/src/lib/components/inputlist/InputList.component.tsx +4 -2
- package/src/lib/components/inputv2/inputv2.tsx +11 -5
- package/src/lib/components/searchinput/SearchInput.component.tsx +1 -0
- package/src/lib/components/searchinput/SearchInput.test.tsx +6 -6
- package/src/lib/components/tablev2/Tablestyle.tsx +2 -4
- package/src/lib/components/text/Text.component.tsx +18 -10
- package/src/lib/components/tooltip/Tooltip.component.tsx +1 -1
- package/src/lib/index.ts +3 -2
- package/src/lib/next.ts +3 -3
- package/src/lib/utils.ts +42 -0
- package/stories/GlobalHealthBar/globalhealthbar.stories.tsx +1 -1
- package/stories/banner.stories.tsx +37 -5
- package/stories/inputlist.stories.tsx +18 -6
- package/stories/linetimeseriechart.stories.tsx +325 -6
- package/tsconfig.json +1 -1
- package/dist/components/date/FormattedDateTime.spec.d.ts +0 -2
- package/dist/components/date/FormattedDateTime.spec.d.ts.map +0 -1
- package/dist/components/date/FormattedDateTime.spec.js +0 -161
- package/dist/components/date/dateDiffer.spec.d.ts +0 -2
- package/dist/components/date/dateDiffer.spec.d.ts.map +0 -1
- package/dist/components/date/dateDiffer.spec.js +0 -6
|
@@ -11,10 +11,13 @@ import {
|
|
|
11
11
|
import { lineTimeSeriesColorRange } from '../src/lib/style/theme';
|
|
12
12
|
import { useEffect } from 'react';
|
|
13
13
|
import {
|
|
14
|
+
SAMPLE_DURATION_LAST_ONE_HOUR,
|
|
14
15
|
SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS,
|
|
16
|
+
SAMPLE_FREQUENCY_LAST_ONE_HOUR,
|
|
15
17
|
SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS,
|
|
16
18
|
} from '../src/lib/components/constants';
|
|
17
19
|
import { Button } from '../src/lib/components/buttonv2/Buttonv2.component';
|
|
20
|
+
import { useTheme } from 'styled-components';
|
|
18
21
|
|
|
19
22
|
const ChartWithProviders = (props) => {
|
|
20
23
|
return (
|
|
@@ -71,10 +74,6 @@ const meta: Meta<typeof LineTimeSerieChart> = {
|
|
|
71
74
|
options: ['default', 'percentage', 'symmetrical'],
|
|
72
75
|
},
|
|
73
76
|
yAxisTitle: { control: 'text' },
|
|
74
|
-
timeFormat: {
|
|
75
|
-
control: 'select',
|
|
76
|
-
options: ['date-time', 'date'],
|
|
77
|
-
},
|
|
78
77
|
},
|
|
79
78
|
};
|
|
80
79
|
|
|
@@ -638,7 +637,6 @@ export const DateFormatExample: Story = {
|
|
|
638
637
|
duration:
|
|
639
638
|
longTermPrometheusData[longTermPrometheusData.length - 1][0] -
|
|
640
639
|
longTermPrometheusData[0][0],
|
|
641
|
-
timeFormat: 'date',
|
|
642
640
|
},
|
|
643
641
|
};
|
|
644
642
|
|
|
@@ -719,6 +717,51 @@ export const SyncIdExample: Story = {
|
|
|
719
717
|
interval={SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS}
|
|
720
718
|
duration={SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS}
|
|
721
719
|
/>
|
|
720
|
+
|
|
721
|
+
<LineTimeSerieChart
|
|
722
|
+
syncId="sync-id"
|
|
723
|
+
series={[
|
|
724
|
+
{
|
|
725
|
+
data: prometheusData as [number, string | number | null][],
|
|
726
|
+
resource: 'ip-10-160-122-207.eu-north-1.compute.internal',
|
|
727
|
+
metricPrefix: 'cpu',
|
|
728
|
+
getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
|
|
729
|
+
},
|
|
730
|
+
]}
|
|
731
|
+
title="CPU Usage"
|
|
732
|
+
height={200}
|
|
733
|
+
startingTimeStamp={Number(prometheusData[0][0])}
|
|
734
|
+
isLoading={false}
|
|
735
|
+
yAxisType={'percentage'}
|
|
736
|
+
interval={SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS}
|
|
737
|
+
duration={SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS}
|
|
738
|
+
/>
|
|
739
|
+
|
|
740
|
+
<LineTimeSerieChart
|
|
741
|
+
syncId="sync-id"
|
|
742
|
+
series={[
|
|
743
|
+
{
|
|
744
|
+
data: prometheusData3 as [number, string | number | null][],
|
|
745
|
+
resource: 'ip-10-160-122-207.eu-north-1.compute.internal',
|
|
746
|
+
metricPrefix: 'memory',
|
|
747
|
+
getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
data: prometheusData4 as [number, string | number | null][],
|
|
751
|
+
resource: 'ip-10-160-122-207.eu-north-2.compute.internal',
|
|
752
|
+
metricPrefix: 'memory',
|
|
753
|
+
getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
|
|
754
|
+
},
|
|
755
|
+
]}
|
|
756
|
+
title="Memory Usage"
|
|
757
|
+
height={200}
|
|
758
|
+
startingTimeStamp={Number(prometheusData3[0][0])}
|
|
759
|
+
isLoading={false}
|
|
760
|
+
yAxisType={'percentage'}
|
|
761
|
+
interval={SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS}
|
|
762
|
+
duration={SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS}
|
|
763
|
+
/>
|
|
764
|
+
|
|
722
765
|
<ChartLegend shape="line" direction="vertical" />
|
|
723
766
|
</ChartLegendWrapper>
|
|
724
767
|
);
|
|
@@ -744,7 +787,6 @@ export const CustomTooltipExample: Story = {
|
|
|
744
787
|
yAxisTitle: '',
|
|
745
788
|
interval: SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS,
|
|
746
789
|
duration: SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS,
|
|
747
|
-
timeFormat: 'date-time',
|
|
748
790
|
renderTooltip: (props) => {
|
|
749
791
|
return <div>Custom Tooltip</div>;
|
|
750
792
|
},
|
|
@@ -849,3 +891,280 @@ export const DynamicColorSetExample: Story = {
|
|
|
849
891
|
);
|
|
850
892
|
},
|
|
851
893
|
};
|
|
894
|
+
|
|
895
|
+
export const EmptyDataExample: Story = {
|
|
896
|
+
render: () => {
|
|
897
|
+
const theme = useTheme();
|
|
898
|
+
const now = Date.now() / 1000;
|
|
899
|
+
|
|
900
|
+
return (
|
|
901
|
+
<ChartLegendWrapper
|
|
902
|
+
// @ts-ignore
|
|
903
|
+
colorSet={{ Success: theme.statusHealthy, Failed: theme.statusCritical }}
|
|
904
|
+
sortOrder="status"
|
|
905
|
+
>
|
|
906
|
+
<LineTimeSerieChart
|
|
907
|
+
series={[]}
|
|
908
|
+
title="Empty Data - Last Hour"
|
|
909
|
+
height={150}
|
|
910
|
+
duration={60 * 60} // 1 hour
|
|
911
|
+
interval={60} // 1 minute
|
|
912
|
+
startingTimeStamp={now - 60 * 60}
|
|
913
|
+
isLoading={false}
|
|
914
|
+
yAxisType="default"
|
|
915
|
+
/>
|
|
916
|
+
<ChartLegend shape="line" direction="vertical" />
|
|
917
|
+
</ChartLegendWrapper>
|
|
918
|
+
);
|
|
919
|
+
},
|
|
920
|
+
};
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
// Generate 1-hour data with 30s intervals, all zeros
|
|
924
|
+
const generateAllZeroValuesData = (): [number, string][] => {
|
|
925
|
+
const baseTimestamp = 1740405600;
|
|
926
|
+
const points: [number, string][] = [];
|
|
927
|
+
for (let i = 0; i <= 120; i++) {
|
|
928
|
+
const timestamp = baseTimestamp + i * 30;
|
|
929
|
+
points.push([timestamp, '0']);
|
|
930
|
+
}
|
|
931
|
+
return points;
|
|
932
|
+
};
|
|
933
|
+
|
|
934
|
+
const allZeroValuesData = generateAllZeroValuesData();
|
|
935
|
+
|
|
936
|
+
export const AllZeroValuesExample: Story = {
|
|
937
|
+
render: () => {
|
|
938
|
+
return (
|
|
939
|
+
<ChartLegendWrapper colorSet={{ 'server-1': lineTimeSeriesColorRange[0] }}>
|
|
940
|
+
<LineTimeSerieChart yAxisType='default' startingTimeStamp={allZeroValuesData[0][0]} interval={SAMPLE_FREQUENCY_LAST_ONE_HOUR} duration={SAMPLE_DURATION_LAST_ONE_HOUR}
|
|
941
|
+
series={[{ data: allZeroValuesData, resource: 'server-1', metricPrefix: 'bandwidth', getTooltipLabel: (prefix, resource) => `${resource}-${prefix}` }]} title="All Zero Values" height={200} />
|
|
942
|
+
</ChartLegendWrapper>
|
|
943
|
+
);
|
|
944
|
+
},
|
|
945
|
+
};
|
|
946
|
+
|
|
947
|
+
// Data with small values (below 1)
|
|
948
|
+
const smallValuesData: [number, string][] = [
|
|
949
|
+
[1740405600, '0.047'],
|
|
950
|
+
[1740406320, '0.053'],
|
|
951
|
+
[1740407760, '0.040'],
|
|
952
|
+
[1740408480, '0.059'],
|
|
953
|
+
[1740409200, '0.062'],
|
|
954
|
+
[1740409920, '0.057'],
|
|
955
|
+
[1740410640, '0.045'],
|
|
956
|
+
[1740411360, '0.058'],
|
|
957
|
+
[1740412080, '0.053'],
|
|
958
|
+
[1740412800, '0.064'],
|
|
959
|
+
[1740413520, '0.081'],
|
|
960
|
+
[1740414240, '0.064'],
|
|
961
|
+
[1740415680, '0.097'],
|
|
962
|
+
[1740416400, '0.055'],
|
|
963
|
+
[1740417120, '0.047'],
|
|
964
|
+
[1740417840, '0.072'],
|
|
965
|
+
[1740418560, '0.061'],
|
|
966
|
+
[1740419280, '0.051'],
|
|
967
|
+
[1740420000, '0.039'],
|
|
968
|
+
[1740420720, '0.046'],
|
|
969
|
+
[1740421440, '0.035'],
|
|
970
|
+
[1740422160, '0.046'],
|
|
971
|
+
[1740422880, '0.043'],
|
|
972
|
+
[1740423600, '0.036'],
|
|
973
|
+
[1740467520, '0.042'],
|
|
974
|
+
[1740468240, '0.053'],
|
|
975
|
+
[1740468960, '0.055'],
|
|
976
|
+
[1740469680, '0.046'],
|
|
977
|
+
[1740470400, '0.043'],
|
|
978
|
+
[1740471120, '0.055'],
|
|
979
|
+
[1740471840, '0.046'],
|
|
980
|
+
[1740472560, '0.047'],
|
|
981
|
+
[1740473280, '0.044'],
|
|
982
|
+
[1740474000, '0.055'],
|
|
983
|
+
[1740474720, '0.042'],
|
|
984
|
+
[1740475440, '0.061'],
|
|
985
|
+
[1740476160, '0.042'],
|
|
986
|
+
[1740476880, '0.038'],
|
|
987
|
+
[1740477600, '0.041'],
|
|
988
|
+
[1740478320, '0.052'],
|
|
989
|
+
[1740479040, '0.042'],
|
|
990
|
+
[1740479760, '0.034'],
|
|
991
|
+
[1740480480, '0.036'],
|
|
992
|
+
[1740481200, '0.037'],
|
|
993
|
+
[1740481920, '0.049'],
|
|
994
|
+
[1740482640, '0.041'],
|
|
995
|
+
[1740483360, '0.037'],
|
|
996
|
+
[1740484080, '0.035'],
|
|
997
|
+
[1740484800, '0.039'],
|
|
998
|
+
[1740485520, '0.047'],
|
|
999
|
+
[1740486240, '0.046'],
|
|
1000
|
+
[1740486960, '0.042'],
|
|
1001
|
+
[1740487680, '0.035'],
|
|
1002
|
+
[1740488400, '0.034'],
|
|
1003
|
+
[1740489120, '0.041'],
|
|
1004
|
+
[1740489840, '0.058'],
|
|
1005
|
+
[1740490560, '0.040'],
|
|
1006
|
+
[1740491280, '0.045'],
|
|
1007
|
+
[1740492000, '0.045'],
|
|
1008
|
+
];
|
|
1009
|
+
|
|
1010
|
+
const verySmallValuesData: [number, string][] = [
|
|
1011
|
+
[1740405600, '0.00000475'],
|
|
1012
|
+
[1740406320, '0.00000530'],
|
|
1013
|
+
[1740407760, '0.00000401'],
|
|
1014
|
+
[1740408480, '0.00000591'],
|
|
1015
|
+
[1740409200, '0.00000624'],
|
|
1016
|
+
[1740409920, '0.00000574'],
|
|
1017
|
+
[1740410640, '0.00000451'],
|
|
1018
|
+
[1740411360, '0.00000586'],
|
|
1019
|
+
[1740412080, '0.00000530'],
|
|
1020
|
+
[1740412800, '0.00000649'],
|
|
1021
|
+
[1740413520, '0.00000812'],
|
|
1022
|
+
[1740414240, '0.00000648'],
|
|
1023
|
+
[1740415680, '0.00000671'],
|
|
1024
|
+
[1740416400, '0.00000552'],
|
|
1025
|
+
[1740417120, '0.00000479'],
|
|
1026
|
+
[1740417840, '0.00000721'],
|
|
1027
|
+
[1740418560, '0.00000619'],
|
|
1028
|
+
[1740419280, '0.00000510'],
|
|
1029
|
+
[1740420000, '0.00000395'],
|
|
1030
|
+
[1740420720, '0.00000469'],
|
|
1031
|
+
[1740421440, '0.00000350'],
|
|
1032
|
+
[1740422160, '0.00000466'],
|
|
1033
|
+
[1740422880, '0.00000435'],
|
|
1034
|
+
[1740423600, '0.00000367'],
|
|
1035
|
+
];
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
export const SmallValuesExample: Story = {
|
|
1040
|
+
render: () => {
|
|
1041
|
+
return (
|
|
1042
|
+
<ChartLegendWrapper
|
|
1043
|
+
colorSet={{
|
|
1044
|
+
'server-1': lineTimeSeriesColorRange[0],
|
|
1045
|
+
'server-2': lineTimeSeriesColorRange[1],
|
|
1046
|
+
}}
|
|
1047
|
+
>
|
|
1048
|
+
<LineTimeSerieChart
|
|
1049
|
+
series={[
|
|
1050
|
+
{
|
|
1051
|
+
data: smallValuesData,
|
|
1052
|
+
resource: 'server-1',
|
|
1053
|
+
metricPrefix: 'rate',
|
|
1054
|
+
getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
|
|
1055
|
+
},
|
|
1056
|
+
]}
|
|
1057
|
+
title="Small Values (0.003 - 0.008 range)"
|
|
1058
|
+
height={200}
|
|
1059
|
+
startingTimeStamp={smallValuesData[0][0]}
|
|
1060
|
+
isLoading={false}
|
|
1061
|
+
yAxisType={'default'}
|
|
1062
|
+
interval={SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS}
|
|
1063
|
+
duration={SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS}
|
|
1064
|
+
/>
|
|
1065
|
+
|
|
1066
|
+
<LineTimeSerieChart
|
|
1067
|
+
series={[
|
|
1068
|
+
{
|
|
1069
|
+
data: verySmallValuesData,
|
|
1070
|
+
resource: 'server-2',
|
|
1071
|
+
metricPrefix: 'rate',
|
|
1072
|
+
getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
|
|
1073
|
+
},
|
|
1074
|
+
]}
|
|
1075
|
+
title="Very Small Values (0.000003 - 0.000008 range)"
|
|
1076
|
+
height={200}
|
|
1077
|
+
startingTimeStamp={verySmallValuesData[0][0]}
|
|
1078
|
+
isLoading={false}
|
|
1079
|
+
yAxisType={'default'}
|
|
1080
|
+
interval={SAMPLE_FREQUENCY_LAST_TWENTY_FOUR_HOURS}
|
|
1081
|
+
duration={SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS}
|
|
1082
|
+
/>
|
|
1083
|
+
<ChartLegend shape="line" direction="vertical" />
|
|
1084
|
+
</ChartLegendWrapper>
|
|
1085
|
+
);
|
|
1086
|
+
},
|
|
1087
|
+
};
|
|
1088
|
+
// Generate 1-hour data with 30s intervals (120 points)
|
|
1089
|
+
const generateBigValuesData = (): [number, string][] => {
|
|
1090
|
+
const baseTimestamp = 1740405600;
|
|
1091
|
+
const points: [number, string][] = [];
|
|
1092
|
+
for (let i = 0; i <= 120; i++) {
|
|
1093
|
+
const timestamp = baseTimestamp + i * 30;
|
|
1094
|
+
// Exponential growth from 1000 to ~100M
|
|
1095
|
+
const value = Math.floor(1000 * Math.pow(1.1, i));
|
|
1096
|
+
points.push([timestamp, value.toString()]);
|
|
1097
|
+
}
|
|
1098
|
+
return points;
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1101
|
+
const generateBigValuesData2 = (): [number, string][] => {
|
|
1102
|
+
const baseTimestamp = 1740405600;
|
|
1103
|
+
const points: [number, string][] = [];
|
|
1104
|
+
for (let i = 0; i <= 120; i++) {
|
|
1105
|
+
const timestamp = baseTimestamp + i * 30;
|
|
1106
|
+
// Fluctuating between 10000 and 15000 with random variation
|
|
1107
|
+
const value = 12500 + Math.sin(i * 0.2) * 2500 + Math.random() * 500;
|
|
1108
|
+
points.push([timestamp, value.toFixed(2)]);
|
|
1109
|
+
}
|
|
1110
|
+
return points;
|
|
1111
|
+
};
|
|
1112
|
+
|
|
1113
|
+
const bigValuesData = generateBigValuesData();
|
|
1114
|
+
const bigValuesData2 = generateBigValuesData2();
|
|
1115
|
+
export const BigValuesExample: Story = {
|
|
1116
|
+
render: () => {
|
|
1117
|
+
return (
|
|
1118
|
+
<ChartLegendWrapper
|
|
1119
|
+
colorSet={{
|
|
1120
|
+
'server-1': lineTimeSeriesColorRange[0],
|
|
1121
|
+
'server-2': lineTimeSeriesColorRange[1],
|
|
1122
|
+
}}
|
|
1123
|
+
>
|
|
1124
|
+
<LineTimeSerieChart
|
|
1125
|
+
series={[
|
|
1126
|
+
{
|
|
1127
|
+
data: bigValuesData2,
|
|
1128
|
+
resource: 'server-2',
|
|
1129
|
+
metricPrefix: 'bandwidth',
|
|
1130
|
+
getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
|
|
1131
|
+
},
|
|
1132
|
+
]}
|
|
1133
|
+
title="Big Values"
|
|
1134
|
+
height={200}
|
|
1135
|
+
yAxisTitle='Big Number Example '
|
|
1136
|
+
startingTimeStamp={bigValuesData2[0][0]}
|
|
1137
|
+
isLoading={false}
|
|
1138
|
+
yAxisType={'default'}
|
|
1139
|
+
interval={SAMPLE_FREQUENCY_LAST_ONE_HOUR}
|
|
1140
|
+
duration={SAMPLE_DURATION_LAST_ONE_HOUR}
|
|
1141
|
+
/>
|
|
1142
|
+
<LineTimeSerieChart
|
|
1143
|
+
series={[
|
|
1144
|
+
{
|
|
1145
|
+
data: bigValuesData2,
|
|
1146
|
+
resource: 'server-2',
|
|
1147
|
+
metricPrefix: 'bandwidth',
|
|
1148
|
+
getTooltipLabel: (prefix, resource) => `${resource}-${prefix}`,
|
|
1149
|
+
},
|
|
1150
|
+
]}
|
|
1151
|
+
title="Big Values"
|
|
1152
|
+
height={200}
|
|
1153
|
+
yAxisTitle='Big Number Example '
|
|
1154
|
+
startingTimeStamp={bigValuesData2[0][0]}
|
|
1155
|
+
isLoading={false}
|
|
1156
|
+
unitRange={UNIT_RANGE_BS}
|
|
1157
|
+
yAxisType={'default'}
|
|
1158
|
+
interval={SAMPLE_FREQUENCY_LAST_ONE_HOUR}
|
|
1159
|
+
duration={SAMPLE_DURATION_LAST_ONE_HOUR}
|
|
1160
|
+
/>
|
|
1161
|
+
</ChartLegendWrapper>
|
|
1162
|
+
);
|
|
1163
|
+
},
|
|
1164
|
+
};
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
|
|
1168
|
+
|
|
1169
|
+
|
|
1170
|
+
|
package/tsconfig.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormattedDateTime.spec.d.ts","sourceRoot":"","sources":["../../../src/lib/components/date/FormattedDateTime.spec.tsx"],"names":[],"mappings":""}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { FormattedDateTime } from './FormattedDateTime';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
|
-
describe('FormatttedDateTime', () => {
|
|
6
|
-
it('should display the date in the expected format', () => {
|
|
7
|
-
//S
|
|
8
|
-
render(_jsx(FormattedDateTime, { format: "date", value: new Date('2022-10-01T00:00:00Z') }));
|
|
9
|
-
//V
|
|
10
|
-
expect(screen.getByText('2022-10-01')).toBeInTheDocument();
|
|
11
|
-
});
|
|
12
|
-
it('should display the date time second in the expected format', () => {
|
|
13
|
-
//S
|
|
14
|
-
render(_jsx(FormattedDateTime, { format: "date-time-second", value: new Date('2022-10-01T00:00:00Z') }));
|
|
15
|
-
//V
|
|
16
|
-
expect(screen.getByText('2022-10-01 00:00:00')).toBeInTheDocument();
|
|
17
|
-
});
|
|
18
|
-
it('should display the date time in the expected format', () => {
|
|
19
|
-
//S
|
|
20
|
-
render(_jsx(FormattedDateTime, { format: "date-time", value: new Date('2022-10-01T00:00:00Z') }));
|
|
21
|
-
//V
|
|
22
|
-
expect(screen.getByText('2022-10-01 00:00')).toBeInTheDocument();
|
|
23
|
-
});
|
|
24
|
-
it('should display the time second in the expected format', () => {
|
|
25
|
-
//S
|
|
26
|
-
render(_jsx(FormattedDateTime, { format: "time-second", value: new Date('2022-10-01T00:00:00Z') }));
|
|
27
|
-
//V
|
|
28
|
-
expect(screen.getByText('00:00:00')).toBeInTheDocument();
|
|
29
|
-
});
|
|
30
|
-
it('should display the time in the expected format', () => {
|
|
31
|
-
//S
|
|
32
|
-
render(_jsx(FormattedDateTime, { format: "time", value: new Date('2022-10-01T00:00:00Z') }));
|
|
33
|
-
//V
|
|
34
|
-
expect(screen.getByText('00:00')).toBeInTheDocument();
|
|
35
|
-
});
|
|
36
|
-
it('should display a relative date with the right format when the date occured few seconds before', async () => {
|
|
37
|
-
//S
|
|
38
|
-
const today = new Date('2022-10-10T12:00:00Z');
|
|
39
|
-
jest.useFakeTimers('modern');
|
|
40
|
-
jest.setSystemTime(today);
|
|
41
|
-
render(_jsx(FormattedDateTime, { format: "relative", value: new Date('2022-10-10T11:59:37Z') }));
|
|
42
|
-
//V
|
|
43
|
-
expect(screen.getByText('few seconds ago')).toBeInTheDocument();
|
|
44
|
-
//E
|
|
45
|
-
await userEvent.hover(screen.getByText('few seconds ago'));
|
|
46
|
-
//V
|
|
47
|
-
expect(screen.getByText('2022-10-10 11:59:37')).toBeInTheDocument();
|
|
48
|
-
});
|
|
49
|
-
it('should display a relative date with the right format when the date occured 1 minute before', async () => {
|
|
50
|
-
//S
|
|
51
|
-
const today = new Date('2022-10-10T12:00:00Z');
|
|
52
|
-
jest.useFakeTimers('modern');
|
|
53
|
-
jest.setSystemTime(today);
|
|
54
|
-
render(_jsx(FormattedDateTime, { format: "relative", value: new Date('2022-10-10T11:59:00Z') }));
|
|
55
|
-
//V
|
|
56
|
-
expect(screen.getByText('1 minute ago')).toBeInTheDocument();
|
|
57
|
-
//E
|
|
58
|
-
await userEvent.hover(screen.getByText('1 minute ago'));
|
|
59
|
-
//V
|
|
60
|
-
expect(screen.getByText('2022-10-10 11:59:00')).toBeInTheDocument();
|
|
61
|
-
});
|
|
62
|
-
it('should display a relative date with the right format when the date occured 2 minutes before', async () => {
|
|
63
|
-
//S
|
|
64
|
-
const today = new Date('2022-10-10T12:00:00Z');
|
|
65
|
-
jest.useFakeTimers('modern');
|
|
66
|
-
jest.setSystemTime(today);
|
|
67
|
-
render(_jsx(FormattedDateTime, { format: "relative", value: new Date('2022-10-10T11:57:26Z') }));
|
|
68
|
-
//V
|
|
69
|
-
expect(screen.getByText('2 minutes ago')).toBeInTheDocument();
|
|
70
|
-
//E
|
|
71
|
-
await userEvent.hover(screen.getByText('2 minutes ago'));
|
|
72
|
-
//V
|
|
73
|
-
expect(screen.getByText('2022-10-10 11:57:26')).toBeInTheDocument();
|
|
74
|
-
});
|
|
75
|
-
it('should display a relative date with the right format when the date occured 1 day before', async () => {
|
|
76
|
-
//S
|
|
77
|
-
const today = new Date('2022-10-10T12:00:00Z');
|
|
78
|
-
jest.useFakeTimers('modern');
|
|
79
|
-
jest.setSystemTime(today);
|
|
80
|
-
render(_jsx(FormattedDateTime, { format: "relative", value: new Date('2022-10-09T11:57:26Z') }));
|
|
81
|
-
//V
|
|
82
|
-
expect(screen.getByText('1 day ago')).toBeInTheDocument();
|
|
83
|
-
//E
|
|
84
|
-
await userEvent.hover(screen.getByText('1 day ago'));
|
|
85
|
-
//V
|
|
86
|
-
expect(screen.getByText('2022-10-09 11:57:26')).toBeInTheDocument();
|
|
87
|
-
});
|
|
88
|
-
it('should display a relative date with the right format when the date occured 2 days before', async () => {
|
|
89
|
-
//S
|
|
90
|
-
const today = new Date('2022-10-10T12:00:00Z');
|
|
91
|
-
jest.useFakeTimers('modern');
|
|
92
|
-
jest.setSystemTime(today);
|
|
93
|
-
render(_jsx(FormattedDateTime, { format: "relative", value: new Date('2022-10-08T11:57:26Z') }));
|
|
94
|
-
//V
|
|
95
|
-
expect(screen.getByText('2 days ago')).toBeInTheDocument();
|
|
96
|
-
//E
|
|
97
|
-
await userEvent.hover(screen.getByText('2 days ago'));
|
|
98
|
-
//V
|
|
99
|
-
expect(screen.getByText('2022-10-08 11:57:26')).toBeInTheDocument();
|
|
100
|
-
});
|
|
101
|
-
it('should display a relative date with the right format when the date occured 1 month before', async () => {
|
|
102
|
-
//S
|
|
103
|
-
const today = new Date('2022-10-10T12:00:00Z');
|
|
104
|
-
jest.useFakeTimers('modern');
|
|
105
|
-
jest.setSystemTime(today);
|
|
106
|
-
render(_jsx(FormattedDateTime, { format: "relative", value: new Date('2022-09-08T11:57:26Z') }));
|
|
107
|
-
//V
|
|
108
|
-
expect(screen.getByText('32 days ago')).toBeInTheDocument();
|
|
109
|
-
//E
|
|
110
|
-
await userEvent.hover(screen.getByText('32 days ago'));
|
|
111
|
-
//V
|
|
112
|
-
expect(screen.getByText('2022-09-08 11:57:26')).toBeInTheDocument();
|
|
113
|
-
});
|
|
114
|
-
it('should display a relative date with the right format when the date occured 2 months before', async () => {
|
|
115
|
-
//S
|
|
116
|
-
const today = new Date('2022-10-10T12:00:00Z');
|
|
117
|
-
jest.useFakeTimers('modern');
|
|
118
|
-
jest.setSystemTime(today);
|
|
119
|
-
render(_jsx(FormattedDateTime, { format: "relative", value: new Date('2022-08-08T11:57:26Z') }));
|
|
120
|
-
//V
|
|
121
|
-
expect(screen.getByText('63 days ago')).toBeInTheDocument();
|
|
122
|
-
//E
|
|
123
|
-
await userEvent.hover(screen.getByText('63 days ago'));
|
|
124
|
-
//V
|
|
125
|
-
expect(screen.getByText('2022-08-08 11:57:26')).toBeInTheDocument();
|
|
126
|
-
});
|
|
127
|
-
it('should display a relative date with the right format when the date occured 2 months after', async () => {
|
|
128
|
-
//S
|
|
129
|
-
const today = new Date('2022-10-10T12:00:00Z');
|
|
130
|
-
jest.useFakeTimers('modern');
|
|
131
|
-
jest.setSystemTime(today);
|
|
132
|
-
render(_jsx(FormattedDateTime, { format: "relative", value: new Date('2022-12-12T11:57:26Z') }));
|
|
133
|
-
//V
|
|
134
|
-
expect(screen.getByText('in 63 days')).toBeInTheDocument();
|
|
135
|
-
//E
|
|
136
|
-
await userEvent.hover(screen.getByText('in 63 days'));
|
|
137
|
-
//V
|
|
138
|
-
expect(screen.getByText('2022-12-12 11:57:26')).toBeInTheDocument();
|
|
139
|
-
});
|
|
140
|
-
it('should display the date in the expected format of the xaxis tick in the chart', () => {
|
|
141
|
-
//S
|
|
142
|
-
render(_jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute", value: new Date('2022-10-06T18:33:00Z') }));
|
|
143
|
-
//V
|
|
144
|
-
expect(screen.getByText('06 Oct 18:33')).toBeInTheDocument();
|
|
145
|
-
});
|
|
146
|
-
it('should display the date in the expected format of date in the chart', () => {
|
|
147
|
-
//S
|
|
148
|
-
render(_jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute-second", value: new Date('2022-10-06T18:33:00Z') }));
|
|
149
|
-
//V
|
|
150
|
-
expect(screen.getByText('06 Oct 18:33:00')).toBeInTheDocument();
|
|
151
|
-
});
|
|
152
|
-
it('should display 3 letter month for September date', () => {
|
|
153
|
-
//S
|
|
154
|
-
render(_jsxs(_Fragment, { children: [_jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute", value: new Date('2022-09-06T18:33:00Z') }), _jsx(FormattedDateTime, { format: "day-month-abbreviated-hour-minute-second", value: new Date('2022-09-06T18:33:00Z') }), _jsx(FormattedDateTime, { format: "chart-date", value: new Date('2022-09-06T18:33:00Z') })] }));
|
|
155
|
-
//V
|
|
156
|
-
expect(screen.getByText(/06 Sep 18:33/)).toBeInTheDocument();
|
|
157
|
-
expect(screen.getByText(/06 Sep 18:33:00/)).toBeInTheDocument();
|
|
158
|
-
expect(screen.getByText(/Tue06Sep/)).toBeInTheDocument();
|
|
159
|
-
expect(screen.queryByText(/Sept/)).not.toBeInTheDocument();
|
|
160
|
-
});
|
|
161
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dateDiffer.spec.d.ts","sourceRoot":"","sources":["../../../src/lib/components/date/dateDiffer.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { getDateDaysDiff } from './dateDiffer';
|
|
2
|
-
describe('Date Differ', () => {
|
|
3
|
-
it('should computes the difference of days between 2 dates', () => {
|
|
4
|
-
expect(getDateDaysDiff(new Date('2022-10-10T20:10:39Z'), new Date('2022-11-29T15:14:39Z'), 'days')).toBe(49);
|
|
5
|
-
});
|
|
6
|
-
});
|