diff --git a/src/components/system-info/SystemInfo.module.css b/src/components/system-info/SystemInfo.module.css new file mode 100644 index 0000000..41bdd20 --- /dev/null +++ b/src/components/system-info/SystemInfo.module.css @@ -0,0 +1,3 @@ +.clickPrompt { + font-style: italic; +} diff --git a/src/components/system-info/SystemInfo.tsx b/src/components/system-info/SystemInfo.tsx index a5dbc4c..c3d345e 100644 --- a/src/components/system-info/SystemInfo.tsx +++ b/src/components/system-info/SystemInfo.tsx @@ -4,10 +4,19 @@ import { ListItemIcon, ListItemText, } from '@suid/material'; -import { Component, createEffect, createSignal, For, Show } from 'solid-js'; +import { + Component, + createEffect, + createSignal, + For, + onMount, + Show, +} from 'solid-js'; import SystemSecurityUpdateWarningIcon from '@suid/icons-material/SystemSecurityUpdateWarning'; import Dialog from '../dialog'; import dispatch from '../../workers/dispatcher-main'; +import { sleep } from '../../lib/async-wait'; +import style from './SystemInfo.module.css'; const [error, setError] = createSignal([]); @@ -63,6 +72,35 @@ const SystemInfo: Component = (props) => { } }; + let content: any; + + onMount(() => { + if (!!content) { + content.onclick = function () { + document.execCommand('copy'); + }; + + content.addEventListener('copy', function (event: any) { + event.preventDefault(); + if (event.clipboardData) { + event.clipboardData.setData('text/plain', content.textContent); + console.log(event.clipboardData.getData('text')); + } + }); + } + }); + + const clickHandler = async (event: any) => { + const range = document.createRange(); + range.selectNode(content); + window.getSelection()?.removeAllRanges(); + window.getSelection()?.addRange(range); + document.execCommand('copy'); + await sleep(300); + window.getSelection()?.removeAllRanges(); + console.log({ caller: 'SystemInfo / clickHandler', event, range }); + }; + return ( <> @@ -79,23 +117,26 @@ const SystemInfo: Component = (props) => { closeHandler={() => 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}

-
- 0}> -
-

Errors:

-
    - {(item) =>
  • {item.message}
  • }
    -
+
+
Click to copy to clipboard
+
+

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}

- + 0}> +
+

Errors:

+
    + {(item) =>
  • {item.message}
  • }
    +
+
+
+