diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-11-19 10:02:29 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-11-19 10:02:29 -0600 |
| commit | db12f96e20afdb90eb54015579692def67b19851 (patch) | |
| tree | b87c00d1121048e5ae043d1112b88fe09b3f981c /src | |
| parent | 33456f0477a3517a10b719c65c46ad547258b95e (diff) | |
| download | slskd-db12f96e20afdb90eb54015579692def67b19851.tar.gz | |
improve layout of edit/view
Diffstat (limited to 'src')
| -rw-r--r-- | src/web/src/components/System/Options/Edit.js | 16 | ||||
| -rw-r--r-- | src/web/src/components/System/Options/View.js | 32 | ||||
| -rw-r--r-- | src/web/src/components/System/System.css | 10 |
3 files changed, 46 insertions, 12 deletions
diff --git a/src/web/src/components/System/Options/Edit.js b/src/web/src/components/System/Options/Edit.js index 6623e034..dfcb0072 100644 --- a/src/web/src/components/System/Options/Edit.js +++ b/src/web/src/components/System/Options/Edit.js @@ -56,23 +56,25 @@ const Edit = ({ cancelAction }) => { return ( <> - <div style={{textAlign: 'right'}}> - <Button primary disabled={!isDirty} onClick={() => save(yaml)}><Icon name='save'/>Save</Button> - <Button onClick={() => cancelAction()}><Icon name='close'/>Cancel</Button> - </div> - {yamlError && <Message icon='x' negative>{yamlError}</Message>} <CodeEditor value={yaml} language='yaml' onChange={(e) => update(e.target.value)} padding={10} style={{ - marginTop: 14, border: '1px solid #d4d4d5', - backgroundColor: '#f5f5f5', + backgroundColor: 'rgb(250, 250, 250)', + fontSize: '1em', fontFamily: 'ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace', + overflow: 'auto', + height: yamlError ? 'calc(100vh - 316px)' : 'calc(100vh - 254px)' }} /> + {yamlError && <Message className='yaml-error' icon='x' negative>{yamlError}</Message>} + <div className='footer-buttons'> + <Button primary disabled={!isDirty} onClick={() => save(yaml)}><Icon name='save'/>Save</Button> + <Button onClick={() => cancelAction()}><Icon name='close'/>Cancel</Button> + </div> </> ); } diff --git a/src/web/src/components/System/Options/View.js b/src/web/src/components/System/Options/View.js index f232c61d..980a90d8 100644 --- a/src/web/src/components/System/Options/View.js +++ b/src/web/src/components/System/Options/View.js @@ -1,15 +1,37 @@ import React from 'react'; -import { Button, Table } from 'semantic-ui-react'; +import yaml from 'yaml'; + +import { Icon, Button } from 'semantic-ui-react'; +import CodeEditor from '@uiw/react-textarea-code-editor'; const View = ({ options, editAction }) => { const { remoteConfiguration } = options; + const doc = new yaml.Document(); + doc.contents = options; + + const optionsAsYaml = doc.toString(); + return ( <> - {remoteConfiguration && <div style={{textAlign: 'right'}}> - <Button primary disabled={!remoteConfiguration} onClick={() => editAction()}>Edit</Button> - </div>} - <pre>{JSON.stringify(options, null, 2)}</pre> + <CodeEditor + value={optionsAsYaml} + language='yaml' + disabled={true} + padding={10} + style={{ + border: '1px solid #d4d4d5', + fontSize: '1em', + fontFamily: 'ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace', + overflow: 'auto', + height: 'calc(100vh - 254px)' + }} + /> + <div className='footer-buttons'> + {remoteConfiguration ? + <Button primary onClick={() => editAction()}><Icon name='edit'/>Edit</Button> : + <Button disabled icon='x'><Icon name='lock'/>Remote Configuration Disabled</Button>} + </div> </> ); } diff --git a/src/web/src/components/System/System.css b/src/web/src/components/System/System.css index 63817287..3a930667 100644 --- a/src/web/src/components/System/System.css +++ b/src/web/src/components/System/System.css @@ -26,4 +26,14 @@ .full-height { height: calc(100vh - 175px); +} + +.yaml-error { + white-space: nowrap; + overflow: overlay; +} + +.footer-buttons { + margin-top: 14px; + text-align: right; }
\ No newline at end of file |
