Adjust UI colors and behavior

This commit is contained in:
Nick Mowen 2022-12-06 08:17:40 -07:00
parent 78c1d3b784
commit d721bf7abe

View File

@ -9,7 +9,6 @@ import * as monaco from 'monaco-editor';
export default function Config() { export default function Config() {
const { data: config } = useSWR('config/raw'); const { data: config } = useSWR('config/raw');
const [newCode, setNewCode] = useState();
const [success, setSuccess] = useState(); const [success, setSuccess] = useState();
const [error, setError] = useState(); const [error, setError] = useState();
@ -19,7 +18,7 @@ export default function Config() {
} }
axios axios
.post('config/save', newCode, { .post('config/save', window.editor.getValue(), {
headers: { 'Content-Type': 'text/plain' }, headers: { 'Content-Type': 'text/plain' },
}) })
.then((response) => { .then((response) => {
@ -37,7 +36,7 @@ export default function Config() {
}; };
const handleCopyConfig = async () => { const handleCopyConfig = async () => {
await window.navigator.clipboard.writeText(newCode); await window.navigator.clipboard.writeText(window.editor.getValue());
}; };
useEffect(() => { useEffect(() => {
@ -45,9 +44,11 @@ export default function Config() {
return; return;
} }
monaco.editor.create(document.getElementById('container'), { window.editor = monaco.editor.create(document.getElementById('container'), {
language: 'yaml', language: 'yaml',
value: config, value: config,
scrollBeyondLastLine: false,
theme: 'vs-dark',
}); });
}); });
@ -63,11 +64,9 @@ export default function Config() {
<Button className="mx-2" onClick={(e) => handleCopyConfig(e)}> <Button className="mx-2" onClick={(e) => handleCopyConfig(e)}>
Copy Config Copy Config
</Button> </Button>
{newCode && ( <Button className="mx-2" onClick={(e) => onHandleSaveConfig(e)}>
<Button className="mx-2" onClick={(e) => onHandleSaveConfig(e)}> Save & Restart
Save & Restart </Button>
</Button>
)}
</div> </div>
</div> </div>