Merge branch 'bugfix_advanced_settings' into develop
This commit is contained in:
@@ -24,7 +24,7 @@ const _Entry = forwardRef((props, ref) => {
|
|||||||
<div className={styles.entry_container}>
|
<div className={styles.entry_container}>
|
||||||
<div
|
<div
|
||||||
className={input_wrapper_class_names}
|
className={input_wrapper_class_names}
|
||||||
style={{width: props.width }}
|
style={{width: props.width || "20rem" }}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import styles from "./EntryWithSaveButton.module.scss";
|
||||||
|
import { _Entry } from "../_atoms/_entry/_Entry";
|
||||||
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { clsx } from "clsx";
|
||||||
|
|
||||||
|
export const EntryWithSaveButton = (props) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const onChangeFunction = (e) => {
|
||||||
|
props.onChangeFunction?.(e.target.value);
|
||||||
|
};
|
||||||
|
const saveFunction = () => {
|
||||||
|
props.saveFunction();
|
||||||
|
};
|
||||||
|
const is_disabled = props.state === "pending";
|
||||||
|
|
||||||
|
const save_button_class_names = clsx(styles.save_button, {
|
||||||
|
[styles.is_disabled]: is_disabled
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.container}>
|
||||||
|
<_Entry width={props.width} onChange={onChangeFunction} ui_variable={props.variable} is_disabled={is_disabled}/>
|
||||||
|
<button className={save_button_class_names} onClick={saveFunction}>
|
||||||
|
{is_disabled
|
||||||
|
? <CircularProgress size="1.4rem" sx={{ color: "var(--dark_basic_text_color)" }}/>
|
||||||
|
: <p className={styles.save_button_label}>{t("config_page.translation.deepl_auth_key.save")}</p>
|
||||||
|
}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.save_button {
|
||||||
|
padding: 0.8rem 1.2rem;
|
||||||
|
background-color: var(--primary_600_color);
|
||||||
|
border-radius: 0.4rem;
|
||||||
|
text-align: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
min-width: 5.4rem;
|
||||||
|
&:hover {
|
||||||
|
background-color: var(--primary_500_color);
|
||||||
|
}
|
||||||
|
&:active {
|
||||||
|
background-color: var(--primary_700_color);
|
||||||
|
}
|
||||||
|
&.is_disabled {
|
||||||
|
pointer-events: none;
|
||||||
|
background-color: var(--primary_800_color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.save_button_label {
|
||||||
|
font-size: 1.4rem;
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ export { ComputeDevice } from "./compute_device/ComputeDevice";
|
|||||||
export { DeeplAuthKey, OpenWebpage_DeeplAuthKey } from "./deepl_auth_key/DeeplAuthKey";
|
export { DeeplAuthKey, OpenWebpage_DeeplAuthKey } from "./deepl_auth_key/DeeplAuthKey";
|
||||||
export { DropdownMenu } from "./dropdown_menu/DropdownMenu";
|
export { DropdownMenu } from "./dropdown_menu/DropdownMenu";
|
||||||
export { Entry } from "./entry/Entry";
|
export { Entry } from "./entry/Entry";
|
||||||
|
export { EntryWithSaveButton } from "./entry_with_save_button/EntryWithSaveButton";
|
||||||
export { HotkeysEntry } from "./hotkeys_entry/HotkeysEntry";
|
export { HotkeysEntry } from "./hotkeys_entry/HotkeysEntry";
|
||||||
export { LabelComponent } from "./label_component/LabelComponent";
|
export { LabelComponent } from "./label_component/LabelComponent";
|
||||||
export { RadioButton } from "./radio_button/RadioButton";
|
export { RadioButton } from "./radio_button/RadioButton";
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
Slider,
|
Slider,
|
||||||
SwitchBox,
|
SwitchBox,
|
||||||
Entry,
|
Entry,
|
||||||
|
EntryWithSaveButton,
|
||||||
HotkeysEntry,
|
HotkeysEntry,
|
||||||
RadioButton,
|
RadioButton,
|
||||||
OpenWebpage_DeeplAuthKey,
|
OpenWebpage_DeeplAuthKey,
|
||||||
@@ -75,6 +76,9 @@ export const SwitchBoxContainer = (props) => (
|
|||||||
export const EntryContainer = (props) => (
|
export const EntryContainer = (props) => (
|
||||||
<CommonContainer Component={Entry} {...props} add_break_point={false} />
|
<CommonContainer Component={Entry} {...props} add_break_point={false} />
|
||||||
);
|
);
|
||||||
|
export const EntryWithSaveButtonContainer = (props) => (
|
||||||
|
<CommonContainer Component={EntryWithSaveButton} {...props} add_break_point={false} />
|
||||||
|
);
|
||||||
|
|
||||||
export const HotkeysEntryContainer = (props) => (
|
export const HotkeysEntryContainer = (props) => (
|
||||||
<CommonContainer Component={HotkeysEntry} {...props} />
|
<CommonContainer Component={HotkeysEntry} {...props} />
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
ActionButtonContainer,
|
ActionButtonContainer,
|
||||||
EntryContainer,
|
EntryContainer,
|
||||||
|
EntryWithSaveButtonContainer,
|
||||||
} from "../_templates/Templates";
|
} from "../_templates/Templates";
|
||||||
|
|
||||||
|
|
||||||
@@ -30,54 +31,58 @@ export const AdvancedSettings = () => {
|
|||||||
|
|
||||||
const OscIpAddressContainer = () => {
|
const OscIpAddressContainer = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [ui_variable, setUiVariable] = useState("");
|
|
||||||
const { currentOscIpAddress, setOscIpAddress } = useOscIpAddress();
|
const { currentOscIpAddress, setOscIpAddress } = useOscIpAddress();
|
||||||
const onChangeFunction = (e) => {
|
const [input_value, seInputValue] = useState(currentOscIpAddress.data);
|
||||||
const value = e.currentTarget.value;
|
|
||||||
if (value === "") {
|
const onChangeFunction = (value) => {
|
||||||
setUiVariable("");
|
seInputValue(value);
|
||||||
} else {
|
};
|
||||||
setUiVariable(value);
|
|
||||||
setOscIpAddress(value);
|
const saveFunction = () => {
|
||||||
}
|
setOscIpAddress(input_value);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(()=> {
|
useEffect(()=> {
|
||||||
setUiVariable(currentOscIpAddress.data);
|
seInputValue(currentOscIpAddress.data);
|
||||||
}, [currentOscIpAddress]);
|
}, [currentOscIpAddress]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EntryContainer
|
<EntryWithSaveButtonContainer
|
||||||
label={t("config_page.advanced_settings.osc_ip_address.label")}
|
label={t("config_page.advanced_settings.osc_ip_address.label")}
|
||||||
ui_variable={ui_variable}
|
variable={input_value}
|
||||||
onChange={onChangeFunction}
|
saveFunction={saveFunction}
|
||||||
|
onChangeFunction={onChangeFunction}
|
||||||
|
state={currentOscIpAddress.state}
|
||||||
|
width="14rem"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const OscPortContainer = () => {
|
const OscPortContainer = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [ui_variable, setUiVariable] = useState("");
|
|
||||||
const { currentOscPort, setOscPort } = useOscPort();
|
const { currentOscPort, setOscPort } = useOscPort();
|
||||||
const onChangeFunction = (e) => {
|
const [input_value, seInputValue] = useState(currentOscPort.data);
|
||||||
const value = e.currentTarget.value;
|
|
||||||
if (value === "") {
|
const onChangeFunction = (value) => {
|
||||||
setUiVariable("");
|
seInputValue(value);
|
||||||
} else {
|
};
|
||||||
setUiVariable(value);
|
|
||||||
setOscPort(value);
|
const saveFunction = () => {
|
||||||
}
|
setOscPort(input_value);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(()=> {
|
useEffect(()=> {
|
||||||
setUiVariable(currentOscPort.data);
|
seInputValue(currentOscPort.data);
|
||||||
}, [currentOscPort]);
|
}, [currentOscPort]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EntryContainer
|
<EntryWithSaveButtonContainer
|
||||||
label={t("config_page.advanced_settings.osc_port.label")}
|
label={t("config_page.advanced_settings.osc_port.label")}
|
||||||
ui_variable={ui_variable}
|
variable={input_value}
|
||||||
onChange={onChangeFunction}
|
saveFunction={saveFunction}
|
||||||
|
onChangeFunction={onChangeFunction}
|
||||||
|
state={currentOscPort.state}
|
||||||
|
width="10rem"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ import {
|
|||||||
useSpeakerMaxWords,
|
useSpeakerMaxWords,
|
||||||
|
|
||||||
useDeepLAuthKey,
|
useDeepLAuthKey,
|
||||||
|
|
||||||
|
|
||||||
|
useOscIpAddress,
|
||||||
|
useOscPort,
|
||||||
} from "@logics_configs";
|
} from "@logics_configs";
|
||||||
import { ui_configs } from "../ui_configs";
|
import { ui_configs } from "../ui_configs";
|
||||||
|
|
||||||
@@ -29,9 +33,13 @@ export const _useBackendErrorHandling = () => {
|
|||||||
const { updateSpeakerPhraseTimeout } = useSpeakerPhraseTimeout();
|
const { updateSpeakerPhraseTimeout } = useSpeakerPhraseTimeout();
|
||||||
const { updateSpeakerMaxWords } = useSpeakerMaxWords();
|
const { updateSpeakerMaxWords } = useSpeakerMaxWords();
|
||||||
|
|
||||||
const { updateDeepLAuthKey } = useDeepLAuthKey();
|
const { updateDeepLAuthKey, saveErrorDeepLAuthKey } = useDeepLAuthKey();
|
||||||
|
|
||||||
const errorHandling_Backend = ({message, data, endpoint}) => {
|
|
||||||
|
const { saveErrorOscIpAddress } = useOscIpAddress();
|
||||||
|
const { saveErrorOscPort } = useOscPort();
|
||||||
|
|
||||||
|
const errorHandling_Backend = ({message, data, endpoint, _result}) => {
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case "No mic device detected":
|
case "No mic device detected":
|
||||||
showNotification_Error(t("common_error.no_device_mic"));
|
showNotification_Error(t("common_error.no_device_mic"));
|
||||||
@@ -111,8 +119,12 @@ export const _useBackendErrorHandling = () => {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (endpoint === "/set/data/deepl_auth_key") updateDeepLAuthKey(data);
|
// determine by endpoint, not message.
|
||||||
showNotification_Error(message);
|
if (endpoint === "/set/data/deepl_auth_key") saveErrorDeepLAuthKey({message, data, endpoint, _result});
|
||||||
|
if (endpoint === "/set/data/osc_ip_address") saveErrorOscIpAddress({message, data, endpoint, _result});
|
||||||
|
if (endpoint === "/set/data/osc_port") saveErrorOscPort({message, data, endpoint, _result});
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { useStore_OscIpAddress } from "@store";
|
import { useStore_OscIpAddress } from "@store";
|
||||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||||
|
import { useNotificationStatus } from "@logics_common";
|
||||||
|
|
||||||
export const useOscIpAddress = () => {
|
export const useOscIpAddress = () => {
|
||||||
|
const { showNotification_Error } = useNotificationStatus();
|
||||||
const { asyncStdoutToPython } = useStdoutToPython();
|
const { asyncStdoutToPython } = useStdoutToPython();
|
||||||
const { currentOscIpAddress, updateOscIpAddress, pendingOscIpAddress } = useStore_OscIpAddress();
|
const { currentOscIpAddress, updateOscIpAddress, pendingOscIpAddress } = useStore_OscIpAddress();
|
||||||
|
|
||||||
@@ -15,10 +17,17 @@ export const useOscIpAddress = () => {
|
|||||||
asyncStdoutToPython("/set/data/osc_ip_address", osc_ip_address);
|
asyncStdoutToPython("/set/data/osc_ip_address", osc_ip_address);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const saveErrorOscIpAddress = ({data, message, _result}) => {
|
||||||
|
updateOscIpAddress(d => d.data);
|
||||||
|
showNotification_Error(_result);
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentOscIpAddress,
|
currentOscIpAddress,
|
||||||
getOscIpAddress,
|
getOscIpAddress,
|
||||||
updateOscIpAddress,
|
updateOscIpAddress,
|
||||||
setOscIpAddress,
|
setOscIpAddress,
|
||||||
|
|
||||||
|
saveErrorOscIpAddress,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import { useStore_OscPort } from "@store";
|
import { useStore_OscPort } from "@store";
|
||||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||||
|
import { useNotificationStatus } from "@logics_common";
|
||||||
|
|
||||||
export const useOscPort = () => {
|
export const useOscPort = () => {
|
||||||
|
const { showNotification_Error } = useNotificationStatus();
|
||||||
const { asyncStdoutToPython } = useStdoutToPython();
|
const { asyncStdoutToPython } = useStdoutToPython();
|
||||||
const { currentOscPort, updateOscPort, pendingOscPort } = useStore_OscPort();
|
const { currentOscPort, updateOscPort, pendingOscPort } = useStore_OscPort();
|
||||||
|
|
||||||
@@ -15,10 +17,17 @@ export const useOscPort = () => {
|
|||||||
asyncStdoutToPython("/set/data/osc_port", osc_port);
|
asyncStdoutToPython("/set/data/osc_port", osc_port);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const saveErrorOscPort = ({data, message, _result}) => {
|
||||||
|
updateOscPort(d => d.data);
|
||||||
|
showNotification_Error(_result);
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentOscPort,
|
currentOscPort,
|
||||||
getOscPort,
|
getOscPort,
|
||||||
updateOscPort,
|
updateOscPort,
|
||||||
setOscPort,
|
setOscPort,
|
||||||
|
|
||||||
|
saveErrorOscPort,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -18,22 +18,30 @@ export const useDeepLAuthKey = () => {
|
|||||||
pendingDeepLAuthKey();
|
pendingDeepLAuthKey();
|
||||||
asyncStdoutToPython("/set/data/deepl_auth_key", selected_deepl_auth_key);
|
asyncStdoutToPython("/set/data/deepl_auth_key", selected_deepl_auth_key);
|
||||||
};
|
};
|
||||||
const saveSuccessDeepLAuthKey = (saved_deepl_auth_key) => {
|
|
||||||
updateDeepLAuthKey(saved_deepl_auth_key);
|
|
||||||
showNotification_Success(t("config_page.translation.deepl_auth_key.auth_key_success"));
|
|
||||||
};
|
|
||||||
|
|
||||||
const deleteDeepLAuthKey = () => {
|
const deleteDeepLAuthKey = () => {
|
||||||
pendingDeepLAuthKey();
|
pendingDeepLAuthKey();
|
||||||
asyncStdoutToPython("/delete/data/deepl_auth_key");
|
asyncStdoutToPython("/delete/data/deepl_auth_key");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const savedDeepLAuthKey = (data) => {
|
||||||
|
updateDeepLAuthKey(data);
|
||||||
|
showNotification_Success(t("config_page.translation.deepl_auth_key.auth_key_success"));
|
||||||
|
};
|
||||||
|
|
||||||
|
const saveErrorDeepLAuthKey = ({data, message}) => {
|
||||||
|
updateDeepLAuthKey(data);
|
||||||
|
showNotification_Error(message);
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentDeepLAuthKey,
|
currentDeepLAuthKey,
|
||||||
getDeepLAuthKey,
|
getDeepLAuthKey,
|
||||||
updateDeepLAuthKey,
|
updateDeepLAuthKey,
|
||||||
setDeepLAuthKey,
|
setDeepLAuthKey,
|
||||||
saveSuccessDeepLAuthKey,
|
|
||||||
deleteDeepLAuthKey,
|
deleteDeepLAuthKey,
|
||||||
|
|
||||||
|
saveErrorDeepLAuthKey,
|
||||||
|
savedDeepLAuthKey,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -148,7 +148,7 @@ export const useReceiveRoutes = () => {
|
|||||||
const { updateSpeakerPhraseTimeout } = useSpeakerPhraseTimeout();
|
const { updateSpeakerPhraseTimeout } = useSpeakerPhraseTimeout();
|
||||||
const { updateSpeakerMaxWords } = useSpeakerMaxWords();
|
const { updateSpeakerMaxWords } = useSpeakerMaxWords();
|
||||||
|
|
||||||
const { updateDeepLAuthKey, saveSuccessDeepLAuthKey } = useDeepLAuthKey();
|
const { updateDeepLAuthKey, savedDeepLAuthKey } = useDeepLAuthKey();
|
||||||
const { updateSelectedCTranslate2WeightType } = useSelectedCTranslate2WeightType();
|
const { updateSelectedCTranslate2WeightType } = useSelectedCTranslate2WeightType();
|
||||||
const {
|
const {
|
||||||
updateDownloadedCTranslate2WeightTypeStatus,
|
updateDownloadedCTranslate2WeightTypeStatus,
|
||||||
@@ -352,7 +352,7 @@ export const useReceiveRoutes = () => {
|
|||||||
|
|
||||||
// Translation
|
// Translation
|
||||||
"/get/data/deepl_auth_key": updateDeepLAuthKey,
|
"/get/data/deepl_auth_key": updateDeepLAuthKey,
|
||||||
"/set/data/deepl_auth_key": saveSuccessDeepLAuthKey,
|
"/set/data/deepl_auth_key": savedDeepLAuthKey,
|
||||||
"/delete/data/deepl_auth_key": () => updateDeepLAuthKey(""),
|
"/delete/data/deepl_auth_key": () => updateDeepLAuthKey(""),
|
||||||
|
|
||||||
"/get/data/ctranslate2_weight_type": updateSelectedCTranslate2WeightType,
|
"/get/data/ctranslate2_weight_type": updateSelectedCTranslate2WeightType,
|
||||||
@@ -523,6 +523,9 @@ export const useReceiveRoutes = () => {
|
|||||||
"/set/data/speaker_record_timeout": errorHandling_Backend,
|
"/set/data/speaker_record_timeout": errorHandling_Backend,
|
||||||
"/set/data/speaker_phrase_timeout": errorHandling_Backend,
|
"/set/data/speaker_phrase_timeout": errorHandling_Backend,
|
||||||
"/set/data/speaker_max_phrases": errorHandling_Backend,
|
"/set/data/speaker_max_phrases": errorHandling_Backend,
|
||||||
|
|
||||||
|
"/set/data/osc_ip_address": errorHandling_Backend,
|
||||||
|
"/set/data/osc_port": errorHandling_Backend,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -555,12 +558,14 @@ export const useReceiveRoutes = () => {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 400:
|
case 400:
|
||||||
|
case 500:
|
||||||
const error_route = error_status_routes[parsed_data.endpoint];
|
const error_route = error_status_routes[parsed_data.endpoint];
|
||||||
if (error_route) {
|
if (error_route) {
|
||||||
error_route({
|
error_route({
|
||||||
message: parsed_data.result.message,
|
message: parsed_data.result.message,
|
||||||
data: parsed_data.result.data,
|
data: parsed_data.result.data,
|
||||||
endpoint: parsed_data.endpoint,
|
endpoint: parsed_data.endpoint,
|
||||||
|
_result: parsed_data.result,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
handleInvalidEndpoint(parsed_data);
|
handleInvalidEndpoint(parsed_data);
|
||||||
|
|||||||
Reference in New Issue
Block a user