[Update/bugfix] To get software version.(show it to the console for now.)
fix the error that was wrong amount arguments.
This commit is contained in:
@@ -193,7 +193,7 @@ action_mapping = {
|
|||||||
"/controller/callback_enable_check_mic_threshold": {"mic":"/action/check_mic_threshold_energy"},
|
"/controller/callback_enable_check_mic_threshold": {"mic":"/action/check_mic_threshold_energy"},
|
||||||
}
|
}
|
||||||
|
|
||||||
def handleConfigRequest(endpoint):
|
def handleConfigRequest(endpoint, _data):
|
||||||
handler = config_mapping.get(endpoint)
|
handler = config_mapping.get(endpoint)
|
||||||
if handler is None:
|
if handler is None:
|
||||||
response = "Invalid endpoint"
|
response = "Invalid endpoint"
|
||||||
|
|||||||
22
src-ui/logics/useConfig.js
Normal file
22
src-ui/logics/useConfig.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import {
|
||||||
|
useSoftwareVersion,
|
||||||
|
} from "@store";
|
||||||
|
|
||||||
|
import { useStdoutToPython } from "./useStdoutToPython";
|
||||||
|
|
||||||
|
export const useConfig = () => {
|
||||||
|
const {
|
||||||
|
updateSoftwareVersion,
|
||||||
|
} = useSoftwareVersion();
|
||||||
|
|
||||||
|
const { asyncStdoutToPython } = useStdoutToPython();
|
||||||
|
|
||||||
|
return {
|
||||||
|
getSoftwareVersion: () => {
|
||||||
|
asyncStdoutToPython({endpoint: "/config/version"});
|
||||||
|
},
|
||||||
|
updateSoftwareVersion: (payload) => {
|
||||||
|
updateSoftwareVersion(payload.data);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { useMainFunction } from "./useMainFunction";
|
import { useMainFunction } from "./useMainFunction";
|
||||||
|
import { useConfig } from "./useConfig";
|
||||||
|
|
||||||
export const useReceiveRoutes = () => {
|
export const useReceiveRoutes = () => {
|
||||||
const {
|
const {
|
||||||
@@ -7,22 +8,28 @@ export const useReceiveRoutes = () => {
|
|||||||
updateTranscriptionReceiveStatus,
|
updateTranscriptionReceiveStatus,
|
||||||
} = useMainFunction();
|
} = useMainFunction();
|
||||||
|
|
||||||
|
const {
|
||||||
|
updateSoftwareVersion,
|
||||||
|
} = useConfig();
|
||||||
|
|
||||||
const routes = {
|
const routes = {
|
||||||
"/controller/callback_toggle_translation": updateTranslationStatus,
|
"/controller/callback_toggle_translation": updateTranslationStatus,
|
||||||
"/controller/callback_toggle_transcription_send": updateTranscriptionSendStatus,
|
"/controller/callback_toggle_transcription_send": updateTranscriptionSendStatus,
|
||||||
"/controller/callback_toggle_transcription_receive": updateTranscriptionReceiveStatus,
|
"/controller/callback_toggle_transcription_receive": updateTranscriptionReceiveStatus,
|
||||||
|
|
||||||
|
"/config/version": updateSoftwareVersion,
|
||||||
};
|
};
|
||||||
|
|
||||||
const receiveRoutes = (parsed_data) => {
|
const receiveRoutes = (parsed_data) => {
|
||||||
if (parsed_data.status === "ok") {
|
if (parsed_data.status === 200) {
|
||||||
const route = routes[parsed_data.id];
|
const route = routes[parsed_data.endpoint];
|
||||||
if (route) {
|
if (route) {
|
||||||
route({ data: parsed_data.data });
|
route({ data: parsed_data.result });
|
||||||
} else {
|
} else {
|
||||||
console.error(`Invalid path: ${parsed_data.id}`);
|
console.error(`Invalid path: ${parsed_data.endpoint}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("Received data status is not 'ok'.", parsed_data);
|
console.log("Received data status is not '200'.", parsed_data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return { receiveRoutes };
|
return { receiveRoutes };
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ export const useStartPython = () => {
|
|||||||
let parsed_data = "";
|
let parsed_data = "";
|
||||||
try {
|
try {
|
||||||
parsed_data = JSON.parse(line);
|
parsed_data = JSON.parse(line);
|
||||||
|
receiveRoutes(parsed_data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
parsed_data = line;
|
parsed_data = line;
|
||||||
}
|
}
|
||||||
console.log("from python:", parsed_data);
|
console.log("from python:", parsed_data);
|
||||||
receiveRoutes(parsed_data);
|
|
||||||
});
|
});
|
||||||
command.stderr.on("data", line => console.error("stderr:", line));
|
command.stderr.on("data", line => console.error("stderr:", line));
|
||||||
const backend_subprocess = await command.spawn();
|
const backend_subprocess = await command.spawn();
|
||||||
|
|||||||
@@ -95,6 +95,8 @@ const createAsyncAtomWithHook = (initialValue, base_ame) => {
|
|||||||
return { atomInstance, useHook };
|
return { atomInstance, useHook };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const { atomInstance: Atom_SoftwareVersion, useHook: useSoftwareVersion } = createAtomWithHook("-", "SoftwareVersion");
|
||||||
|
|
||||||
export const { atomInstance: Atom_UiLanguageStatus, useHook: useUiLanguageStatus } = createAtomWithHook("en", "UiLanguageStatus");
|
export const { atomInstance: Atom_UiLanguageStatus, useHook: useUiLanguageStatus } = createAtomWithHook("en", "UiLanguageStatus");
|
||||||
export const { atomInstance: Atom_TranslationStatus, useHook: useTranslationStatus } = createAsyncAtomWithHook(false, "TranslationStatus");
|
export const { atomInstance: Atom_TranslationStatus, useHook: useTranslationStatus } = createAsyncAtomWithHook(false, "TranslationStatus");
|
||||||
export const { atomInstance: Atom_TranscriptionSendStatus, useHook: useTranscriptionSendStatus } = createAsyncAtomWithHook(false, "TranscriptionSendStatus");
|
export const { atomInstance: Atom_TranscriptionSendStatus, useHook: useTranscriptionSendStatus } = createAsyncAtomWithHook(false, "TranscriptionSendStatus");
|
||||||
|
|||||||
@@ -4,7 +4,14 @@ import { Topbar } from "./topbar/Topbar";
|
|||||||
import { SidebarSection } from "./sidebar_section/SidebarSection";
|
import { SidebarSection } from "./sidebar_section/SidebarSection";
|
||||||
import { SettingSection } from "./setting_section/SettingSection.jsx";
|
import { SettingSection } from "./setting_section/SettingSection.jsx";
|
||||||
|
|
||||||
|
import { useSoftwareVersion } from "@store";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
// import { useConfig } from "@logics/useConfig";
|
||||||
export const ConfigWindow = () => {
|
export const ConfigWindow = () => {
|
||||||
|
const { currentSoftwareVersion, updateSoftwareVersion } = useSoftwareVersion();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<Topbar />
|
<Topbar />
|
||||||
@@ -12,6 +19,11 @@ export const ConfigWindow = () => {
|
|||||||
<SidebarSection />
|
<SidebarSection />
|
||||||
<SettingSection />
|
<SettingSection />
|
||||||
</div>
|
</div>
|
||||||
|
<p className={styles.software_version}>
|
||||||
|
{
|
||||||
|
t("config_window.version", {version: currentSoftwareVersion})
|
||||||
|
}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
background-color: var(--dark_950_color);
|
background-color: var(--dark_950_color);
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.main_container {
|
.main_container {
|
||||||
@@ -14,3 +15,10 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
padding-top: var(--config_window_topbar_height);
|
padding-top: var(--config_window_topbar_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.software_version {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0.8rem;
|
||||||
|
left: 1.2rem;
|
||||||
|
font-size: 1.4rem;
|
||||||
|
}
|
||||||
@@ -4,16 +4,23 @@ import styles from "./MainWindow.module.scss";
|
|||||||
import { SidebarSection } from "./sidebar_section/SidebarSection";
|
import { SidebarSection } from "./sidebar_section/SidebarSection";
|
||||||
import { MainSection } from "./main_section/MainSection";
|
import { MainSection } from "./main_section/MainSection";
|
||||||
import { useStartPython } from "@logics/useStartPython";
|
import { useStartPython } from "@logics/useStartPython";
|
||||||
|
import { useConfig } from "@logics/useConfig";
|
||||||
|
|
||||||
export const MainWindow = () => {
|
export const MainWindow = () => {
|
||||||
const { asyncStartPython } = useStartPython();
|
const { asyncStartPython } = useStartPython();
|
||||||
const hasRunRef = useRef(false);
|
const hasRunRef = useRef(false);
|
||||||
const main_window = getCurrent();
|
const main_window = getCurrent();
|
||||||
|
|
||||||
|
const { getSoftwareVersion } = useConfig();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
main_window.setDecorations(true);
|
main_window.setDecorations(true);
|
||||||
if (!hasRunRef.current) {
|
if (!hasRunRef.current) {
|
||||||
asyncStartPython();
|
asyncStartPython().then((result) => {
|
||||||
|
getSoftwareVersion();
|
||||||
|
}).catch((err) => {
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return () => hasRunRef.current = true;
|
return () => hasRunRef.current = true;
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user