Skip to content

Commit

Permalink
feat(dcellar-web-ui): add dashboard module (#288)
Browse files Browse the repository at this point in the history
* feat(dcellar-web-ui): add billing history

* feat(dcellar-web-ui): add billing history

* fix(dcellar-web-ui): fix some billint history issues

* feat(dcellar-web-ui): add billing history

* fix(dcellar-web-ui): fix some billint history issues

* feat(dcellar-web-ui): migrate billing type to types

* chore(dcellar-web-ui): remove log

* feat(dcellar-web-ui): change the precision of billing history to 18

* fix(dcellar-web-ui): delete object format

* feat(dcellar-web-ui): update filter type data

* feat(dcellar-web-ui): add billing history

* feat(dcellar-web-ui): add billing history

* fix(dcellar-web-ui): fix some billint history issues

* feat(dcellar-web-ui): migrate billing type to types

* chore(dcellar-web-ui): remove log

* feat(dcellar-web-ui): change the precision of billing history to 18

* fix(dcellar-web-ui): delete object format

* feat(dcellar-web-ui): update filter type data

* feat(dcellar-web-ui): add dashboard module

* feat(dcellar-web-ui): add loading to dashboard

* feat(dcellar-web-ui): add bucket chart and opt constants

* fix(dcellar-web-ui): remove feature value in barchart hook

* fix(dcellar-web-ui): fix bar chart y-axis

* fix(dcellar-web-ui): fix invlid date and compatiable 429

* fix(dcellar-web-ui): set as nonrefundable button width

* fix(dcellar-web-ui): mergeArr function error

* fix(dcellar-web-ui): merge arr error

* feat(dcellar-web-ui): enlargement upload limit to 100 (#286)

* feat(dcellar-web-ui): enlargement upload limit to 100

* fix(dcellar-web-ui): upload tab z-index

* feat(dcellar-web-ui): only one task can be signed before the upload task
  • Loading branch information
devinxl authored Nov 30, 2023
1 parent 12d06ba commit 708380b
Show file tree
Hide file tree
Showing 82 changed files with 1,292 additions and 422 deletions.
2 changes: 1 addition & 1 deletion apps/dcellar-web-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"ahooks": "3.7.7",
"hash-wasm": "4.10.0",
"@babel/core": "^7.20.12",
"@bnb-chain/greenfield-js-sdk": "1.0.4",
"@bnb-chain/greenfield-js-sdk": "1.0.6",
"@bnb-chain/greenfield-cosmos-types": "0.4.0-alpha.23",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
Expand Down
1 change: 1 addition & 0 deletions apps/dcellar-web-ui/public/js/iconfont_v0.6.min.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions apps/dcellar-web-ui/src/base/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const {
NEXT_PUBLIC_GREENFIELD_CHAIN_MAINNET_RPC_URL,
} = publicRuntimeConfig || {};
const {
NEXT_PRIVATE_BILLING_API_URL
NEXT_PRIVATE_BILLING_API_URL,
NEXT_PRIVATE_EXPLORER_API_URL,
} = serverRuntimeConfig || {};

export type TRuntimeEnv = 'development' | 'qa' | 'testnet' | 'mainnet';
Expand All @@ -36,4 +37,5 @@ export const GREENFIELD_CHAIN_EXPLORER_URL = NEXT_PUBLIC_GREENFIELD_CHAIN_EXPLOR
export const BSC_EXPLORER_URL = NEXT_PUBLIC_BSC_EXPLORER_URL;
export const GREENFIELD_MAINNET_ID = NEXT_PUBLIC_GREENFIELD_CHAIN_MAINNET_ID;
export const GREENFIELD_MAINNET_RPC_URL = NEXT_PUBLIC_GREENFIELD_CHAIN_MAINNET_RPC_URL;
export const BILLING_API_URL = NEXT_PRIVATE_BILLING_API_URL;
export const BILLING_API_URL = NEXT_PRIVATE_BILLING_API_URL;
export const EXPLORER_API_URL = NEXT_PRIVATE_EXPLORER_API_URL;
1 change: 1 addition & 0 deletions apps/dcellar-web-ui/src/base/theme/light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const light = {
'label-normal': '#EEBE11',
'label-active': '#F1CA3C',
primary: '#00BA34',
chartTick: rgba('#AEB4BC', 0.3),
},
bg: {
bottom: '#f5f5f5',
Expand Down
6 changes: 3 additions & 3 deletions apps/dcellar-web-ui/src/components/ConnectWallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { DCButton, DCButtonProps } from '@/components/common/DCButton';
import { Text } from '@totejs/uikit';
import { smMedia } from '@/modules/responsive';
import { useRouter } from 'next/router';
import { InternalRoutePaths } from '@/utils/constant';
import { useAccount, useDisconnect } from 'wagmi';
import { ssrLandingRoutes } from '@/pages/_app';
import { useOffChainAuth } from '@/context/off-chain-auth/useOffChainAuth';
import { checkOffChainDataAvailable, setLogin } from '@/store/slices/persist';
import { useAsyncEffect } from 'ahooks';
import { useAppDispatch } from '@/store';
import { useModal } from '@totejs/walletkit';
import { InternalRoutePaths } from '@/constants/paths';

interface ConnectWalletProps extends DCButtonProps {
icon?: ReactElement;
Expand Down Expand Up @@ -67,7 +67,7 @@ export const ConnectWallet = memo<Partial<ConnectWalletProps>>(function ConnectB
router.push(
!!router.query.originAsPath
? decodeURIComponent(router.query.originAsPath as string)
: InternalRoutePaths.buckets,
: InternalRoutePaths.dashboard,
);
}, [address, trustEvent, isAuthPending, router]);

Expand All @@ -79,7 +79,7 @@ export const ConnectWallet = memo<Partial<ConnectWalletProps>>(function ConnectB
router.push(
!!router.query.originAsPath
? decodeURIComponent(router.query.originAsPath as string)
: InternalRoutePaths.buckets,
: InternalRoutePaths.dashboard,
);
};

Expand Down
4 changes: 2 additions & 2 deletions apps/dcellar-web-ui/src/components/ErrorComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Link from 'next/link';
import { Image } from '@totejs/uikit';
import { useRouter } from 'next/router';
import { useAppSelector } from '@/store';
import { InternalRoutePaths } from '@/utils/constant';
import { InternalRoutePaths } from '@/constants/paths';
import { IconFont } from '@/components/IconFont';

const Container = styled.main`
Expand Down Expand Up @@ -98,7 +98,7 @@ function ErrorComponent({ statusCode }: ErrorComponentProps) {
>
{desc}
</Text>
<Link href={address ? InternalRoutePaths.buckets : '/'} legacyBehavior passHref replace>
<Link href={address ? InternalRoutePaths.dashboard : '/'} legacyBehavior passHref replace>
<DCButton w={132} h={32} as="a" mb={40} fontSize={12} borderRadius={4}>
{isNoBucket ? 'Back to Home' : 'Go to Home'}
</DCButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { DCButton } from '../common/DCButton';
import { useWalletSwitchNetWork } from '@/context/WalletConnectContext';
import { useLogin } from '@/hooks/useLogin';
import { IconFont } from '@/components/IconFont';
import { CHAIN_NAMES } from '@/utils/constant';
import { CHAIN_NAMES } from '@/constants/wallet';

export const WrongNetworkModal = ({ isOpen, onClose }: any) => {
const { logout } = useLogin();
Expand Down
13 changes: 13 additions & 0 deletions apps/dcellar-web-ui/src/components/charts/BarChart/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { BaseChart, BaseChartProps } from '@/components/charts/BaseChart';
import { useBarChartOptions } from './useBarChartOptions';

export interface BarChartProps extends BaseChartProps {
noData: boolean
}

export function BarChart({noData, ...props}: BarChartProps) {
const { options, ...restProps } = props;
const finalOptions = useBarChartOptions(options, noData);

return <BaseChart options={finalOptions} {...restProps} />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { useColorMode, useColorModeValue, useTheme } from '@totejs/uikit';
import { useEffect, useState } from 'react';
import { merge } from 'lodash-es';
import { cssVar } from '@/utils/common';
import { noDataOptions } from '@/constants/chart';

export function useBarChartOptions(options: any, noData: boolean) {
const theme = useTheme();
const { colorMode } = useColorMode();
const colors = useColorModeValue(theme.colors.light, theme.colors.dark);

const [finalOptions, setFinalOptions] = useState({});

useEffect(() => {
if (colorMode !== document.documentElement.dataset.theme) {
return;
}
if (noData) {
return setFinalOptions(noDataOptions);
}
const defaultOptions = {
title: {
text: 'Cost Trend',
textStyle: {
color: cssVar('readable.normal'),
fontSize: 16,
fontWeight: 700,
},
left: 0,
padding: [5, 5, 5, 0],
textAlign: 'left',
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
},
grid: {
containLabel: true,
left: 'left',
right: '0%',
bottom: '0%',
},
toolbox: {
feature: {
dataView: { show: false, readOnly: false },
restore: { show: false },
saveAsImage: { show: false },
},
},
legend: {
icon: 'circle',
itemHeight: 8,
itemWidth: 8,
itemGap: 16,
right: 30,
textStyle: {
fontWeight: 400,
},
},
xAxis: [{
type: 'category',
axisTick: {
show: true,
alignWithLabel: true,
lineStyle: {
color: cssVar('bg.bottom'),
},
},
axisLabel: {
color: cssVar('readable.tertiary'),
fontSize: 12,
fontWeight: 500,
margin: 16,
lineHeight: 12,
},
axisLine: {
show: false,
margin: 18,
},
axisPointer: {
lineStyle: {
color: cssVar('readable.secondary'),
type: 'solid',
},
},
}],
yAxis: [{
type: 'value',
position: 'left',
alignTicks: true,
splitNumber: 5,
axisLine: {
show: false,
},
axisLabel: {
color: cssVar('readable.tertiary'),
fontSize: 12,
fontWeight: 500,
},
splitLine: {
lineStyle: {
color: cssVar('bg.bottom'),
},
},
}],
series: [
],
};

const finalOptions = merge(defaultOptions, options);

setFinalOptions(finalOptions);
}, [colors, options, colorMode, noData]);

return finalOptions;
}
12 changes: 7 additions & 5 deletions apps/dcellar-web-ui/src/components/charts/LineChart/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { BaseChart, BaseChartProps } from '@/components/charts/BaseChart';
import { useLineChartOptions } from '@/components/charts/LineChart/useLineChartOptions';

export interface LineChartProps extends BaseChartProps {}
export interface LineChartProps extends BaseChartProps {
noData: boolean
}

export function LineChart(props: LineChartProps) {
const { options } = props;
const finalOptions = useLineChartOptions(options);
export function LineChart({noData, ...props}: LineChartProps) {
const { options, ...restProps } = props;
const finalOptions = useLineChartOptions(options, noData);

return <BaseChart options={finalOptions} />;
return <BaseChart options={finalOptions} {...restProps} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {merge} from 'lodash-es';
import * as echarts from 'echarts/core';

import { cssVar } from '@/utils/common';
import { noDataOptions } from '@/constants/chart';

export function useLineChartOptions(options: any) {
export function useLineChartOptions(options: any, noData: boolean) {
const theme = useTheme();
const { colorMode } = useColorMode();
const colors = useColorModeValue(theme.colors.light, theme.colors.dark);
Expand All @@ -16,6 +17,9 @@ export function useLineChartOptions(options: any) {
if (colorMode !== document.documentElement.dataset.theme) {
return;
}
if (noData) {
return setFinalOptions(noDataOptions);
}
const defaultOptions = {
tooltip: {
trigger: 'axis',
Expand All @@ -24,12 +28,14 @@ export function useLineChartOptions(options: any) {
padding: 8,
textStyle: {
color: cssVar('readable.normal'),
fontSize: 12,
},
axisPointer: {
type: 'line',
z: -1,
lineStyle: {
color: cssVar('readable.secondary'),
type: 'solid',
color: cssVar('readable.disable'),
},
},
extraCssText: `box-shadow: ${cssVar('chartTooltip', 'shadows')};border-radius:4px;`,
Expand All @@ -45,12 +51,19 @@ export function useLineChartOptions(options: any) {
type: 'category',
boundaryGap: false,
axisLabel: {
margin: 7,
fontSize: 10,
marginTop: 4,
fontWeight: 500,
lineHeight: 14,
lineHeight: 15,
color: cssVar('readable.disable'),
fontSize: 10,
fontFamily: 'Inter',
color: cssVar('readable.secondary'),
},
splitLine: {
show: true,
lineStyle: {
type: 'dashed',
color: cssVar('readable.chartTick'),
},
},
axisLine: {
lineStyle: {
Expand All @@ -60,31 +73,47 @@ export function useLineChartOptions(options: any) {
axisTick: {
alignWithLabel: true,
lineStyle: {
color: cssVar('readable.border'),
color: cssVar('readable.chartTick'),
},
},
},
yAxis: {
show: true,
type: 'value',
splitNumber: 4,
scale: true,
splitLine: {
spiltLine: {
lineStyle: {
color: 'red',
}
},
axisTick: {
show: true,
alignWithLabel: true,
lineStyle: {
color: cssVar('readable.border'),
},
},
axisLine: {
show: true,
lineStyle: {
color: cssVar('readable.border'),
},
},
splitLine: {
show: false,
},
axisLabel: {
margin: 4,
fontSize: 10,
marginRight: 4,
fontWeight: 500,
lineHeight: 14,
lineHeight: 15,
color: cssVar('readable.disabled'),
fontSize: 12,
fontFamily: 'Inter',
color: cssVar('readable.secondary'),
},
},
grid: {
left: 6,
right: 18,
left: 4,
right: 20,
top: 6,
bottom: 0,
containLabel: true,
Expand All @@ -94,7 +123,7 @@ export function useLineChartOptions(options: any) {
type: 'line',
smooth: true,
symbol: 'circle',
symbolSize: 8,
symbolSize: 6,
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
Expand All @@ -111,8 +140,8 @@ export function useLineChartOptions(options: any) {
color: colors.scene.primary.active,
},
itemStyle: {
borderWidth: 1,
color: colors.bg.middle,
borderWidth: 2,
borderColor: colors.scene.primary.active,
opacity: 0,
},
Expand All @@ -126,9 +155,11 @@ export function useLineChartOptions(options: any) {
],
};

// const variantOptions = merge(defaultOptions, detailOptions);
const finalOptions = merge(defaultOptions, options);

setFinalOptions(finalOptions);
}, [colors, options, colorMode]);
}, [colors, options, colorMode, noData]);

return finalOptions;
}
Loading

0 comments on commit 708380b

Please sign in to comment.