Skip to content

Commit

Permalink
fix: some bugs in cluster overview (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
xigongdaEricyang committed Mar 30, 2023
1 parent 57da856 commit 0fcd9d4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
14 changes: 11 additions & 3 deletions src/components/DashboardCard/LineCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ function LineCard(props: IProps) {
if (!loading && chartRef.current) {
updateChart();
}
}, [loading, chartRef.current]);
}, [loading, chartRef.current]);

useEffect(() => {
if (baseLine != undefined && chartRef.current) {
if (chartRef.current) {
chartRef.current.updateBaseline(baseLine);
}
}, [baseLine, chartRef.current]);
Expand All @@ -37,6 +37,14 @@ function LineCard(props: IProps) {
updateChart();
};

useEffect(() => {
chartRef.current?.configDetailChart({
valueType,
isCard: true,
});
updateChart();
}, [valueType]);

const updateChart = () => {
const realRange = data.length > 0 ? (data[data.length - 1].time - data[0].time) : 0;
const gap = Math.floor(realRange / 10); // 10 ticks max
Expand All @@ -62,7 +70,7 @@ function LineCard(props: IProps) {
loading ? <Spin /> : (
<LineChart
renderChart={renderLineChart}
ref={ref => chartRef.current = ref}
ref={chartRef}
options={{ padding: [20, 20, 60, 6 * maxNumLen + 30] }}
/>)
);
Expand Down
5 changes: 2 additions & 3 deletions src/pages/ServiceManage/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ import { getVersionFeatures } from '@/utils/versionFeature';
import Modal from '@/components/Modal';
import { IDispatch, IRootState } from '@/store';
import { formatVersion } from '@/utils/dashboard';
import { isCommunityVersion } from '@/utils';

import styles from './index.module.less';
import { isCommunityVersion } from '@/utils';
import { ICluster } from '@base/utils/interface';

const mapDispatch: any = (dispatch: IDispatch) => ({
asyncUseSpaces: dispatch.nebula.asyncUseSpaces,
Expand All @@ -41,7 +40,7 @@ interface IProps
ReturnType<typeof mapDispatch>,
RouteComponentProps {
baseRouter?: string;
cluster?: ICluster;
cluster?: any;
}

const OverviewCardHeader = (props: IHaderProps) => {
Expand Down
31 changes: 17 additions & 14 deletions src/utils/metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,19 @@ export const calcMetricInfo = (rawMetric: string) => {
}

const calcServiceMetricValueType = (metricName: string): VALUE_TYPE => {
let valueType = VALUE_TYPE.number;
const valueTypes = Object.keys(ServiceMetricValueTypeMap) as VALUE_TYPE[];
for (let i = 0; i < valueTypes.length; i++) {
const curValueType = valueTypes[i];
if (ServiceMetricValueTypeMap[curValueType].includes(metricName)) {
valueType = curValueType as VALUE_TYPE;
break;
}
if (metricName.includes('num')) {
return VALUE_TYPE.number;
}
if (metricName.includes('latency')) {
return VALUE_TYPE.latency;
}
return valueType;
if (metricName.includes('bytes')) {
return VALUE_TYPE.byte;
}
if (metricName.includes('seconds')) {
return VALUE_TYPE.byteSecond;
}
return VALUE_TYPE.number;
}

export const filterServiceMetrics = (payload: {
Expand Down Expand Up @@ -216,11 +219,11 @@ export const RawServiceMetrics = [
"write_bytes_total",
]

export const ServiceMetricValueTypeMap = {
[VALUE_TYPE.byte]: ["write_bytes_total", "memory_bytes_gauge", "read_bytes_total"],
[VALUE_TYPE.byteSecond]: [],
[VALUE_TYPE.numberSecond]: ["cpu_seconds_total"]
}
// export const ServiceMetricValueTypeMap = {
// [VALUE_TYPE.byte]: ["write_bytes_total", "memory_bytes_gauge", "read_bytes_total"],
// [VALUE_TYPE.byteSecond]: [],
// [VALUE_TYPE.numberSecond]: ["cpu_seconds_total"],
// }

export const getQueryMap = (metricItem: IServiceMetricItem) => {
const res = {};
Expand Down

0 comments on commit 0fcd9d4

Please sign in to comment.