379 lines
20 KiB
HTML
379 lines
20 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete {{ object.name }} - Analytics Metrics{% endblock %}
|
|
|
|
{% block content %}
|
|
<!-- BEGIN breadcrumb -->
|
|
<ol class="breadcrumb float-xl-end">
|
|
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'analytics:dashboard' %}">Analytics</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'analytics:metric_list' %}">Metrics</a></li>
|
|
<li class="breadcrumb-item active">Delete Confirmation</li>
|
|
</ol>
|
|
<!-- END breadcrumb -->
|
|
|
|
<!-- BEGIN page-header -->
|
|
<h1 class="page-header">
|
|
Delete Metric
|
|
<small>Confirmation Required</small>
|
|
</h1>
|
|
<!-- END page-header -->
|
|
|
|
<div class="row justify-content-center">
|
|
<div class="col-xl-8">
|
|
<!-- BEGIN panel -->
|
|
<div class="panel panel-inverse">
|
|
<div class="panel-heading">
|
|
<h4 class="panel-title">
|
|
<i class="fa fa-exclamation-triangle text-warning me-2"></i>
|
|
Confirm Metric Deletion
|
|
</h4>
|
|
</div>
|
|
<div class="panel-body">
|
|
<!-- Warning Alert -->
|
|
<div class="alert alert-warning d-flex align-items-center mb-4">
|
|
<i class="fa fa-exclamation-triangle fa-2x me-3"></i>
|
|
<div>
|
|
<h6 class="alert-heading mb-1">Warning: Permanent Deletion</h6>
|
|
<p class="mb-0">You are about to permanently delete an analytics metric. This action cannot be undone and will affect all historical data and dashboard displays.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Metric Information -->
|
|
<div class="row mb-4">
|
|
<div class="col-md-6">
|
|
<h6 class="mb-3">Metric Details</h6>
|
|
<table class="table table-borderless">
|
|
<tr>
|
|
<td class="fw-bold" width="140">Name:</td>
|
|
<td>{{ object.name }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Description:</td>
|
|
<td>{{ object.description|default:"No description" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Category:</td>
|
|
<td>
|
|
<span class="badge bg-primary">{{ object.get_category_display }}</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Current Value:</td>
|
|
<td>
|
|
{% if object.current_value is not None %}
|
|
<span class="fw-bold">{{ object.current_value }}{% if object.unit %} {{ object.unit }}{% endif %}</span>
|
|
{% else %}
|
|
<span class="text-muted">No data</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Status:</td>
|
|
<td>
|
|
<span class="badge bg-{% if object.status == 'ACTIVE' %}success{% elif object.status == 'DRAFT' %}warning{% else %}secondary{% endif %}">
|
|
{{ object.get_status_display }}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6 class="mb-3">Metric Statistics</h6>
|
|
<table class="table table-borderless">
|
|
<tr>
|
|
<td class="fw-bold" width="140">Created:</td>
|
|
<td>{{ object.created_at|date:"M d, Y" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Created By:</td>
|
|
<td>{{ object.created_by.get_full_name|default:"System" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Last Updated:</td>
|
|
<td>{{ object.last_updated|date:"M d, Y H:i"|default:"Never" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Update Count:</td>
|
|
<td>{{ object.update_count }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Frequency:</td>
|
|
<td>{{ object.get_update_frequency_display }}</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Impact Assessment -->
|
|
<div class="alert alert-info mb-4">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-info-circle me-2"></i>Impact Assessment
|
|
</h6>
|
|
<ul class="mb-0">
|
|
<li><strong>Metric Definition:</strong> The metric configuration and calculation query will be permanently deleted</li>
|
|
<li><strong>Historical Data:</strong> All {{ object.update_count }} historical data points will be removed</li>
|
|
<li><strong>Dashboard Widgets:</strong> Any dashboard widgets displaying this metric will show no data</li>
|
|
<li><strong>Reports:</strong> Reports referencing this metric may fail or show incomplete data</li>
|
|
<li><strong>Alerts:</strong> Any alerts configured for this metric will be deactivated</li>
|
|
<li><strong>Audit Trail:</strong> Deletion will be logged for compliance purposes</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- Target Information -->
|
|
{% if object.target_value is not None %}
|
|
<div class="alert alert-warning mb-4">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-target me-2"></i>Target Configuration Warning
|
|
</h6>
|
|
<p class="mb-2">This metric has target configuration that will be lost:</p>
|
|
<ul class="mb-0">
|
|
<li><strong>Target Value:</strong> {{ object.target_value }}{% if object.unit %} {{ object.unit }}{% endif %}</li>
|
|
<li><strong>Direction:</strong> {{ object.get_target_direction_display }}</li>
|
|
{% if object.warning_threshold %}
|
|
<li><strong>Warning Threshold:</strong> {{ object.warning_threshold }}{% if object.unit %} {{ object.unit }}{% endif %}</li>
|
|
{% endif %}
|
|
{% if object.critical_threshold %}
|
|
<li><strong>Critical Threshold:</strong> {{ object.critical_threshold }}{% if object.unit %} {{ object.unit }}{% endif %}</li>
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Related Data Summary -->
|
|
<div class="row mb-4">
|
|
<div class="col-md-3">
|
|
<div class="text-center p-3 border rounded">
|
|
<div class="fs-24px fw-bold text-primary">{{ object.update_count }}</div>
|
|
<div class="small text-muted">Data Points</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="text-center p-3 border rounded">
|
|
<div class="fs-24px fw-bold text-info">{{ object.alert_count }}</div>
|
|
<div class="small text-muted">Active Alerts</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="text-center p-3 border rounded">
|
|
<div class="fs-24px fw-bold text-warning">{{ object.dashboard_count }}</div>
|
|
<div class="small text-muted">Dashboard Uses</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="text-center p-3 border rounded">
|
|
<div class="fs-24px fw-bold text-secondary">{{ object.report_count }}</div>
|
|
<div class="small text-muted">Report Uses</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Alternative Actions -->
|
|
<div class="card border-secondary mb-4">
|
|
<div class="card-header bg-light">
|
|
<h6 class="card-title mb-0">
|
|
<i class="fa fa-lightbulb me-2"></i>Alternative Actions
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="card-text">Consider these alternatives instead of deletion:</p>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<ul class="list-unstyled">
|
|
<li class="mb-2">
|
|
<i class="fa fa-pause text-warning me-2"></i>
|
|
<a href="{% url 'analytics:metric_deactivate' object.pk %}" class="text-decoration-none">
|
|
Deactivate the metric
|
|
</a>
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fa fa-archive text-info me-2"></i>
|
|
<a href="{% url 'analytics:metric_archive' object.pk %}" class="text-decoration-none">
|
|
Archive the metric
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<ul class="list-unstyled">
|
|
<li class="mb-2">
|
|
<i class="fa fa-edit text-primary me-2"></i>
|
|
<a href="{% url 'analytics:metric_update' object.pk %}" class="text-decoration-none">
|
|
Edit metric configuration
|
|
</a>
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fa fa-download text-success me-2"></i>
|
|
Export historical data
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Active Alerts Warning -->
|
|
{% if object.alert_count > 0 %}
|
|
<div class="alert alert-danger mb-4">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-bell me-2"></i>Active Alerts Found
|
|
</h6>
|
|
<p class="mb-2">This metric has {{ object.alert_count }} active alert(s) that will be affected:</p>
|
|
<ul class="mb-0">
|
|
{% for alert in object.alerts.all %}
|
|
<li>{{ alert.name }} - {{ alert.get_condition_display }}: {{ alert.threshold_value }}</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Dashboard Usage Warning -->
|
|
{% if object.dashboard_count > 0 %}
|
|
<div class="alert alert-warning mb-4">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-tachometer-alt me-2"></i>Dashboard Usage Warning
|
|
</h6>
|
|
<p class="mb-0">This metric is currently displayed on {{ object.dashboard_count }} dashboard widget(s). Deleting it will cause these widgets to show no data.</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Deletion Form -->
|
|
<form method="post" id="delete-form">
|
|
{% csrf_token %}
|
|
|
|
<div class="card border-danger">
|
|
<div class="card-header bg-danger text-white">
|
|
<h6 class="card-title mb-0">
|
|
<i class="fa fa-trash me-2"></i>Deletion Confirmation
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirm-understanding" required>
|
|
<label class="form-check-label" for="confirm-understanding">
|
|
I understand that this action will permanently delete the metric and cannot be undone
|
|
</label>
|
|
</div>
|
|
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirm-data-loss" required>
|
|
<label class="form-check-label" for="confirm-data-loss">
|
|
I acknowledge that all {{ object.update_count }} historical data points will be lost
|
|
</label>
|
|
</div>
|
|
|
|
{% if object.alert_count > 0 %}
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirm-alerts" required>
|
|
<label class="form-check-label" for="confirm-alerts">
|
|
I understand that {{ object.alert_count }} active alert(s) will be deactivated
|
|
</label>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if object.dashboard_count > 0 %}
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirm-dashboards" required>
|
|
<label class="form-check-label" for="confirm-dashboards">
|
|
I acknowledge that {{ object.dashboard_count }} dashboard widget(s) will be affected
|
|
</label>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Reason for Deletion <span class="text-danger">*</span></label>
|
|
<select class="form-select" name="deletion_reason" required>
|
|
<option value="">Select reason...</option>
|
|
<option value="OBSOLETE">Metric is obsolete</option>
|
|
<option value="DUPLICATE">Duplicate metric</option>
|
|
<option value="INCORRECT">Incorrect calculation</option>
|
|
<option value="REPLACED">Replaced by another metric</option>
|
|
<option value="COMPLIANCE">Compliance requirement</option>
|
|
<option value="CLEANUP">Data cleanup</option>
|
|
<option value="OTHER">Other</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Additional Notes</label>
|
|
<textarea class="form-control" name="deletion_notes" rows="3"
|
|
placeholder="Provide additional details about why this metric is being deleted..."></textarea>
|
|
</div>
|
|
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" name="export_data_before_delete" id="export-checkbox">
|
|
<label class="form-check-label" for="export-checkbox">
|
|
Export historical data before deletion
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Action Buttons -->
|
|
<div class="d-flex justify-content-between mt-4">
|
|
<div>
|
|
<a href="{% url 'analytics:metric_detail' object.pk %}" class="btn btn-secondary">
|
|
<i class="fa fa-arrow-left me-2"></i>Cancel
|
|
</a>
|
|
<a href="{% url 'analytics:metric_deactivate' object.pk %}" class="btn btn-warning ms-2">
|
|
<i class="fa fa-pause me-2"></i>Deactivate Instead
|
|
</a>
|
|
</div>
|
|
<button type="submit" class="btn btn-danger" id="delete-btn" disabled>
|
|
<i class="fa fa-trash me-2"></i>Permanently Delete Metric
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<!-- END panel -->
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block js %}
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Enable/disable delete button based on checkboxes
|
|
function updateDeleteButton() {
|
|
var allChecked = true;
|
|
$('input[type="checkbox"][required]').each(function() {
|
|
if (!$(this).is(':checked')) {
|
|
allChecked = false;
|
|
return false;
|
|
}
|
|
});
|
|
|
|
var reasonSelected = $('select[name="deletion_reason"]').val() !== '';
|
|
|
|
$('#delete-btn').prop('disabled', !(allChecked && reasonSelected));
|
|
}
|
|
|
|
// Check on checkbox change
|
|
$('input[type="checkbox"], select[name="deletion_reason"]').on('change', updateDeleteButton);
|
|
|
|
// Form submission confirmation
|
|
$('#delete-form').on('submit', function(e) {
|
|
var confirmText = 'Are you absolutely sure you want to permanently delete "{{ object.name }}"?';
|
|
{% if object.alert_count > 0 %}
|
|
confirmText += '\n\nThis will deactivate {{ object.alert_count }} alert(s)!';
|
|
{% endif %}
|
|
{% if object.dashboard_count > 0 %}
|
|
confirmText += '\n\nThis will affect {{ object.dashboard_count }} dashboard widget(s)!';
|
|
{% endif %}
|
|
confirmText += '\n\nAll {{ object.update_count }} historical data points will be lost!';
|
|
confirmText += '\n\nThis action cannot be undone.';
|
|
|
|
if (!confirm(confirmText)) {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
|
|
// Auto-focus on first checkbox
|
|
$('#confirm-understanding').focus();
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|