liste déroulante postes téléphoniques
This commit is contained in:
12
config.json
12
config.json
@@ -2,22 +2,25 @@
|
|||||||
"agents": [
|
"agents": [
|
||||||
{
|
{
|
||||||
"id": "agent1",
|
"id": "agent1",
|
||||||
|
"accessCode": "AGENT001",
|
||||||
"name": "Marie DUPONT",
|
"name": "Marie DUPONT",
|
||||||
"email": "marie.dupont@callcenter.fr",
|
"email": "AGENT001@callcenter.fr",
|
||||||
"password": "demo123",
|
"password": "demo123",
|
||||||
"centresAssignes": ["centre1", "centre2", "centre3"]
|
"centresAssignes": ["centre1", "centre2", "centre3"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "agent2",
|
"id": "agent2",
|
||||||
|
"accessCode": "AGENT002",
|
||||||
"name": "Jean MARTIN",
|
"name": "Jean MARTIN",
|
||||||
"email": "jean.martin@callcenter.fr",
|
"email": "AGENT002@callcenter.fr",
|
||||||
"password": "demo456",
|
"password": "demo456",
|
||||||
"centresAssignes": ["centre2", "centre4", "centre5"]
|
"centresAssignes": ["centre2", "centre4", "centre5"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "agent3",
|
"id": "agent3",
|
||||||
|
"accessCode": "AGENT003",
|
||||||
"name": "Sophie BERNARD",
|
"name": "Sophie BERNARD",
|
||||||
"email": "sophie.bernard@callcenter.fr",
|
"email": "AGENT003@callcenter.fr",
|
||||||
"password": "demo789",
|
"password": "demo789",
|
||||||
"centresAssignes": ["centre1", "centre3", "centre4", "centre5"]
|
"centresAssignes": ["centre1", "centre3", "centre4", "centre5"]
|
||||||
}
|
}
|
||||||
@@ -109,6 +112,7 @@
|
|||||||
"signalR": {
|
"signalR": {
|
||||||
"serverUrl": "http://10.90.20.201:8002/signalR",
|
"serverUrl": "http://10.90.20.201:8002/signalR",
|
||||||
"serviceProvider": "RDVPREM",
|
"serviceProvider": "RDVPREM",
|
||||||
"enabled": true
|
"enabled": true,
|
||||||
|
"terminalsSimulation": ["3001", "3002", "3003", "3004", "3005"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,8 +17,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<h2>Connexion Agent</h2>
|
<h2>Connexion Agent</h2>
|
||||||
<form id="loginForm">
|
<form id="loginForm">
|
||||||
<input type="email" id="email" placeholder="Email" required>
|
<input type="text" id="accessCode" placeholder="Code d'accès" required>
|
||||||
<input type="password" id="password" placeholder="Mot de passe" required>
|
<input type="password" id="password" placeholder="Mot de passe" required>
|
||||||
|
<input type="text" id="terminal" list="terminalList" placeholder="Poste téléphonique" required autocomplete="off">
|
||||||
|
<datalist id="terminalList">
|
||||||
|
</datalist>
|
||||||
<button type="submit">Se connecter</button>
|
<button type="submit">Se connecter</button>
|
||||||
<div id="loginError" class="error-message"></div>
|
<div id="loginError" class="error-message"></div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
37
main.js
37
main.js
@@ -81,6 +81,9 @@ function initializeSignalR() {
|
|||||||
sendSignalRStatus();
|
sendSignalRStatus();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Configurer les méthodes SignalR
|
||||||
|
setupSignalRMethods();
|
||||||
|
|
||||||
// Démarrer la connexion
|
// Démarrer la connexion
|
||||||
startSignalRConnection();
|
startSignalRConnection();
|
||||||
|
|
||||||
@@ -91,6 +94,16 @@ function initializeSignalR() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setupSignalRMethods() {
|
||||||
|
// Écouter les événements IPBX
|
||||||
|
signalRConnection.on('IpbxEvent', (name, args) => {
|
||||||
|
if (!args) return;
|
||||||
|
const event = args[0];
|
||||||
|
console.log('Événement IPBX reçu:', event);
|
||||||
|
// TODO: Gérer les événements d'appel
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function startSignalRConnection() {
|
async function startSignalRConnection() {
|
||||||
try {
|
try {
|
||||||
signalRStatus = 'connecting';
|
signalRStatus = 'connecting';
|
||||||
@@ -171,6 +184,30 @@ ipcMain.handle('get-signalr-status', () => {
|
|||||||
return signalRStatus;
|
return signalRStatus;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Récupérer la liste des terminaux téléphoniques
|
||||||
|
ipcMain.handle('get-terminal-list', async () => {
|
||||||
|
// Mode simulation si SignalR non connecté
|
||||||
|
if (!signalRConnection || signalRStatus !== 'connected') {
|
||||||
|
console.log('SignalR non connecté, utilisation des terminaux de simulation');
|
||||||
|
return config.signalR.terminalsSimulation || ['3001', '3002', '3003'];
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
console.log('Récupération des terminaux pour:', config.signalR.serviceProvider);
|
||||||
|
const terminals = await signalRConnection.invoke(
|
||||||
|
'GetTerminalListByServiceProvider',
|
||||||
|
config.signalR.serviceProvider
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('Terminaux disponibles:', terminals);
|
||||||
|
return terminals || [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur récupération terminaux:', error);
|
||||||
|
// Retourner les terminaux de simulation en cas d'erreur
|
||||||
|
return config.signalR.terminalsSimulation || ['3001', '3002', '3003'];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Connexion agent
|
// Connexion agent
|
||||||
ipcMain.handle('login-agent', (event, credentials) => {
|
ipcMain.handle('login-agent', (event, credentials) => {
|
||||||
const agent = config.agents.find(a =>
|
const agent = config.agents.find(a =>
|
||||||
|
|||||||
93
renderer.js
93
renderer.js
@@ -18,12 +18,17 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
// Écouter les changements de statut SignalR
|
// Écouter les changements de statut SignalR
|
||||||
ipcRenderer.on('signalr-status', (event, status) => {
|
ipcRenderer.on('signalr-status', (event, status) => {
|
||||||
updateSignalRIndicator(status);
|
updateSignalRIndicator(status);
|
||||||
|
// Recharger les terminaux à chaque changement de statut
|
||||||
|
loadTerminals();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Obtenir le statut initial SignalR
|
// Obtenir le statut initial SignalR
|
||||||
const initialStatus = await ipcRenderer.invoke('get-signalr-status');
|
const initialStatus = await ipcRenderer.invoke('get-signalr-status');
|
||||||
updateSignalRIndicator(initialStatus);
|
updateSignalRIndicator(initialStatus);
|
||||||
|
|
||||||
|
// Toujours charger les terminaux (simulation ou réels)
|
||||||
|
loadTerminals();
|
||||||
|
|
||||||
// Vérifier si un agent est déjà connecté
|
// Vérifier si un agent est déjà connecté
|
||||||
const agentData = await ipcRenderer.invoke('get-current-agent');
|
const agentData = await ipcRenderer.invoke('get-current-agent');
|
||||||
if (agentData) {
|
if (agentData) {
|
||||||
@@ -66,19 +71,44 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
async function handleLogin(e) {
|
async function handleLogin(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const email = document.getElementById('email').value;
|
const accessCode = document.getElementById('accessCode').value;
|
||||||
const password = document.getElementById('password').value;
|
const password = document.getElementById('password').value;
|
||||||
|
const terminal = document.getElementById('terminal').value;
|
||||||
const errorDiv = document.getElementById('loginError');
|
const errorDiv = document.getElementById('loginError');
|
||||||
|
|
||||||
const result = await ipcRenderer.invoke('login-agent', { email, password });
|
// Vérifier que le terminal est sélectionné et valide
|
||||||
|
if (!terminal) {
|
||||||
|
errorDiv.textContent = 'Veuillez sélectionner un poste téléphonique';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (result.success) {
|
// Valider que le terminal existe dans la liste
|
||||||
currentAgent = result.agent;
|
if (!validateTerminal(terminal)) {
|
||||||
currentCentres = result.centres;
|
errorDiv.textContent = 'Poste téléphonique invalide. Veuillez choisir un poste de la liste.';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sauvegarder le terminal sélectionné pour la prochaine fois
|
||||||
|
localStorage.setItem('last-terminal', terminal);
|
||||||
|
|
||||||
|
// Pour l'instant, utiliser l'authentification locale (simulation)
|
||||||
|
// TODO: Intégrer l'authentification SignalR
|
||||||
|
const config = await ipcRenderer.invoke('get-config');
|
||||||
|
const agent = config.agents.find(a =>
|
||||||
|
a.email === `${accessCode}@callcenter.fr` &&
|
||||||
|
a.password === password
|
||||||
|
);
|
||||||
|
|
||||||
|
if (agent) {
|
||||||
|
currentAgent = agent;
|
||||||
|
currentAgent.terminal = terminal; // Ajouter le terminal sélectionné
|
||||||
|
currentCentres = config.centres.filter(c =>
|
||||||
|
agent.centresAssignes.includes(c.id)
|
||||||
|
);
|
||||||
errorDiv.textContent = '';
|
errorDiv.textContent = '';
|
||||||
showMainPage();
|
showMainPage();
|
||||||
} else {
|
} else {
|
||||||
errorDiv.textContent = result.message;
|
errorDiv.textContent = 'Code d\'accès ou mot de passe incorrect';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,6 +436,57 @@ async function saveNotes() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === GESTION DES TERMINAUX ===
|
||||||
|
let availableTerminals = []; // Stocker les terminaux disponibles
|
||||||
|
|
||||||
|
async function loadTerminals() {
|
||||||
|
const terminalInput = document.getElementById('terminal');
|
||||||
|
const terminalDatalist = document.getElementById('terminalList');
|
||||||
|
if (!terminalInput || !terminalDatalist) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Récupérer les terminaux depuis le serveur SignalR
|
||||||
|
const terminals = await ipcRenderer.invoke('get-terminal-list');
|
||||||
|
availableTerminals = terminals || [];
|
||||||
|
|
||||||
|
if (terminals && terminals.length > 0) {
|
||||||
|
// Vider la datalist
|
||||||
|
terminalDatalist.innerHTML = '';
|
||||||
|
|
||||||
|
// Ajouter chaque terminal comme option
|
||||||
|
terminals.forEach(terminal => {
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.value = terminal;
|
||||||
|
terminalDatalist.appendChild(option);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Restaurer la dernière sélection si disponible
|
||||||
|
const lastTerminal = localStorage.getItem('last-terminal');
|
||||||
|
if (lastTerminal && terminals.includes(lastTerminal)) {
|
||||||
|
terminalInput.value = lastTerminal;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Activer l'input
|
||||||
|
terminalInput.disabled = false;
|
||||||
|
terminalInput.placeholder = 'Poste téléphonique (tapez pour filtrer)';
|
||||||
|
} else {
|
||||||
|
terminalDatalist.innerHTML = '';
|
||||||
|
terminalInput.placeholder = 'Aucun poste disponible';
|
||||||
|
terminalInput.disabled = true;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur chargement des terminaux:', error);
|
||||||
|
terminalDatalist.innerHTML = '';
|
||||||
|
terminalInput.placeholder = 'Erreur de chargement';
|
||||||
|
terminalInput.disabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Valider que le terminal saisi existe dans la liste
|
||||||
|
function validateTerminal(terminal) {
|
||||||
|
return availableTerminals.includes(terminal);
|
||||||
|
}
|
||||||
|
|
||||||
// === GESTION INDICATEUR SIGNALR ===
|
// === GESTION INDICATEUR SIGNALR ===
|
||||||
function updateSignalRStatus() {
|
function updateSignalRStatus() {
|
||||||
// Fonction appelée au chargement pour initialiser l'interface
|
// Fonction appelée au chargement pour initialiser l'interface
|
||||||
|
|||||||
15
styles.css
15
styles.css
@@ -120,6 +120,21 @@ body {
|
|||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#loginForm input:disabled {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Style pour l'input avec datalist */
|
||||||
|
#loginForm input[list] {
|
||||||
|
cursor: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
#loginForm input[list]::-webkit-calendar-picker-indicator {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#loginForm button {
|
#loginForm button {
|
||||||
|
|||||||
Reference in New Issue
Block a user