mirror of
https://github.com/balzack/databag.git
synced 2025-02-11 19:19:16 +00:00
hide ice service option when not supported
This commit is contained in:
parent
094be15b05
commit
b61f3da878
@ -285,65 +285,43 @@ export function Dashboard(props) {
|
||||
|
||||
{ state.enableIce && (
|
||||
<>
|
||||
<TouchableOpacity style={styles.ice} activeOpacity={1}
|
||||
onPress={() => actions.setEnableIce(!state.iceService)}>
|
||||
<Text style={styles.modalLabel}>{ state.strings.iceService }</Text>
|
||||
<Switch style={styles.switch} value={state.iceService}
|
||||
onValueChange={actions.setIceService} trackColor={styles.track}/>
|
||||
</TouchableOpacity>
|
||||
|
||||
{ !state.iceService && (
|
||||
<>
|
||||
<InputField style={styles.field}
|
||||
label={state.strings.relayUrl}
|
||||
value={state.iceUrl}
|
||||
autoCapitalize={'none'}
|
||||
spellCheck={false}
|
||||
disabled={!state.enableIce}
|
||||
onChangeText={actions.setIceUrl}
|
||||
/>
|
||||
|
||||
<InputField style={styles.field}
|
||||
label={state.strings.relayUsername}
|
||||
value={state.iceUsername}
|
||||
autoCapitalize={'none'}
|
||||
spellCheck={false}
|
||||
disabled={!state.enableIce}
|
||||
onChangeText={actions.setIceUsername}
|
||||
/>
|
||||
|
||||
<InputField style={styles.field}
|
||||
label={state.strings.relayPassword}
|
||||
value={state.icePassword}
|
||||
autoCapitalize={'none'}
|
||||
spellCheck={false}
|
||||
disabled={!state.enableIce}
|
||||
onChangeText={actions.setIcePassword}
|
||||
/>
|
||||
</>
|
||||
{ state.iceServiceFlag != null && (
|
||||
<TouchableOpacity style={styles.ice} activeOpacity={1}
|
||||
onPress={() => actions.setIceServiceFlag(!state.iceServiceFlag)}>
|
||||
<Text style={styles.modalLabel}>{ state.strings.iceService }</Text>
|
||||
<Switch style={styles.switch} value={state.iceServiceFlag}
|
||||
onValueChange={actions.setIceServiceFlag} trackColor={styles.track}/>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
|
||||
{ state.iceService && (
|
||||
<>
|
||||
<InputField style={styles.field}
|
||||
label={'TURN_KEY_ID'}
|
||||
value={state.iceUsername}
|
||||
autoCapitalize={'none'}
|
||||
spellCheck={false}
|
||||
disabled={!state.enableIce}
|
||||
onChangeText={actions.setIceUsername}
|
||||
/>
|
||||
|
||||
<InputField style={styles.field}
|
||||
label={'TURN_KEY_API_TOKEN'}
|
||||
value={state.icePassword}
|
||||
autoCapitalize={'none'}
|
||||
spellCheck={false}
|
||||
disabled={!state.enableIce}
|
||||
onChangeText={actions.setIcePassword}
|
||||
/>
|
||||
</>
|
||||
{ !state.iceServiceFlag && (
|
||||
<InputField style={styles.field}
|
||||
label={state.strings.relayUrl}
|
||||
value={state.iceUrl}
|
||||
autoCapitalize={'none'}
|
||||
spellCheck={false}
|
||||
disabled={!state.enableIce}
|
||||
onChangeText={actions.setIceUrl}
|
||||
/>
|
||||
)}
|
||||
|
||||
<InputField style={styles.field}
|
||||
label={state.iceServiceFlag ? 'TURN_KEY_ID' : state.strings.relayUsername}
|
||||
value={state.iceUsername}
|
||||
autoCapitalize={'none'}
|
||||
spellCheck={false}
|
||||
disabled={!state.enableIce}
|
||||
onChangeText={actions.setIceUsername}
|
||||
/>
|
||||
|
||||
<InputField style={styles.field}
|
||||
label={state.iceServiceFlag ? 'TURN_KEY_API_TOKEN' : state.strings.relayPassword}
|
||||
value={state.icePassword}
|
||||
autoCapitalize={'none'}
|
||||
spellCheck={false}
|
||||
disabled={!state.enableIce}
|
||||
onChangeText={actions.setIcePassword}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
|
@ -41,7 +41,7 @@ export function useDashboard(server, token, mfa) {
|
||||
enableBinary: true,
|
||||
createToken: null,
|
||||
enableIce: false,
|
||||
iceService: false,
|
||||
iceServiceFlag: false,
|
||||
iceUrl: null,
|
||||
iceUsername: null,
|
||||
icePassword: null,
|
||||
@ -81,7 +81,10 @@ export function useDashboard(server, token, mfa) {
|
||||
const accounts = nodeAccounts.map(setAccountItem);
|
||||
const { keyType, accountStorage, domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceService, iceUrl, iceUsername, icePassword } = config || {};
|
||||
const storage = Math.ceil(accountStorage / 1073741824);
|
||||
updateState({ keyType, storage: storage.toString(), domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceService, iceUrl, iceUsername, icePassword, accounts, mfaEnabled });
|
||||
const iceServiceFlag = iceService === 'cloudflare' ? true : iceService == null ? null : true;
|
||||
console.log("ICE:", iceService, iceServiceFlag);
|
||||
|
||||
updateState({ keyType, storage: storage.toString(), domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceServiceFlag, iceUrl, iceUsername, icePassword, accounts, mfaEnabled });
|
||||
}
|
||||
|
||||
const refreshAccounts = async () => {
|
||||
@ -151,8 +154,8 @@ export function useDashboard(server, token, mfa) {
|
||||
setEnableIce: (enableIce) => {
|
||||
updateState({ enableIce });
|
||||
},
|
||||
setIceService: (iceService) => {
|
||||
updateState({ iceService });
|
||||
setIceServiceFlag: (iceServiceFlag) => {
|
||||
updateState({ iceServiceFlag });
|
||||
},
|
||||
setIceUrl: (iceUrl) => {
|
||||
updateState({ iceUrl });
|
||||
@ -164,7 +167,8 @@ export function useDashboard(server, token, mfa) {
|
||||
updateState({ icePassword });
|
||||
},
|
||||
saveConfig: async () => {
|
||||
const { storage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceService, iceUrl, iceUsername, icePassword } = state;
|
||||
const { storage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceServiceFlag, iceUrl, iceUsername, icePassword } = state;
|
||||
const iceService = iceServiceFlag ? 'cloudflare' : '';
|
||||
const accountStorage = Number(storage) * 1073741824;
|
||||
const config = { accountStorage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceService, iceUrl, iceUsername, icePassword };
|
||||
await setNodeConfig(server, token, config);
|
||||
|
Loading…
Reference in New Issue
Block a user