aboutsummaryrefslogtreecommitdiffstats
path: root/src/web
diff options
context:
space:
mode:
Diffstat (limited to 'src/web')
-rw-r--r--src/web/src/components/System/Info/index.js30
-rw-r--r--src/web/src/components/System/Options/index.js38
2 files changed, 47 insertions, 21 deletions
diff --git a/src/web/src/components/System/Info/index.js b/src/web/src/components/System/Info/index.js
index d1b504e2..063303ac 100644
--- a/src/web/src/components/System/Info/index.js
+++ b/src/web/src/components/System/Info/index.js
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { useState, useEffect } from 'react';
import YAML from 'yaml';
import { restart, shutdown, getVersion } from '../../../lib/application';
@@ -7,11 +7,19 @@ import { Modal, Header, Divider } from 'semantic-ui-react';
import {
CodeEditor,
+ LoaderSegment,
ShrinkableButton,
+ Switch,
} from '../../Shared';
const Info = ({ state }) => {
- const stateAsYaml = YAML.stringify(state, { simpleKeys: true, sortMapEntries: true });
+ const [contents, setContents] = useState();
+
+ useEffect(() => {
+ setTimeout(() => {
+ setContents(YAML.stringify(state, { simpleKeys: true, sortMapEntries: true }));
+ }, 250);
+ }, [state]);
return (
<>
@@ -21,6 +29,7 @@ const Info = ({ state }) => {
icon='refresh'
mediaQuery='(max-width: 516px)'
primary
+ disabled={!contents}
onClick={() => getVersion({ forceCheck: true })}
>
Check for Updates
@@ -32,6 +41,7 @@ const Info = ({ state }) => {
icon='shutdown'
mediaQuery='(max-width: 516px)'
negative
+ disabled={!contents}
>
Shut Down
</ShrinkableButton>
@@ -48,6 +58,7 @@ const Info = ({ state }) => {
icon='redo'
mediaQuery='(max-width: 516px)'
negative
+ disabled={!contents}
>
Restart
</ShrinkableButton>
@@ -60,12 +71,15 @@ const Info = ({ state }) => {
/>
</div>
<Divider/>
- <CodeEditor
- style={{minHeight: 500}}
- value={stateAsYaml}
- basicSetup={false}
- editable={false}
- />
+ <Switch
+ loading={!contents && <LoaderSegment/>}
+ >
+ <CodeEditor
+ value={contents}
+ basicSetup={false}
+ editable={false}
+ />
+ </Switch>
</>
);
};
diff --git a/src/web/src/components/System/Options/index.js b/src/web/src/components/System/Options/index.js
index afc1f545..16928a29 100644
--- a/src/web/src/components/System/Options/index.js
+++ b/src/web/src/components/System/Options/index.js
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useState, useEffect } from 'react';
import YAML from 'yaml';
import DebugModal from './DebugModal';
@@ -7,30 +7,38 @@ import EditModal from './EditModal';
import { Divider } from 'semantic-ui-react';
import {
CodeEditor,
+ LoaderSegment,
ShrinkableButton,
+ Switch,
} from '../../Shared';
const Index = ({ options }) => {
const [debugModal, setDebugModal] = useState(false);
const [editModal, setEditModal] = useState(false);
+ const [contents, setContents] = useState();
+
+ useEffect(() => {
+ setTimeout(() => {
+ setContents(YAML.stringify(options, { simpleKeys: true, sortMapEntries: true }));
+ }, 250);
+ }, [options]);
const { remoteConfiguration, debug } = options;
- const optionsAsYaml = YAML.stringify(options, { simpleKeys: true, sortMapEntries: true });
-
- const DebugButton = () => {
+ const DebugButton = ({ ...props }) => {
if (!debug) return <></>;
return <ShrinkableButton
icon='bug'
mediaQuery='(max-width: 516px)'
onClick={() => setDebugModal(true)}
+ {...props}
>
Debug View
</ShrinkableButton>;
};
- const EditButton = () => {
+ const EditButton = ({ ...props }) => {
if (!remoteConfiguration) {
return <ShrinkableButton
disabled
@@ -44,22 +52,26 @@ const Index = ({ options }) => {
icon='edit'
mediaQuery='(max-width: 516px)'
onClick={() => setEditModal(true)}
+ {...props}
>Edit</ShrinkableButton>;
};
return (
<>
<div className='header-buttons'>
- <DebugButton/>
- <EditButton/>
+ <DebugButton disabled={!contents}/>
+ <EditButton disabled={!contents}/>
</div>
<Divider/>
- <CodeEditor
- style={{minHeight: 500}}
- value={optionsAsYaml}
- basicSetup={false}
- editable={false}
- />
+ <Switch
+ loading={!contents && <LoaderSegment/>}
+ >
+ <CodeEditor
+ value={contents}
+ basicSetup={false}
+ editable={false}
+ />
+ </Switch>
<DebugModal
open={debugModal}
onClose={() => setDebugModal(false)}