Files
CyberPanel/databases/templates/databases/deleteDatabase.html
2025-06-15 01:10:08 +05:00

551 lines
15 KiB
HTML

{% extends "baseTemplate/index.html" %}
{% load i18n %}
{% block title %}{% trans "Delete Database - CyberPanel" %}{% endblock %}
{% block header_scripts %}
<style>
/* Modern page styles matching new design */
.page-wrapper {
background: transparent;
padding: 20px;
}
.page-container {
max-width: 900px;
margin: 0 auto;
}
.page-header {
margin-bottom: 30px;
}
.page-title {
font-size: 28px;
font-weight: 700;
color: #2f3640;
margin-bottom: 8px;
}
.page-subtitle {
font-size: 14px;
color: #8893a7;
}
/* Card styles */
.content-card {
background: white;
border-radius: 12px;
padding: 30px;
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
border: 1px solid #e8e9ff;
margin-bottom: 25px;
}
.card-title {
font-size: 18px;
font-weight: 700;
color: #2f3640;
margin-bottom: 25px;
display: flex;
align-items: center;
gap: 10px;
}
.card-title::before {
content: '';
width: 4px;
height: 24px;
background: #dc3545;
border-radius: 2px;
}
/* Form styles */
.form-group {
margin-bottom: 24px;
}
.form-label {
display: block;
font-size: 13px;
font-weight: 600;
color: #64748b;
margin-bottom: 8px;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.form-control {
width: 100%;
padding: 10px 14px;
border: 1px solid #e8e9ff;
border-radius: 8px;
font-size: 14px;
color: #2f3640;
background: white;
transition: all 0.2s ease;
}
.form-control:hover {
border-color: #dc3545;
}
.form-control:focus {
outline: none;
border-color: #dc3545;
box-shadow: 0 0 0 3px rgba(220,53,69,0.1);
}
/* Website selector card */
.website-selector-card {
background: #fff5f5;
border: 1px solid #ffdddd;
border-radius: 10px;
padding: 20px;
margin-bottom: 25px;
}
/* Database selector section */
.database-selector-section {
display: none;
}
/* Database info card */
.database-info-card {
background: #f8f9ff;
border: 1px solid #e8e9ff;
border-radius: 10px;
padding: 20px;
margin-bottom: 25px;
display: none;
}
.info-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 0;
border-bottom: 1px solid #e8e9ff;
}
.info-row:last-child {
border-bottom: none;
}
.info-label {
font-size: 13px;
font-weight: 600;
color: #64748b;
}
.info-value {
font-size: 14px;
color: #2f3640;
font-weight: 600;
font-family: 'Courier New', monospace;
}
/* Warning box */
.warning-box {
background: #fff3e0;
border: 1px solid #ffe0b2;
border-radius: 10px;
padding: 20px;
margin-bottom: 25px;
display: flex;
align-items: start;
gap: 15px;
}
.warning-icon {
color: #ff9800;
font-size: 24px;
flex-shrink: 0;
}
.warning-content {
flex: 1;
}
.warning-title {
font-size: 16px;
font-weight: 700;
color: #2f3640;
margin-bottom: 8px;
}
.warning-text {
font-size: 14px;
color: #64748b;
line-height: 1.6;
}
.warning-list {
margin-top: 12px;
padding-left: 20px;
}
.warning-list li {
font-size: 13px;
color: #64748b;
margin-bottom: 6px;
}
/* Button styles */
.btn {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 12px 24px;
border: none;
border-radius: 8px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
text-decoration: none;
}
.btn-danger {
background: #dc3545;
color: white;
}
.btn-danger:hover {
background: #c82333;
box-shadow: 0 4px 12px rgba(220,53,69,0.3);
transform: translateY(-1px);
}
.btn-danger:disabled {
background: #ccc;
cursor: not-allowed;
transform: none;
box-shadow: none;
}
.btn-secondary {
background: #f8f9ff;
color: #5b5fcf;
border: 1px solid #e8e9ff;
}
.btn-secondary:hover {
background: #eef0ff;
border-color: #5b5fcf;
}
/* Confirmation section */
.confirmation-section {
background: #ffebee;
border: 1px solid #ffcdd2;
border-radius: 10px;
padding: 25px;
margin-top: 25px;
text-align: center;
display: none;
}
.confirmation-icon {
font-size: 48px;
color: #dc3545;
margin-bottom: 15px;
}
.confirmation-title {
font-size: 20px;
font-weight: 700;
color: #2f3640;
margin-bottom: 10px;
}
.confirmation-text {
font-size: 14px;
color: #64748b;
margin-bottom: 20px;
}
.confirmation-database {
font-size: 18px;
font-weight: 700;
color: #dc3545;
margin-bottom: 25px;
font-family: 'Courier New', monospace;
}
.confirmation-buttons {
display: flex;
gap: 12px;
justify-content: center;
}
/* Alert styles */
.alert {
padding: 16px 20px;
border-radius: 10px;
margin-bottom: 20px;
display: flex;
align-items: center;
gap: 12px;
animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(-10px); }
to { opacity: 1; transform: translateY(0); }
}
.alert-danger {
background: #ffebee;
border: 1px solid #ffcdd2;
color: #c62828;
}
.alert-success {
background: #e8f5e9;
border: 1px solid #c8e6c9;
color: #2e7d32;
}
/* Loading spinner */
.loading-spinner {
display: inline-block;
width: 16px;
height: 16px;
border: 2px solid #f3f3f3;
border-top: 2px solid #dc3545;
border-radius: 50%;
animation: spin 1s linear infinite;
margin-left: 10px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* Button container */
.button-container {
margin-top: 30px;
padding-top: 30px;
border-top: 1px solid #e8e9ff;
}
/* Empty state */
.empty-state {
text-align: center;
padding: 40px;
color: #8893a7;
}
.empty-state i {
font-size: 48px;
color: #e8e9ff;
margin-bottom: 16px;
}
.empty-state-text {
font-size: 14px;
color: #8893a7;
}
/* Hide elements by default */
.hidden {
display: none !important;
}
@media (max-width: 768px) {
.content-card {
padding: 20px;
}
.confirmation-buttons {
flex-direction: column;
}
.btn {
width: 100%;
justify-content: center;
}
}
</style>
{% endblock %}
{% block content %}
{% load static %}
{% get_current_language as LANGUAGE_CODE %}
<div class="page-wrapper" ng-controller="deleteDatabase">
<div class="page-container">
<div class="page-header">
<h1 class="page-title">{% trans "Delete Database" %}</h1>
<p class="page-subtitle">{% trans "Permanently remove a database from your server" %}</p>
</div>
<div class="content-card">
<h2 class="card-title">
{% trans "Database Selection" %}
<span ng-hide="deleteDatabaseLoading" class="loading-spinner"></span>
</h2>
<div class="website-selector-card">
<div class="form-group">
<label class="form-label">{% trans "Select Website" %}</label>
<select ng-change="fetchDatabases()" ng-model="databaseWebsite" class="form-control">
<option value="">-- {% trans "Select a website" %} --</option>
{% for items in websitesList %}
<option>{{ items }}</option>
{% endfor %}
</select>
</div>
</div>
<div class="database-selector-section" ng-hide="fetchedDatabases">
<div class="form-group">
<label class="form-label">{% trans "Select Database to Delete" %}</label>
<select ng-model="selectedDB" ng-change="databaseSelected()" class="form-control">
<option value="">-- {% trans "Select a database" %} --</option>
<option ng-repeat="db in dbnames track by $index">{$ db.dbName $}</option>
</select>
</div>
<div ng-show="dbnames.length === 0" class="empty-state">
<i class="fas fa-database"></i>
<div class="empty-state-text">{% trans "No databases found for this website" %}</div>
</div>
</div>
<div class="database-info-card" ng-show="selectedDB && databaseInfo">
<div class="info-row">
<span class="info-label">{% trans "Database Name" %}</span>
<span class="info-value">{$ selectedDB $}</span>
</div>
<div class="info-row" ng-show="databaseInfo.size">
<span class="info-label">{% trans "Database Size" %}</span>
<span class="info-value">{$ databaseInfo.size $}</span>
</div>
<div class="info-row" ng-show="databaseInfo.tables">
<span class="info-label">{% trans "Tables" %}</span>
<span class="info-value">{$ databaseInfo.tables $}</span>
</div>
</div>
<div class="warning-box">
<i class="fas fa-exclamation-triangle warning-icon"></i>
<div class="warning-content">
<div class="warning-title">{% trans "Warning: This action cannot be undone!" %}</div>
<div class="warning-text">
{% trans "Deleting a database will permanently remove:" %}
</div>
<ul class="warning-list">
<li>{% trans "All tables and their data" %}</li>
<li>{% trans "All stored procedures and functions" %}</li>
<li>{% trans "All user permissions for this database" %}</li>
<li>{% trans "All triggers and events" %}</li>
</ul>
</div>
</div>
<div class="button-container" ng-hide="fetchedDatabases">
<button type="button" ng-click="confirmDelete()" class="btn btn-danger"
ng-disabled="!selectedDB">
<i class="fas fa-trash"></i>
{% trans "Delete Database" %}
</button>
</div>
</div>
<!-- Confirmation Section -->
<div class="content-card confirmation-section" id="deleteConfirmation">
<i class="fas fa-exclamation-circle confirmation-icon"></i>
<h3 class="confirmation-title">{% trans "Are you absolutely sure?" %}</h3>
<p class="confirmation-text">
{% trans "This action will permanently delete the database and all its data." %}
</p>
<div class="confirmation-database">{$ selectedDB $}</div>
<div class="confirmation-buttons">
<button type="button" ng-click="cancelDelete()" class="btn btn-secondary">
<i class="fas fa-times"></i>
{% trans "Cancel" %}
</button>
<button type="button" ng-click="deleteDatabase()" class="btn btn-danger">
<i class="fas fa-trash"></i>
{% trans "Yes, Delete Database" %}
</button>
</div>
</div>
<!-- Alert Messages -->
<div ng-hide="databaseDeletionFailed" class="alert alert-danger">
<i class="fas fa-exclamation-circle"></i>
<span>{% trans "Error message:" %} {$ errorMessage $}</span>
</div>
<div ng-hide="databaseDeleted" class="alert alert-success">
<i class="fas fa-check-circle"></i>
<span>{% trans "Database deleted successfully." %}</span>
</div>
<div ng-hide="couldNotConnect" class="alert alert-danger">
<i class="fas fa-network-wired"></i>
<span>{% trans "Could not connect to server. Please refresh this page." %}</span>
</div>
</div>
</div>
{% endblock %}
{% block footer_scripts %}
<script>
// Enhance the controller
$(document).ready(function() {
var scope = angular.element($('[ng-controller="deleteDatabase"]')).scope();
if (scope) {
// Add confirmation dialog
scope.confirmDelete = function() {
if (scope.selectedDB) {
$('#deleteConfirmation').fadeIn();
}
};
scope.cancelDelete = function() {
$('#deleteConfirmation').fadeOut();
};
// Database selected handler
scope.databaseSelected = function() {
if (scope.selectedDB) {
// Mock database info - in real implementation, fetch from server
scope.databaseInfo = {
size: '25.3 MB',
tables: '12'
};
$('.database-info-card').fadeIn();
} else {
$('.database-info-card').fadeOut();
}
};
// Override fetchDatabases to show selector
var originalFetchDatabases = scope.fetchDatabases;
scope.fetchDatabases = function() {
if (originalFetchDatabases) {
originalFetchDatabases();
}
if (scope.databaseWebsite) {
$('.database-selector-section').fadeIn();
} else {
$('.database-selector-section').fadeOut();
}
};
// Initialize hidden elements
scope.deleteDatabaseLoading = true;
scope.fetchedDatabases = true;
scope.databaseDeletionFailed = true;
scope.databaseDeleted = true;
scope.couldNotConnect = true;
}
});
</script>
{% endblock %}