Skip to content

Commit 018d62d

Browse files
authored
Fix/control panel button issue (#308)
* fix: button * chore: fix control panel storage selection
1 parent 6168f74 commit 018d62d

File tree

7 files changed

+163
-104
lines changed

7 files changed

+163
-104
lines changed

infrastructure/blindvote/src/crypto/pedersen.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,16 @@ function addPoints(arr: any[]) {
286286
* Helper function to compare encodings
287287
*/
288288
function encEq(A: any, B: any) {
289-
return Buffer.from(A.toRawBytes()).equals(Buffer.from(B.toRawBytes()));
289+
const bytesA = A.toRawBytes();
290+
const bytesB = B.toRawBytes();
291+
292+
if (bytesA.length !== bytesB.length) return false;
293+
294+
for (let i = 0; i < bytesA.length; i++) {
295+
if (bytesA[i] !== bytesB[i]) return false;
296+
}
297+
298+
return true;
290299
}
291300

292301
export function verifyFinal(C_aggb: Uint8Array, H_Sb: Uint8Array, M: number): boolean {

infrastructure/control-panel/src/routes/+layout.svelte

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,25 @@
3131
size="sm"
3232
class="whitespace-nowrap"
3333
variant="solid"
34-
callback={() => goto('/monitoring')}>Start Monitoring</ButtonAction
34+
callback={() => {
35+
// Get selected items from the current page
36+
const evaultsData = sessionStorage.getItem('selectedEVaults');
37+
const platformsData = sessionStorage.getItem('selectedPlatforms');
38+
39+
// If no items selected, show alert
40+
if (
41+
(!evaultsData || JSON.parse(evaultsData).length === 0) &&
42+
(!platformsData || JSON.parse(platformsData).length === 0)
43+
) {
44+
alert(
45+
'Please select eVaults and/or platforms first before starting monitoring.'
46+
);
47+
return;
48+
}
49+
50+
// Navigate to monitoring
51+
goto('/monitoring');
52+
}}>Start Monitoring</ButtonAction
3553
>
3654
</div>
3755
{:else}

infrastructure/control-panel/src/routes/+page.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@
6969
} else {
7070
selectedEVaults = selectedEVaults.filter((i) => i !== index);
7171
}
72+
73+
// Store selections immediately in sessionStorage
74+
const selectedEVaultData = selectedEVaults.map((i) => evaults[i]);
75+
sessionStorage.setItem('selectedEVaults', JSON.stringify(selectedEVaultData));
7276
}
7377
7478
// Handle platform selection changes
@@ -78,6 +82,10 @@
7882
} else {
7983
selectedPlatforms = selectedPlatforms.filter((i) => i !== index);
8084
}
85+
86+
// Store selections immediately in sessionStorage
87+
const selectedPlatformData = selectedPlatforms.map((i) => platforms[i]);
88+
sessionStorage.setItem('selectedPlatforms', JSON.stringify(selectedPlatformData));
8189
}
8290
8391
// Navigate to monitoring with selected items

infrastructure/control-panel/src/routes/monitoring/+page.svelte

Lines changed: 104 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,11 @@
4242
selectedPlatforms = JSON.parse(platformsData);
4343
}
4444
45-
// Check if any items are selected, if not redirect back to home
45+
// Check if any items are selected, if not show selection interface
4646
if (
4747
(!selectedEVaults || selectedEVaults.length === 0) &&
4848
(!selectedPlatforms || selectedPlatforms.length === 0)
4949
) {
50-
goto('/');
5150
return;
5251
}
5352
@@ -483,69 +482,77 @@
483482
}
484483
</script>
485484

