added sorting by usage and users, added usage and users to card display, and enabled serach for tags
This commit is contained in:
parent
50e0daf4c4
commit
cebc1cf649
1 changed files with 21 additions and 5 deletions
|
|
@ -97,6 +97,8 @@
|
|||
<option value="created_at">Sort by Created Date</option>
|
||||
<option value="name">Sort by Name</option>
|
||||
<option value="status">Sort by Status</option>
|
||||
<option value="total_messages">Sort by Total Messages</option>
|
||||
<option value="unique_users">Sort by Unique Users</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
|
|
@ -605,13 +607,15 @@ function displayAgents(agentsToShow) {
|
|||
<div>
|
||||
<h6 class="mb-1 fw-bold">${agent.agent_name}</h6>
|
||||
<p class="text-muted mb-2 small">${agent.agent_description || 'No description'}</p>
|
||||
<div class="d-flex gap-2 align-items-center">
|
||||
<div class="d-flex gap-2 align-items-center flex-wrap">
|
||||
<span class="agent-status status-${agent.agent_status || 'Development'}">
|
||||
${agent.agent_status || 'Development'}
|
||||
</span>
|
||||
${agent.agent_version ? `<span class="badge bg-light text-dark">v${agent.agent_version}</span>` : ''}
|
||||
${agent.quality_audit_status ? '<span class="badge bg-success" title="Quality Audited"><i class="fas fa-certificate"></i></span>' : ''}
|
||||
${agent.quality_audit_status && agent.risk_factor ? getRiskFactorBadge(agent.risk_factor) : ''}
|
||||
${agent.total_messages ? `<span class="badge bg-info text-white" title="Total Messages"><i class="fas fa-comments me-1"></i>${agent.total_messages.toLocaleString()}</span>` : ''}
|
||||
${agent.unique_users ? `<span class="badge bg-primary" title="Unique Users"><i class="fas fa-users me-1"></i>${agent.unique_users}</span>` : ''}
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-end">
|
||||
|
|
@ -1040,14 +1044,15 @@ async function deleteAgent() {
|
|||
function filterAgents() {
|
||||
const searchTerm = document.getElementById('searchInput').value.toLowerCase();
|
||||
const statusFilter = document.getElementById('statusFilter').value;
|
||||
|
||||
|
||||
let filtered = agents.filter(agent => {
|
||||
const matchesSearch = agent.agent_name.toLowerCase().includes(searchTerm) ||
|
||||
(agent.agent_description || '').toLowerCase().includes(searchTerm);
|
||||
(agent.agent_description || '').toLowerCase().includes(searchTerm) ||
|
||||
(agent.agent_tags || []).some(tag => tag.toLowerCase().includes(searchTerm));
|
||||
const matchesStatus = !statusFilter || agent.agent_status === statusFilter;
|
||||
return matchesSearch && matchesStatus;
|
||||
});
|
||||
|
||||
|
||||
displayAgents(filtered);
|
||||
}
|
||||
|
||||
|
|
@ -1058,11 +1063,22 @@ function sortAndDisplayAgents() {
|
|||
return a.agent_name.localeCompare(b.agent_name);
|
||||
} else if (sortBy === 'status') {
|
||||
return (a.agent_status || 'Development').localeCompare(b.agent_status || 'Development');
|
||||
} else if (sortBy === 'total_messages') {
|
||||
// High to low (most used first), treat null/undefined as 0
|
||||
const aVal = a.total_messages || 0;
|
||||
const bVal = b.total_messages || 0;
|
||||
return bVal - aVal; // Descending order
|
||||
} else if (sortBy === 'unique_users') {
|
||||
// High to low (most users first), treat null/undefined as 0
|
||||
const aVal = a.unique_users || 0;
|
||||
const bVal = b.unique_users || 0;
|
||||
return bVal - aVal; // Descending order
|
||||
} else {
|
||||
// Default: created_at (newest first)
|
||||
return new Date(b.agent_created_at) - new Date(a.agent_created_at);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
displayAgents(sorted);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue