switch crypto implementation and add spinner
This commit is contained in:
@ -15,7 +15,6 @@ invoke('get_config').then(config => $appState.config = config);
|
||||
listen('credentials-request', (tauriEvent) => {
|
||||
$appState.pendingRequests.put(tauriEvent.payload);
|
||||
});
|
||||
window.state = $appState;
|
||||
|
||||
acceptRequest();
|
||||
</script>
|
||||
|
113
src/ui/Spinner.svelte
Normal file
113
src/ui/Spinner.svelte
Normal file
@ -0,0 +1,113 @@
|
||||
<script>
|
||||
export let color = 'base-content';
|
||||
export let thickness = '2px';
|
||||
let classes = '';
|
||||
export { classes as class };
|
||||
|
||||
const colorVars = {
|
||||
'primary': 'p',
|
||||
'primary-focus': 'pf',
|
||||
'primary-content': 'pc',
|
||||
'secondary': 's',
|
||||
'secondary-focus': 'sf',
|
||||
'secondary-content': 'sc',
|
||||
'accent': 'a',
|
||||
'accent-focus': 'af',
|
||||
'accent-content': 'ac',
|
||||
'neutral': 'n',
|
||||
'neutral-focus': 'nf',
|
||||
'neutral-content': 'nc',
|
||||
'base-100': 'b1',
|
||||
'base-200': 'b2',
|
||||
'base-300': 'b3',
|
||||
'base-content': 'bc',
|
||||
'info': 'in',
|
||||
'info-content': 'inc',
|
||||
'success': 'su',
|
||||
'success-content': 'suc',
|
||||
'warning': 'wa',
|
||||
'warning-content': 'wac',
|
||||
'error': 'er',
|
||||
'error-content': 'erc',
|
||||
}
|
||||
|
||||
let arcStyle = `border-width: ${thickness};`;
|
||||
arcStyle += `border-color: hsl(var(--${colorVars[color]})) transparent transparent transparent;`;
|
||||
</script>
|
||||
|
||||
<style>
|
||||
#spinner {
|
||||
position: relative;
|
||||
|
||||
animation: spin;
|
||||
animation-duration: 1.5s;
|
||||
animation-iteration-count: infinite;
|
||||
animation-timing-function: linear;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
50% { transform: rotate(225deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.arc {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
border-radius: 9999px;
|
||||
}
|
||||
|
||||
.arc-top {
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.arc-right {
|
||||
animation: spin-right;
|
||||
animation-duration: 3s;
|
||||
animation-iteration-count: infinite;
|
||||
}
|
||||
|
||||
.arc-bottom {
|
||||
animation: spin-bottom;
|
||||
animation-duration: 3s;
|
||||
animation-iteration-count: infinite;
|
||||
}
|
||||
|
||||
.arc-left {
|
||||
animation: spin-left;
|
||||
animation-duration: 3s;
|
||||
animation-iteration-count: infinite;
|
||||
}
|
||||
|
||||
@keyframes spin-top {
|
||||
0% { transform: rotate(-45deg); }
|
||||
50% { transform: rotate(315deg); }
|
||||
100% { transform: rotate(-45deg); }
|
||||
}
|
||||
|
||||
@keyframes spin-right {
|
||||
0% { transform: rotate(45deg); }
|
||||
50% { transform: rotate(315deg); }
|
||||
100% { transform: rotate(405deg); }
|
||||
}
|
||||
|
||||
@keyframes spin-bottom {
|
||||
0% { transform: rotate(135deg); }
|
||||
50% { transform: rotate(315deg); }
|
||||
100% { transform: rotate(495deg); }
|
||||
}
|
||||
|
||||
@keyframes spin-left {
|
||||
0% { transform: rotate(225deg); }
|
||||
50% { transform: rotate(315deg); }
|
||||
100% { transform: rotate(585deg); }
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<div id="spinner" class="w-6 h-6 {classes}">
|
||||
<div class="arc arc-top w-full h-full" style={arcStyle}></div>
|
||||
<div class="arc arc-right w-full h-full" style={arcStyle}></div>
|
||||
<div class="arc arc-bottom w-full h-full" style={arcStyle}></div>
|
||||
<div class="arc arc-left w-full h-full" style={arcStyle}></div>
|
||||
</div>
|
@ -7,6 +7,7 @@
|
||||
import { navigate } from '../lib/routing.js';
|
||||
import Link from '../ui/Link.svelte';
|
||||
import ErrorAlert from '../ui/ErrorAlert.svelte';
|
||||
import Spinner from '../ui/Spinner.svelte';
|
||||
|
||||
|
||||
let errorMsg = null;
|
||||
@ -19,6 +20,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
let saving = false;
|
||||
async function save() {
|
||||
if (passphrase !== confirmPassphrase) {
|
||||
alert.shake();
|
||||
@ -27,6 +29,7 @@
|
||||
|
||||
let credentials = {AccessKeyId, SecretAccessKey};
|
||||
try {
|
||||
saving = true;
|
||||
await invoke('save_credentials', {credentials, passphrase});
|
||||
if ($appState.currentRequest) {
|
||||
navigate('Approve');
|
||||
@ -47,6 +50,8 @@
|
||||
if (alert) {
|
||||
alert.shake();
|
||||
}
|
||||
|
||||
saving = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -65,7 +70,13 @@
|
||||
<input type="password" placeholder="Passphrase" bind:value="{passphrase}" class="input input-bordered" />
|
||||
<input type="password" placeholder="Re-enter passphrase" bind:value={confirmPassphrase} class="input input-bordered" on:change={confirm} />
|
||||
|
||||
<input type="submit" class="btn btn-primary" />
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{#if saving}
|
||||
<Spinner class="w-5 h-5" color="primary-content" thickness="2px"/>
|
||||
{:else}
|
||||
Submit
|
||||
{/if}
|
||||
</button>
|
||||
<Link target="Home" hotkey="Escape">
|
||||
<button class="btn btn-sm btn-outline w-full">Cancel</button>
|
||||
</Link>
|
||||
|
@ -7,12 +7,14 @@
|
||||
import { getRootCause } from '../lib/errors.js';
|
||||
import ErrorAlert from '../ui/ErrorAlert.svelte';
|
||||
import Link from '../ui/Link.svelte';
|
||||
import Spinner from '../ui/Spinner.svelte';
|
||||
|
||||
|
||||
let errorMsg = null;
|
||||
let alert;
|
||||
let passphrase = '';
|
||||
let loadTime = 0;
|
||||
let saving = false;
|
||||
async function unlock() {
|
||||
// The hotkey for navigating here from homepage is Enter, which also
|
||||
// happens to trigger the form submit event
|
||||
@ -21,6 +23,7 @@
|
||||
}
|
||||
|
||||
try {
|
||||
saving = true;
|
||||
let r = await invoke('unlock', {passphrase});
|
||||
$appState.credentialStatus = 'unlocked';
|
||||
if ($appState.currentRequest) {
|
||||
@ -43,6 +46,8 @@
|
||||
if (alert) {
|
||||
alert.shake();
|
||||
}
|
||||
|
||||
saving = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +67,14 @@
|
||||
<!-- svelte-ignore a11y-autofocus -->
|
||||
<input autofocus name="password" type="password" placeholder="correct horse battery staple" bind:value="{passphrase}" class="input input-bordered" />
|
||||
|
||||
<input type="submit" class="btn btn-primary" />
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{#if saving}
|
||||
<Spinner class="w-5 h-5" color="primary-content" thickness="2px"/>
|
||||
{:else}
|
||||
Submit
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<Link target="Home" hotkey="Escape">
|
||||
<button class="btn btn-outline btn-sm w-full">Cancel</button>
|
||||
</Link>
|
||||
|
Reference in New Issue
Block a user