1
0
Fork 0
mirror of https://git.sr.ht/~ashkeel/strimertul synced 2024-09-18 01:50:50 +00:00

Auto-redirect frontend after port change

This commit is contained in:
Ash Keel 2021-11-19 19:52:01 +01:00
parent 1be08573c5
commit 63d791e3fe
No known key found for this signature in database
GPG key ID: BAD8D93E7314ED3E
2 changed files with 7 additions and 5 deletions

View file

@ -51,8 +51,7 @@
},
"http": {
"header": "Web server configuration",
"server-port": "HTTP server port",
"server-port-note": "Note: You must restart strimertul after changing this!",
"server-bind": "HTTP server bind",
"static-content": "Static content",
"enable-static": "Enable static server",
"static-root-path": "Static content root path"

View file

@ -1,5 +1,5 @@
import { RouteComponentProps } from '@reach/router';
import React from 'react';
import React, { useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { useDispatch } from 'react-redux';
import { useModule } from '../../lib/react-utils';
@ -20,7 +20,7 @@ export default function HTTPPage(
<>
<h1 className="title is-4">{t('http.header')}</h1>
<div className="field">
<label className="label">{t('http.server-port')}</label>
<label className="label">{t('http.server-bind')}</label>
<p className="control">
<input
disabled={busy}
@ -38,7 +38,6 @@ export default function HTTPPage(
}
/>
</p>
<p className="help">{t('http.server-port-note')}</p>
</div>
<label className="label">{t('http.static-content')}</label>
<div className="field">
@ -82,6 +81,10 @@ export default function HTTPPage(
className="button"
onClick={() => {
dispatch(setHTTPConfig(httpConfig));
const port = httpConfig.bind.split(':', 2)[1] ?? '4337';
if (port !== window.location.port) {
window.location.port = port;
}
}}
>
{t('actions.save')}