mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 09:45:22 +03:00
Add ability to copy config
This commit is contained in:
parent
a8c0c64303
commit
3bdd61c5e1
@ -4,19 +4,30 @@ import CodeEditor from '@uiw/react-textarea-code-editor';
|
|||||||
import ActivityIndicator from '../components/ActivityIndicator';
|
import ActivityIndicator from '../components/ActivityIndicator';
|
||||||
import Heading from '../components/Heading';
|
import Heading from '../components/Heading';
|
||||||
import { useState } from 'preact/hooks';
|
import { useState } from 'preact/hooks';
|
||||||
|
import Button from '../components/Button';
|
||||||
|
|
||||||
export default function Config() {
|
export default function Config() {
|
||||||
const { data: config } = useSWR('config/raw');
|
const { data: config } = useSWR('config/raw');
|
||||||
const [newCode, setNewCode] = useState(config);
|
const [newCode, setNewCode] = useState(config);
|
||||||
const [error, setError] = useState();
|
const [error, setError] = useState();
|
||||||
|
|
||||||
|
const handleCopyConfig = async () => {
|
||||||
|
await window.navigator.clipboard.writeText(newCode);
|
||||||
|
};
|
||||||
|
|
||||||
if (!config) {
|
if (!config) {
|
||||||
return <ActivityIndicator />;
|
return <ActivityIndicator />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4 p-2 px-4">
|
<div className="space-y-4 p-2 px-4">
|
||||||
|
<div className="flex justify-between">
|
||||||
<Heading>Config</Heading>
|
<Heading>Config</Heading>
|
||||||
|
<div>
|
||||||
|
<Button className="mx-2" onClick={(e) => handleCopyConfig(e)}>Copy Config</Button>
|
||||||
|
<Button className="mx-2">Save & Restart</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{error && <div className="max-h-20 text-red-500">There is an error</div>}
|
{error && <div className="max-h-20 text-red-500">There is an error</div>}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user