-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated visualization of farmer state and expected time to win
moved components into the components directory
- Loading branch information
Showing
95 changed files
with
486 additions
and
248 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...components/core/GuestRoute/GuestRoute.tsx → ...core/components/GuestRoute/GuestRoute.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...onents/core/ModalDialogs/ModalDialogs.tsx → .../components/ModalDialogs/ModalDialogs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...onents/core/PrivateRoute/PrivateRoute.tsx → .../components/PrivateRoute/PrivateRoute.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions
42
electron-react/src/components/core/components/StateIndicator/StateIndicator.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React, { ReactNode } from 'react'; | ||
import styled from 'styled-components'; | ||
import { FiberManualRecord as FiberManualRecordIcon } from '@material-ui/icons'; | ||
import Flex from '../Flex'; | ||
import State from '../../constants/State'; | ||
import StateColor from '../../constants/StateColor'; | ||
|
||
const Color = { | ||
[State.SUCCESS]: StateColor.SUCCESS, | ||
[State.WARNING]: StateColor.WARNING, | ||
[State.ERROR]: StateColor.ERROR, | ||
}; | ||
|
||
const StyledFiberManualRecordIcon = styled(FiberManualRecordIcon)` | ||
font-size: 1rem; | ||
`; | ||
|
||
const StyledFlexContainer = styled(({ color: Color, ...rest }) => <Flex {...rest} />)` | ||
color: ${({ color }) => color}; | ||
`; | ||
|
||
type Props = { | ||
children: ReactNode; | ||
state: State; | ||
indicator?: boolean; | ||
}; | ||
|
||
export default function StateComponent(props: Props) { | ||
const { children, state, indicator } = props; | ||
const color = Color[state]; | ||
|
||
return ( | ||
<StyledFlexContainer color={color} alignItems="center" gap={1}> | ||
<span> | ||
{children} | ||
</span> | ||
{indicator && ( | ||
<StyledFiberManualRecordIcon /> | ||
)} | ||
</StyledFlexContainer> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
electron-react/src/components/core/components/StateIndicator/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './StateIndicator'; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export { default as Accordion } from './Accordion'; | ||
export { default as AdvancedOptions } from './AdvancedOptions'; | ||
export { default as AlertDialog } from './AlertDialog'; | ||
export { default as Button } from './Button'; | ||
export { default as ButtonSelected } from './ButtonSelected'; | ||
export { default as Card } from './Card'; | ||
export { default as CardHero } from './CardHero'; | ||
export { default as CardStep } from './CardStep'; | ||
export { default as Checkbox } from './Checkbox'; | ||
export { default as ConfirmDialog } from './ConfirmDialog'; | ||
export { default as DarkModeToggle } from './DarkModeToggle'; | ||
export { default as Flex } from './Flex'; | ||
export { default as Form } from './Form'; | ||
export { default as FormatBytes } from './FormatBytes'; | ||
export { default as FormatConnectionStatus } from './FormatConnectionStatus'; | ||
export { default as GuestRoute } from './GuestRoute'; | ||
export { default as IconButton } from './IconButton'; | ||
export { default as Indicator } from './Indicator'; | ||
export { default as Link } from './Link'; | ||
export { default as Loading } from './Loading'; | ||
export { default as LocaleToggle } from './LocaleToggle'; | ||
export { default as Log } from './Log'; | ||
export { default as Logo } from './Logo'; | ||
export { default as ModalDialogs } from './ModalDialogs'; | ||
export { default as More } from './More'; | ||
export { default as PrivateRoute } from './PrivateRoute'; | ||
export { default as RadioGroup } from './RadioGroup'; | ||
export { default as Select } from './Select'; | ||
export { default as SideBarItem } from './SideBarItem'; | ||
export { default as Spinner } from './Spinner'; | ||
export { default as StateIndicator } from './StateIndicator'; | ||
export { default as Table } from './Table'; | ||
export { default as TextField } from './TextField'; | ||
export { default as ThemeProvider } from './ThemeProvider'; | ||
export { default as ToolbarSpacing } from './ToolbarSpacing'; | ||
export { default as TooltipIcon } from './TooltipIcon'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
enum State { | ||
SUCCESS, | ||
WARNING, | ||
ERROR, | ||
} | ||
|
||
export default State; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as State } from './State'; | ||
export { default as StateColor } from './StateColor'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,2 @@ | ||
export { default as Accordion } from './Accordion'; | ||
export { default as AdvancedOptions } from './AdvancedOptions'; | ||
export { default as AlertDialog } from './AlertDialog'; | ||
export { default as Button } from './Button'; | ||
export { default as ButtonSelected } from './ButtonSelected'; | ||
export { default as Card } from './Card'; | ||
export { default as CardHero } from './CardHero'; | ||
export { default as CardStep } from './CardStep'; | ||
export { default as Checkbox } from './Checkbox'; | ||
export { default as ConfirmDialog } from './ConfirmDialog'; | ||
export { default as DarkModeToggle } from './DarkModeToggle'; | ||
export { default as Flex } from './Flex'; | ||
export { default as Form } from './Form'; | ||
export { default as FormatBytes } from './FormatBytes'; | ||
export { default as FormatConnectionStatus } from './FormatConnectionStatus'; | ||
export { default as GuestRoute } from './GuestRoute'; | ||
export { default as IconButton } from './IconButton'; | ||
export { default as Indicator } from './Indicator'; | ||
export { default as Link } from './Link'; | ||
export { default as Loading } from './Loading'; | ||
export { default as LocaleToggle } from './LocaleToggle'; | ||
export { default as Log } from './Log'; | ||
export { default as Logo } from './Logo'; | ||
export { default as ModalDialogs } from './ModalDialogs'; | ||
export { default as More } from './More'; | ||
export { default as PrivateRoute } from './PrivateRoute'; | ||
export { default as RadioGroup } from './RadioGroup'; | ||
export { default as Select } from './Select'; | ||
export { default as SideBarItem } from './SideBarItem'; | ||
export { default as Spinner } from './Spinner'; | ||
export { default as Table } from './Table'; | ||
export { default as TextField } from './TextField'; | ||
export { default as ThemeProvider } from './ThemeProvider'; | ||
export { default as ToolbarSpacing } from './ToolbarSpacing'; | ||
export { default as TooltipIcon } from './TooltipIcon'; | ||
export * from './components'; | ||
export * from './constants'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
electron-react/src/components/farm/card/FarmCardNotAvailable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { ReactNode } from 'react'; | ||
import { Trans } from '@lingui/macro'; | ||
import { State, StateIndicator } from '@chia/core'; | ||
import FarmCard from './FarmCard'; | ||
|
||
type Props = { | ||
title: ReactNode; | ||
state?: State; | ||
}; | ||
|
||
export default function FarmCardNotAvailable(props: Props) { | ||
const { title, state } = props; | ||
|
||
return ( | ||
<FarmCard | ||
title={title} | ||
value={state ? ( | ||
<StateIndicator state={state}> | ||
<Trans id="FarmCardExpectedTimeToWin.notAvailable">Not Available</Trans> | ||
</StateIndicator> | ||
) : ( | ||
<Trans id="FarmCardExpectedTimeToWin.notAvailable">Not Available</Trans> | ||
)} | ||
description={( | ||
<Trans id="FarmCardExpectedTimeToWin.notAvailableDescription"> | ||
Wait for synchronization | ||
</Trans> | ||
)} | ||
valueColor="initial" | ||
/> | ||
); | ||
} |
72 changes: 70 additions & 2 deletions
72
electron-react/src/components/farm/card/FarmCardStatus.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,81 @@ | ||
import React from 'react'; | ||
import { Trans } from '@lingui/macro'; | ||
import { useSelector } from 'react-redux'; | ||
import { StateIndicator, State } from '@chia/core'; | ||
import type { RootState } from '../../../modules/rootReducer'; | ||
import FarmCard from './FarmCard'; | ||
import FarmStatus from '../FarmerStatus'; | ||
import useFullNodeState from '../../../hooks/useFullNodeState'; | ||
import FullNodeState from '../../../constants/FullNodeState'; | ||
import FarmCardNotAvailable from './FarmCardNotAvailable'; | ||
|
||
export default function FarmCardStatus() { | ||
const fullNodeState = useFullNodeState(); | ||
const farmerConnected = useSelector( | ||
(state: RootState) => state.daemon_state.farmer_connected, | ||
); | ||
const farmerRunning = useSelector( | ||
(state: RootState) => state.daemon_state.farmer_running, | ||
); | ||
|
||
if (fullNodeState === FullNodeState.SYNCHING) { | ||
return ( | ||
<FarmCard | ||
title={<Trans id="FarmCardStatus.title">Farming Status</Trans>} | ||
value={( | ||
<StateIndicator state={State.WARNING} indicator> | ||
<Trans id="FarmCardStatus.synching">Syncing</Trans> | ||
</StateIndicator> | ||
)} | ||
/> | ||
); | ||
} | ||
|
||
if (fullNodeState === FullNodeState.ERROR) { | ||
return ( | ||
<FarmCardNotAvailable | ||
title={ | ||
<Trans id="FarmCardStatus.title">Farming Status</Trans> | ||
} | ||
/> | ||
); | ||
} | ||
|
||
if (!farmerConnected) { | ||
return ( | ||
<FarmCard | ||
title={<Trans id="FarmCardStatus.title">Farming Status</Trans>} | ||
value={( | ||
<StateIndicator state={State.ERROR} indicator> | ||
<Trans id="FarmCardStatus.error">Error</Trans> | ||
</StateIndicator> | ||
)} | ||
description={<Trans id="FarmCardStatus.farmerIsNotConnected">Farmer is not connected</Trans>} | ||
/> | ||
); | ||
} | ||
|
||
if (!farmerRunning) { | ||
return ( | ||
<FarmCard | ||
title={<Trans id="FarmCardStatus.title">Farming Status</Trans>} | ||
value={( | ||
<StateIndicator state={State.ERROR} indicator> | ||
<Trans id="FarmCardStatus.error">Error</Trans> | ||
</StateIndicator> | ||
)} | ||
description={<Trans id="FarmCardStatus.farmerIsNotRunning">Farmer is not running</Trans>} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<FarmCard | ||
title={<Trans id="FarmCardStatus.title">Farming Status</Trans>} | ||
value={<FarmStatus />} | ||
value={( | ||
<StateIndicator state={State.SUCCESS} indicator> | ||
<Trans id="FarmerStatus.farming">Farming</Trans> | ||
</StateIndicator> | ||
)} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.