1263 lines
41 KiB
HTML
1263 lines
41 KiB
HTML
{% extends 'base.html' %}
|
|
{% load static %}
|
|
|
|
{% block title %}Risk Assessments{% endblock %}
|
|
|
|
{% block extra_css %}
|
|
<link href="{% static 'assets/plugins/datatables.net-bs5/css/dataTables.bootstrap5.min.css' %}" rel="stylesheet" />
|
|
<link href="{% static 'assets/plugins/datatables.net-responsive-bs5/css/responsive.bootstrap5.min.css' %}" rel="stylesheet" />
|
|
<link href="{% static 'assets/plugins/datatables.net-buttons-bs5/css/buttons.bootstrap5.min.css' %}" rel="stylesheet" />
|
|
<style>
|
|
.page-header-section {
|
|
background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
|
|
color: white;
|
|
border-radius: 0.5rem;
|
|
padding: 2rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.stats-cards {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 1rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.stat-card {
|
|
background: white;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.5rem;
|
|
padding: 1.5rem;
|
|
text-align: center;
|
|
transition: transform 0.2s, box-shadow 0.2s;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.stat-card:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.stat-card::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
height: 3px;
|
|
background: var(--card-color);
|
|
}
|
|
|
|
.stat-icon {
|
|
width: 50px;
|
|
height: 50px;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin: 0 auto 1rem;
|
|
color: white;
|
|
font-size: 1.25rem;
|
|
}
|
|
|
|
.stat-number {
|
|
font-size: 2rem;
|
|
font-weight: bold;
|
|
color: #495057;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.stat-label {
|
|
color: #6c757d;
|
|
font-size: 0.875rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.stat-trend {
|
|
font-size: 0.75rem;
|
|
margin-top: 0.25rem;
|
|
}
|
|
|
|
.trend-up { color: #dc3545; }
|
|
.trend-down { color: #28a745; }
|
|
.trend-stable { color: #6c757d; }
|
|
|
|
.filters-section {
|
|
background: white;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.5rem;
|
|
padding: 1.5rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.filter-row {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 1rem;
|
|
align-items: end;
|
|
}
|
|
|
|
.assessments-table-section {
|
|
background: white;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.5rem;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.section-header {
|
|
background: #f8f9fa;
|
|
border-bottom: 1px solid #dee2e6;
|
|
padding: 1rem 1.5rem;
|
|
font-weight: 600;
|
|
color: #495057;
|
|
display: flex;
|
|
justify-content: between;
|
|
align-items: center;
|
|
}
|
|
|
|
.assessment-card {
|
|
background: white;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.5rem;
|
|
padding: 1.5rem;
|
|
margin-bottom: 1rem;
|
|
transition: all 0.2s;
|
|
cursor: pointer;
|
|
position: relative;
|
|
}
|
|
|
|
.assessment-card:hover {
|
|
border-color: #dc3545;
|
|
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.assessment-card::before {
|
|
content: '';
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
width: 4px;
|
|
background: var(--risk-color);
|
|
border-radius: 0.5rem 0 0 0.5rem;
|
|
}
|
|
|
|
.assessment-header {
|
|
display: flex;
|
|
justify-content: between;
|
|
align-items: start;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.assessment-title {
|
|
font-size: 1.25rem;
|
|
font-weight: 600;
|
|
color: #495057;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.assessment-id {
|
|
font-size: 0.875rem;
|
|
color: #6c757d;
|
|
font-family: monospace;
|
|
}
|
|
|
|
.assessment-badges {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.risk-level-badge {
|
|
padding: 0.375rem 0.75rem;
|
|
border-radius: 0.25rem;
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.risk-critical { background: #dc3545; color: white; }
|
|
.risk-high { background: #fd7e14; color: white; }
|
|
.risk-medium { background: #ffc107; color: #212529; }
|
|
.risk-low { background: #28a745; color: white; }
|
|
|
|
.status-badge {
|
|
padding: 0.375rem 0.75rem;
|
|
border-radius: 0.25rem;
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.status-draft { background: #6c757d; color: white; }
|
|
.status-pending { background: #ffc107; color: #212529; }
|
|
.status-approved { background: #28a745; color: white; }
|
|
.status-rejected { background: #dc3545; color: white; }
|
|
|
|
.assessment-description {
|
|
color: #6c757d;
|
|
margin-bottom: 1rem;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.assessment-meta {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
|
gap: 1rem;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.meta-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
font-size: 0.875rem;
|
|
color: #6c757d;
|
|
}
|
|
|
|
.meta-icon {
|
|
color: #dc3545;
|
|
width: 16px;
|
|
}
|
|
|
|
.risk-matrix {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
|
|
gap: 1rem;
|
|
margin-bottom: 1rem;
|
|
padding: 1rem;
|
|
background: #f8f9fa;
|
|
border-radius: 0.375rem;
|
|
}
|
|
|
|
.matrix-item {
|
|
text-align: center;
|
|
}
|
|
|
|
.matrix-value {
|
|
font-size: 1.25rem;
|
|
font-weight: bold;
|
|
color: var(--risk-color);
|
|
margin-bottom: 0.25rem;
|
|
}
|
|
|
|
.matrix-label {
|
|
font-size: 0.75rem;
|
|
color: #6c757d;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.assessment-progress {
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.progress-header {
|
|
display: flex;
|
|
justify-content: between;
|
|
align-items: center;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.progress-title {
|
|
font-size: 0.875rem;
|
|
font-weight: 600;
|
|
color: #495057;
|
|
}
|
|
|
|
.progress-percentage {
|
|
font-size: 0.875rem;
|
|
font-weight: bold;
|
|
color: #dc3545;
|
|
}
|
|
|
|
.progress-bar-container {
|
|
height: 8px;
|
|
background: #e9ecef;
|
|
border-radius: 4px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.progress-bar-fill {
|
|
height: 100%;
|
|
background: linear-gradient(90deg, #dc3545, #fd7e14);
|
|
border-radius: 4px;
|
|
transition: width 0.3s ease;
|
|
}
|
|
|
|
.assessment-actions {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
justify-content: end;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.btn-action {
|
|
padding: 0.375rem 0.75rem;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.25rem;
|
|
background: white;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
font-size: 0.875rem;
|
|
text-decoration: none;
|
|
color: #495057;
|
|
}
|
|
|
|
.btn-action:hover {
|
|
border-color: #dc3545;
|
|
color: #dc3545;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.btn-primary-action {
|
|
background: #dc3545;
|
|
border-color: #dc3545;
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary-action:hover {
|
|
background: #c82333;
|
|
border-color: #c82333;
|
|
color: white;
|
|
}
|
|
|
|
.quick-filters {
|
|
display: flex;
|
|
gap: 0.5rem;
|
|
margin-bottom: 1rem;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.quick-filter {
|
|
padding: 0.5rem 1rem;
|
|
border: 1px solid #dee2e6;
|
|
background: white;
|
|
border-radius: 0.25rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
font-size: 0.875rem;
|
|
text-decoration: none;
|
|
color: #495057;
|
|
}
|
|
|
|
.quick-filter:hover, .quick-filter.active {
|
|
background: #dc3545;
|
|
color: white;
|
|
border-color: #dc3545;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.view-toggle {
|
|
display: flex;
|
|
gap: 0.25rem;
|
|
background: #f8f9fa;
|
|
border-radius: 0.25rem;
|
|
padding: 0.25rem;
|
|
}
|
|
|
|
.toggle-btn {
|
|
padding: 0.5rem 1rem;
|
|
border: none;
|
|
background: transparent;
|
|
border-radius: 0.25rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
font-size: 0.875rem;
|
|
color: #6c757d;
|
|
}
|
|
|
|
.toggle-btn.active {
|
|
background: white;
|
|
color: #dc3545;
|
|
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.bulk-actions {
|
|
background: #f8f9fa;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.375rem;
|
|
padding: 1rem;
|
|
margin-bottom: 1rem;
|
|
display: none;
|
|
}
|
|
|
|
.bulk-actions.show {
|
|
display: block;
|
|
}
|
|
|
|
.assessment-alerts {
|
|
margin-top: 1rem;
|
|
padding: 1rem;
|
|
background: #fff3cd;
|
|
border-radius: 0.375rem;
|
|
border-left: 4px solid #ffc107;
|
|
}
|
|
|
|
.assessment-alerts h6 {
|
|
color: #856404;
|
|
margin-bottom: 0.75rem;
|
|
}
|
|
|
|
.alert-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
margin-bottom: 0.5rem;
|
|
font-size: 0.875rem;
|
|
color: #856404;
|
|
}
|
|
|
|
.alert-icon {
|
|
width: 16px;
|
|
height: 16px;
|
|
border-radius: 50%;
|
|
background: #ffc107;
|
|
color: white;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 0.75rem;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.mitigation-preview {
|
|
background: #e8f5e8;
|
|
border-radius: 0.375rem;
|
|
padding: 0.75rem;
|
|
margin-top: 1rem;
|
|
}
|
|
|
|
.mitigation-title {
|
|
font-size: 0.875rem;
|
|
font-weight: 600;
|
|
color: #2e7d32;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.mitigation-list {
|
|
list-style: none;
|
|
padding: 0;
|
|
margin: 0;
|
|
}
|
|
|
|
.mitigation-item {
|
|
font-size: 0.75rem;
|
|
color: #2e7d32;
|
|
margin-bottom: 0.25rem;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.mitigation-icon {
|
|
width: 12px;
|
|
height: 12px;
|
|
border-radius: 50%;
|
|
background: #28a745;
|
|
color: white;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 0.625rem;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.page-header-section {
|
|
padding: 1.5rem;
|
|
}
|
|
|
|
.stats-cards {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
}
|
|
|
|
.filter-row {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.assessment-header {
|
|
flex-direction: column;
|
|
align-items: start;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.assessment-meta {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
|
|
.risk-matrix {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
}
|
|
|
|
.assessment-actions {
|
|
flex-direction: column;
|
|
align-items: stretch;
|
|
}
|
|
|
|
.quick-filters {
|
|
justify-content: center;
|
|
}
|
|
}
|
|
|
|
@media print {
|
|
.filters-section, .bulk-actions, .assessment-actions {
|
|
display: none !important;
|
|
}
|
|
|
|
.section-header {
|
|
background: none;
|
|
border-bottom: 2px solid #000;
|
|
color: #000;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div id="content" class="app-content">
|
|
<!-- Page Header -->
|
|
<div class="d-flex align-items-center mb-3">
|
|
<div>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'quality:dashboard' %}">Quality</a></li>
|
|
<li class="breadcrumb-item active">Risk Assessments</li>
|
|
</ol>
|
|
<h1 class="page-header mb-0">
|
|
<i class="fas fa-shield-alt me-2"></i>Risk Assessments
|
|
</h1>
|
|
</div>
|
|
<div class="ms-auto">
|
|
<button type="button" class="btn btn-outline-secondary me-2" onclick="exportAssessments()">
|
|
<i class="fas fa-download me-1"></i>Export
|
|
</button>
|
|
<button type="button" class="btn btn-outline-info me-2" onclick="importAssessments()">
|
|
<i class="fas fa-upload me-1"></i>Import
|
|
</button>
|
|
<a href="{% url 'quality:risk_assessment_create' %}" class="btn btn-danger">
|
|
<i class="fas fa-plus me-1"></i>New Assessment
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Statistics Cards -->
|
|
<div class="stats-cards">
|
|
<div class="stat-card" style="--card-color: #dc3545;">
|
|
<div class="stat-icon" style="background: #dc3545;">
|
|
<i class="fas fa-shield-alt"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.total_assessments|default:0 }}</div>
|
|
<div class="stat-label">Total Assessments</div>
|
|
<div class="stat-trend trend-up">
|
|
<i class="fas fa-arrow-up me-1"></i>+8.3% this month
|
|
</div>
|
|
</div>
|
|
|
|
<div class="stat-card" style="--card-color: #fd7e14;">
|
|
<div class="stat-icon" style="background: #fd7e14;">
|
|
<i class="fas fa-exclamation-triangle"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.high_risk|default:0 }}</div>
|
|
<div class="stat-label">High Risk</div>
|
|
<div class="stat-trend trend-up">
|
|
<i class="fas fa-arrow-up me-1"></i>+2 this week
|
|
</div>
|
|
</div>
|
|
|
|
<div class="stat-card" style="--card-color: #ffc107;">
|
|
<div class="stat-icon" style="background: #ffc107;">
|
|
<i class="fas fa-clock"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.pending_review|default:0 }}</div>
|
|
<div class="stat-label">Pending Review</div>
|
|
<div class="stat-trend trend-stable">
|
|
<i class="fas fa-minus me-1"></i>No change
|
|
</div>
|
|
</div>
|
|
|
|
<div class="stat-card" style="--card-color: #28a745;">
|
|
<div class="stat-icon" style="background: #28a745;">
|
|
<i class="fas fa-check-circle"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.mitigated_risks|default:0 }}</div>
|
|
<div class="stat-label">Mitigated</div>
|
|
<div class="stat-trend trend-down">
|
|
<i class="fas fa-arrow-down me-1"></i>-5.2% this month
|
|
</div>
|
|
</div>
|
|
|
|
<div class="stat-card" style="--card-color: #6f42c1;">
|
|
<div class="stat-icon" style="background: #6f42c1;">
|
|
<i class="fas fa-calendar-check"></i>
|
|
</div>
|
|
<div class="stat-number">{{ stats.overdue_reviews|default:0 }}</div>
|
|
<div class="stat-label">Overdue Reviews</div>
|
|
<div class="stat-trend trend-up">
|
|
<i class="fas fa-arrow-up me-1"></i>+1 this week
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Quick Filters -->
|
|
<div class="quick-filters">
|
|
<a href="?risk_level=all" class="quick-filter {% if not request.GET.risk_level or request.GET.risk_level == 'all' %}active{% endif %}">
|
|
<i class="fas fa-list me-1"></i>All Assessments
|
|
</a>
|
|
<a href="?risk_level=critical" class="quick-filter {% if request.GET.risk_level == 'critical' %}active{% endif %}">
|
|
<i class="fas fa-exclamation-circle me-1"></i>Critical
|
|
</a>
|
|
<a href="?risk_level=high" class="quick-filter {% if request.GET.risk_level == 'high' %}active{% endif %}">
|
|
<i class="fas fa-exclamation-triangle me-1"></i>High Risk
|
|
</a>
|
|
<a href="?risk_level=medium" class="quick-filter {% if request.GET.risk_level == 'medium' %}active{% endif %}">
|
|
<i class="fas fa-minus-circle me-1"></i>Medium Risk
|
|
</a>
|
|
<a href="?status=pending" class="quick-filter {% if request.GET.status == 'pending' %}active{% endif %}">
|
|
<i class="fas fa-clock me-1"></i>Pending Review
|
|
</a>
|
|
<a href="?status=overdue" class="quick-filter {% if request.GET.status == 'overdue' %}active{% endif %}">
|
|
<i class="fas fa-calendar-times me-1"></i>Overdue
|
|
</a>
|
|
</div>
|
|
|
|
<!-- Filters Section -->
|
|
<div class="filters-section">
|
|
<h6 class="mb-3">
|
|
<i class="fas fa-filter me-2"></i>Advanced Filters
|
|
</h6>
|
|
|
|
<form method="get" id="filter-form">
|
|
<div class="filter-row">
|
|
<div>
|
|
<label class="form-label">Search Assessments</label>
|
|
<input type="text" class="form-control" name="search"
|
|
value="{{ request.GET.search }}" placeholder="Search assessments...">
|
|
</div>
|
|
|
|
<div>
|
|
<label class="form-label">Risk Level</label>
|
|
<select class="form-select" name="risk_level">
|
|
<option value="">All Risk Levels</option>
|
|
<option value="critical" {% if request.GET.risk_level == 'critical' %}selected{% endif %}>Critical</option>
|
|
<option value="high" {% if request.GET.risk_level == 'high' %}selected{% endif %}>High</option>
|
|
<option value="medium" {% if request.GET.risk_level == 'medium' %}selected{% endif %}>Medium</option>
|
|
<option value="low" {% if request.GET.risk_level == 'low' %}selected{% endif %}>Low</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="form-label">Status</label>
|
|
<select class="form-select" name="status">
|
|
<option value="">All Statuses</option>
|
|
<option value="draft" {% if request.GET.status == 'draft' %}selected{% endif %}>Draft</option>
|
|
<option value="pending" {% if request.GET.status == 'pending' %}selected{% endif %}>Pending Review</option>
|
|
<option value="approved" {% if request.GET.status == 'approved' %}selected{% endif %}>Approved</option>
|
|
<option value="rejected" {% if request.GET.status == 'rejected' %}selected{% endif %}>Rejected</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="form-label">Department</label>
|
|
<select class="form-select" name="department">
|
|
<option value="">All Departments</option>
|
|
{% for dept in departments %}
|
|
<option value="{{ dept.id }}" {% if request.GET.department == dept.id|stringformat:"s" %}selected{% endif %}>
|
|
{{ dept.name }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="form-label">Assessor</label>
|
|
<select class="form-select" name="assessor">
|
|
<option value="">All Assessors</option>
|
|
{% for user in assessors %}
|
|
<option value="{{ user.id }}" {% if request.GET.assessor == user.id|stringformat:"s" %}selected{% endif %}>
|
|
{{ user.get_full_name }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
|
|
<div>
|
|
<button type="submit" class="btn btn-danger">
|
|
<i class="fas fa-search me-1"></i>Filter
|
|
</button>
|
|
<a href="{% url 'quality:risk_assessment_list' %}" class="btn btn-outline-secondary ms-2">
|
|
<i class="fas fa-times me-1"></i>Clear
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Bulk Actions -->
|
|
<div class="bulk-actions" id="bulk-actions">
|
|
<div class="d-flex align-items-center justify-content-between">
|
|
<div>
|
|
<span id="selected-count">0</span> assessments selected
|
|
</div>
|
|
<div>
|
|
<button type="button" class="btn btn-outline-primary btn-sm me-2" onclick="bulkExport()">
|
|
<i class="fas fa-download me-1"></i>Export Selected
|
|
</button>
|
|
<button type="button" class="btn btn-outline-info btn-sm me-2" onclick="bulkUpdate()">
|
|
<i class="fas fa-edit me-1"></i>Update Status
|
|
</button>
|
|
<button type="button" class="btn btn-outline-success btn-sm me-2" onclick="bulkApprove()">
|
|
<i class="fas fa-check me-1"></i>Approve Selected
|
|
</button>
|
|
<button type="button" class="btn btn-outline-danger btn-sm" onclick="bulkArchive()">
|
|
<i class="fas fa-archive me-1"></i>Archive Selected
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Assessments Section -->
|
|
<div class="assessments-table-section">
|
|
<div class="section-header">
|
|
<div>
|
|
<i class="fas fa-shield-alt me-2"></i>Risk Assessments ({{ assessments|length }})
|
|
</div>
|
|
<div class="d-flex align-items-center gap-2">
|
|
<div class="view-toggle">
|
|
<button type="button" class="toggle-btn active" onclick="setView('cards')" data-view="cards">
|
|
<i class="fas fa-th-large"></i>
|
|
</button>
|
|
<button type="button" class="toggle-btn" onclick="setView('table')" data-view="table">
|
|
<i class="fas fa-table"></i>
|
|
</button>
|
|
</div>
|
|
<div class="form-check form-switch">
|
|
<input class="form-check-input" type="checkbox" id="select-all">
|
|
<label class="form-check-label" for="select-all">Select All</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="p-3" id="assessments-container">
|
|
{% for assessment in assessments %}
|
|
<div class="assessment-card" style="--risk-color: {% if assessment.risk_level == 'critical' %}#dc3545{% elif assessment.risk_level == 'high' %}#fd7e14{% elif assessment.risk_level == 'medium' %}#ffc107{% else %}#28a745{% endif %};" onclick="viewAssessment({{ assessment.id }})">
|
|
<div class="form-check position-absolute" style="top: 1rem; left: 1rem;">
|
|
<input class="form-check-input assessment-checkbox" type="checkbox" value="{{ assessment.id }}" onclick="event.stopPropagation();">
|
|
</div>
|
|
|
|
<div class="assessment-header">
|
|
<div>
|
|
<div class="assessment-title">{{ assessment.title }}</div>
|
|
<div class="assessment-id">ID: {{ assessment.assessment_id|default:assessment.id }}</div>
|
|
</div>
|
|
<div class="assessment-badges">
|
|
<span class="risk-level-badge risk-{{ assessment.risk_level|lower }}">
|
|
{{ assessment.get_risk_level_display }}
|
|
</span>
|
|
<span class="status-badge status-{{ assessment.status|lower }}">
|
|
{{ assessment.get_status_display }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="assessment-description">
|
|
{{ assessment.description|truncatechars:200 }}
|
|
</div>
|
|
|
|
<div class="assessment-meta">
|
|
<div class="meta-item">
|
|
<i class="fas fa-building meta-icon"></i>
|
|
<span>{{ assessment.department.name|default:"No Department" }}</span>
|
|
</div>
|
|
<div class="meta-item">
|
|
<i class="fas fa-user meta-icon"></i>
|
|
<span>{{ assessment.assessor.get_full_name|default:"No Assessor" }}</span>
|
|
</div>
|
|
<div class="meta-item">
|
|
<i class="fas fa-calendar-alt meta-icon"></i>
|
|
<span>{{ assessment.assessment_date|date:"M d, Y"|default:"Not set" }}</span>
|
|
</div>
|
|
<div class="meta-item">
|
|
<i class="fas fa-calendar-check meta-icon"></i>
|
|
<span>Next: {{ assessment.next_review_date|date:"M d, Y"|default:"Not scheduled" }}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="risk-matrix">
|
|
<div class="matrix-item">
|
|
<div class="matrix-value" style="color: var(--risk-color);">{{ assessment.likelihood|default:"-" }}</div>
|
|
<div class="matrix-label">Likelihood</div>
|
|
</div>
|
|
|
|
<div class="matrix-item">
|
|
<div class="matrix-value" style="color: var(--risk-color);">{{ assessment.impact|default:"-" }}</div>
|
|
<div class="matrix-label">Impact</div>
|
|
</div>
|
|
|
|
<div class="matrix-item">
|
|
<div class="matrix-value" style="color: var(--risk-color);">{{ assessment.risk_score|default:"-" }}</div>
|
|
<div class="matrix-label">Risk Score</div>
|
|
</div>
|
|
|
|
<div class="matrix-item">
|
|
<div class="matrix-value" style="color: var(--risk-color);">{{ assessment.residual_risk|default:"-" }}</div>
|
|
<div class="matrix-label">Residual Risk</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% if assessment.mitigation_progress %}
|
|
<div class="assessment-progress">
|
|
<div class="progress-header">
|
|
<div class="progress-title">Mitigation Progress</div>
|
|
<div class="progress-percentage">{{ assessment.mitigation_progress|default:0 }}%</div>
|
|
</div>
|
|
<div class="progress-bar-container">
|
|
<div class="progress-bar-fill" style="width: {{ assessment.mitigation_progress|default:0 }}%;"></div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if assessment.mitigation_actions.exists %}
|
|
<div class="mitigation-preview">
|
|
<div class="mitigation-title">
|
|
<i class="fas fa-shield-alt me-1"></i>Mitigation Actions ({{ assessment.mitigation_actions.count }})
|
|
</div>
|
|
<ul class="mitigation-list">
|
|
{% for action in assessment.mitigation_actions.all|slice:":3" %}
|
|
<li class="mitigation-item">
|
|
<div class="mitigation-icon">
|
|
<i class="fas fa-check"></i>
|
|
</div>
|
|
<span>{{ action.title|truncatechars:50 }}</span>
|
|
</li>
|
|
{% endfor %}
|
|
{% if assessment.mitigation_actions.count > 3 %}
|
|
<li class="mitigation-item">
|
|
<div class="mitigation-icon">
|
|
<i class="fas fa-plus"></i>
|
|
</div>
|
|
<span>+{{ assessment.mitigation_actions.count|add:"-3" }} more actions</span>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if assessment.alerts.exists %}
|
|
<div class="assessment-alerts">
|
|
<h6><i class="fas fa-exclamation-triangle me-2"></i>Active Alerts</h6>
|
|
{% for alert in assessment.alerts.all|slice:":3" %}
|
|
<div class="alert-item">
|
|
<div class="alert-icon">
|
|
<i class="fas fa-exclamation"></i>
|
|
</div>
|
|
<span>{{ alert.message|truncatechars:60 }}</span>
|
|
</div>
|
|
{% endfor %}
|
|
{% if assessment.alerts.count > 3 %}
|
|
<div class="text-muted">+{{ assessment.alerts.count|add:"-3" }} more alerts</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="assessment-actions">
|
|
<a href="{% url 'quality:risk_assessment_detail' assessment.id %}" class="btn-action" onclick="event.stopPropagation();">
|
|
<i class="fas fa-eye me-1"></i>View
|
|
</a>
|
|
{% if assessment.can_edit %}
|
|
<a href="{% url 'quality:risk_assessment_edit' assessment.id %}" class="btn-action" onclick="event.stopPropagation();">
|
|
<i class="fas fa-edit me-1"></i>Edit
|
|
</a>
|
|
{% endif %}
|
|
{% if assessment.can_approve %}
|
|
<button type="button" class="btn-action" onclick="event.stopPropagation(); approveAssessment({{ assessment.id }});">
|
|
<i class="fas fa-check me-1"></i>Approve
|
|
</button>
|
|
{% endif %}
|
|
<button type="button" class="btn-primary-action" onclick="event.stopPropagation(); viewMitigations({{ assessment.id }});">
|
|
<i class="fas fa-shield-alt me-1"></i>Mitigations
|
|
</button>
|
|
<button type="button" class="btn-action" onclick="event.stopPropagation(); generateReport({{ assessment.id }});">
|
|
<i class="fas fa-file-alt me-1"></i>Report
|
|
</button>
|
|
</div>
|
|
</div>
|
|
{% empty %}
|
|
<div class="text-center py-5">
|
|
<div class="text-muted">
|
|
<i class="fas fa-shield-alt fa-3x mb-3"></i>
|
|
<h5>No Risk Assessments Found</h5>
|
|
<p>No assessments match your current filters.</p>
|
|
<a href="{% url 'quality:risk_assessment_create' %}" class="btn btn-danger">
|
|
<i class="fas fa-plus me-1"></i>Create First Assessment
|
|
</a>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<!-- Pagination -->
|
|
{% if is_paginated %}
|
|
<div class="d-flex justify-content-between align-items-center p-3">
|
|
<div class="text-muted">
|
|
Showing {{ assessments|length }} of {{ total_assessments }} assessments
|
|
</div>
|
|
|
|
<nav aria-label="Assessments pagination">
|
|
<ul class="pagination pagination-sm mb-0">
|
|
{% if page_obj.has_previous %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page=1{{ request.GET.urlencode }}">First</a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.previous_page_number }}{{ request.GET.urlencode }}">Previous</a>
|
|
</li>
|
|
{% endif %}
|
|
|
|
<li class="page-item active">
|
|
<span class="page-link">{{ page_obj.number }} of {{ page_obj.paginator.num_pages }}</span>
|
|
</li>
|
|
|
|
{% if page_obj.has_next %}
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.next_page_number }}{{ request.GET.urlencode }}">Next</a>
|
|
</li>
|
|
<li class="page-item">
|
|
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}{{ request.GET.urlencode }}">Last</a>
|
|
</li>
|
|
{% endif %}
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Bulk Update Modal -->
|
|
<div class="modal fade" id="bulkUpdateModal" tabindex="-1">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">
|
|
<i class="fas fa-edit me-2"></i>Bulk Update Assessments
|
|
</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="mb-3">
|
|
<label class="form-label">Update Action</label>
|
|
<select class="form-select" id="bulk-action">
|
|
<option value="">Select Action</option>
|
|
<option value="approve">Approve</option>
|
|
<option value="reject">Reject</option>
|
|
<option value="archive">Archive</option>
|
|
<option value="schedule_review">Schedule Review</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Reason</label>
|
|
<textarea class="form-control" id="bulk-reason" rows="3"
|
|
placeholder="Please provide a reason for this bulk update..."></textarea>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">
|
|
<i class="fas fa-times me-1"></i>Cancel
|
|
</button>
|
|
<button type="button" class="btn btn-danger" onclick="confirmBulkUpdate()">
|
|
<i class="fas fa-check me-1"></i>Update Selected
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block extra_js %}
|
|
<script src="{% static 'assets/plugins/datatables.net/js/jquery.dataTables.min.js' %}"></script>
|
|
<script src="{% static 'assets/plugins/datatables.net-bs5/js/dataTables.bootstrap5.min.js' %}"></script>
|
|
<script src="{% static 'assets/plugins/datatables.net-responsive-bs5/js/responsive.bootstrap5.min.js' %}"></script>
|
|
<script src="{% static 'assets/plugins/datatables.net-buttons-bs5/js/buttons.bootstrap5.min.js' %}"></script>
|
|
|
|
<script>
|
|
let selectedAssessments = [];
|
|
|
|
$(document).ready(function() {
|
|
// Handle select all checkbox
|
|
$('#select-all').change(function() {
|
|
$('.assessment-checkbox').prop('checked', this.checked);
|
|
updateBulkActions();
|
|
});
|
|
|
|
// Handle individual checkboxes
|
|
$('.assessment-checkbox').change(function() {
|
|
updateBulkActions();
|
|
|
|
// Update select all checkbox
|
|
const totalCheckboxes = $('.assessment-checkbox').length;
|
|
const checkedCheckboxes = $('.assessment-checkbox:checked').length;
|
|
$('#select-all').prop('checked', totalCheckboxes === checkedCheckboxes);
|
|
});
|
|
});
|
|
|
|
function updateBulkActions() {
|
|
const selectedCount = $('.assessment-checkbox:checked').length;
|
|
$('#selected-count').text(selectedCount);
|
|
|
|
if (selectedCount > 0) {
|
|
$('#bulk-actions').addClass('show');
|
|
} else {
|
|
$('#bulk-actions').removeClass('show');
|
|
}
|
|
|
|
selectedAssessments = $('.assessment-checkbox:checked').map(function() {
|
|
return this.value;
|
|
}).get();
|
|
}
|
|
|
|
function setView(viewType) {
|
|
$('.toggle-btn').removeClass('active');
|
|
$(`[data-view="${viewType}"]`).addClass('active');
|
|
|
|
// In a real implementation, this would switch between card and table views
|
|
if (viewType === 'table') {
|
|
// Convert to table view
|
|
showAlert('Table view activated', 'info');
|
|
} else {
|
|
// Convert to card view
|
|
showAlert('Card view activated', 'info');
|
|
}
|
|
}
|
|
|
|
function viewAssessment(assessmentId) {
|
|
window.location.href = `/quality/risk-assessments/${assessmentId}/`;
|
|
}
|
|
|
|
function approveAssessment(assessmentId) {
|
|
if (confirm('Approve this risk assessment?')) {
|
|
fetch(`/quality/risk-assessments/${assessmentId}/approve/`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
|
|
}
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert('Assessment approved successfully', 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error approving assessment', 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error approving assessment', 'danger');
|
|
});
|
|
}
|
|
}
|
|
|
|
function viewMitigations(assessmentId) {
|
|
window.open(`/quality/risk-assessments/${assessmentId}/mitigations/`, '_blank');
|
|
}
|
|
|
|
function generateReport(assessmentId) {
|
|
window.open(`/quality/risk-assessments/${assessmentId}/report/`, '_blank');
|
|
}
|
|
|
|
function exportAssessments() {
|
|
const selectedAssessments = $('.assessment-checkbox:checked').map(function() {
|
|
return this.value;
|
|
}).get();
|
|
|
|
let url = '/quality/risk-assessments/export/';
|
|
if (selectedAssessments.length > 0) {
|
|
url += '?assessments=' + selectedAssessments.join(',');
|
|
}
|
|
|
|
window.open(url, '_blank');
|
|
}
|
|
|
|
function importAssessments() {
|
|
// Create file input for importing assessments
|
|
const input = document.createElement('input');
|
|
input.type = 'file';
|
|
input.accept = '.csv,.xlsx';
|
|
input.onchange = function(e) {
|
|
const file = e.target.files[0];
|
|
if (file) {
|
|
const formData = new FormData();
|
|
formData.append('file', file);
|
|
|
|
fetch('/quality/risk-assessments/import/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
|
|
},
|
|
body: formData
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert(`${data.imported_count} assessments imported successfully`, 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error importing assessments: ' + (data.error || 'Unknown error'), 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error importing assessments', 'danger');
|
|
});
|
|
}
|
|
};
|
|
input.click();
|
|
}
|
|
|
|
function bulkExport() {
|
|
if (selectedAssessments.length === 0) {
|
|
showAlert('Please select assessments to export', 'warning');
|
|
return;
|
|
}
|
|
|
|
const url = '/quality/risk-assessments/export/?assessments=' + selectedAssessments.join(',');
|
|
window.open(url, '_blank');
|
|
}
|
|
|
|
function bulkUpdate() {
|
|
if (selectedAssessments.length === 0) {
|
|
showAlert('Please select assessments to update', 'warning');
|
|
return;
|
|
}
|
|
|
|
new bootstrap.Modal(document.getElementById('bulkUpdateModal')).show();
|
|
}
|
|
|
|
function confirmBulkUpdate() {
|
|
const action = document.getElementById('bulk-action').value;
|
|
const reason = document.getElementById('bulk-reason').value;
|
|
|
|
if (!action) {
|
|
showAlert('Please select an action', 'warning');
|
|
return;
|
|
}
|
|
|
|
if (!reason.trim()) {
|
|
showAlert('Please provide a reason for this update', 'warning');
|
|
return;
|
|
}
|
|
|
|
fetch('/quality/risk-assessments/bulk-update/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
assessment_ids: selectedAssessments,
|
|
action: action,
|
|
reason: reason
|
|
})
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert(`${data.updated_count} assessments updated successfully`, 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error updating assessments', 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error updating assessments', 'danger');
|
|
});
|
|
|
|
bootstrap.Modal.getInstance(document.getElementById('bulkUpdateModal')).hide();
|
|
}
|
|
|
|
function bulkApprove() {
|
|
if (selectedAssessments.length === 0) {
|
|
showAlert('Please select assessments to approve', 'warning');
|
|
return;
|
|
}
|
|
|
|
if (confirm(`Approve ${selectedAssessments.length} selected assessments?`)) {
|
|
fetch('/quality/risk-assessments/bulk-approve/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
assessment_ids: selectedAssessments
|
|
})
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert(`${data.approved_count} assessments approved successfully`, 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error approving assessments', 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error approving assessments', 'danger');
|
|
});
|
|
}
|
|
}
|
|
|
|
function bulkArchive() {
|
|
if (selectedAssessments.length === 0) {
|
|
showAlert('Please select assessments to archive', 'warning');
|
|
return;
|
|
}
|
|
|
|
if (confirm(`Archive ${selectedAssessments.length} selected assessments?`)) {
|
|
fetch('/quality/risk-assessments/bulk-archive/', {
|
|
method: 'POST',
|
|
headers: {
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({
|
|
assessment_ids: selectedAssessments
|
|
})
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showAlert(`${data.archived_count} assessments archived successfully`, 'success');
|
|
setTimeout(() => location.reload(), 1500);
|
|
} else {
|
|
showAlert('Error archiving assessments', 'danger');
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showAlert('Error archiving assessments', 'danger');
|
|
});
|
|
}
|
|
}
|
|
|
|
function showAlert(message, type) {
|
|
const alertDiv = document.createElement('div');
|
|
alertDiv.className = `alert alert-${type} alert-dismissible fade show position-fixed`;
|
|
alertDiv.style.cssText = 'top: 20px; right: 20px; z-index: 1060; min-width: 300px;';
|
|
alertDiv.innerHTML = `
|
|
${message}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
`;
|
|
|
|
document.body.appendChild(alertDiv);
|
|
|
|
setTimeout(() => {
|
|
if (alertDiv.parentNode) {
|
|
alertDiv.remove();
|
|
}
|
|
}, 5000);
|
|
}
|
|
</script>
|
|
{% endblock %}
|
|
|