fix(ihm_client): favicon via chemin relatif /favicon.svg pour HTTPS
All checks were successful
Build and Push Docker image (ext) / docker (push) Successful in 51s

This commit is contained in:
4NK CI Bot 2025-09-18 16:26:06 +00:00
parent a40416a248
commit a6f54dc8f5
5 changed files with 91 additions and 91 deletions

View File

@ -9,6 +9,7 @@
<link rel="stylesheet" href="./style/4nk.css"> <link rel="stylesheet" href="./style/4nk.css">
<script src="https://unpkg.com/html5-qrcode"></script> <script src="https://unpkg.com/html5-qrcode"></script>
<title>4NK Application</title> <title>4NK Application</title>
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
</head> </head>
<body> <body>
<div id="header-container"></div> <div id="header-container"></div>

View File

@ -29,8 +29,8 @@ export interface TransactionInfo {
txid: string; txid: string;
version: number; version: number;
locktime: number; locktime: number;
vin: Vin[]; vin: Vin[];
vout: any[]; vout: any[];
size: number; size: number;
weight: number; weight: number;
fee: number; fee: number;
@ -63,7 +63,7 @@ export function getDocumentValidation(container: HTMLElement) {
function createDropButton( function createDropButton(
label: string, label: string,
onDrop: (file: File, updateVisuals: (file: File) => void) => void, onDrop: (file: File, updateVisuals: (file: File) => void) => void,
accept: string = '*/*' accept: string = '*/*'
): HTMLElement { ): HTMLElement {
const wrapper = document.createElement('div'); const wrapper = document.createElement('div');
wrapper.style.cssText = ` wrapper.style.cssText = `
@ -161,7 +161,7 @@ export function getDocumentValidation(container: HTMLElement) {
const certDropButton = createDropButton('Drop certificate', async (file, updateVisuals) => { const certDropButton = createDropButton('Drop certificate', async (file, updateVisuals) => {
try { try {
const text = await file.text(); const text = await file.text();
const json = JSON.parse(text); const json = JSON.parse(text);
if ( if (
typeof json === 'object' && typeof json === 'object' &&
@ -257,7 +257,7 @@ export function getDocumentValidation(container: HTMLElement) {
} else { } else {
continue; continue;
} }
if (vout.scriptpubkey_asm) { if (vout.scriptpubkey_asm) {
const hash = extractHexFromScriptAsm(vout.scriptpubkey_asm); const hash = extractHexFromScriptAsm(vout.scriptpubkey_asm);
if (hash) { if (hash) {
@ -279,7 +279,7 @@ export function getDocumentValidation(container: HTMLElement) {
found = false; found = false;
for (const label of Object.keys(state.certificate.pcd_commitment)) { for (const label of Object.keys(state.certificate.pcd_commitment)) {
// Compute the hash for this label // Compute the hash for this label
console.log(`Computing hash with label ${label}`) console.log(`Computing hash with label ${label}`)
const fileHex = service.getHashForFile(commitedIn, label, fileBlob); const fileHex = service.getHashForFile(commitedIn, label, fileBlob);
console.log(`Found hash ${fileHex}`); console.log(`Found hash ${fileHex}`);

View File

@ -36,10 +36,10 @@ export function createKeyValueSection(title: string, id: string, isRoleSection =
type: string, type: string,
data: Uint8Array data: Uint8Array
}; };
const nonRoleRowStates: { const nonRoleRowStates: {
keyInput: HTMLInputElement, keyInput: HTMLInputElement,
valueInput: HTMLInputElement, valueInput: HTMLInputElement,
fileInput: HTMLInputElement, fileInput: HTMLInputElement,
fileBlob: fileBlob | null fileBlob: fileBlob | null
}[] = []; }[] = [];
@ -102,7 +102,7 @@ export function createKeyValueSection(title: string, id: string, isRoleSection =
rowState.fileBlob = { rowState.fileBlob = {
type: file.type, type: file.type,
data: uint8, data: uint8,
}; };
valueInput.value = `📄 ${file.name}`; valueInput.value = `📄 ${file.name}`;
@ -184,7 +184,7 @@ export function createKeyValueSection(title: string, id: string, isRoleSection =
const key = row.keyInput.value.trim(); const key = row.keyInput.value.trim();
if (!key) continue; if (!key) continue;
if (row.fileBlob) { if (row.fileBlob) {
data[key] = row.fileBlob; data[key] = row.fileBlob;
} else { } else {
data[key] = row.valueInput.value.trim(); data[key] = row.valueInput.value.trim();
} }

View File

@ -45,15 +45,15 @@ class ChatElement extends HTMLElement {
private allMembers = membersMock.map(member => ({ private allMembers = membersMock.map(member => ({
id: member.id, id: member.id,
name: member.name, name: member.name,
roleName: 'Default Role' roleName: 'Default Role'
})); }));
private messageState: number = 0; private messageState: number = 0;
private selectedRole: string | null = null; private selectedRole: string | null = null;
private dmMembersSet: Set<string> = new Set(); private dmMembersSet: Set<string> = new Set();
private addressMap: Record<string, string> = {}; private addressMap: Record<string, string> = {};
private isLoading = false; private isLoading = false;
constructor() { constructor() {
super(); super();
this.attachShadow({ mode: 'open' }); this.attachShadow({ mode: 'open' });
@ -144,12 +144,12 @@ class ChatElement extends HTMLElement {
this.notificationBadge = document.querySelector('.notification-badge'); this.notificationBadge = document.querySelector('.notification-badge');
this.notificationBoard = document.getElementById('notification-board'); this.notificationBoard = document.getElementById('notification-board');
this.notificationBell = document.getElementById('notification-bell'); this.notificationBell = document.getElementById('notification-bell');
if (!this.notificationBadge || !this.notificationBoard || !this.notificationBell) { if (!this.notificationBadge || !this.notificationBoard || !this.notificationBell) {
console.error('Notification elements not found'); console.error('Notification elements not found');
} }
}); });
// Initialiser les événements de notification // Initialiser les événements de notification
document.addEventListener('click', (event: Event): void => { document.addEventListener('click', (event: Event): void => {
if (this.notificationBoard && this.notificationBoard.style.display === 'block' && if (this.notificationBoard && this.notificationBoard.style.display === 'block' &&
@ -206,16 +206,16 @@ class ChatElement extends HTMLElement {
// Show notifications // Show notifications
private renderNotifications() { private renderNotifications() {
if (!this.notificationBoard) return; if (!this.notificationBoard) return;
// Reset the interface // Reset the interface
this.notificationBoard.innerHTML = ''; this.notificationBoard.innerHTML = '';
// Displays "No notifications available" if there are no notifications // Displays "No notifications available" if there are no notifications
if (this.notifications.length === 0) { if (this.notifications.length === 0) {
this.notificationBoard.innerHTML = '<div class="no-notification">No notifications available</div>'; this.notificationBoard.innerHTML = '<div class="no-notification">No notifications available</div>';
return; return;
} }
// Add each notification to the list // Add each notification to the list
this.notifications.forEach((notif, index) => { this.notifications.forEach((notif, index) => {
const notifElement = document.createElement('div'); const notifElement = document.createElement('div');
@ -234,7 +234,7 @@ class ChatElement extends HTMLElement {
this.notificationBadge.textContent = count > 99 ? '+99' : count.toString(); this.notificationBadge.textContent = count > 99 ? '+99' : count.toString();
(this.notificationBadge as HTMLElement).style.display = count > 0 ? 'block' : 'none'; (this.notificationBadge as HTMLElement).style.display = count > 0 ? 'block' : 'none';
} }
// Add notification // Add notification
private async addNotification(memberId: string, message: any) { private async addNotification(memberId: string, message: any) {
@ -242,11 +242,11 @@ class ChatElement extends HTMLElement {
// Obtenir l'emoji à partir du Pairing Process // Obtenir l'emoji à partir du Pairing Process
const pairingProcess = await this.getPairingProcess(memberId); const pairingProcess = await this.getPairingProcess(memberId);
const memberEmoji = await addressToEmoji(pairingProcess); const memberEmoji = await addressToEmoji(pairingProcess);
// Obtenir le processus et le rôle // Obtenir le processus et le rôle
const processId = this.getAttribute('process-id'); const processId = this.getAttribute('process-id');
const processEmoji = processId ? await addressToEmoji(processId) : '📝'; const processEmoji = processId ? await addressToEmoji(processId) : '📝';
// Trouver le rôle du membre // Trouver le rôle du membre
const member = this.allMembers.find(m => String(m.id) === memberId); const member = this.allMembers.find(m => String(m.id) === memberId);
const role = message.metadata?.roleName || 'Member'; const role = message.metadata?.roleName || 'Member';
@ -270,7 +270,7 @@ class ChatElement extends HTMLElement {
this.notifications.push(notification); this.notifications.push(notification);
this.renderNotifications(); this.renderNotifications();
this.updateNotificationBadge(); this.updateNotificationBadge();
} catch (error) { } catch (error) {
console.error('Error creating notification:', error); console.error('Error creating notification:', error);
} }
@ -287,7 +287,7 @@ class ChatElement extends HTMLElement {
console.error('no process id set'); console.error('no process id set');
return; return;
} }
const messageText = messageInput.value.trim(); const messageText = messageInput.value.trim();
if (messageText === '') { if (messageText === '') {
console.error('❌ Empty message'); console.error('❌ Empty message');
@ -353,13 +353,13 @@ class ChatElement extends HTMLElement {
await service.handleApiReturn(approveChangeReturn); await service.handleApiReturn(approveChangeReturn);
await this.lookForMyDms(); await this.lookForMyDms();
const groupList = this.shadowRoot?.querySelector('#group-list'); const groupList = this.shadowRoot?.querySelector('#group-list');
const tabs = this.shadowRoot?.querySelectorAll('.tab'); const tabs = this.shadowRoot?.querySelectorAll('.tab');
const memberList = groupList?.querySelector('.member-list'); const memberList = groupList?.querySelector('.member-list');
if (memberList) { if (memberList) {
memberList.innerHTML = ''; memberList.innerHTML = '';
await this.loadAllMembers(); await this.loadAllMembers();
if (tabs) { if (tabs) {
await this.switchTab('members', tabs); await this.switchTab('members', tabs);
@ -385,7 +385,7 @@ class ChatElement extends HTMLElement {
} }
} }
// TODO rewrite that // TODO rewrite that
// private async lookForChildren(): Promise<string | null> { // private async lookForChildren(): Promise<string | null> {
// // Filter processes for the children of current process // // Filter processes for the children of current process
// const service = await Services.getInstance(); // const service = await Services.getInstance();
@ -478,8 +478,8 @@ class ChatElement extends HTMLElement {
const publicMemberData = service.getPublicData(process); const publicMemberData = service.getPublicData(process);
if (publicMemberData) { if (publicMemberData) {
const extractedName = publicMemberData['memberPublicName']; const extractedName = publicMemberData['memberPublicName'];
if (extractedName !== undefined && extractedName !== null) { if (extractedName !== undefined && extractedName !== null) {
memberPublicName = extractedName; memberPublicName = extractedName;
} }
} }
} }
@ -577,9 +577,9 @@ class ChatElement extends HTMLElement {
const processes = await service.getMyProcesses(); const processes = await service.getMyProcesses();
const myAddresses = await service.getMemberFromDevice(); const myAddresses = await service.getMemberFromDevice();
const allMembers = await service.getAllMembers(); const allMembers = await service.getAllMembers();
this.dmMembersSet.clear(); this.dmMembersSet.clear();
try { try {
for (const processId of processes) { for (const processId of processes) {
const process = await service.getProcess(processId); const process = await service.getProcess(processId);
@ -591,7 +591,7 @@ class ChatElement extends HTMLElement {
const roles = service.getRoles(process); const roles = service.getRoles(process);
const members = roles.dm.members; const members = roles.dm.members;
for (const member of members) {; for (const member of members) {;
if (!service.compareMembers(member.sp_addresses, myAddresses)) { if (!service.compareMembers(member.sp_addresses, myAddresses)) {
for (const [id, mem] of Object.entries(allMembers)) { for (const [id, mem] of Object.entries(allMembers)) {
if (service.compareMembers(mem.sp_addresses, member.sp_addresses)) { if (service.compareMembers(mem.sp_addresses, member.sp_addresses)) {
this.dmMembersSet.add(id); this.dmMembersSet.add(id);
@ -607,7 +607,7 @@ class ChatElement extends HTMLElement {
console.log("dmMembersSet:", this.dmMembersSet); console.log("dmMembersSet:", this.dmMembersSet);
return null; return null;
} }
private async loadMemberChat(pairingProcess: string) { private async loadMemberChat(pairingProcess: string) {
if (this.isLoading) { if (this.isLoading) {
console.log('Already loading messages, skipping...'); console.log('Already loading messages, skipping...');
@ -629,14 +629,14 @@ class ChatElement extends HTMLElement {
// Set the selected member // Set the selected member
this.selectedMember = pairingProcess; this.selectedMember = pairingProcess;
console.log("SELECTED MEMBER: ", this.selectedMember); console.log("SELECTED MEMBER: ", this.selectedMember);
const chatHeader = this.shadowRoot?.querySelector('#chat-header'); const chatHeader = this.shadowRoot?.querySelector('#chat-header');
const messagesContainer = this.shadowRoot?.querySelector('#messages'); const messagesContainer = this.shadowRoot?.querySelector('#messages');
if (!chatHeader || !messagesContainer) return; if (!chatHeader || !messagesContainer) return;
messagesContainer.innerHTML = ''; messagesContainer.innerHTML = '';
const emojis = await addressToEmoji(pairingProcess); const emojis = await addressToEmoji(pairingProcess);
const transaction = db.transaction("labels", "readonly"); const transaction = db.transaction("labels", "readonly");
@ -647,7 +647,7 @@ class ChatElement extends HTMLElement {
const label = request.result; const label = request.result;
chatHeader.textContent = label ? `Chat with ${label.label} (${emojis})` : `Chat with member (${emojis})`; chatHeader.textContent = label ? `Chat with ${label.label} (${emojis})` : `Chat with member (${emojis})`;
}; };
request.onerror = () => { request.onerror = () => {
chatHeader.textContent = `Chat with member (${emojis})`; chatHeader.textContent = `Chat with member (${emojis})`;
}; };
@ -717,18 +717,18 @@ class ChatElement extends HTMLElement {
messageElement.className = 'message-container'; messageElement.className = 'message-container';
const myProcessId = await this.getMyProcessId(); const myProcessId = await this.getMyProcessId();
const isCurrentUser = message.metadata.sender === myProcessId; const isCurrentUser = message.metadata.sender === myProcessId;
messageElement.style.justifyContent = isCurrentUser ? 'flex-end' : 'flex-start'; messageElement.style.justifyContent = isCurrentUser ? 'flex-end' : 'flex-start';
const messageContent = document.createElement('div'); const messageContent = document.createElement('div');
messageContent.className = isCurrentUser ? 'message user' : 'message'; messageContent.className = isCurrentUser ? 'message user' : 'message';
const myEmoji = await addressToEmoji(myProcessId); const myEmoji = await addressToEmoji(myProcessId);
const otherEmoji = await addressToEmoji(this.selectedMember); const otherEmoji = await addressToEmoji(this.selectedMember);
const senderEmoji = isCurrentUser ? myEmoji : otherEmoji; const senderEmoji = isCurrentUser ? myEmoji : otherEmoji;
if (message.type === 'file') { if (message.type === 'file') {
let fileContent = ''; let fileContent = '';
if (message.content.type.startsWith('image/')) { if (message.content.type.startsWith('image/')) {
@ -748,7 +748,7 @@ class ChatElement extends HTMLElement {
</div> </div>
`; `;
} }
messageContent.innerHTML = ` messageContent.innerHTML = `
<div class="message-content"> <div class="message-content">
<strong>${senderEmoji}</strong>: ${fileContent} <strong>${senderEmoji}</strong>: ${fileContent}
@ -767,11 +767,11 @@ class ChatElement extends HTMLElement {
</div> </div>
`; `;
} }
messageElement.appendChild(messageContent); messageElement.appendChild(messageContent);
messagesContainer.appendChild(messageElement); messagesContainer.appendChild(messageElement);
} }
this.scrollToBottom(messagesContainer); this.scrollToBottom(messagesContainer);
} else { } else {
console.log('No messages found'); console.log('No messages found');
@ -789,16 +789,16 @@ class ChatElement extends HTMLElement {
const service = await Services.getInstance(); const service = await Services.getInstance();
const database = await Database.getInstance(); const database = await Database.getInstance();
const db = database.db; const db = database.db;
const chatHeader = this.shadowRoot?.querySelector('#chat-header'); const chatHeader = this.shadowRoot?.querySelector('#chat-header');
const messagesContainer = this.shadowRoot?.querySelector('#messages'); const messagesContainer = this.shadowRoot?.querySelector('#messages');
if (!chatHeader || !messagesContainer) return; if (!chatHeader || !messagesContainer) return;
messagesContainer.innerHTML = ''; messagesContainer.innerHTML = '';
const emojis = await addressToEmoji(pairingProcess); const emojis = await addressToEmoji(pairingProcess);
const transaction = db.transaction("labels", "readonly"); const transaction = db.transaction("labels", "readonly");
const store = transaction.objectStore("labels"); const store = transaction.objectStore("labels");
const request = store.get(emojis); const request = store.get(emojis);
@ -808,9 +808,9 @@ class ChatElement extends HTMLElement {
if (this.selectedMember === pairingProcess) { if (this.selectedMember === pairingProcess) {
chatHeader.textContent = label ? `Chat with ${label.label} (${emojis})` : `Chat with member (${emojis})`; chatHeader.textContent = label ? `Chat with ${label.label} (${emojis})` : `Chat with member (${emojis})`;
} }
}; };
request.onerror = () => { request.onerror = () => {
chatHeader.textContent = `Chat with member (${emojis})`; chatHeader.textContent = `Chat with member (${emojis})`;
}; };
@ -844,20 +844,20 @@ class ChatElement extends HTMLElement {
messageElement.className = 'message-container'; messageElement.className = 'message-container';
const myProcessId = await this.getMyProcessId(); const myProcessId = await this.getMyProcessId();
const isCurrentUser = message.metadata.sender === myProcessId; const isCurrentUser = message.metadata.sender === myProcessId;
messageElement.style.justifyContent = isCurrentUser ? 'flex-end' : 'flex-start'; messageElement.style.justifyContent = isCurrentUser ? 'flex-end' : 'flex-start';
const messageContent = document.createElement('div'); const messageContent = document.createElement('div');
messageContent.className = isCurrentUser ? 'message user' : 'message'; messageContent.className = isCurrentUser ? 'message user' : 'message';
const myEmoji = await addressToEmoji(myProcessId); const myEmoji = await addressToEmoji(myProcessId);
const otherEmoji = await addressToEmoji(this.selectedMember); const otherEmoji = await addressToEmoji(this.selectedMember);
const senderEmoji = isCurrentUser ? myEmoji : otherEmoji; const senderEmoji = isCurrentUser ? myEmoji : otherEmoji;
if (message.type === 'file') { if (message.type === 'file') {
let fileContent = ''; let fileContent = '';
if (message.content.type.startsWith('image/')) { if (message.content.type.startsWith('image/')) {
@ -877,7 +877,7 @@ class ChatElement extends HTMLElement {
</div> </div>
`; `;
} }
messageContent.innerHTML = ` messageContent.innerHTML = `
<div class="message-content"> <div class="message-content">
<strong>${senderEmoji}</strong>: ${fileContent} <strong>${senderEmoji}</strong>: ${fileContent}
@ -896,11 +896,11 @@ class ChatElement extends HTMLElement {
</div> </div>
`; `;
} }
messageElement.appendChild(messageContent); messageElement.appendChild(messageContent);
messagesContainer.appendChild(messageElement); messagesContainer.appendChild(messageElement);
} }
this.scrollToBottom(messagesContainer); this.scrollToBottom(messagesContainer);
} else { } else {
console.log('No messages found'); console.log('No messages found');
@ -918,7 +918,7 @@ class ChatElement extends HTMLElement {
for (let offset = 0; offset < byteCharacters.length; offset += 512) { for (let offset = 0; offset < byteCharacters.length; offset += 512) {
const slice = byteCharacters.slice(offset, offset + 512); const slice = byteCharacters.slice(offset, offset + 512);
const byteNumbers = new Array(slice.length); const byteNumbers = new Array(slice.length);
for (let i = 0; i < slice.length; i++) { for (let i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i); byteNumbers[i] = slice.charCodeAt(i);
} }
@ -934,9 +934,9 @@ class ChatElement extends HTMLElement {
async getAddressMap() { async getAddressMap() {
const service = await Services.getInstance(); const service = await Services.getInstance();
const allMembers = await service.getAllMembers(); const allMembers = await service.getAllMembers();
const addressMap: Record<string, string> = {}; const addressMap: Record<string, string> = {};
for (const [key, values] of Object.entries(allMembers)) { for (const [key, values] of Object.entries(allMembers)) {
if (values.sp_addresses) { if (values.sp_addresses) {
@ -955,9 +955,9 @@ class ChatElement extends HTMLElement {
const service = await Services.getInstance(); const service = await Services.getInstance();
const allMembers = await service.getAllMembers(); const allMembers = await service.getAllMembers();
console.log('Available members:', allMembers); console.log('Available members:', allMembers);
const sortedAddresses = [...addresses].sort(); const sortedAddresses = [...addresses].sort();
for (const [key, value] of Object.entries(allMembers)) { for (const [key, value] of Object.entries(allMembers)) {
if (value.sp_addresses.length === sortedAddresses.length) { if (value.sp_addresses.length === sortedAddresses.length) {
const sortedValue = [...value.sp_addresses].sort(); const sortedValue = [...value.sp_addresses].sort();
@ -966,7 +966,7 @@ class ChatElement extends HTMLElement {
} }
} }
} }
return null; // No match found return null; // No match found
} }
@ -974,10 +974,10 @@ class ChatElement extends HTMLElement {
console.log('Toggle members called with roleData:', roleData); console.log('Toggle members called with roleData:', roleData);
let memberList = roleElement.querySelector('.member-list'); let memberList = roleElement.querySelector('.member-list');
const roleName = roleElement.querySelector('.role-name')?.textContent || ''; const roleName = roleElement.querySelector('.role-name')?.textContent || '';
if (memberList) { if (memberList) {
console.log('Existing memberList found, toggling display'); console.log('Existing memberList found, toggling display');
(memberList as HTMLElement).style.display = (memberList as HTMLElement).style.display =
(memberList as HTMLElement).style.display === 'none' ? 'block' : 'none'; (memberList as HTMLElement).style.display === 'none' ? 'block' : 'none';
return; return;
} }
@ -992,7 +992,7 @@ class ChatElement extends HTMLElement {
console.log('Processing member:', member); console.log('Processing member:', member);
const memberItem = document.createElement('li'); const memberItem = document.createElement('li');
memberItem.className = 'member-item'; memberItem.className = 'member-item';
const memberContainer = document.createElement('div'); const memberContainer = document.createElement('div');
memberContainer.className = 'member-container'; memberContainer.className = 'member-container';
@ -1016,7 +1016,7 @@ class ChatElement extends HTMLElement {
memberItem.onclick = async (event) => { memberItem.onclick = async (event) => {
event.stopPropagation(); event.stopPropagation();
try { try {
if (pairingProcess) { if (pairingProcess) {
await this.loadMemberChat(pairingProcess); await this.loadMemberChat(pairingProcess);
} }
@ -1033,7 +1033,7 @@ class ChatElement extends HTMLElement {
roleElement.appendChild(memberList); roleElement.appendChild(memberList);
} }
private async switchTab(tabType: string, tabs: NodeListOf<Element>) { private async switchTab(tabType: string, tabs: NodeListOf<Element>) {
const service = await Services.getInstance(); const service = await Services.getInstance();
@ -1079,13 +1079,13 @@ class ChatElement extends HTMLElement {
console.log('All processes:', allProcesses); console.log('All processes:', allProcesses);
const myProcesses: string[] = await service.getMyProcesses(); const myProcesses: string[] = await service.getMyProcesses();
console.log('My processes:', myProcesses); console.log('My processes:', myProcesses);
const groupList = this.shadowRoot?.querySelector('#group-list'); const groupList = this.shadowRoot?.querySelector('#group-list');
if (!groupList) { if (!groupList) {
console.warn('⚠️ Group list element not found'); console.warn('⚠️ Group list element not found');
return; return;
} }
groupList.innerHTML = ''; groupList.innerHTML = '';
const tabContent = document.createElement('div'); const tabContent = document.createElement('div');
@ -1284,9 +1284,9 @@ class ChatElement extends HTMLElement {
<div id="file-list"></div> <div id="file-list"></div>
</div> </div>
<span>Select the deadline:</span> <span>Select the deadline:</span>
<input type="date" <input type="date"
id="date-input" id="date-input"
min="${today}" min="${today}"
value="${today}"> value="${today}">
<button id="send-request-button">Send</button> <button id="send-request-button">Send</button>
</div> </div>
@ -1392,11 +1392,11 @@ class ChatElement extends HTMLElement {
const service = await Services.getInstance(); const service = await Services.getInstance();
const process = await service.getProcess(processId); const process = await service.getProcess(processId);
console.log("Process récupéré:", process); console.log("Process récupéré:", process);
// Récupérer les rôles directement depuis le dernier état // Récupérer les rôles directement depuis le dernier état
const roles = service.getRoles(process); const roles = service.getRoles(process);
console.log("Roles trouvés:", roles); console.log("Roles trouvés:", roles);
if (!roles) return []; if (!roles) return [];
type RoleData = { type RoleData = {
members?: { sp_addresses?: string[] }[]; members?: { sp_addresses?: string[] }[];
@ -1420,7 +1420,7 @@ class ChatElement extends HTMLElement {
Object.entries(roles).forEach(([roleName, roleData]: [string, any]) => { Object.entries(roles).forEach(([roleName, roleData]: [string, any]) => {
const roleItem = document.createElement('li'); const roleItem = document.createElement('li');
roleItem.className = 'role-signature'; roleItem.className = 'role-signature';
const roleContainer = document.createElement('div'); const roleContainer = document.createElement('div');
roleContainer.className = 'role-signature-container'; roleContainer.className = 'role-signature-container';
@ -1446,7 +1446,7 @@ class ChatElement extends HTMLElement {
event.stopPropagation(); event.stopPropagation();
await this.toggleMembers(filteredRoleData, roleItem); await this.toggleMembers(filteredRoleData, roleItem);
}); });
roleContainer.appendChild(roleNameSpan); roleContainer.appendChild(roleNameSpan);
roleItem.appendChild(roleContainer); roleItem.appendChild(roleContainer);
signatureDescription.appendChild(roleItem); signatureDescription.appendChild(roleItem);
@ -1456,7 +1456,7 @@ class ChatElement extends HTMLElement {
//fonction qui ferme la signature //fonction qui ferme la signature
private closeSignature() { private closeSignature() {
const closeSignature = this.shadowRoot?.querySelector('#close-signature'); const closeSignature = this.shadowRoot?.querySelector('#close-signature');
const signatureArea = this.shadowRoot?.querySelector('.signature-area'); const signatureArea = this.shadowRoot?.querySelector('.signature-area');
if (closeSignature && signatureArea) { if (closeSignature && signatureArea) {
closeSignature.addEventListener('click', () => { closeSignature.addEventListener('click', () => {
@ -1475,7 +1475,7 @@ class ChatElement extends HTMLElement {
private async getMyProcessId() { private async getMyProcessId() {
const service = await Services.getInstance(); const service = await Services.getInstance();
return service.getPairingProcessId(); return service.getPairingProcessId();
} }
//fonction qui renvoie les processus où le sp_adress est impliqué //fonction qui renvoie les processus où le sp_adress est impliqué
@ -1493,11 +1493,11 @@ class ChatElement extends HTMLElement {
console.log("Mon adresse:", currentMember[0], memberEmoji); console.log("Mon adresse:", currentMember[0], memberEmoji);
const processes = await service.getProcesses(); const processes = await service.getProcesses();
for (const [processId, process] of Object.entries(processes)) { for (const [processId, process] of Object.entries(processes)) {
try { try {
const roles = process.states[0]?.roles; const roles = process.states[0]?.roles;
if (!roles) { if (!roles) {
console.log(`Pas de rôles trouvés pour le processus ${processId}`); console.log(`Pas de rôles trouvés pour le processus ${processId}`);
continue; continue;
@ -1505,7 +1505,7 @@ class ChatElement extends HTMLElement {
for (const roleName in roles) { for (const roleName in roles) {
const role = roles[roleName]; const role = roles[roleName];
if (role.members && Array.isArray(role.members)) { if (role.members && Array.isArray(role.members)) {
for (const member of role.members) { for (const member of role.members) {
if (member.sp_addresses && Array.isArray(member.sp_addresses)) { if (member.sp_addresses && Array.isArray(member.sp_addresses)) {
@ -1523,7 +1523,7 @@ class ChatElement extends HTMLElement {
continue; continue;
} }
} }
return this.userProcessSet; return this.userProcessSet;
} catch (e) { } catch (e) {
console.error('❌ Erreur:', e); console.error('❌ Erreur:', e);
@ -1533,7 +1533,7 @@ class ChatElement extends HTMLElement {
// Send a file // Send a file
private async sendFile(file: File) { private async sendFile(file: File) {
const MAX_FILE_SIZE = 1 * 1024 * 1024; const MAX_FILE_SIZE = 1 * 1024 * 1024;
if (file.size > MAX_FILE_SIZE) { if (file.size > MAX_FILE_SIZE) {
alert('Le fichier est trop volumineux. Taille maximum : 1MB'); alert('Le fichier est trop volumineux. Taille maximum : 1MB');
return; return;
@ -1553,10 +1553,10 @@ class ChatElement extends HTMLElement {
const timestamp = Date.now(); const timestamp = Date.now();
const processId = this.getAttribute('process-id'); const processId = this.getAttribute('process-id');
const uniqueKey = `${processId}${timestamp}`; const uniqueKey = `${processId}${timestamp}`;
const dbRequest = indexedDB.open('4nk'); const dbRequest = indexedDB.open('4nk');
dbRequest.onerror = (event) => { dbRequest.onerror = (event) => {
console.error("Database error:", dbRequest.error); console.error("Database error:", dbRequest.error);
}; };
@ -1698,12 +1698,12 @@ class ChatElement extends HTMLElement {
private async getProcesses(): Promise<any[]> { private async getProcesses(): Promise<any[]> {
const service = await Services.getInstance(); const service = await Services.getInstance();
const processes = await service.getProcesses(); const processes = await service.getProcesses();
const res = Object.entries(processes).map(([key, value]) => ({ const res = Object.entries(processes).map(([key, value]) => ({
key, key,
value, value,
})); }));
return res; return res;
} }
@ -1735,4 +1735,3 @@ class ChatElement extends HTMLElement {
customElements.define('chat-element', ChatElement); customElements.define('chat-element', ChatElement);
export { ChatElement };*/ export { ChatElement };*/

View File

@ -83,7 +83,7 @@ export default class ModalService {
if (container) { if (container) {
let html = await fetch('/src/components/modal/waiting-modal.html').then((res) => res.text()); let html = await fetch('/src/components/modal/waiting-modal.html').then((res) => res.text());
container.innerHTML += html; container.innerHTML += html;
} }
} }
async injectValidationModal(processDiff: any) { async injectValidationModal(processDiff: any) {