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,15 +285,16 @@ export function Dashboard(props) {
|
|||||||
|
|
||||||
{ state.enableIce && (
|
{ state.enableIce && (
|
||||||
<>
|
<>
|
||||||
|
{ state.iceServiceFlag != null && (
|
||||||
<TouchableOpacity style={styles.ice} activeOpacity={1}
|
<TouchableOpacity style={styles.ice} activeOpacity={1}
|
||||||
onPress={() => actions.setEnableIce(!state.iceService)}>
|
onPress={() => actions.setIceServiceFlag(!state.iceServiceFlag)}>
|
||||||
<Text style={styles.modalLabel}>{ state.strings.iceService }</Text>
|
<Text style={styles.modalLabel}>{ state.strings.iceService }</Text>
|
||||||
<Switch style={styles.switch} value={state.iceService}
|
<Switch style={styles.switch} value={state.iceServiceFlag}
|
||||||
onValueChange={actions.setIceService} trackColor={styles.track}/>
|
onValueChange={actions.setIceServiceFlag} trackColor={styles.track}/>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
|
||||||
{ !state.iceService && (
|
{ !state.iceServiceFlag && (
|
||||||
<>
|
|
||||||
<InputField style={styles.field}
|
<InputField style={styles.field}
|
||||||
label={state.strings.relayUrl}
|
label={state.strings.relayUrl}
|
||||||
value={state.iceUrl}
|
value={state.iceUrl}
|
||||||
@ -302,9 +303,10 @@ export function Dashboard(props) {
|
|||||||
disabled={!state.enableIce}
|
disabled={!state.enableIce}
|
||||||
onChangeText={actions.setIceUrl}
|
onChangeText={actions.setIceUrl}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
<InputField style={styles.field}
|
<InputField style={styles.field}
|
||||||
label={state.strings.relayUsername}
|
label={state.iceServiceFlag ? 'TURN_KEY_ID' : state.strings.relayUsername}
|
||||||
value={state.iceUsername}
|
value={state.iceUsername}
|
||||||
autoCapitalize={'none'}
|
autoCapitalize={'none'}
|
||||||
spellCheck={false}
|
spellCheck={false}
|
||||||
@ -313,7 +315,7 @@ export function Dashboard(props) {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<InputField style={styles.field}
|
<InputField style={styles.field}
|
||||||
label={state.strings.relayPassword}
|
label={state.iceServiceFlag ? 'TURN_KEY_API_TOKEN' : state.strings.relayPassword}
|
||||||
value={state.icePassword}
|
value={state.icePassword}
|
||||||
autoCapitalize={'none'}
|
autoCapitalize={'none'}
|
||||||
spellCheck={false}
|
spellCheck={false}
|
||||||
@ -323,30 +325,6 @@ export function Dashboard(props) {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{ 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}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<View style={styles.pad} />
|
<View style={styles.pad} />
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
@ -41,7 +41,7 @@ export function useDashboard(server, token, mfa) {
|
|||||||
enableBinary: true,
|
enableBinary: true,
|
||||||
createToken: null,
|
createToken: null,
|
||||||
enableIce: false,
|
enableIce: false,
|
||||||
iceService: false,
|
iceServiceFlag: false,
|
||||||
iceUrl: null,
|
iceUrl: null,
|
||||||
iceUsername: null,
|
iceUsername: null,
|
||||||
icePassword: null,
|
icePassword: null,
|
||||||
@ -81,7 +81,10 @@ export function useDashboard(server, token, mfa) {
|
|||||||
const accounts = nodeAccounts.map(setAccountItem);
|
const accounts = nodeAccounts.map(setAccountItem);
|
||||||
const { keyType, accountStorage, domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceService, iceUrl, iceUsername, icePassword } = config || {};
|
const { keyType, accountStorage, domain, enableImage, enableAudio, enableVideo, enableBinary, transformSupported, allowUnsealed, pushSupported, enableIce, iceService, iceUrl, iceUsername, icePassword } = config || {};
|
||||||
const storage = Math.ceil(accountStorage / 1073741824);
|
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 () => {
|
const refreshAccounts = async () => {
|
||||||
@ -151,8 +154,8 @@ export function useDashboard(server, token, mfa) {
|
|||||||
setEnableIce: (enableIce) => {
|
setEnableIce: (enableIce) => {
|
||||||
updateState({ enableIce });
|
updateState({ enableIce });
|
||||||
},
|
},
|
||||||
setIceService: (iceService) => {
|
setIceServiceFlag: (iceServiceFlag) => {
|
||||||
updateState({ iceService });
|
updateState({ iceServiceFlag });
|
||||||
},
|
},
|
||||||
setIceUrl: (iceUrl) => {
|
setIceUrl: (iceUrl) => {
|
||||||
updateState({ iceUrl });
|
updateState({ iceUrl });
|
||||||
@ -164,7 +167,8 @@ export function useDashboard(server, token, mfa) {
|
|||||||
updateState({ icePassword });
|
updateState({ icePassword });
|
||||||
},
|
},
|
||||||
saveConfig: async () => {
|
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 accountStorage = Number(storage) * 1073741824;
|
||||||
const config = { accountStorage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceService, iceUrl, iceUsername, icePassword };
|
const config = { accountStorage, domain, keyType, enableImage, pushSupported, allowUnsealed, transformSupported, enableAudio, enableVideo, enableBinary, enableIce, iceService, iceUrl, iceUsername, icePassword };
|
||||||
await setNodeConfig(server, token, config);
|
await setNodeConfig(server, token, config);
|
||||||
|
Loading…
Reference in New Issue
Block a user