improvements
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
|
config.json
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
/node_modules
|
/node_modules
|
||||||
/.pnp
|
/.pnp
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ const BusControlTabs = () => {
|
|||||||
content: <BusControl busControlConfig={busControl} mainConfig={config}/>
|
content: <BusControl busControlConfig={busControl} mainConfig={config}/>
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
// setTabComponents(components);
|
|
||||||
|
|
||||||
// set the active tab to the first tab
|
// set the active tab to the first tab
|
||||||
if (components.length > 0) {
|
if (components.length > 0) {
|
||||||
setActiveTab(components[0].id);
|
setActiveTab(components[0].id);
|
||||||
@@ -55,7 +53,7 @@ const BusControlTabs = () => {
|
|||||||
{tabComponents.map((tab) => (
|
{tabComponents.map((tab) => (
|
||||||
<button
|
<button
|
||||||
key={tab.id}
|
key={tab.id}
|
||||||
className={`px-4 py-2 ${
|
className={`px-4 py-2 text-sm ${
|
||||||
activeTab === tab.id
|
activeTab === tab.id
|
||||||
? "border-b-2 border-blue-500 text-blue-500"
|
? "border-b-2 border-blue-500 text-blue-500"
|
||||||
: "text-gray-500"
|
: "text-gray-500"
|
||||||
|
|||||||
+2
-2
@@ -13,8 +13,8 @@ const geistMono = Geist_Mono({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Create Next App",
|
title: "Jam-Session Web",
|
||||||
description: "Generated by create next app",
|
description: "A web interface for jamming the session",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RootLayout({
|
export default function RootLayout({
|
||||||
|
|||||||
+4
-2
@@ -40,7 +40,8 @@ const Page = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchConfig().then((config: Config) => {
|
fetchConfig().then((config: Config) => {
|
||||||
setAppConfig(config);
|
setAppConfig(config);
|
||||||
initConnection(`ws://${window.location.hostname}:${config.webserver.port}`);
|
const webserverIP = config.webserver.ip || window.location.hostname;
|
||||||
|
initConnection(`ws://${webserverIP}:${config.webserver.port}`);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -55,7 +56,8 @@ const Page = () => {
|
|||||||
setWebSocketConnected(isConnected);
|
setWebSocketConnected(isConnected);
|
||||||
if (!isConnected) {
|
if (!isConnected) {
|
||||||
console.log("Reconnecting to WebSocket");
|
console.log("Reconnecting to WebSocket");
|
||||||
initConnection(`ws://${window.location.hostname}:${appConfig.webserver.port}`);
|
const webserverIP = appConfig.webserver.ip || window.location.hostname;
|
||||||
|
initConnection(`ws://${webserverIP}:${appConfig.webserver.port}`);
|
||||||
} else {
|
} else {
|
||||||
// check if mixer is connected
|
// check if mixer is connected
|
||||||
withTimeout(fetchValue("/info"), 1500)
|
withTimeout(fetchValue("/info"), 1500)
|
||||||
|
|||||||
@@ -5,7 +5,11 @@ export const fetchConfig = async <T>(): Promise<T | null> => {
|
|||||||
console.error(`Failed to fetch config:`, response.statusText);
|
console.error(`Failed to fetch config:`, response.statusText);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return await response.json();
|
const config = await response.json();
|
||||||
|
// apply defaults
|
||||||
|
config.polling_interval = config.polling_interval || 1000;
|
||||||
|
|
||||||
|
return config
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error fetching config from:`, error);
|
console.error(`Error fetching config from:`, error);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user