diff --git a/src/pages/block-sync/block-sync.ts b/src/pages/block-sync/block-sync.ts
index c9f725c..2be1683 100644
--- a/src/pages/block-sync/block-sync.ts
+++ b/src/pages/block-sync/block-sync.ts
@@ -107,10 +107,10 @@ document.addEventListener("DOMContentLoaded", async () => {
if (currentBlockHeight === -1) {
console.log('⚠️ Block height not available, connecting to relays...');
updateStatus('⚠️ Connexion aux relays...', 'loading');
-
+
// Attendre que les services se connectent aux relays
await services.connectAllRelays();
-
+
// Attendre que la hauteur de bloc soit définie
await services.waitForBlockHeight();
}
@@ -133,13 +133,13 @@ document.addEventListener("DOMContentLoaded", async () => {
updateSyncItem('blocksToScan', '0', 'completed');
updateSyncItem('blocksScanned', '0', 'completed');
updateSyncItem('transactionsFound', '0', 'completed');
-
+
// Activer le bouton et rediriger automatiquement
if (continueBtn) {
continueBtn.disabled = false;
continueBtn.textContent = 'Aller au pairing';
}
-
+
// Auto-redirection après 3 secondes
setTimeout(() => {
console.log('🔗 Auto-redirecting to pairing page...');
@@ -168,15 +168,15 @@ document.addEventListener("DOMContentLoaded", async () => {
const currentBlock = parseInt(progressMatch[1]);
const totalBlocks = parseInt(progressMatch[2]);
const percentage = parseInt(progressMatch[3]);
-
+
// Mettre à jour l'interface avec les détails de progression
updateStatus(`🔍 Synchronisation des blocs: ${currentBlock}/${totalBlocks} (${percentage}%)`, 'loading');
updateProgress(percentage);
-
+
// Mettre à jour les éléments de synchronisation
updateSyncItem('blocksScanned', currentBlock.toString(), 'pending');
updateSyncItem('blocksToScan', (totalBlocks - currentBlock).toString(), 'pending');
-
+
lastProgressMessage = `Bloc ${currentBlock}/${totalBlocks} (${percentage}%)`;
}
}
@@ -188,28 +188,28 @@ document.addEventListener("DOMContentLoaded", async () => {
// Effectuer la synchronisation
await services.updateDeviceBlockHeight();
console.log('✅ Block scan completed successfully');
-
+
// Restaurer la fonction console.log originale
console.log = originalConsoleLog;
-
+
updateStatus('✅ Synchronisation terminée', 'success');
updateProgress(100);
updateSyncItem('blocksScanned', toScan.toString(), 'completed');
updateSyncItem('blocksToScan', '0', 'completed');
updateSyncItem('transactionsFound', '0', 'completed');
-
+
// Activer le bouton et rediriger automatiquement
if (continueBtn) {
continueBtn.disabled = false;
continueBtn.textContent = 'Aller au pairing';
}
-
+
// Auto-redirection après 3 secondes
setTimeout(() => {
console.log('🔗 Auto-redirecting to pairing page...');
window.location.href = '/src/pages/pairing/pairing.html';
}, 3000);
-
+
} catch (error) {
// Restaurer la fonction console.log originale en cas d'erreur
console.log = originalConsoleLog;
@@ -222,7 +222,7 @@ document.addEventListener("DOMContentLoaded", async () => {
} catch (error) {
console.error('❌ Error in block sync page:', error);
updateStatus(`❌ Erreur: ${(error as Error).message}`, 'error');
-
+
// Rediriger vers la page appropriée selon l'erreur
const errorMessage = (error as Error).message;
if (errorMessage.includes('PBKDF2') || errorMessage.includes('security')) {
diff --git a/src/templates/page-template.html b/src/templates/page-template.html
deleted file mode 100644
index d85d8eb..0000000
--- a/src/templates/page-template.html
+++ /dev/null
@@ -1,199 +0,0 @@
-
-
-
-
-
- {{PAGE_TITLE}} - LeCoffre
-
-
-
-
-
-
{{PAGE_ICON}} {{PAGE_TITLE}}
-
{{PAGE_SUBTITLE}}
-
-
- {{INITIAL_STATUS}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/utils/page-template.utils.ts b/src/utils/page-template.utils.ts
deleted file mode 100644
index c93fe00..0000000
--- a/src/utils/page-template.utils.ts
+++ /dev/null
@@ -1,211 +0,0 @@
-/**
- * Utilitaire pour gérer le template standardisé des pages
- */
-export class PageTemplate {
- private container: HTMLElement;
- private status: HTMLElement;
- private progressContainer: HTMLElement;
- private progressFill: HTMLElement;
- private stepsContainer: HTMLElement;
- private contentArea: HTMLElement;
- private continueBtn: HTMLButtonElement;
-
- constructor() {
- this.container = document.querySelector('.container') as HTMLElement;
- this.status = document.getElementById('status') as HTMLElement;
- this.progressContainer = document.getElementById('progressContainer') as HTMLElement;
- this.progressFill = document.getElementById('progressFill') as HTMLElement;
- this.stepsContainer = document.getElementById('stepsContainer') as HTMLElement;
- this.contentArea = document.getElementById('contentArea') as HTMLElement;
- this.continueBtn = document.getElementById('continueBtn') as HTMLButtonElement;
- }
-
- /**
- * Met à jour le statut de la page
- */
- updateStatus(message: string, type: 'loading' | 'success' | 'error' = 'loading'): void {
- if (this.status) {
- this.status.textContent = message;
- this.status.className = `status ${type}`;
- }
- }
-
- /**
- * Cache le statut de la page
- */
- hideStatus(): void {
- if (this.status) {
- this.status.style.display = 'none';
- }
- }
-
- /**
- * Affiche la barre de progression
- */
- showProgress(): void {
- if (this.progressContainer) {
- this.progressContainer.style.display = 'block';
- }
- }
-
- /**
- * Cache la barre de progression
- */
- hideProgress(): void {
- if (this.progressContainer) {
- this.progressContainer.style.display = 'none';
- }
- }
-
- /**
- * Met à jour le pourcentage de progression
- */
- updateProgress(percentage: number): void {
- if (this.progressFill) {
- this.progressFill.style.width = `${Math.min(100, Math.max(0, percentage))}%`;
- }
- }
-
- /**
- * Affiche les étapes
- */
- showSteps(): void {
- if (this.stepsContainer) {
- this.stepsContainer.style.display = 'block';
- }
- }
-
- /**
- * Cache les étapes
- */
- hideSteps(): void {
- if (this.stepsContainer) {
- this.stepsContainer.style.display = 'none';
- }
- }
-
- /**
- * Met à jour une étape
- */
- updateStep(stepId: string, value: string, status: 'pending' | 'completed' | 'error' = 'pending'): void {
- let stepElement = document.getElementById(stepId);
- if (!stepElement) {
- stepElement = document.createElement('div');
- stepElement.id = stepId;
- stepElement.className = 'step-item';
- this.stepsContainer.appendChild(stepElement);
- }
-
- stepElement.innerHTML = `
- ${this.getStepLabel(stepId)}
- ${value}
- ${this.getStatusText(status)}
- `;
- }
-
- /**
- * Affiche le bouton continuer
- */
- showContinueButton(text: string = 'Continuer', onClick?: () => void): void {
- if (this.continueBtn) {
- this.continueBtn.textContent = text;
- this.continueBtn.style.display = 'block';
- this.continueBtn.disabled = false;
-
- if (onClick) {
- this.continueBtn.onclick = onClick;
- }
- }
- }
-
- /**
- * Cache le bouton continuer
- */
- hideContinueButton(): void {
- if (this.continueBtn) {
- this.continueBtn.style.display = 'none';
- }
- }
-
- /**
- * Désactive le bouton continuer
- */
- disableContinueButton(): void {
- if (this.continueBtn) {
- this.continueBtn.disabled = true;
- }
- }
-
- /**
- * Active le bouton continuer
- */
- enableContinueButton(): void {
- if (this.continueBtn) {
- this.continueBtn.disabled = false;
- }
- }
-
- /**
- * Injecte du contenu dans la zone de contenu
- */
- setContent(html: string): void {
- if (this.contentArea) {
- this.contentArea.innerHTML = html;
- }
- }
-
- /**
- * Ajoute du contenu à la zone de contenu
- */
- addContent(html: string): void {
- if (this.contentArea) {
- this.contentArea.innerHTML += html;
- }
- }
-
- /**
- * Vide la zone de contenu
- */
- clearContent(): void {
- if (this.contentArea) {
- this.contentArea.innerHTML = '';
- }
- }
-
- /**
- * Obtient le label d'une étape
- */
- private getStepLabel(stepId: string): string {
- const labels: Record = {
- 'currentBlock': 'Bloc actuel',
- 'birthday': 'Date anniversaire',
- 'blocksToScan': 'Blocs à scanner',
- 'blocksScanned': 'Blocs scannés',
- 'lastScan': 'Dernier scan',
- 'syncStatus': 'Statut de synchronisation',
- 'walletStatus': 'Statut du wallet',
- 'credentialsStatus': 'Statut des credentials',
- 'pairingStatus': 'Statut du pairing'
- };
- return labels[stepId] || stepId;
- }
-
- /**
- * Obtient le texte du statut
- */
- private getStatusText(status: 'pending' | 'completed' | 'error'): string {
- const texts: Record = {
- 'pending': 'En cours',
- 'completed': 'Terminé',
- 'error': 'Erreur'
- };
- return texts[status] || status;
- }
-}
-
-/**
- * Fonction utilitaire pour créer une instance de PageTemplate
- */
-export function createPageTemplate(): PageTemplate {
- return new PageTemplate();
-}