Skip to content

Commit

Permalink
fix(costcneter):fix gpu price alias (#5309)
Browse files Browse the repository at this point in the history
  • Loading branch information
xudaotutou authored Dec 25, 2024
1 parent dade357 commit aaecf4d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type PricePayload = {
price: number;
title: string;
unit: string;
isGpu: boolean;
icon: typeof Img;
};
export function PriceTable({ data }: { data: PricePayload[] }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function PriceTablePanel({ priceData }: { priceData: PricePayload[] }) {
const gpuEnabled = useEnvStore((state) => state.gpuEnabled);
const baseData = priceData.filter((x) => x.title !== 'network' && !x.title.startsWith('gpu-'));
const networkData = priceData.filter((x) => x.title === 'network');
const gpuData = priceData.filter((x) => x.title.startsWith('gpu-'));
const gpuData = priceData.filter((x) => x.isGpu);
return (
<TabPanel>
<Flex direction={'column'} w="720px" mx={'auto'}>
Expand Down
10 changes: 5 additions & 5 deletions frontend/providers/costcenter/src/pages/valuation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type CardItem = {
unit: string;
idx: number; // used to sort
icon: typeof Img;
isGpu: boolean;
};
// 1 ,24,
export const PRICE_CYCLE_SCALE = [1, 24, 168, 720, 8760];
Expand Down Expand Up @@ -57,6 +58,7 @@ function Valuation() {
props = gpuprops;
}
let icon: typeof Img;
let isGpu = x.name.startsWith('gpu-');
let title = x.name;
let unit = [t(props.unit), t(CYCLE[cycleIdx])].join('/');
if (x.name === 'cpu') icon = CpuIcon;
Expand All @@ -69,18 +71,18 @@ function Valuation() {
icon = PortIcon;
title = 'Port';
} else if (x.name.startsWith('gpu-')) {
// const reg = /nvidia/g
icon = NvidiaIcon;
x.alias && (title = x.alias);
} else return [];
const price = (x.unit_price || 0) * (props.scale || 1);
console.log(x.name, x.unit_price, price);
return [
{
title,
price,
unit,
idx: props.idx,
icon
icon,
isGpu
}
];
})
Expand Down Expand Up @@ -113,8 +115,6 @@ function Valuation() {
<Tabs
flex={1}
// mt={'20px'}
// mx={'24px'}
display={'flex'}
flexDir={'column'}
w={'full'}
Expand Down
1 change: 1 addition & 0 deletions frontend/providers/costcenter/src/types/valuation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export type ValuationStandard = {
name: string;
alias?: string;
unit: string;
unit_price?: number;
};
Expand Down

0 comments on commit aaecf4d

Please sign in to comment.