mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-19 16:10:01 +02:00
feat: showing service class name in browser tab and on top of the frontend page
This commit is contained in:
parent
6f3910efd0
commit
639161d373
@ -46,6 +46,7 @@ const reducer = (state: State, action: Action): State => {
|
|||||||
};
|
};
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const [state, dispatch] = useReducer(reducer, null);
|
const [state, dispatch] = useReducer(reducer, null);
|
||||||
|
const [serviceName, setServiceName] = useState(null);
|
||||||
const [webSettings, setWebSettings] = useState<Record<string, WebSetting>>({});
|
const [webSettings, setWebSettings] = useState<Record<string, WebSetting>>({});
|
||||||
const [isInstantUpdate, setIsInstantUpdate] = useState(false);
|
const [isInstantUpdate, setIsInstantUpdate] = useState(false);
|
||||||
const [showSettings, setShowSettings] = useState(false);
|
const [showSettings, setShowSettings] = useState(false);
|
||||||
@ -72,7 +73,12 @@ const App = () => {
|
|||||||
// Fetch data from the API when the client connects
|
// Fetch data from the API when the client connects
|
||||||
fetch(`http://${hostname}:${port}/service-properties`)
|
fetch(`http://${hostname}:${port}/service-properties`)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data: State) => dispatch({ type: 'SET_DATA', data }));
|
.then((data: State) => {
|
||||||
|
dispatch({ type: 'SET_DATA', data });
|
||||||
|
setServiceName(data.name);
|
||||||
|
|
||||||
|
document.title = data.name; // Setting browser tab title
|
||||||
|
});
|
||||||
fetch(`http://${hostname}:${port}/web-settings`)
|
fetch(`http://${hostname}:${port}/web-settings`)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data: Record<string, WebSetting>) => setWebSettings(data));
|
.then((data: Record<string, WebSetting>) => setWebSettings(data));
|
||||||
@ -149,7 +155,7 @@ const App = () => {
|
|||||||
<>
|
<>
|
||||||
<Navbar expand={false} bg="primary" variant="dark" fixed="top">
|
<Navbar expand={false} bg="primary" variant="dark" fixed="top">
|
||||||
<Container fluid>
|
<Container fluid>
|
||||||
<Navbar.Brand>Data Service App</Navbar.Brand>
|
<Navbar.Brand>{serviceName}</Navbar.Brand>
|
||||||
<Navbar.Toggle aria-controls="offcanvasNavbar" onClick={handleShowSettings} />
|
<Navbar.Toggle aria-controls="offcanvasNavbar" onClick={handleShowSettings} />
|
||||||
</Container>
|
</Container>
|
||||||
</Navbar>
|
</Navbar>
|
||||||
|
@ -2,6 +2,7 @@ import { SerializedValue } from '../components/GenericComponent';
|
|||||||
|
|
||||||
export type State = {
|
export type State = {
|
||||||
type: string;
|
type: string;
|
||||||
|
name: string;
|
||||||
value: Record<string, SerializedValue> | null;
|
value: Record<string, SerializedValue> | null;
|
||||||
readonly: boolean;
|
readonly: boolean;
|
||||||
doc: string | null;
|
doc: string | null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user