Jul 10 - Update codes to catch up with the single tenant project (Medium)
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Support Knowledge Base{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<div>
|
||||
<h4 class="mb-0"><i class="bi bi-book me-2 text-primary"></i>Support Knowledge Base</h4>
|
||||
<small class="text-muted">Active entries are injected into the AI chatbot system prompt</small>
|
||||
</div>
|
||||
<div>
|
||||
<a href="{{ url_for('support.admin_tickets') }}" class="btn btn-outline-secondary btn-sm me-1">
|
||||
<i class="bi bi-inbox me-1"></i>Tickets
|
||||
</a>
|
||||
<a href="{{ url_for('support.admin_conversations') }}" class="btn btn-outline-secondary btn-sm">
|
||||
<i class="bi bi-chat-dots me-1"></i>Conversations
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# Add new entry form #}
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header fw-semibold"><i class="bi bi-plus-circle me-2"></i>Add Knowledge Entry</div>
|
||||
<div class="card-body">
|
||||
<form method="post" action="{{ url_for('support.admin_knowledge_add') }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Title <span class="text-danger">*</span></label>
|
||||
<input type="text" name="title" class="form-control" maxlength="200" required
|
||||
placeholder="e.g. Contract Hours, Emergency Contacts, Service Scope">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label fw-semibold">Content <span class="text-danger">*</span></label>
|
||||
<textarea name="body" class="form-control" rows="4" required
|
||||
placeholder="Add facts, FAQs, or instructions the AI should know about this customer's account…"></textarea>
|
||||
<div class="form-text">Keep entries focused and factual. Combined active entries are capped at 6,000 characters.</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-sm">
|
||||
<i class="bi bi-plus me-1"></i>Add Entry
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# Entry list #}
|
||||
{% if entries %}
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header fw-semibold">
|
||||
{{ entries | length }} entr{{ 'ies' if entries | length != 1 else 'y' }}
|
||||
({{ entries | selectattr('active') | list | length }} active)
|
||||
</div>
|
||||
<div class="list-group list-group-flush">
|
||||
{% for entry in entries %}
|
||||
<div class="list-group-item">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div class="flex-grow-1 me-3">
|
||||
<div class="d-flex align-items-center gap-2 mb-1">
|
||||
<span class="fw-semibold">{{ entry.title }}</span>
|
||||
{% if entry.active %}
|
||||
<span class="badge bg-success">Active</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">Inactive</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<p class="mb-1 text-muted small" style="white-space:pre-wrap;">{{ entry.body[:300] }}{% if entry.body | length > 300 %}…{% endif %}</p>
|
||||
<div class="text-muted" style="font-size:.75rem;">
|
||||
Added {{ entry.created_at.strftime('%b %d, %Y') }}
|
||||
{% if entry.creator %} by {{ entry.creator.display_name }}{% endif %}
|
||||
{% if entry.updated_at != entry.created_at %}
|
||||
· Updated {{ entry.updated_at.strftime('%b %d, %Y') }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex gap-1 flex-shrink-0">
|
||||
<a href="{{ url_for('support.admin_knowledge_edit', entry_id=entry.id) }}"
|
||||
class="btn btn-sm btn-outline-secondary">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<form method="post" action="{{ url_for('support.admin_knowledge_toggle', entry_id=entry.id) }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<button type="submit" class="btn btn-sm {{ 'btn-outline-warning' if entry.active else 'btn-outline-success' }}"
|
||||
title="{{ 'Deactivate' if entry.active else 'Activate' }}">
|
||||
<i class="bi bi-{{ 'pause' if entry.active else 'play' }}"></i>
|
||||
</button>
|
||||
</form>
|
||||
<form method="post" action="{{ url_for('support.admin_knowledge_delete', entry_id=entry.id) }}"
|
||||
onsubmit="return confirm('Delete this knowledge entry? The AI will no longer have this context.');">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger" title="Delete">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="text-center text-muted py-5">
|
||||
<i class="bi bi-book fs-1 d-block mb-2"></i>
|
||||
No knowledge entries yet. Add context above to improve the AI assistant's answers.
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user