486-
<section class="flex h-full w-full">
487-
<div class="bg-gray flex h-screen w-screen flex-col">
488-
<div class="z-10 flex w-full items-center justify-between bg-white p-4">
489-
<div>
490-
<h4 class="text-xl font-semibold text-gray-800">Live Monitoring</h4>
491-
<p class="mt-1 text-sm text-gray-600">
492-
Monitoring {selectedEVaults.length} eVault{selectedEVaults.length !== 1
493-
? 's'
494-
: ''} and {selectedPlatforms.length} platform{selectedPlatforms.length !== 1
495-
? 's'
496-
: ''}
497-
</p>
498-
{#if currentFlowStep > 0}
499-
<div class="mt-2 flex items-center gap-2">
500-
<div class="h-3 w-3 animate-pulse rounded-full bg-green-500"></div>
501-
<span class="text-xs font-medium text-green-600">
502-
{currentFlowStep === 1
503-
? 'Platform creating entry locally'
504-
: currentFlowStep === 2
505-
? 'Syncing to eVault'
506-
: currentFlowStep === 3
507-
? 'eVault created metaenvelope'
508-
: currentFlowStep === 4
509-
? 'Awareness Protocol'
510-
: currentFlowStep === 5
511-
? 'All platforms notified'
512-
: 'Complete'}
513-
</span>
514-
</div>
515-
{/if}
516-
</div>
517-
<div class="flex gap-2">
518-
<button
519-
onclick={() => goto('/')}
520-
class="font-geist flex items-center gap-2 rounded-full border border-[#e5e5e5] bg-white px-4 py-2 text-base font-medium text-gray-700 shadow-md transition-colors hover:bg-gray-50"
521-
>
522-
← Back to Control Panel
523-
</button>
524-
<button
525-
onclick={() => (isPaused = !isPaused)}
526-
class="font-geist flex items-center gap-2 rounded-full border border-[#e5e5e5] bg-white px-4 py-2 text-base font-medium text-gray-700 shadow-md transition-colors hover:bg-gray-50"
527-
>
528-
{#if isPaused}
529-
<HugeiconsIcon icon={PlayFreeIcons} size="20px" />
530-
{:else}
531-
<HugeiconsIcon icon={PauseFreeIcons} size="20px" />
485+
{#if (!selectedEVaults || selectedEVaults.length === 0) && (!selectedPlatforms || selectedPlatforms.length === 0)}
486+
<!-- No items selected - show selection interface -->
487+
<div class="flex h-full w-full items-center justify-center">
488+
<div class="text-center">
489+
<h2 class="mb-4 text-2xl font-bold text-gray-900">No Items Selected</h2>
490+
<p class="mb-6 text-gray-600">
491+
Please select eVaults and/or platforms from the home page to start monitoring.
492+
</p>
493+
<button
494+
onclick={() => goto('/')}
495+
class="bg-primary hover:bg-primary-600 rounded-full px-8 py-3 text-lg font-semibold text-white transition-colors"
496+
>
497+
Back to Selection
498+
</button>
499+
</div>
500+
</div>
501+
{:else}
502+
<section class="flex h-full w-full">
503+
<div class="bg-gray flex h-screen w-screen flex-col">
504+
<div class="z-10 flex w-full items-center justify-between bg-white p-4">
505+
<div>
506+
<h4 class="text-xl font-semibold text-gray-800">Live Monitoring</h4>
507+
<p class="mt-1 text-sm text-gray-600">
508+
Monitoring {selectedEVaults.length} eVault{selectedEVaults.length !== 1
509+
? 's'
510+
: ''} and {selectedPlatforms.length} platform{selectedPlatforms.length !==
511+
1
512+
? 's'
513+
: ''}
514+
</p>
515+
{#if currentFlowStep > 0}
516+
<div class="mt-2 flex items-center gap-2">
517+
<div class="h-3 w-3 animate-pulse rounded-full bg-green-500"></div>
518+
<span class="text-xs font-medium text-green-600">
519+
{currentFlowStep === 1
520+
? 'Platform creating entry locally'
521+
: currentFlowStep === 2
522+
? 'Syncing to eVault'
523+
: currentFlowStep === 3
524+
? 'eVault created metaenvelope'
525+
: currentFlowStep === 4
526+
? 'Awareness Protocol'
527+
: currentFlowStep === 5
528+
? 'All platforms notified'
529+
: 'Complete'}
530+
</span>
531+
</div>
532532
{/if}
533-
{isPaused ? 'Resume Live Feed' : 'Pause Live Feed'}
534-
</button>
533+
</div>
534+
<div class="flex gap-2">
535+
<button
536+
onclick={() => goto('/')}
537+
class="font-geist flex items-center gap-2 rounded-full border border-[#e5e5e5] bg-white px-4 py-2 text-base font-medium text-gray-700 shadow-md transition-colors hover:bg-gray-50"
538+
>
539+
← Back to Control Panel
540+
</button>
541+
<button
542+
onclick={() => (isPaused = !isPaused)}
543+
class="font-geist flex items-center gap-2 rounded-full border border-[#e5e5e5] bg-white px-4 py-2 text-base font-medium text-gray-700 shadow-md transition-colors hover:bg-gray-50"
544+
>
545+
{#if isPaused}
546+
<HugeiconsIcon icon={PlayFreeIcons} size="20px" />
547+
{:else}
548+
<HugeiconsIcon icon={PauseFreeIcons} size="20px" />
549+
{/if}
550+
{isPaused ? 'Resume Live Feed' : 'Pause Live Feed'}
551+
</button>
552+
</div>
535553
</div>
536-
</div>
537554

538-
{#if SvelteFlowComponent}
539-
{#if selectedEVaults.length === 0 && selectedPlatforms.length === 0}
540-
<div class="flex flex-grow items-center justify-center">
541-
<div class="text-center">
542-
<h3 class="mb-2 text-xl font-semibold text-gray-700">No Items Selected</h3>
543-
<p class="text-gray-500">
544-
Go back to the main page and select eVaults and platforms to monitor.
545-
</p>
546-
</div>
547-
</div>
548-
{:else}
555+
{#if SvelteFlowComponent}
549556
<div class="flex-grow">
550557
<SvelteFlow
551558
bind:nodes
@@ -583,46 +590,46 @@
583590
</svg>
584591
</SvelteFlow>
585592
</div>
593+
{:else}
594+
<div class="flex flex-grow items-center justify-center text-gray-700">
595+
Loading flow chart...
596+
</div>
586597
{/if}
587-
{:else}
588-
<div class="flex flex-grow items-center justify-center text-gray-700">
589-
Loading flow chart...
590-
</div>
591-
{/if}
592-
</div>
593-
594-
<!-- Flow Messages Panel -->
595-
<div
596-
class="flex h-full w-[40%] cursor-default flex-col bg-white p-4 transition-colors hover:bg-gray-50"
597-
>
598-
<div class="mb-4">
599-
<h3 class="text-lg font-semibold text-gray-800">Data Flow</h3>
600-
<div class="mt-2 text-sm text-gray-600">
601-
Current Step: {currentFlowStep === 0
602-
? 'Waiting for events...'
603-
: currentFlowStep === 1
604-
? 'Platform creating entry locally'
605-
: currentFlowStep === 2
606-
? 'Syncing to eVault'
607-
: currentFlowStep === 3
608-
? 'eVault created metaenvelope'
609-
: currentFlowStep === 4
610-
? 'Awareness Protocol'
611-
: currentFlowStep === 5
612-
? 'All platforms notified'
613-
: 'Complete'}
614-
</div>
615598
</div>
616599

617-
<div class="flex-1 space-y-2 overflow-y-auto">
618-
{#each flowMessages as message, i}
619-
<div class="rounded bg-gray-50 p-2 font-mono text-sm">
620-
{message}
600+
<!-- Flow Messages Panel -->
601+
<div
602+
class="flex h-full w-[40%] cursor-default flex-col bg-white p-4 transition-colors hover:bg-gray-50"
603+
>
604+
<div class="mb-4">
605+
<h3 class="text-lg font-semibold text-gray-800">Data Flow</h3>
606+
<div class="mt-2 text-sm text-gray-600">
607+
Current Step: {currentFlowStep === 0
608+
? 'Waiting for events...'
609+
: currentFlowStep === 1
610+
? 'Platform creating entry locally'
611+
: currentFlowStep === 2
612+
? 'Syncing to eVault'
613+
: currentFlowStep === 3
614+
? 'eVault created metaenvelope'
615+
: currentFlowStep === 4
616+
? 'Awareness Protocol'
617+
: currentFlowStep === 5
618+
? 'All platforms notified'
619+
: 'Complete'}
621620
</div>
622-
{/each}
621+
</div>
622+
623+
<div class="flex-1 space-y-2 overflow-y-auto">
624+
{#each flowMessages as message, i}
625+
<div class="rounded bg-gray-50 p-2 font-mono text-sm">
626+
{message}
627+
</div>
628+
{/each}
629+
</div>
623630
</div>
624-
</div>
625-
</section>
631+
</section>
632+
{/if}
626633

627634
<style>
628635
/*
-15.6 MB
Binary file not shown.

infrastructure/eid-wallet/src/routes/(app)/settings/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
on:click={handleVersionTap}
127127
disabled={isRetrying}
128128
>
129-
Version v0.2.0.1
129+
Version v0.2.0.2
130130
</button>
131131

132132
{#if retryMessage}

infrastructure/eid-wallet/vite.config.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export default defineConfig(async () => ({
1111
tailwindcss(),
1212
sveltekit(),
1313
nodePolyfills({
14-
// Polyfill all Node.js core modules
15-
include: ['buffer', 'crypto', 'stream', 'util'],
14+
// Polyfill specific Node.js core modules
15+
include: ['buffer', 'crypto'],
1616
// Polyfill globals
1717
globals: {
1818
Buffer: true,
@@ -35,13 +35,30 @@ export default defineConfig(async () => ({
3535

3636
// Handle workspace dependencies
3737
optimizeDeps: {
38-
include: ['blindvote']
38+
include: ['blindvote'],
39+
esbuildOptions: {
40+
// Node.js global to ES global conversion
41+
define: {
42+
global: 'globalThis',
43+
},
44+
},
3945
},
4046

4147
// Handle Node.js modules in browser environment
4248
resolve: {
4349
alias: {
44-
'noble-secp256k1': 'noble-secp256k1'
50+
'noble-secp256k1': 'noble-secp256k1',
51+
'blindvote': '../blindvote/src/index.ts'
52+
}
53+
},
54+
55+
// Build configuration
56+
build: {
57+
rollupOptions: {
58+
external: [],
59+
},
60+
commonjsOptions: {
61+
include: [/blindvote/, /node_modules/]
4562
}
4663
},
4764

0 commit comments

Comments
 (0)