From d64adfc2bf9b9c31dca47ab113c06a1268c347c6 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sun, 30 Oct 2022 06:02:06 -0700 Subject: [PATCH] wip work on federation settings --- frontend/src/App.tsx | 2 +- frontend/src/basic/Main.tsx | 18 ++- .../components/Charts/DepthChart/index.tsx | 112 +++++++++--------- .../src/components/SettingsForm/index.tsx | 46 ++++--- frontend/src/models/Coordinator.model.ts | 2 + frontend/src/models/Language.model.ts | 19 --- frontend/src/models/Settings.model.ts | 19 ++- frontend/src/models/index.ts | 2 +- frontend/static/federation.json | 37 +++--- 9 files changed, 138 insertions(+), 119 deletions(-) delete mode 100644 frontend/src/models/Language.model.ts diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 5036a642..fb813daf 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -42,7 +42,7 @@ const App = (): JSX.Element => { useEffect(() => { updateTheme(); - }, [settings]); + }, [settings.fontSize, settings.mode]); useEffect(() => { i18n.changeLanguage(settings.language); diff --git a/frontend/src/basic/Main.tsx b/frontend/src/basic/Main.tsx index e8466ad0..921e2116 100644 --- a/frontend/src/basic/Main.tsx +++ b/frontend/src/basic/Main.tsx @@ -10,9 +10,7 @@ import SettingsPage from './SettingsPage'; import NavBar, { Page } from './NavBar'; import MainDialogs, { OpenDialogs } from './MainDialogs'; -import { apiClient } from '../services/api'; -import { checkVer } from '../utils'; - +import RobotAvatar from '../components/RobotAvatar'; import { Book, LimitList, @@ -24,9 +22,14 @@ import { defaultMaker, defaultRobot, defaultInfo, + Coordinator, } from '../models'; + +import { apiClient } from '../services/api'; +import { checkVer } from '../utils'; import { sha256 } from 'js-sha256'; -import RobotAvatar from '../components/RobotAvatar'; + +import defaultCoordinators from '../../static/federation.json'; const getWindowSize = function (fontSize: number) { // returns window size in EM units @@ -56,6 +59,7 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => { const [robot, setRobot] = useState(defaultRobot); const [maker, setMaker] = useState(defaultMaker); const [info, setInfo] = useState(defaultInfo); + const [coordinators, setCoordinators] = useState(defaultCoordinators); const [fav, setFav] = useState({ type: null, currency: 0 }); const theme = useTheme(); @@ -133,7 +137,7 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => { }; const fetchInfo = function () { - apiClient.get('/api/info/').then((data: any) => { + apiClient.get('/api/info/').then((data: Info) => { const versionInfo: any = checkVer(data.version.major, data.version.minor, data.version.patch); setInfo({ ...data, @@ -141,6 +145,10 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => { coordinatorVersion: versionInfo.coordinatorVersion, clientVersion: versionInfo.clientVersion, }); + setSettings({ + ...settings, + network: data.network, + }); }); }; diff --git a/frontend/src/components/Charts/DepthChart/index.tsx b/frontend/src/components/Charts/DepthChart/index.tsx index 077853e4..796233ec 100644 --- a/frontend/src/components/Charts/DepthChart/index.tsx +++ b/frontend/src/components/Charts/DepthChart/index.tsx @@ -215,62 +215,60 @@ const DepthChart: React.FC = ({ /> ); - // Unkown Bug. Temporarily silenced until cause is found. - - // const generateTooltip: React.FunctionComponent = ( - // pointTooltip: PointTooltipProps, - // ) => { - // const order: Order = pointTooltip.point.data.order; - // return order ? ( - // - // - // - // - // - // - // - // - // - // {order.maker_nick} - // - // - // - // {amountToString( - // order.amount, - // order.has_range, - // order.min_amount, - // order.max_amount, - // )}{' '} - // {currencyDict[order.currency]} - // - // - // - // - // - // - // - // - // - // - // ) : ( - // <> - // ); - // }; + const generateTooltip: React.FunctionComponent = ( + pointTooltip: PointTooltipProps, + ) => { + const order: Order = pointTooltip.point.data.order; + return order ? ( + + + + + + + + + + {order.maker_nick} + + + + {amountToString( + order.amount, + order.has_range, + order.min_amount, + order.max_amount, + )}{' '} + {currencyDict[order.currency]} + + + + + + + + + + + ) : ( + <> + ); + }; const formatAxisX = (value: number): string => { if (xType === 'base_amount') { @@ -362,7 +360,7 @@ const DepthChart: React.FC = ({ useMesh={true} animate={false} crosshairType='cross' - // tooltip={generateTooltip} + tooltip={generateTooltip} onClick={handleOnClick} axisLeft={{ tickSize: 5, diff --git a/frontend/src/components/SettingsForm/index.tsx b/frontend/src/components/SettingsForm/index.tsx index 70584e74..c1af1cee 100644 --- a/frontend/src/components/SettingsForm/index.tsx +++ b/frontend/src/components/SettingsForm/index.tsx @@ -11,10 +11,19 @@ import { ListItemIcon, Slider, Typography, + ToggleButtonGroup, + ToggleButton, } from '@mui/material'; import { Settings } from '../../models'; import SelectLanguage from './SelectLanguage'; -import { Language, Palette, LightMode, DarkMode, SettingsOverscan } from '@mui/icons-material'; +import { + Translate, + Palette, + LightMode, + DarkMode, + SettingsOverscan, + Link, +} from '@mui/icons-material'; interface SettingsFormProps { dense?: boolean; @@ -22,21 +31,6 @@ interface SettingsFormProps { setSettings: (state: Settings) => void; } -const fontSizesBasic = [ - { label: 'XS', value: 12 }, - { label: 'S', value: 13 }, - { label: 'M', value: 14 }, - { label: 'L', value: 15 }, - { label: 'XL', value: 16 }, -]; -const fontSizesPro = [ - { label: 'XS', value: 10 }, - { label: 'S', value: 11 }, - { label: 'M', value: 12 }, - { label: 'L', value: 13 }, - { label: 'XL', value: 14 }, -]; - const SettingsForm = ({ dense = false, settings, setSettings }: SettingsFormProps): JSX.Element => { const theme = useTheme(); const { t } = useTranslation(); @@ -54,7 +48,7 @@ const SettingsForm = ({ dense = false, settings, setSettings }: SettingsFormProp - + + + + + + + setSettings({ ...settings, network: value })} + > + + {t('Mainnet')} + + + {t('Testnet')} + + + diff --git a/frontend/src/models/Coordinator.model.ts b/frontend/src/models/Coordinator.model.ts index 550861dc..5a740360 100644 --- a/frontend/src/models/Coordinator.model.ts +++ b/frontend/src/models/Coordinator.model.ts @@ -12,7 +12,9 @@ export interface Coordinator { website: string | undefined; }; mainnetOnion: string | undefined; + mainnetClearnet: string | undefined; testnetOnion: string | undefined; + testnetClearnet: string | undefined; mainnetNodesPubkeys: string[]; testnetNodesPubkeys: string[]; } diff --git a/frontend/src/models/Language.model.ts b/frontend/src/models/Language.model.ts deleted file mode 100644 index 92530000..00000000 --- a/frontend/src/models/Language.model.ts +++ /dev/null @@ -1,19 +0,0 @@ -export type Language = - | 'en' - | 'es' - | 'ru' - | 'de' - | 'pl' - | 'fr' - | 'ca' - | 'it' - | 'pt' - | 'eu' - | 'cs' - | 'th' - | 'pl' - | 'sv' - | 'zh-SI' - | 'zh-TR'; - -export default Language; diff --git a/frontend/src/models/Settings.model.ts b/frontend/src/models/Settings.model.ts index 5c6c1ea9..7fc5a360 100644 --- a/frontend/src/models/Settings.model.ts +++ b/frontend/src/models/Settings.model.ts @@ -1,6 +1,23 @@ import i18n from '../i18n/Web'; import type Coordinator from './Coordinator.model'; -import type Language from './Language.model'; + +export type Language = + | 'en' + | 'es' + | 'ru' + | 'de' + | 'pl' + | 'fr' + | 'ca' + | 'it' + | 'pt' + | 'eu' + | 'cs' + | 'th' + | 'pl' + | 'sv' + | 'zh-SI' + | 'zh-TR'; export interface Settings { frontend: 'basic' | 'pro'; diff --git a/frontend/src/models/index.ts b/frontend/src/models/index.ts index 3548abe3..268beb05 100644 --- a/frontend/src/models/index.ts +++ b/frontend/src/models/index.ts @@ -6,9 +6,9 @@ export type { Book } from './Book.model'; export type { Robot } from './Robot.model'; export type { Info } from './Info.model'; export type { Settings } from './Settings.model'; +export type { Language } from './Settings.model'; export type { Favorites } from './Favorites.model'; export type { Coordinator } from './Coordinator.model'; -export type { Language } from './Coordinator.model'; export { defaultMaker } from './Maker.model'; export { defaultRobot } from './Robot.model'; diff --git a/frontend/static/federation.json b/frontend/static/federation.json index b49d0269..854890c1 100644 --- a/frontend/static/federation.json +++ b/frontend/static/federation.json @@ -1,21 +1,22 @@ -{ - "coordinator_1": { - "alias": "Maximalist", - "description": "Maximalist Robots. P2P for freedom. No trade limits, low fees.", - "cover_letter": "Hi! I am Mike. I'm a freedom activist based in TorLand. I have been running LN infrastructure since early 2019, long time FOSS contributor....", +[ + { + "alias": "Inception", + "description": "RoboSats original and experimental coordinator", + "coverLetter": "N/A", "contact_methods": { - "email": "maximalist@bitcoin.p2p", - "telegram": "maximalist_robot", - ".....": "...." + "email": "robosats@protonmail.com", + "telegram": "@robosats", + "twitter": "@robosats", + "matrix": "#robosats:matrix.org", + "website": "learn.robosats.com" }, - "color": "#FFFFFF", - "mainnet_onion": "robomaxim......onion", - "testnet_onion": null, - "mainnet_ln_nodes_pubkeys": ["03e96as....", "02aaecc...."], - "testnet_ln_nodes_pubkeys": ["0284ff2...."], - "logo_svg_200x200": " " - }, - "coordinator_2": { - "...": "..." + "color": "#9C27B0", + "mainnetOnion": "robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion", + "mainnetClearnet": "unsafe.robosats.com", + "testnetOnion": "robotestagw3dcxmd66r4rgksb4nmmr43fh77bzn2ia2eucduyeafnyd.onion", + "testnetClearnet": "unsafe.testnet.robosats.com", + "mainnetNodesPubkeys": ["0282eb467bc073833a039940392592bf10cf338a830ba4e392c1667d7697654c7e"], + "testnetNodesPubkeys": ["03ecb271b3e2e36f2b91c92c65bab665e5165f8cdfdada1b5f46cfdd3248c87fd6"], + "logo": "/static/federation/inception.svg" } -} +]