494 lines
24 KiB
HTML
494 lines
24 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}{{ message.subject }} - Message Details{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="container-fluid">
|
|
<!-- Breadcrumb -->
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
|
|
<h4 class="mb-sm-0">Message Details</h4>
|
|
<div class="page-title-right">
|
|
<ol class="breadcrumb m-0">
|
|
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'communications:dashboard' %}">Communications</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'communications:message_list' %}">Messages</a></li>
|
|
<li class="breadcrumb-item active">Details</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<!-- Main Content -->
|
|
<div class="col-lg-8">
|
|
<!-- Message Overview -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fas fa-envelope me-2"></i>
|
|
{{ message.subject }}
|
|
</h5>
|
|
<div class="d-flex gap-2">
|
|
<span class="badge bg-{% if message.message_type == 'EMAIL' %}info{% elif message.message_type == 'SMS' %}success{% elif message.message_type == 'PUSH' %}warning{% else %}secondary{% endif %} fs-6">
|
|
{{ message.get_message_type_display }}
|
|
</span>
|
|
<span class="badge bg-{% if message.priority == 'CRITICAL' %}danger{% elif message.priority == 'URGENT' %}warning{% elif message.priority == 'HIGH' %}info{% else %}secondary{% endif %} fs-6">
|
|
{{ message.get_priority_display }}
|
|
</span>
|
|
<span class="badge bg-{% if message.status == 'SENT' %}success{% elif message.status == 'DELIVERED' %}primary{% elif message.status == 'FAILED' %}danger{% elif message.status == 'PENDING' %}warning{% else %}secondary{% endif %} fs-6">
|
|
{{ message.get_status_display }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<!-- Message Header Info -->
|
|
<div class="row mb-4">
|
|
<div class="col-md-6">
|
|
<div class="table-responsive">
|
|
<table class="table table-borderless">
|
|
<tr>
|
|
<td class="fw-bold text-muted">From:</td>
|
|
<td>
|
|
<div class="d-flex align-items-center">
|
|
<div class="avatar-sm me-2">
|
|
<div class="avatar-title bg-primary text-white rounded-circle">
|
|
{{ message.sender.first_name.0 }}{{ message.sender.last_name.0 }}
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<h6 class="mb-0">{{ message.sender.get_full_name }}</h6>
|
|
<small class="text-muted">{{ message.sender.email }}</small>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold text-muted">Recipients:</td>
|
|
<td>{{ message.messagerecipient_set.count }} recipient{{ message.messagerecipient_set.count|pluralize }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold text-muted">Created:</td>
|
|
<td>{{ message.created_at|date:"l, F d, Y g:i A" }}</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="table-responsive">
|
|
<table class="table table-borderless">
|
|
<tr>
|
|
<td class="fw-bold text-muted">Scheduled:</td>
|
|
<td>
|
|
{% if message.scheduled_time %}
|
|
{{ message.scheduled_time|date:"M d, Y g:i A" }}
|
|
{% else %}
|
|
<span class="text-muted">Immediate</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold text-muted">Template:</td>
|
|
<td>
|
|
{% if message.template %}
|
|
<a href="{% url 'communications:notification_template_detail' message.template.pk %}">
|
|
{{ message.template.template_name }}
|
|
</a>
|
|
{% else %}
|
|
<span class="text-muted">Custom message</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold text-muted">Sent:</td>
|
|
<td>
|
|
{% if message.sent_at %}
|
|
{{ message.sent_at|date:"M d, Y g:i A" }}
|
|
{% else %}
|
|
<span class="text-muted">Not sent</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Message Content -->
|
|
<div class="mt-4">
|
|
<h6 class="text-muted mb-3">Message Content:</h6>
|
|
<div class="bg-light p-4 rounded">
|
|
{{ message.body|linebreaks }}
|
|
</div>
|
|
</div>
|
|
|
|
{% if message.metadata %}
|
|
<div class="mt-4">
|
|
<h6 class="text-muted mb-3">Additional Information:</h6>
|
|
<div class="bg-light p-3 rounded">
|
|
<pre class="mb-0">{{ message.metadata|pprint }}</pre>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Recipients List -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fas fa-users me-2"></i>
|
|
Recipients ({{ message.messagerecipient_set.count }})
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-nowrap table-hover mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Recipient</th>
|
|
<th>Status</th>
|
|
<th>Delivered</th>
|
|
<th>Read</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for recipient in message.messagerecipient_set.all %}
|
|
<tr>
|
|
<td>
|
|
<div class="d-flex align-items-center">
|
|
<div class="avatar-xs me-2">
|
|
<div class="avatar-title bg-soft-primary text-primary rounded-circle">
|
|
{{ recipient.recipient.first_name.0 }}{{ recipient.recipient.last_name.0 }}
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<h6 class="mb-0">{{ recipient.recipient.get_full_name }}</h6>
|
|
<small class="text-muted">{{ recipient.recipient.email }}</small>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<span class="badge bg-{% if recipient.status == 'DELIVERED' %}success{% elif recipient.status == 'FAILED' %}danger{% elif recipient.status == 'PENDING' %}warning{% else %}secondary{% endif %}">
|
|
{{ recipient.get_status_display }}
|
|
</span>
|
|
</td>
|
|
<td>
|
|
{% if recipient.delivered_at %}
|
|
<span class="text-success">
|
|
<i class="fas fa-check me-1"></i>
|
|
{{ recipient.delivered_at|date:"M d, g:i A" }}
|
|
</span>
|
|
{% else %}
|
|
<span class="text-muted">-</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if recipient.read_at %}
|
|
<span class="text-info">
|
|
<i class="fas fa-eye me-1"></i>
|
|
{{ recipient.read_at|date:"M d, g:i A" }}
|
|
</span>
|
|
{% else %}
|
|
<span class="text-muted">-</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>
|
|
{% if recipient.status == 'FAILED' %}
|
|
<button class="btn btn-sm btn-outline-warning" onclick="retryRecipient({{ recipient.id }})">
|
|
<i class="fas fa-redo me-1"></i>Retry
|
|
</button>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="5" class="text-center py-3">
|
|
<span class="text-muted">No recipients found</span>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Delivery Logs -->
|
|
{% if delivery_logs %}
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fas fa-history me-2"></i>
|
|
Delivery History
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-nowrap table-hover mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Channel</th>
|
|
<th>Status</th>
|
|
<th>Delivery Time</th>
|
|
<th>Response</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for log in delivery_logs %}
|
|
<tr>
|
|
<td>
|
|
<span class="badge bg-info">{{ log.channel.get_channel_type_display }}</span>
|
|
</td>
|
|
<td>
|
|
<span class="badge bg-{% if log.status == 'DELIVERED' %}success{% elif log.status == 'FAILED' %}danger{% else %}warning{% endif %}">
|
|
{{ log.get_status_display }}
|
|
</span>
|
|
</td>
|
|
<td>{{ log.delivery_time|date:"M d, Y g:i A" }}</td>
|
|
<td>
|
|
{% if log.response_data %}
|
|
<button class="btn btn-sm btn-outline-secondary" onclick="showResponse('{{ log.response_data|escapejs }}')">
|
|
View Response
|
|
</button>
|
|
{% else %}
|
|
<span class="text-muted">-</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Sidebar -->
|
|
<div class="col-lg-4">
|
|
<!-- Quick Actions -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fas fa-bolt me-2"></i>
|
|
Quick Actions
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="d-grid gap-2">
|
|
{% if message.status == 'DRAFT' %}
|
|
<button class="btn btn-success" onclick="sendMessage()">
|
|
<i class="fas fa-paper-plane me-1"></i>
|
|
Send Message
|
|
</button>
|
|
<a href="{% url 'communications:message_update' message.pk %}" class="btn btn-primary">
|
|
<i class="fas fa-edit me-1"></i>
|
|
Edit Message
|
|
</a>
|
|
{% elif message.status == 'FAILED' %}
|
|
<button class="btn btn-warning" onclick="retryMessage()">
|
|
<i class="fas fa-redo me-1"></i>
|
|
Retry Send
|
|
</button>
|
|
{% endif %}
|
|
|
|
<hr>
|
|
|
|
<button class="btn btn-outline-secondary" onclick="duplicateMessage()">
|
|
<i class="fas fa-copy me-1"></i>
|
|
Duplicate Message
|
|
</button>
|
|
<button class="btn btn-outline-info" onclick="exportMessage()">
|
|
<i class="fas fa-download me-1"></i>
|
|
Export Details
|
|
</button>
|
|
<button class="btn btn-outline-secondary" onclick="printMessage()">
|
|
<i class="fas fa-print me-1"></i>
|
|
Print
|
|
</button>
|
|
|
|
<hr>
|
|
|
|
<a href="{% url 'communications:message_delete' message.pk %}" class="btn btn-outline-danger">
|
|
<i class="fas fa-trash me-1"></i>
|
|
Delete Message
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Message Statistics -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fas fa-chart-bar me-2"></i>
|
|
Delivery Statistics
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-borderless table-sm">
|
|
<tr>
|
|
<td class="fw-bold text-muted">Total Recipients:</td>
|
|
<td>{{ message.messagerecipient_set.count }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold text-muted">Delivered:</td>
|
|
<td>
|
|
<span class="text-success">
|
|
{{ message.messagerecipient_set.filter.status='DELIVERED'.count }}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold text-muted">Failed:</td>
|
|
<td>
|
|
<span class="text-danger">
|
|
{{ message.messagerecipient_set.filter.status='FAILED'.count }}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold text-muted">Read:</td>
|
|
<td>
|
|
<span class="text-info">
|
|
{{ message.messagerecipient_set.exclude.read_at=None.count }}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Message Timeline -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fas fa-clock me-2"></i>
|
|
Timeline
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="timeline">
|
|
<div class="timeline-item">
|
|
<div class="timeline-marker bg-primary"></div>
|
|
<div class="timeline-content">
|
|
<h6 class="timeline-title">Created</h6>
|
|
<p class="timeline-text">{{ message.created_at|date:"M d, Y g:i A" }}</p>
|
|
</div>
|
|
</div>
|
|
|
|
{% if message.scheduled_time %}
|
|
<div class="timeline-item">
|
|
<div class="timeline-marker bg-info"></div>
|
|
<div class="timeline-content">
|
|
<h6 class="timeline-title">Scheduled</h6>
|
|
<p class="timeline-text">{{ message.scheduled_time|date:"M d, Y g:i A" }}</p>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if message.sent_at %}
|
|
<div class="timeline-item">
|
|
<div class="timeline-marker bg-success"></div>
|
|
<div class="timeline-content">
|
|
<h6 class="timeline-title">Sent</h6>
|
|
<p class="timeline-text">{{ message.sent_at|date:"M d, Y g:i A" }}</p>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="timeline-item">
|
|
<div class="timeline-marker bg-secondary"></div>
|
|
<div class="timeline-content">
|
|
<h6 class="timeline-title">Last Updated</h6>
|
|
<p class="timeline-text">{{ message.updated_at|date:"M d, Y g:i A" }}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Response Modal -->
|
|
<div class="modal fade" id="responseModal" tabindex="-1">
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Delivery Response</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<pre id="responseContent"></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block js %}
|
|
<script>
|
|
function sendMessage() {
|
|
if (confirm('Send this message now?')) {
|
|
fetch(`{% url 'communications:send_message' message.id %}`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
'Content-Type': 'application/json',
|
|
}
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
location.reload();
|
|
} else {
|
|
alert('Error sending message: ' + data.error);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
function retryMessage() {
|
|
if (confirm('Retry sending this message?')) {
|
|
// Implementation for retry logic
|
|
alert('Retry functionality will be implemented');
|
|
}
|
|
}
|
|
|
|
function retryRecipient(recipientId) {
|
|
if (confirm('Retry sending to this recipient?')) {
|
|
// Implementation for retry recipient logic
|
|
alert('Retry recipient functionality will be implemented');
|
|
}
|
|
}
|
|
|
|
function duplicateMessage() {
|
|
window.location.href = `{% url 'communications:message_create' %}?duplicate={{ message.id }}`;
|
|
}
|
|
|
|
function exportMessage() {
|
|
window.open(`/communications/export/message/{{ message.id }}/`, '_blank');
|
|
}
|
|
|
|
function printMessage() {
|
|
window.print();
|
|
}
|
|
|
|
function showResponse(responseData) {
|
|
document.getElementById('responseContent').textContent = responseData;
|
|
new bootstrap.Modal(document.getElementById('responseModal')).show();
|
|
}
|
|
</script>
|
|
{% endblock %}
|
|
|