From 229bc14f72cb18f32b08e792f3ba5d2dcadc2156 Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Fri, 10 Mar 2023 23:27:03 +0100 Subject: [PATCH] Adding a component to display basic system info --- src/components/account/Account.tsx | 2 - src/components/system-drawer/SystemDrawer.tsx | 21 +++-- src/components/system-info/SystemInfo.tsx | 86 +++++++++++++++++++ 3 files changed, 102 insertions(+), 7 deletions(-) create mode 100644 src/components/system-info/SystemInfo.tsx diff --git a/src/components/account/Account.tsx b/src/components/account/Account.tsx index 7df11f6..f31cb3c 100644 --- a/src/components/account/Account.tsx +++ b/src/components/account/Account.tsx @@ -2,12 +2,10 @@ import { Component, createSignal, For } from 'solid-js'; import PersonIcon from '@suid/icons-material/Person'; -import style from './Account.module.css'; import { Box, Button, DialogActions, - IconButton, InputLabel, ListItem, ListItemButton, diff --git a/src/components/system-drawer/SystemDrawer.tsx b/src/components/system-drawer/SystemDrawer.tsx index ddc011b..f43e21b 100644 --- a/src/components/system-drawer/SystemDrawer.tsx +++ b/src/components/system-drawer/SystemDrawer.tsx @@ -3,8 +3,16 @@ import { Component, createSignal } from 'solid-js'; import SettingsIcon from '@suid/icons-material/Settings'; import style from './SystemDrawer.module.css'; -import { Drawer, IconButton, List, ListItem } from '@suid/material'; +import { + Box, + Drawer, + IconButton, + List, + ListItem, + ListItemButton, +} from '@suid/material'; import Account from '../account'; +import SystemInfo from '../system-info/SystemInfo'; interface Props {} @@ -17,11 +25,14 @@ const SystemDrawer: Component = (props) => { setOpen(false)} anchor='right'> - - + + - - + + + diff --git a/src/components/system-info/SystemInfo.tsx b/src/components/system-info/SystemInfo.tsx new file mode 100644 index 0000000..a70cab7 --- /dev/null +++ b/src/components/system-info/SystemInfo.tsx @@ -0,0 +1,86 @@ +import { + Icon, + ListItem, + ListItemButton, + ListItemIcon, + ListItemText, + SvgIcon, +} from '@suid/material'; +import { Component, createSignal, Show } from 'solid-js'; +import SystemSecurityUpdateWarningIcon from '@suid/icons-material/SystemSecurityUpdateWarning'; +import Dialog from '../dialog'; +import dispatch from '../../workers/dispatcher-main'; + +interface Props {} + +const SystemInfo: Component = (props) => { + const [open, setOpen] = createSignal(false); + const [settings, setSettings] = createSignal(); + const [account, setAccount] = createSignal(); + const [error, setError] = createSignal(); + + const openDialog = () => { + setOpen(true); + dispatch( + { + action: 'getSettings', + }, + (error, result) => { + console.log({ caller: 'SystemInfo', error, result }); + if (!!error) { + setError(error); + } + if (!!result) { + setSettings(result); + dispatch( + { + action: 'getAccount', + params: { id: settings().currentAccountId }, + }, + (error, result) => { + console.log({ caller: 'SystemInfo', error, result }); + if (!!error) { + setError(error); + } + if (!!result) { + setAccount(result); + } + } + ); + } + } + ); + }; + + return ( + <> + + + + + + System Info + + + + setOpen(false)} + title='System info' + > +
+

Platform: {window.Capacitor.platform}

+

User agent: {navigator.userAgent}

+

App release: {import.meta.env.VITE_GIT_COMMIT_HASH}

+

Account id: {settings()?.currentAccountId}

+

Account name: {account()?.name}

+

Remote DB user: {account()?.remoteDbUser}

+

Remote DB server: {account()?.remoteDbServer}

+
+
+
+ + ); +}; + +export default SystemInfo;