mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
adjust error messaging in dashboard
This commit is contained in:
parent
25c8e64a95
commit
7dd7d4b3eb
@ -28,7 +28,7 @@ console.log("IN DASHBOARD here");
|
||||
<>
|
||||
<div class="settings">
|
||||
<SettingsButton type="text" size="small" icon={<ReloadOutlined />}
|
||||
onClick={() => actions.getAccounts()}></SettingsButton>
|
||||
onClick={() => actions.reload()}></SettingsButton>
|
||||
</div>
|
||||
<div class="settings">
|
||||
<SettingsButton type="text" size="small" icon={<SettingOutlined />}
|
||||
@ -38,7 +38,7 @@ console.log("IN DASHBOARD here");
|
||||
<SettingsButton type="text" size="small" icon={<LogoutOutlined />}
|
||||
onClick={() => actions.logout()}></SettingsButton>
|
||||
</div>
|
||||
{ state.errorMessage && (
|
||||
{ (state.configError || state.accountsError) && (
|
||||
<AlertIcon>
|
||||
<ExclamationCircleOutlined />
|
||||
</AlertIcon>
|
||||
@ -54,7 +54,7 @@ console.log("IN DASHBOARD here");
|
||||
<div class="settings">
|
||||
<Tooltip placement="topRight" title="Reload Accounts">
|
||||
<SettingsButton type="text" size="small" icon={<ReloadOutlined />}
|
||||
onClick={() => actions.getAccounts()}></SettingsButton>
|
||||
onClick={() => actions.reload()}></SettingsButton>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<div class="settings">
|
||||
@ -69,8 +69,15 @@ console.log("IN DASHBOARD here");
|
||||
onClick={() => actions.logout()}></SettingsButton>
|
||||
</Tooltip>
|
||||
</div>
|
||||
{ state.errorMessage && (
|
||||
<Tooltip placement="topRight" title={state.errorMessage}>
|
||||
{ state.configError && (
|
||||
<Tooltip placement="topRight" title="failed to load accounts">
|
||||
<AlertIcon class="alert">
|
||||
<ExclamationCircleOutlined />
|
||||
</AlertIcon>
|
||||
</Tooltip>
|
||||
)}
|
||||
{ state.accountsError && (
|
||||
<Tooltip placement="topRight" title="failed to load config">
|
||||
<AlertIcon class="alert">
|
||||
<ExclamationCircleOutlined />
|
||||
</AlertIcon>
|
||||
|
@ -18,7 +18,8 @@ export function useDashboard() {
|
||||
enableAudio: null,
|
||||
enableVideo: null,
|
||||
|
||||
errorMessage: null,
|
||||
configError: false,
|
||||
accountsError: false,
|
||||
createToken: null,
|
||||
showSettings: false,
|
||||
showCreate: false,
|
||||
@ -91,7 +92,8 @@ export function useDashboard() {
|
||||
logout: () => {
|
||||
app.actions.clearAdmin();
|
||||
},
|
||||
getAccounts: async () => {
|
||||
reload: async () => {
|
||||
await syncConfig();
|
||||
await syncAccounts();
|
||||
},
|
||||
setSettings: async () => {
|
||||
@ -118,13 +120,12 @@ export function useDashboard() {
|
||||
const config = await getNodeConfig(app.state.adminToken);
|
||||
const { storage, domain, keyType, pushSupported, enableImage, enableAudio, enableVideo } = config;
|
||||
const accountStorage = Math.ceil(storage / 1073741824);
|
||||
updateState({ domain, accountStorage, keyType, enableImage, enableAudio, enableVideo, pushSupported });
|
||||
updateState({ configError: false, domain, accountStorage, keyType, enableImage, enableAudio, enableVideo, pushSupported });
|
||||
}
|
||||
catch(err) {
|
||||
console.log(err);
|
||||
updateState({ errorMessage: 'failed to sync config' });
|
||||
updateState({ configError: true });
|
||||
}
|
||||
updateState({ errorMessage: 'failed to sync config' });
|
||||
};
|
||||
|
||||
const syncAccounts = async () => {
|
||||
@ -139,11 +140,11 @@ export function useDashboard() {
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
updateState({ accounts });
|
||||
updateState({ accounstError: false, accounts });
|
||||
}
|
||||
catch(err) {
|
||||
console.log(err);
|
||||
updateState({ errorMessage: 'failed to sync accounts' });
|
||||
updateState({ accountsError: true });
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user