663 lines
26 KiB
TypeScript
Executable File
663 lines
26 KiB
TypeScript
Executable File
declare global {
|
|
interface Window {
|
|
toggleUserList: () => void;
|
|
switchUser: (userId: string | number) => void;
|
|
loadMemberChat: (memberId: string | number) => void;
|
|
}
|
|
}
|
|
|
|
import { groupsMock } from '../../mocks/mock-signature/groupsMock';
|
|
import { messagesMock as initialMessagesMock, messagesMock } from '../../mocks/mock-signature/messagesMock';
|
|
import { membersMock } from '../../mocks/mock-signature/membersMocks';
|
|
import {
|
|
Message,
|
|
DocumentSignature,
|
|
} from '../../models/signature.models';
|
|
import { messageStore } from '../../utils/messageMock';
|
|
import { Member } from '../../interface/memberInterface';
|
|
import { Group } from '../../interface/groupInterface';
|
|
import { getCorrectDOM } from '../../utils/document.utils';
|
|
import chatStyle from '../../../public/style/chat.css?inline';
|
|
import { addressToEmoji } from '../../utils/sp-address.utils';
|
|
|
|
|
|
|
|
let currentUser: Member = membersMock[0];
|
|
|
|
interface LocalNotification {
|
|
memberId: string;
|
|
text: string;
|
|
time: string;
|
|
}
|
|
|
|
|
|
export function initChat() {
|
|
const chatElement = document.createElement('chat-element');
|
|
const container = document.querySelector('.container');
|
|
if (container) {
|
|
container.appendChild(chatElement);
|
|
}
|
|
}
|
|
|
|
class ChatElement extends HTMLElement {
|
|
static get observedAttributes() {
|
|
return ['process-id'];
|
|
}
|
|
|
|
private processId: string | null = null;
|
|
private selectedMemberId: string | null = null;
|
|
private messagesMock: any[] = [];
|
|
private dom: Node;
|
|
private notifications: LocalNotification[] = [];
|
|
private notificationBadge = document.querySelector('.notification-badge');
|
|
private notificationBoard = document.getElementById('notification-board');
|
|
private notificationBell = document.getElementById('notification-bell');
|
|
private selectedSignatories: DocumentSignature[] = [];
|
|
private allMembers = membersMock.map(member => ({
|
|
id: member.id,
|
|
name: member.name,
|
|
roleName: 'Default Role'
|
|
}));
|
|
|
|
|
|
constructor() {
|
|
super();
|
|
this.attachShadow({ mode: 'open' });
|
|
this.messagesMock = messageStore.getMessages();
|
|
this.dom = getCorrectDOM('signature-element');
|
|
this.processId = this.getAttribute('process-id');
|
|
|
|
// Récupérer le processId depuis l'attribut du composant
|
|
console.log('🔍 Constructor - Process ID from element:', this.processId);
|
|
|
|
this.shadowRoot!.innerHTML = `
|
|
|
|
<style>
|
|
${chatStyle}
|
|
</style>
|
|
<div class="container">
|
|
<!-- List of groups -->
|
|
<div class="group-list">
|
|
<ul id="group-list">
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- Chat area -->
|
|
<div class="chat-area">
|
|
<div class="chat-header" id="chat-header">
|
|
<!-- Chat title -->
|
|
</div>
|
|
<div class="messages" id="messages">
|
|
<!-- Messages -->
|
|
</div>
|
|
|
|
<!-- Input area -->
|
|
<div class="input-area">
|
|
<label for="file-input" class="attachment-icon">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
<path d="M13.514 2.444l-10.815 10.785c-.449.449-.678 1.074-.625 1.707l.393 4.696c.041.479.422.86.9.9l4.697.394c.633.053 1.258-.177 1.707-.626l11.875-11.844c.196-.196.195-.512 0-.707l-3.536-3.536c-.195-.195-.511-.196-.707 0l-8.878 8.848c-.162.162-.253.382-.253.611v.725c0 .184.148.332.332.332h.725c.229 0 .448-.092.61-.254l7.11-7.08 1.415 1.415-7.386 7.354c-.375.375-.885.586-1.414.586h-2.414c-.555 0-1-.448-1-1v-2.414c0-.53.211-1.039.586-1.414l9.506-9.477c.781-.781 2.049-.781 2.829-.001l4.243 4.243c.391.391.586.902.586 1.414 0 .512-.196 1.025-.587 1.416l-12.35 12.319c-.748.747-1.76 1.164-2.81 1.164-.257 0-6.243-.467-6.499-.487-.664-.052-1.212-.574-1.268-1.267-.019-.242-.486-6.246-.486-6.499 0-1.05.416-2.062 1.164-2.811l10.936-10.936 1.414 1.444z"/>
|
|
</svg>
|
|
</label>
|
|
<input type="file" id="file-input" style="display: none;" />
|
|
<textarea id="message-input" rows="3" placeholder="Type your message..."></textarea>
|
|
<button id="send-button">Send</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
|
|
window.toggleUserList = this.toggleUserList.bind(this);
|
|
window.switchUser = this.switchUser.bind(this);
|
|
window.loadMemberChat = this.loadMemberChat.bind(this);
|
|
|
|
// Initialiser les événements de notification
|
|
document.addEventListener('click', (event: Event): void => {
|
|
if (this.notificationBoard && this.notificationBoard.style.display === 'block' &&
|
|
!this.notificationBoard.contains(event.target as Node) &&
|
|
this.notificationBell && !this.notificationBell.contains(event.target as Node)) {
|
|
this.notificationBoard.style.display = 'none';
|
|
}
|
|
});
|
|
this.initMessageEvents();
|
|
|
|
document.addEventListener('newMessagingProcess', ((event: CustomEvent) => {
|
|
console.log('🎯 Received newMessagingProcess event:', event.detail);
|
|
this.addNewMessagingProcess(event.detail.processId, event.detail.processName);
|
|
}) as EventListener);
|
|
}
|
|
|
|
attributeChangedCallback(name: string, oldValue: string, newValue: string) {
|
|
console.log(`🔄 Attribute ${name} changed from ${oldValue} to ${newValue}`);
|
|
if (name === 'process-id' && newValue) {
|
|
console.log('🔍 Loading chat with new process ID:', newValue);
|
|
this.loadGroupList(newValue);
|
|
}
|
|
}
|
|
|
|
private initMessageEvents() {
|
|
const sendButton = this.shadowRoot?.querySelector('#send-button');
|
|
if (sendButton) {
|
|
sendButton.addEventListener('click', () => this.sendMessage());
|
|
}
|
|
|
|
const messageInput = this.shadowRoot?.querySelector('#message-input');
|
|
if (messageInput) {
|
|
messageInput.addEventListener('keypress', (event: Event) => {
|
|
const keyEvent = event as KeyboardEvent;
|
|
if (keyEvent.key === 'Enter' && !keyEvent.shiftKey) {
|
|
event.preventDefault();
|
|
this.sendMessage();
|
|
}
|
|
});
|
|
}
|
|
|
|
const fileInput = this.shadowRoot?.querySelector('#file-input') as HTMLInputElement;
|
|
if (fileInput) {
|
|
fileInput.addEventListener('change', (event: Event) => {
|
|
const target = event.target as HTMLInputElement;
|
|
if (target.files && target.files.length > 0) {
|
|
this.sendFile(target.files[0]);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
///////////////////// Notification module /////////////////////
|
|
// Delete a notification
|
|
private removeNotification(index: number) {
|
|
this.notifications?.splice(index, 1); // Ajout de ?.
|
|
this.renderNotifications();
|
|
this.updateNotificationBadge();
|
|
}
|
|
// Show notifications
|
|
private renderNotifications() {
|
|
if (!this.notificationBoard) return;
|
|
|
|
// Reset the interface
|
|
this.notificationBoard.innerHTML = '';
|
|
|
|
// Displays "No notifications available" if there are no notifications
|
|
if (this.notifications.length === 0) {
|
|
this.notificationBoard.innerHTML = '<div class="no-notification">No notifications available</div>';
|
|
return;
|
|
}
|
|
|
|
// Add each notification to the list
|
|
this.notifications.forEach((notif, index) => {
|
|
const notifElement = document.createElement('div');
|
|
notifElement.className = 'notification-item';
|
|
notifElement.textContent = `${notif.text} at ${notif.time}`;
|
|
notifElement.onclick = () => {
|
|
this.loadMemberChat(notif.memberId);
|
|
this.removeNotification(index);
|
|
};
|
|
this.notificationBoard?.appendChild(notifElement);
|
|
});
|
|
}
|
|
private updateNotificationBadge() {
|
|
if (!this.notificationBadge) return;
|
|
const count = this.notifications.length;
|
|
this.notificationBadge.textContent = count > 99 ? '+99' : count.toString();
|
|
(this.notificationBadge as HTMLElement).style.display = count > 0 ? 'block' : 'none';
|
|
}
|
|
|
|
|
|
// Add notification
|
|
private addNotification(memberId: string, message: Message) {
|
|
// Creating a new notification
|
|
const notification = {
|
|
memberId,
|
|
text: `New message from Member ${memberId}: ${message.text}`,
|
|
time: message.time
|
|
};
|
|
|
|
// Added notification to list and interface
|
|
this.notifications.push(notification);
|
|
this.renderNotifications();
|
|
this.updateNotificationBadge();
|
|
}
|
|
|
|
// Send a messsage
|
|
private sendMessage() {
|
|
const messageInput = this.shadowRoot?.querySelector('#message-input') as HTMLInputElement;
|
|
if (!messageInput || !this.selectedMemberId) return;
|
|
|
|
const messageText = messageInput.value.trim();
|
|
if (messageText === '') return;
|
|
|
|
const newMessage: Message = {
|
|
id: Date.now(),
|
|
sender: "4NK",
|
|
text: messageText,
|
|
time: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }),
|
|
type: 'text' as const
|
|
};
|
|
|
|
messageStore.addMessage(this.selectedMemberId, newMessage);
|
|
this.messagesMock = messageStore.getMessages();
|
|
this.loadMemberChat(this.selectedMemberId);
|
|
|
|
messageInput.value = '';
|
|
|
|
setTimeout(() => {
|
|
if (this.selectedMemberId) {
|
|
const autoReply = {
|
|
id: Date.now(),
|
|
sender: "Member",
|
|
text: "OK...",
|
|
time: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }),
|
|
type: 'text' as const
|
|
};
|
|
messageStore.addMessage(this.selectedMemberId, autoReply);
|
|
this.messagesMock = messageStore.getMessages();
|
|
this.loadMemberChat(this.selectedMemberId);
|
|
this.addNotification(this.selectedMemberId, autoReply);
|
|
}
|
|
}, 2000);
|
|
}
|
|
|
|
private scrollToBottom(container: Element) {
|
|
(container as HTMLElement).scrollTop = (container as HTMLElement).scrollHeight;
|
|
}
|
|
|
|
|
|
// Load the list of members
|
|
private async loadMemberChat(memberId: string | number) {
|
|
this.selectedMemberId = String(memberId);
|
|
const memberMessages = this.messagesMock.find(m => String(m.memberId) === String(memberId));
|
|
|
|
const chatHeader = this.shadowRoot?.querySelector('#chat-header');
|
|
const messagesContainer = this.shadowRoot?.querySelector('#messages');
|
|
|
|
if (!chatHeader || !messagesContainer) return;
|
|
|
|
const memberAddress = String(memberId);
|
|
const emojis = await addressToEmoji(memberAddress);
|
|
chatHeader.textContent = `Chat with ${emojis}`;
|
|
messagesContainer.innerHTML = '';
|
|
|
|
if (memberMessages) {
|
|
for (const message of memberMessages.messages) {
|
|
const messageElement = document.createElement('div');
|
|
messageElement.className = 'message-container';
|
|
|
|
const messageContent = document.createElement('div');
|
|
messageContent.className = 'message';
|
|
|
|
if (message.type === 'file') {
|
|
messageContent.innerHTML = `<a href="${message.fileData}" download="${message.fileName}" target="_blank">${message.fileName}</a>`;
|
|
messageContent.classList.add('user');
|
|
} else {
|
|
const senderDisplay = message.sender === "4NK"
|
|
? "Me"
|
|
: await addressToEmoji(memberAddress);
|
|
|
|
messageContent.innerHTML = `<strong>${senderDisplay}</strong>: ${message.text} <span style="float: right;">${message.time}</span>`;
|
|
if (message.sender === "4NK") {
|
|
messageContent.classList.add('user');
|
|
}
|
|
}
|
|
|
|
messageElement.appendChild(messageContent);
|
|
messagesContainer.appendChild(messageElement);
|
|
}
|
|
}
|
|
|
|
this.scrollToBottom(messagesContainer);
|
|
}
|
|
|
|
private async toggleMembers(roleData: any, roleElement: HTMLElement) {
|
|
let memberList = roleElement.querySelector('.member-list');
|
|
if (memberList) {
|
|
(memberList as HTMLElement).style.display =
|
|
(memberList as HTMLElement).style.display === 'none' ? 'block' : 'none';
|
|
return;
|
|
}
|
|
|
|
memberList = document.createElement('ul');
|
|
memberList.className = 'member-list';
|
|
|
|
// Récupérer les membres avec leurs sp_addresses
|
|
if (roleData.members) {
|
|
for (const member of roleData.members) {
|
|
const memberItem = document.createElement('li');
|
|
memberItem.className = 'member-item';
|
|
|
|
const memberContainer = document.createElement('div');
|
|
memberContainer.className = 'member-container';
|
|
|
|
|
|
const emojiSpan = document.createElement('span');
|
|
emojiSpan.className = 'member-emoji';
|
|
if (member.sp_addresses?.[0]) {
|
|
const emojis = await addressToEmoji(member.sp_addresses[0]);
|
|
emojiSpan.textContent = emojis;
|
|
}
|
|
|
|
memberContainer.appendChild(emojiSpan);
|
|
memberItem.appendChild(memberContainer);
|
|
|
|
memberItem.onclick = (event) => {
|
|
event.stopPropagation();
|
|
this.loadMemberChat(member.sp_addresses[0]);
|
|
};
|
|
|
|
memberList.appendChild(memberItem);
|
|
}
|
|
}
|
|
|
|
roleElement.appendChild(memberList);
|
|
}
|
|
|
|
|
|
// Toggle the list of Roles
|
|
private toggleRoles(group: Group, groupElement: HTMLElement) {
|
|
console.log('=== toggleRoles START ===');
|
|
console.log('Group:', group.name);
|
|
console.log('Group roles:', group.roles); // Afficher tous les rôles disponibles
|
|
|
|
let roleList = groupElement.querySelector('.role-list');
|
|
console.log('Existing roleList:', roleList);
|
|
|
|
if (roleList) {
|
|
const roleItems = roleList.querySelectorAll('.role-item');
|
|
roleItems.forEach(roleItem => {
|
|
console.log('Processing roleItem:', roleItem.innerHTML); // Voir le contenu HTML complet
|
|
|
|
let container = roleItem.querySelector('.role-item-container');
|
|
if (!container) {
|
|
container = document.createElement('div');
|
|
container.className = 'role-item-container';
|
|
|
|
// Créer un span pour le nom du rôle
|
|
const nameSpan = document.createElement('span');
|
|
nameSpan.className = 'role-name';
|
|
nameSpan.textContent = roleItem.textContent?.trim() || '';
|
|
|
|
container.appendChild(nameSpan);
|
|
roleItem.textContent = '';
|
|
roleItem.appendChild(container);
|
|
}
|
|
|
|
// Récupérer le nom du rôle
|
|
const roleName = roleItem.textContent?.trim();
|
|
console.log('Role name from textContent:', roleName);
|
|
|
|
// Alternative pour obtenir le nom du rôle
|
|
const roleNameAlt = container.querySelector('.role-name')?.textContent;
|
|
console.log('Role name from span:', roleNameAlt);
|
|
|
|
if (!container.querySelector('.folder-icon')) {
|
|
const folderButton = document.createElement('span');
|
|
folderButton.className = 'folder-icon';
|
|
|
|
folderButton.addEventListener('click', (event) => {
|
|
event.stopPropagation();
|
|
console.log('Clicked role name:', roleName);
|
|
console.log('Available roles:', group.roles.map(r => r.name));
|
|
|
|
const role = group.roles.find(r => r.name === roleName);
|
|
if (role) {
|
|
console.log('Found role:', role);
|
|
} else {
|
|
console.error('Role not found. Name:', roleName);
|
|
console.error('Available roles:', group.roles);
|
|
}
|
|
});
|
|
|
|
container.appendChild(folderButton);
|
|
}
|
|
});
|
|
|
|
(roleList as HTMLElement).style.display =
|
|
(roleList as HTMLElement).style.display === 'none' ? 'block' : 'none';
|
|
}
|
|
}
|
|
|
|
|
|
private async loadGroupList(processId: string): Promise<void> {
|
|
console.log('🔍 Loading group list with processId:', processId);
|
|
const groupList = this.shadowRoot?.querySelector('#group-list');
|
|
if (!groupList) return;
|
|
|
|
groupList.innerHTML = '';
|
|
|
|
const dbRequest = window.indexedDB.open('4nk');
|
|
const db = await new Promise<IDBDatabase>((resolve, reject) => {
|
|
dbRequest.onsuccess = () => resolve(dbRequest.result);
|
|
dbRequest.onerror = () => reject(dbRequest.error);
|
|
});
|
|
|
|
const transaction = db.transaction(['processes'], 'readonly');
|
|
const processStore = transaction.objectStore('processes');
|
|
const processRequest = processStore.get(processId);
|
|
|
|
const process = await new Promise<any>((resolve, reject) => {
|
|
processRequest.onsuccess = () => {
|
|
console.log('🔍 Process found:', processRequest.result);
|
|
resolve(processRequest.result);
|
|
};
|
|
processRequest.onerror = () => reject(processRequest.error);
|
|
});
|
|
|
|
if (!process?.states?.[0]?.encrypted_pcd?.roles) {
|
|
console.error('❌ Process structure invalid:', process);
|
|
return;
|
|
}
|
|
|
|
const roles = process.states[0].encrypted_pcd.roles;
|
|
console.log('🔑 Roles found:', roles);
|
|
|
|
const li = document.createElement('li');
|
|
li.className = 'group-list-item';
|
|
li.setAttribute('data-process-id', processId);
|
|
|
|
const container = document.createElement('div');
|
|
container.className = 'group-item-container';
|
|
|
|
const nameSpan = document.createElement('span');
|
|
nameSpan.textContent = `Process : `;
|
|
nameSpan.className = 'process-name';
|
|
|
|
container.appendChild(nameSpan);
|
|
|
|
await addressToEmoji(processId).then(emojis => {
|
|
const emojiSpan = document.createElement('span');
|
|
emojiSpan.className = 'process-emoji';
|
|
emojiSpan.textContent = emojis;
|
|
container.appendChild(emojiSpan);
|
|
});
|
|
|
|
li.appendChild(container);
|
|
|
|
const roleList = document.createElement('ul');
|
|
roleList.className = 'role-list';
|
|
|
|
Object.keys(roles).forEach(roleName => {
|
|
const roleItem = document.createElement('li');
|
|
roleItem.className = 'role-item';
|
|
|
|
const roleContainer = document.createElement('div');
|
|
roleContainer.className = 'role-item-container';
|
|
|
|
const roleNameSpan = document.createElement('span');
|
|
roleNameSpan.className = 'role-name';
|
|
roleNameSpan.textContent = roleName;
|
|
|
|
roleContainer.addEventListener('click', (event) => {
|
|
event.stopPropagation();
|
|
this.toggleMembers(roles[roleName], roleItem);
|
|
});
|
|
|
|
roleContainer.appendChild(roleNameSpan);
|
|
roleItem.appendChild(roleContainer);
|
|
roleList.appendChild(roleItem);
|
|
});
|
|
|
|
li.appendChild(roleList);
|
|
groupList.appendChild(li);
|
|
}
|
|
|
|
|
|
// Function to manage the list of users
|
|
private toggleUserList() {
|
|
const userList = getCorrectDOM('userList');
|
|
if (!userList) return;
|
|
|
|
if (!(userList as HTMLElement).classList.contains('show')) {
|
|
(userList as HTMLElement).innerHTML = membersMock.map(member => `
|
|
<div class="user-list-item" onclick="switchUser('${member.id}')">
|
|
<span class="user-avatar">${member.avatar}</span>
|
|
<div>
|
|
<span class="user-name">${member.name}</span>
|
|
<span class="user-email">${member.email}</span>
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
}
|
|
(userList as HTMLElement).classList.toggle('show');
|
|
}
|
|
|
|
private switchUser(userId: string | number) {
|
|
const user = membersMock.find(member => member.id === userId);
|
|
if (!user) return;
|
|
currentUser = user;
|
|
this.updateCurrentUserDisplay();
|
|
const userList = getCorrectDOM('userList') as HTMLElement;
|
|
userList?.classList.remove('show');
|
|
}
|
|
|
|
// Function to update the display of the current user
|
|
private updateCurrentUserDisplay() {
|
|
const userDisplay = getCorrectDOM('current-user') as HTMLElement;
|
|
if (userDisplay) {
|
|
userDisplay.innerHTML = `
|
|
<div class="current-user-info">
|
|
<span class="user-avatar">${currentUser.avatar}</span>
|
|
<span class="user-name">${currentUser.name}</span>
|
|
</div>
|
|
`;
|
|
}
|
|
}
|
|
// Generate an automatic response
|
|
private generateAutoReply(senderName: string): Message {
|
|
return {
|
|
id: Date.now(),
|
|
sender: senderName,
|
|
text: "OK...",
|
|
time: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }),
|
|
type: 'text' as const
|
|
};
|
|
}
|
|
|
|
// Send a file
|
|
private sendFile(file: File) {
|
|
if (!this.selectedMemberId) return;
|
|
|
|
const MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
if (file.size > MAX_FILE_SIZE) {
|
|
alert('File is too large. Maximum size is 5MB');
|
|
return;
|
|
}
|
|
|
|
const reader = new FileReader();
|
|
reader.readAsDataURL(file);
|
|
|
|
reader.onload = () => {
|
|
const fileMessage = {
|
|
id: Date.now(),
|
|
sender: "4NK",
|
|
fileName: file.name,
|
|
fileData: reader.result,
|
|
time: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }),
|
|
type: 'file' as const
|
|
};
|
|
|
|
messageStore.addMessage(this.selectedMemberId!, fileMessage);
|
|
this.messagesMock = messageStore.getMessages();
|
|
this.loadMemberChat(this.selectedMemberId!);
|
|
|
|
const fileInput = this.shadowRoot?.querySelector('#file-input') as HTMLInputElement;
|
|
if (fileInput) fileInput.value = '';
|
|
};
|
|
}
|
|
|
|
connectedCallback() {
|
|
this.updateCurrentUserDisplay();
|
|
|
|
if (this.processId) {
|
|
console.log('🔍 Loading chat with process ID:', this.processId);
|
|
this.loadGroupList(this.processId);
|
|
} else {
|
|
console.error('❌ No process ID found in element attributes');
|
|
}
|
|
// Si un membre est sélectionné par défaut, charger ses messages
|
|
if (this.selectedMemberId) {
|
|
this.loadMemberChat(this.selectedMemberId);
|
|
}
|
|
}
|
|
|
|
private addNewMessagingProcess(processId: string, processName: string) {
|
|
console.log('🎯 Adding new messaging process:', { processId, processName });
|
|
const groupList = this.shadowRoot?.querySelector('#group-list');
|
|
if (!groupList) {
|
|
console.error('Group list not found in shadow DOM');
|
|
return;
|
|
}
|
|
|
|
// Vérifier si le processus existe déjà
|
|
const existingProcess = groupList.querySelector(`[data-process-id="${processId}"]`);
|
|
if (existingProcess) {
|
|
console.log('Process already exists:', processId);
|
|
return;
|
|
}
|
|
|
|
// Créer le nouveau groupe
|
|
const li = document.createElement('li');
|
|
li.className = 'group-list-item';
|
|
li.setAttribute('data-process-id', processId);
|
|
|
|
// Créer le conteneur flex
|
|
const container = document.createElement('div');
|
|
container.className = 'group-item-container';
|
|
|
|
// Créer un span pour le nom du processus
|
|
const nameSpan = document.createElement('span');
|
|
nameSpan.textContent = processName;
|
|
nameSpan.className = 'process-name';
|
|
|
|
// Créer un span pour les emojis
|
|
const emojiSpan = document.createElement('span');
|
|
emojiSpan.className = 'process-emoji';
|
|
|
|
// Ajouter les emojis de l'adresse
|
|
addressToEmoji(processId).then(emojis => {
|
|
emojiSpan.textContent = emojis;
|
|
});
|
|
|
|
container.appendChild(nameSpan);
|
|
container.appendChild(emojiSpan);
|
|
li.appendChild(container);
|
|
|
|
// Créer la liste des rôles
|
|
const roleList = document.createElement('ul');
|
|
roleList.className = 'role-list';
|
|
roleList.style.display = 'none';
|
|
|
|
// Ajouter un rôle par défaut pour le messaging
|
|
const roleItem = document.createElement('li');
|
|
roleItem.className = 'role-item';
|
|
roleItem.textContent = 'Messaging';
|
|
roleList.appendChild(roleItem);
|
|
|
|
li.appendChild(roleList);
|
|
groupList.appendChild(li);
|
|
|
|
console.log('🎯 New messaging process added successfully');
|
|
}
|
|
}
|
|
|
|
customElements.define('chat-element', ChatElement);
|
|
export { ChatElement };
|
|
|