Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(costcneter):fix gpu price alias #5309

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading