[Update] Config Page: Others Tab. Add section, send message button type.
This commit is contained in:
@@ -31,6 +31,7 @@ const StartPythonFacadeComponent = () => {
|
|||||||
getSelectedSpeakerDevice,
|
getSelectedSpeakerDevice,
|
||||||
|
|
||||||
getEnableAutoClearMessageBox,
|
getEnableAutoClearMessageBox,
|
||||||
|
getSendMessageButtonType,
|
||||||
} = useConfig();
|
} = useConfig();
|
||||||
|
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ const StartPythonFacadeComponent = () => {
|
|||||||
getSelectedSpeakerDevice();
|
getSelectedSpeakerDevice();
|
||||||
|
|
||||||
getEnableAutoClearMessageBox();
|
getEnableAutoClearMessageBox();
|
||||||
|
getSendMessageButtonType();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,27 +1,28 @@
|
|||||||
import clsx from "clsx";
|
|
||||||
import { useState } from "react";
|
|
||||||
import styles from "./RadioButton.module.scss";
|
import styles from "./RadioButton.module.scss";
|
||||||
|
|
||||||
export const RadioButton = (props) => {
|
export const RadioButton = (props) => {
|
||||||
const options = [
|
|
||||||
{ radio_button_id: "1", label: "AAAAAAAA" },
|
|
||||||
{ radio_button_id: "2", label: "BBBBBB" }
|
|
||||||
];
|
|
||||||
|
|
||||||
const changeValue = (e) => {
|
|
||||||
console.log(e.target.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
{options.map((option) => (
|
{props.options.map((option) => (
|
||||||
<label key={option.radio_button_id} className={styles.radio_button_wrapper}>
|
<label key={option.radio_button_id} className={styles.radio_button_wrapper}>
|
||||||
<input
|
{props.checked_variable.data === option.radio_button_id
|
||||||
type="radio"
|
? <>
|
||||||
name="radio"
|
{ props.checked_variable.state === "loading" && <span className={styles.loader}></span> }
|
||||||
value={option.radio_button_id}
|
<input
|
||||||
onChange={changeValue}
|
type="radio"
|
||||||
/>
|
name="radio"
|
||||||
|
value={option.radio_button_id}
|
||||||
|
onChange={() => props.selectFunction(option.radio_button_id)}
|
||||||
|
checked
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
: <input
|
||||||
|
type="radio"
|
||||||
|
name="radio"
|
||||||
|
value={option.radio_button_id}
|
||||||
|
onChange={() => props.selectFunction(option.radio_button_id)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
<p className={styles.radio_button_label}>{option.label}</p>
|
<p className={styles.radio_button_label}>{option.label}</p>
|
||||||
</label>
|
</label>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@import "@scss_mixins";
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -12,6 +14,7 @@
|
|||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
padding: 0.6rem 0.8rem;
|
padding: 0.6rem 0.8rem;
|
||||||
border-radius: 0.4rem;
|
border-radius: 0.4rem;
|
||||||
|
position: relative;
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: var(--dark_800_color);
|
background-color: var(--dark_800_color);
|
||||||
}
|
}
|
||||||
@@ -38,4 +41,8 @@ input[type="radio"] {
|
|||||||
.radio_button_label {
|
.radio_button_label {
|
||||||
font-size: 1.4rem;
|
font-size: 1.4rem;
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loader {
|
||||||
|
@include loader(2rem, 0.2rem, left, -1.6rem);
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ export const Others = () => {
|
|||||||
} = useSettingBox();
|
} = useSettingBox();
|
||||||
|
|
||||||
const { currentEnableAutoClearMessageBox, toggleEnableAutoClearMessageBox } = useConfig();
|
const { currentEnableAutoClearMessageBox, toggleEnableAutoClearMessageBox } = useConfig();
|
||||||
|
const { currentSendMessageButtonType, setSendMessageButtonType } = useConfig();
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -24,7 +25,16 @@ export const Others = () => {
|
|||||||
toggleFunction={toggleEnableAutoClearMessageBox}
|
toggleFunction={toggleEnableAutoClearMessageBox}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* <RadioButtonContainer label={t("config_page.send_message_button_type.label")} checkbox_id="checkbox_id_1"/> */}
|
<RadioButtonContainer
|
||||||
|
label={t("config_page.send_message_button_type.label")}
|
||||||
|
selectFunction={setSendMessageButtonType}
|
||||||
|
options={[
|
||||||
|
{ radio_button_id: "hide", label: t("config_page.send_message_button_type.hide") },
|
||||||
|
{ radio_button_id: "show", label: t("config_page.send_message_button_type.show") },
|
||||||
|
{ radio_button_id: "show_and_disable_enter_key", label: t("config_page.send_message_button_type.show_and_disable_enter_key") },
|
||||||
|
]}
|
||||||
|
checked_variable={currentSendMessageButtonType}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
useSelectedSpeakerDevice,
|
useSelectedSpeakerDevice,
|
||||||
|
|
||||||
useEnableAutoClearMessageBox,
|
useEnableAutoClearMessageBox,
|
||||||
|
useSendMessageButtonType,
|
||||||
} from "@store";
|
} from "@store";
|
||||||
|
|
||||||
import { useStdoutToPython } from "./useStdoutToPython";
|
import { useStdoutToPython } from "./useStdoutToPython";
|
||||||
@@ -25,6 +26,7 @@ export const useConfig = () => {
|
|||||||
const { updateSpeakerDeviceList } = useSpeakerDeviceList();
|
const { updateSpeakerDeviceList } = useSpeakerDeviceList();
|
||||||
const { updateSelectedSpeakerDevice } = useSelectedSpeakerDevice();
|
const { updateSelectedSpeakerDevice } = useSelectedSpeakerDevice();
|
||||||
const { currentEnableAutoClearMessageBox, updateEnableAutoClearMessageBox } = useEnableAutoClearMessageBox();
|
const { currentEnableAutoClearMessageBox, updateEnableAutoClearMessageBox } = useEnableAutoClearMessageBox();
|
||||||
|
const { currentSendMessageButtonType, updateSendMessageButtonType } = useSendMessageButtonType();
|
||||||
|
|
||||||
|
|
||||||
const asyncPending = () => new Promise(() => {});
|
const asyncPending = () => new Promise(() => {});
|
||||||
@@ -117,6 +119,20 @@ export const useConfig = () => {
|
|||||||
updateEnableAutoClearMessageBox(payload.data);
|
updateEnableAutoClearMessageBox(payload.data);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getSendMessageButtonType: () => {
|
||||||
|
updateSendMessageButtonType(asyncPending);
|
||||||
|
asyncStdoutToPython("/config/send_message_button_type");
|
||||||
|
},
|
||||||
|
setSendMessageButtonType: (selected_type) => {
|
||||||
|
updateSendMessageButtonType(asyncPending);
|
||||||
|
asyncStdoutToPython("/controller/callback_set_send_message_button_type", selected_type);
|
||||||
|
},
|
||||||
|
currentSendMessageButtonType: currentSendMessageButtonType,
|
||||||
|
updateSendMessageButtonType: (payload) => {
|
||||||
|
updateSendMessageButtonType(payload.data);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -28,6 +28,7 @@ export const useReceiveRoutes = () => {
|
|||||||
updateSelectedSpeakerDevice,
|
updateSelectedSpeakerDevice,
|
||||||
|
|
||||||
updateEnableAutoClearMessageBox,
|
updateEnableAutoClearMessageBox,
|
||||||
|
updateSendMessageButtonType,
|
||||||
} = useConfig();
|
} = useConfig();
|
||||||
|
|
||||||
const { updateVolumeVariable_Mic, updateVolumeVariable_Speaker } = useVolume();
|
const { updateVolumeVariable_Mic, updateVolumeVariable_Speaker } = useVolume();
|
||||||
@@ -62,6 +63,8 @@ export const useReceiveRoutes = () => {
|
|||||||
"/controller/callback_enable_auto_clear_chatbox": updateEnableAutoClearMessageBox,
|
"/controller/callback_enable_auto_clear_chatbox": updateEnableAutoClearMessageBox,
|
||||||
"/controller/callback_disable_auto_clear_chatbox": updateEnableAutoClearMessageBox,
|
"/controller/callback_disable_auto_clear_chatbox": updateEnableAutoClearMessageBox,
|
||||||
|
|
||||||
|
"/config/send_message_button_type": updateSendMessageButtonType,
|
||||||
|
"/controller/callback_set_send_message_button_type": updateSendMessageButtonType,
|
||||||
|
|
||||||
|
|
||||||
"/controller/callback_messagebox_send": updateSentMessageLog,
|
"/controller/callback_messagebox_send": updateSentMessageLog,
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ export const { atomInstance: Atom_WordFilterList, useHook: useWordFilterList } =
|
|||||||
|
|
||||||
// Others
|
// Others
|
||||||
export const { atomInstance: Atom_EnableAutoClearMessageBox, useHook: useEnableAutoClearMessageBox } = createAsyncAtomWithHook(true, "EnableAutoClearMessageBox");
|
export const { atomInstance: Atom_EnableAutoClearMessageBox, useHook: useEnableAutoClearMessageBox } = createAsyncAtomWithHook(true, "EnableAutoClearMessageBox");
|
||||||
|
export const { atomInstance: Atom_SendMessageButtonType, useHook: useSendMessageButtonType } = createAsyncAtomWithHook("show", "SendMessageButtonType");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user