adding logout button to admin config

This commit is contained in:
balzack 2025-02-21 22:00:31 -08:00
parent 12bee2f75e
commit 7e63b6ac62
7 changed files with 24 additions and 17 deletions

View File

@ -12,6 +12,7 @@ export function useAccounts() {
strings: display.state.strings,
members: [] as Member[],
loading: false,
secretText: '',
});
const updateState = (value: any) => {

View File

@ -213,4 +213,7 @@ export const styles = StyleSheet.create({
secretIcon: {
marginLeft: 8,
},
icon: {
backgroundColor: 'transparent',
},
});

View File

@ -60,15 +60,13 @@ export function Setup() {
<View style={styles.setup}>
<View style={styles.header}>
<View style={styles.busy}>
{ state.loading && (
{ (state.loading || state.updating) && (
<ActivityIndicator size={18} />
)}
</View>
<Text style={styles.title}>{ state.strings.setup }</Text>
<View style={styles.busy}>
{ state.updating && (
<ActivityIndicator size={18} />
)}
<IconButton style={styles.icon} iconColor={Colors.primary} mode="contained" icon="logout" onPress={actions.logout} />
</View>
</View>
<Divider style={styles.line} bold={true} />
@ -84,8 +82,8 @@ export function Setup() {
style={styles.radioButton}
label=""
mode="android"
status={state.setup?.keyType === 'RSA_2048' ? 'checked' : 'unchecked'}
onPress={() => { actions.setKeyType('RSA_2048') }}
status={state.setup?.keyType === 'RSA2048' ? 'checked' : 'unchecked'}
onPress={() => { actions.setKeyType('RSA2048') }}
/>
</View>
<View style={styles.radio}>
@ -96,8 +94,8 @@ export function Setup() {
style={styles.radioButton}
label=""
mode="android"
status={state.setup?.keyType === 'RSA_4096' ? 'checked' : 'unchecked'}
onPress={() => { actions.setKeyType('RSA_4096') }}
status={state.setup?.keyType === 'RSA4096' ? 'checked' : 'unchecked'}
onPress={() => { actions.setKeyType('RSA4096') }}
/>
</View>
</View>

View File

@ -41,7 +41,7 @@ export function useSetup() {
const mfaEnabled = await service.checkMFAuth();
setup.current = await service.getSetup();
loading.current = false;
const storage = Math.floor(setup.current?.accountStorage || 0 / 1073741824);
const storage = Math.floor((setup.current?.accountStorage || 0) / 1073741824);
updateState({ setup: setup.current, mfaEnabled, accountStorage: storage.toString(), loading: false });
} catch (err) {
console.log(err);
@ -87,6 +87,7 @@ export function useSetup() {
}, []);
const actions = {
logout: app.actions.adminLogout,
clearError: () => {
updateState({ error: false });
},
@ -152,7 +153,8 @@ export function useSetup() {
save();
}
},
setKeyType: (keyType: KeyType) => {
setKeyType: (type: string) => {
const keyType = type === 'RSA2048' ? KeyType.RSA_2048 : KeyType.RSA_4096;
if (setup.current) {
setup.current.keyType = keyType;
updateState({ setup: setup.current });
@ -230,6 +232,8 @@ export function useSetup() {
},
setEnableService: (iceService: boolean) => {
if (setup.current) {
const iceUrl = iceService ? 'https://rtc.live.cloudflare.com/v1/turn/keys/%%TURN_KEY_ID%%/credentials/generate' : '';
setup.current.iceUrl = iceUrl;
setup.current.iceService = iceService ? ICEService.Cloudflare : ICEService.Default;
updateState({ setup: setup.current });
save();

View File

@ -83,7 +83,7 @@
.modal {
.prompt {
padding: 8px;
font-size: 14px;
font-size: 15px;
}
.copy {
@ -95,7 +95,7 @@
}
.value {
font-size: 12px;
font-size: 15px;
padding: 16px;
}

View File

@ -4,7 +4,7 @@ import { useSetup } from './useSetup.hook'
import { PinInput, Image, Button, Radio, Group, Loader, Modal, Divider, Text, TextInput, Switch, ActionIcon } from '@mantine/core'
import { modals } from '@mantine/modals'
import { useDisclosure } from '@mantine/hooks'
import { IconCheck, IconCopy } from '@tabler/icons-react'
import { IconCheck, IconLogout, IconCopy } from '@tabler/icons-react'
export function Setup() {
const { state, actions } = useSetup();
@ -53,7 +53,7 @@ export function Setup() {
<div className={classes.setup}>
<div className={classes.header}>
<div className={classes.loader}>
{ state.loading && (
{ (state.loading || state.updating) && (
<Loader size={18} />
)}
</div>
@ -61,9 +61,9 @@ export function Setup() {
<Text className={classes.title}>{ state.strings.setup }</Text>
</div>
<div className={classes.loader}>
{ state.updating && (
<Loader size={18} />
)}
<ActionIcon className={classes.action} variant="light" onClick={actions.logout}>
<IconLogout />
</ActionIcon>
</div>
</div>
<div className={classes.content}>

View File

@ -87,6 +87,7 @@ export function useSetup() {
}, []);
const actions = {
logout: app.actions.adminLogout,
clearError: () => {
updateState({ error: false });
},