From a9f3ff803789d4a238bab2ba4c30d5eeb883250d Mon Sep 17 00:00:00 2001 From: NicolasCantu Date: Thu, 23 Oct 2025 21:16:15 +0200 Subject: [PATCH] Display existing processes in status field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Motivations :** - User wants to see each retrieved process displayed as a message in the status field - Need to show process information after authentication or initialization **Modifications :** - Added displayExistingProcesses() function to fetch and display processes - Modified handleMainPairing() to call displayExistingProcesses() after authentication - Modified initHomePage() to display processes even if authentication fails - Each process shows: ID (truncated), states count, members count, last update - Processes displayed in scrollable container with styled cards **Pages affectΓ©es :** - src/pages/home/home.ts --- src/pages/home/home.ts | 70 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/src/pages/home/home.ts b/src/pages/home/home.ts index 715c57f..2ada4b5 100755 --- a/src/pages/home/home.ts +++ b/src/pages/home/home.ts @@ -153,6 +153,10 @@ export async function initHomePage(): Promise { console.log('πŸ” Auto-triggering WebAuthn authentication...'); await handleMainPairing(); + // Display existing processes even if authentication fails + console.log('πŸ“Š Displaying existing processes...'); + await displayExistingProcesses(); + // Hide loading spinner after initialization console.log('πŸ”§ Hiding loading spinner...'); hideHomeLoadingSpinner(); @@ -581,15 +585,79 @@ async function handleMainPairing(): Promise { // Now proceed with pairing process await prepareAndSendPairingTx(); + // Display any existing processes in the status field + await displayExistingProcesses(); + } catch (error) { console.error('Pairing failed:', error); - + if (mainStatus) { mainStatus.innerHTML = '❌ Authentication failed'; } } } +// Display existing processes in the status field +async function displayExistingProcesses(): Promise { + try { + const service = await Services.getInstance(); + const processes = await service.getProcesses(); + + const container = getCorrectDOM('login-4nk-component') as HTMLElement; + const mainStatus = container.querySelector('#main-status') as HTMLElement; + + if (!mainStatus) { + console.warn('Main status element not found'); + return; + } + + const processCount = Object.keys(processes).length; + console.log(`πŸ“Š Found ${processCount} existing processes`); + + if (processCount === 0) { + if (mainStatus) { + mainStatus.innerHTML = 'πŸ“‹ No existing processes found'; + } + return; + } + + // Create a list of processes to display + let processesHtml = `
+

πŸ“‹ Existing Processes (${processCount})

`; + + for (const [processId, process] of Object.entries(processes)) { + const processInfo = { + id: processId.substring(0, 8) + '...', + states: process.states?.length || 0, + members: Object.keys(process.members || {}).length, + lastUpdate: process.last_update || 'Unknown' + }; + + processesHtml += ` +
+ Process: ${processInfo.id}
+ + States: ${processInfo.states} | Members: ${processInfo.members} | Updated: ${processInfo.lastUpdate} + +
`; + } + + processesHtml += '
'; + + if (mainStatus) { + mainStatus.innerHTML = processesHtml; + } + + } catch (error) { + console.error('❌ Error displaying processes:', error); + const container = getCorrectDOM('login-4nk-component') as HTMLElement; + const mainStatus = container.querySelector('#main-status') as HTMLElement; + if (mainStatus) { + mainStatus.innerHTML = '❌ Error loading processes'; + } + } +} + // Account Actions export function setupAccountActions(): void { const container = getCorrectDOM('login-4nk-component') as HTMLElement;