Fix parseApi not accepting versions that don't start with 'v' (#441)

* fix parseApi not accepting versions that don't start with 'v'

Signed-off-by: Sebastian Malton <smalton@mirantis.com>

Co-authored-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
Sebastian MaltonandSebastian Malton authored and GitHub committed 2020-06-11 13:19:01 -04:00
1 parent 5c5454166f
commit 00557c9940
9 files changed
+1956 -2477

No files matched your search

@@ -150,7 +150,7 @@ export function BarChart(props: Props) {
}
};
const options = merge(barOptions, customOptions);
if (!chartData.datasets.length) {
if (chartData.datasets.length == 0) {
return <NoMetrics/>
}
return (
@@ -170,9 +170,17 @@ export const memoryOptions: ChartOptions = {
scales: {
yAxes: [{
ticks: {
callback: value => {
if (!value) return 0;
return parseFloat(value) < 1 ? value.toFixed(3) : bytesToUnits(parseInt(value));
callback: (value: number | string): string => {
if (typeof value == "string") {
const float = parseFloat(value);
if (float < 1) {
return float.toFixed(3);
}
return bytesToUnits(parseInt(value));
}
return `${value}`;
},
stepSize: 1
}
@@ -194,11 +202,12 @@ export const cpuOptions: ChartOptions = {
scales: {
yAxes: [{
ticks: {
callback: value => {
if (value == 0) return 0;
if (value < 10) return value.toFixed(3);
if (value < 100) return value.toFixed(2);
return value.toFixed(1);
callback: (value: number | string): string => {
const float = parseFloat(`${value}`);
if (float == 0) return "0";
if (float < 10) return float.toFixed(3);
if (float < 100) return float.toFixed(2);
return float.toFixed(1);
}
}
}]
+1 -4
View File
@@ -19,10 +19,7 @@ export interface ChartDataSet extends ChartDataSets {
}
export interface ChartProps {
data: {
labels?: Array<string | string[]>;
datasets?: ChartDataSet[];
};
data: ChartData;
width?: number | string;
height?: number | string;
options?: ChartOptions; // Passed to ChartJS instance
@@ -7,7 +7,6 @@ import { cssNames } from "../../utils";
import { themeStore } from "../../theme.store";
interface Props extends ChartProps {
data: ChartData;
title?: string;
}