mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 09:45:22 +03:00
Add copy functionality to logs
This commit is contained in:
parent
fbbfa98308
commit
98247e1ee6
@ -1,6 +1,6 @@
|
|||||||
import { h } from 'preact';
|
import { h } from 'preact';
|
||||||
import Heading from '../components/Heading';
|
import Heading from '../components/Heading';
|
||||||
import { useEffect, useState } from 'preact/hooks';
|
import { useCallback, useEffect, useState } from 'preact/hooks';
|
||||||
import ButtonsTabbed from '../components/ButtonsTabbed';
|
import ButtonsTabbed from '../components/ButtonsTabbed';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
import Button from '../components/Button';
|
import Button from '../components/Button';
|
||||||
@ -13,6 +13,13 @@ export default function Logs() {
|
|||||||
const { data: go2rtcLogs } = useSWR('logs/go2rtc');
|
const { data: go2rtcLogs } = useSWR('logs/go2rtc');
|
||||||
const { data: nginxLogs } = useSWR('logs/nginx');
|
const { data: nginxLogs } = useSWR('logs/nginx');
|
||||||
|
|
||||||
|
const handleCopyLogs = useCallback(() => {
|
||||||
|
async function copy() {
|
||||||
|
await window.navigator.clipboard.writeText(JSON.stringify(logs, null, 2));
|
||||||
|
}
|
||||||
|
copy();
|
||||||
|
}, [logs]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
switch (logService) {
|
switch (logService) {
|
||||||
case 'frigate':
|
case 'frigate':
|
||||||
@ -36,7 +43,7 @@ export default function Logs() {
|
|||||||
<div className='overflow-auto font-mono text-sm text-gray-900 dark:text-gray-100 rounded bg-gray-100 dark:bg-gray-800 p-2 whitespace-pre-wrap'>
|
<div className='overflow-auto font-mono text-sm text-gray-900 dark:text-gray-100 rounded bg-gray-100 dark:bg-gray-800 p-2 whitespace-pre-wrap'>
|
||||||
{logs}
|
{logs}
|
||||||
</div>
|
</div>
|
||||||
<Button className="">
|
<Button className="" onClick={handleCopyLogs}>
|
||||||
Copy to Clipboard
|
Copy to Clipboard
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user