From 1be08573c502b92995861bc7bab0723f2b7f822a Mon Sep 17 00:00:00 2001 From: Ash Keel Date: Fri, 19 Nov 2021 19:46:48 +0100 Subject: [PATCH] Fix new static server setting not working --- frontend/src/store/api/types.ts | 2 +- frontend/src/ui/App.tsx | 2 +- frontend/src/ui/pages/HTTP.tsx | 12 +++++------- modules/http/server.go | 23 +++++++++-------------- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/frontend/src/store/api/types.ts b/frontend/src/store/api/types.ts index 2e4bc76..252cb17 100644 --- a/frontend/src/store/api/types.ts +++ b/frontend/src/store/api/types.ts @@ -5,7 +5,6 @@ import KilovoltWS from '@strimertul/kilovolt-client'; interface ModuleConfig { configured: boolean; kv: boolean; - static: boolean; twitch: boolean; stulbe: boolean; loyalty: boolean; @@ -13,6 +12,7 @@ interface ModuleConfig { interface HTTPConfig { bind: string; + enable_static_server: boolean; path: string; } diff --git a/frontend/src/ui/App.tsx b/frontend/src/ui/App.tsx index 678da15..ea43d89 100644 --- a/frontend/src/ui/App.tsx +++ b/frontend/src/ui/App.tsx @@ -84,7 +84,7 @@ export default function App(): React.ReactElement { return
{t('system.loading')}
; } - const basepath = process.env.NODE_ENV === 'development' ? '/' : '/ui/'; + const basepath = '/ui/'; const routeItem = ({ route, name, subroutes }: RouteItem) => (
  • diff --git a/frontend/src/ui/pages/HTTP.tsx b/frontend/src/ui/pages/HTTP.tsx index f3d05da..675202a 100644 --- a/frontend/src/ui/pages/HTTP.tsx +++ b/frontend/src/ui/pages/HTTP.tsx @@ -10,12 +10,11 @@ export default function HTTPPage( params: RouteComponentProps, ): React.ReactElement { const { t } = useTranslation(); - const [moduleConfig, setModuleConfig] = useModule(modules.moduleConfig); const [httpConfig, setHTTPConfig] = useModule(modules.httpConfig); const dispatch = useDispatch(); - const busy = moduleConfig === null || httpConfig === null; - const active = moduleConfig?.static ?? false; + const busy = httpConfig === null; + const active = httpConfig?.enable_static_server ?? false; return ( <> @@ -50,9 +49,9 @@ export default function HTTPPage( checked={active} onChange={(ev) => dispatch( - apiReducer.actions.moduleConfigChanged({ - ...moduleConfig, - static: ev.target.checked, + apiReducer.actions.httpConfigChanged({ + ...httpConfig, + enable_static_server: ev.target.checked, }), ) } @@ -82,7 +81,6 @@ export default function HTTPPage(