mirror of
https://git.sr.ht/~ashkeel/strimertul
synced 2024-09-20 02:00:49 +00:00
Auto-redirect frontend after port change
This commit is contained in:
parent
1be08573c5
commit
63d791e3fe
2 changed files with 7 additions and 5 deletions
|
@ -51,8 +51,7 @@
|
||||||
},
|
},
|
||||||
"http": {
|
"http": {
|
||||||
"header": "Web server configuration",
|
"header": "Web server configuration",
|
||||||
"server-port": "HTTP server port",
|
"server-bind": "HTTP server bind",
|
||||||
"server-port-note": "Note: You must restart strimertul after changing this!",
|
|
||||||
"static-content": "Static content",
|
"static-content": "Static content",
|
||||||
"enable-static": "Enable static server",
|
"enable-static": "Enable static server",
|
||||||
"static-root-path": "Static content root path"
|
"static-root-path": "Static content root path"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { RouteComponentProps } from '@reach/router';
|
import { RouteComponentProps } from '@reach/router';
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { useModule } from '../../lib/react-utils';
|
import { useModule } from '../../lib/react-utils';
|
||||||
|
@ -20,7 +20,7 @@ export default function HTTPPage(
|
||||||
<>
|
<>
|
||||||
<h1 className="title is-4">{t('http.header')}</h1>
|
<h1 className="title is-4">{t('http.header')}</h1>
|
||||||
<div className="field">
|
<div className="field">
|
||||||
<label className="label">{t('http.server-port')}</label>
|
<label className="label">{t('http.server-bind')}</label>
|
||||||
<p className="control">
|
<p className="control">
|
||||||
<input
|
<input
|
||||||
disabled={busy}
|
disabled={busy}
|
||||||
|
@ -38,7 +38,6 @@ export default function HTTPPage(
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</p>
|
</p>
|
||||||
<p className="help">{t('http.server-port-note')}</p>
|
|
||||||
</div>
|
</div>
|
||||||
<label className="label">{t('http.static-content')}</label>
|
<label className="label">{t('http.static-content')}</label>
|
||||||
<div className="field">
|
<div className="field">
|
||||||
|
@ -82,6 +81,10 @@ export default function HTTPPage(
|
||||||
className="button"
|
className="button"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
dispatch(setHTTPConfig(httpConfig));
|
dispatch(setHTTPConfig(httpConfig));
|
||||||
|
const port = httpConfig.bind.split(':', 2)[1] ?? '4337';
|
||||||
|
if (port !== window.location.port) {
|
||||||
|
window.location.port = port;
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('actions.save')}
|
{t('actions.save')}
|
||||||
|
|
Loading…
Reference in a new issue