Adding a <SystemInfo> component to display basic system info

This commit is contained in:
Eric van der Vlist 2023-03-10 23:27:03 +01:00
parent 9e08a70002
commit 229bc14f72
3 changed files with 102 additions and 7 deletions

View File

@ -2,12 +2,10 @@ import { Component, createSignal, For } from 'solid-js';
import PersonIcon from '@suid/icons-material/Person'; import PersonIcon from '@suid/icons-material/Person';
import style from './Account.module.css';
import { import {
Box, Box,
Button, Button,
DialogActions, DialogActions,
IconButton,
InputLabel, InputLabel,
ListItem, ListItem,
ListItemButton, ListItemButton,

View File

@ -3,8 +3,16 @@ import { Component, createSignal } from 'solid-js';
import SettingsIcon from '@suid/icons-material/Settings'; import SettingsIcon from '@suid/icons-material/Settings';
import style from './SystemDrawer.module.css'; 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 Account from '../account';
import SystemInfo from '../system-info/SystemInfo';
interface Props {} interface Props {}
@ -17,11 +25,14 @@ const SystemDrawer: Component<Props> = (props) => {
<SettingsIcon /> <SettingsIcon />
</IconButton> </IconButton>
<Drawer open={open()} onClose={() => setOpen(false)} anchor='right'> <Drawer open={open()} onClose={() => setOpen(false)} anchor='right'>
<Box
sx={{ width: '100%', maxWidth: 200, bgcolor: 'background.paper' }}
>
<List> <List>
<ListItem>
<Account /> <Account />
</ListItem> <SystemInfo />
</List> </List>
</Box>
</Drawer> </Drawer>
</div> </div>
</> </>

View File

@ -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> = (props) => {
const [open, setOpen] = createSignal(false);
const [settings, setSettings] = createSignal<any>();
const [account, setAccount] = createSignal<any>();
const [error, setError] = createSignal<any>();
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 (
<>
<ListItem>
<ListItemButton onClick={openDialog}>
<ListItemIcon>
<SystemSecurityUpdateWarningIcon />
</ListItemIcon>
<ListItemText>System Info</ListItemText>
</ListItemButton>
</ListItem>
<Show when={open()}>
<Dialog
open={open()}
closeHandler={() => setOpen(false)}
title='System info'
>
<div>
<p>Platform: {window.Capacitor.platform}</p>
<p>User agent: {navigator.userAgent}</p>
<p>App release: {import.meta.env.VITE_GIT_COMMIT_HASH}</p>
<p>Account id: {settings()?.currentAccountId}</p>
<p>Account name: {account()?.name}</p>
<p>Remote DB user: {account()?.remoteDbUser}</p>
<p>Remote DB server: {account()?.remoteDbServer}</p>
</div>
</Dialog>
</Show>
</>
);
};
export default SystemInfo;