mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-01-15 03:52:04 +01:00
584 lines
17 KiB
HTML
584 lines
17 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: var(--text-primary, #2f3640);
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.page-subtitle {
|
|
font-size: 14px;
|
|
color: var(--text-secondary, #8893a7);
|
|
}
|
|
|
|
/* Card styles */
|
|
.content-card {
|
|
background: var(--bg-secondary, white);
|
|
border-radius: 12px;
|
|
padding: 30px;
|
|
box-shadow: 0 2px 8px var(--shadow-color, rgba(0,0,0,0.08));
|
|
border: 1px solid var(--border-color, #e8e9ff);
|
|
margin-bottom: 25px;
|
|
}
|
|
|
|
.card-title {
|
|
font-size: 18px;
|
|
font-weight: 700;
|
|
color: var(--text-primary, #2f3640);
|
|
margin-bottom: 25px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
.card-title::before {
|
|
content: '';
|
|
width: 4px;
|
|
height: 24px;
|
|
background: var(--danger-text, #dc3545);
|
|
border-radius: 2px;
|
|
}
|
|
|
|
/* Form styles */
|
|
.form-group {
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.form-label {
|
|
display: block;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: var(--text-secondary, #64748b);
|
|
margin-bottom: 8px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
.form-control {
|
|
width: 100%;
|
|
padding: 10px 14px;
|
|
border: 1px solid var(--border-color, #e8e9ff);
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
color: var(--text-primary, #2f3640);
|
|
background: var(--bg-secondary, white);
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.form-control:hover {
|
|
border-color: var(--danger-text, #dc3545);
|
|
}
|
|
|
|
.form-control:focus {
|
|
outline: none;
|
|
border-color: var(--danger-text, #dc3545);
|
|
box-shadow: 0 0 0 3px var(--danger-shadow, rgba(220,53,69,0.1));
|
|
}
|
|
|
|
/* Windows selectbox fixes */
|
|
select.form-control {
|
|
cursor: pointer;
|
|
-webkit-appearance: none;
|
|
-moz-appearance: none;
|
|
appearance: none;
|
|
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
|
|
background-repeat: no-repeat;
|
|
background-position: right 12px center;
|
|
background-size: 20px;
|
|
padding-right: 40px;
|
|
line-height: 1.5;
|
|
min-height: 44px;
|
|
}
|
|
|
|
/* Windows-specific fixes */
|
|
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
|
|
select.form-control {
|
|
color: var(--text-primary, #2f3640) !important;
|
|
background-color: var(--bg-secondary, white) !important;
|
|
}
|
|
}
|
|
|
|
/* Fix for Windows Edge and Chrome */
|
|
select.form-control::-ms-expand {
|
|
display: none;
|
|
}
|
|
|
|
select.form-control:focus {
|
|
color: var(--text-primary, #2f3640);
|
|
background-color: var(--bg-secondary, white);
|
|
}
|
|
|
|
/* Website selector card */
|
|
.website-selector-card {
|
|
background: var(--bg-secondary, #fff5f5);
|
|
border: 1px solid var(--border-color, #ffdddd);
|
|
border-radius: 10px;
|
|
padding: 20px;
|
|
margin-bottom: 25px;
|
|
}
|
|
|
|
/* Database selector section */
|
|
.database-selector-section {
|
|
display: none;
|
|
}
|
|
|
|
/* Database info card */
|
|
.database-info-card {
|
|
background: var(--bg-hover, #f8f9ff);
|
|
border: 1px solid var(--border-color, #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 var(--border-color, #e8e9ff);
|
|
}
|
|
|
|
.info-row:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.info-label {
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: var(--text-secondary, #64748b);
|
|
}
|
|
|
|
.info-value {
|
|
font-size: 14px;
|
|
color: var(--text-primary, #2f3640);
|
|
font-weight: 600;
|
|
font-family: 'Courier New', monospace;
|
|
}
|
|
|
|
/* Warning box */
|
|
.warning-box {
|
|
background: var(--warning-bg, #fff3e0);
|
|
border: 1px solid var(--warning-border, #ffe0b2);
|
|
border-radius: 10px;
|
|
padding: 20px;
|
|
margin-bottom: 25px;
|
|
display: flex;
|
|
align-items: start;
|
|
gap: 15px;
|
|
}
|
|
|
|
.warning-icon {
|
|
color: var(--warning-text, #ff9800);
|
|
font-size: 24px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.warning-content {
|
|
flex: 1;
|
|
}
|
|
|
|
.warning-title {
|
|
font-size: 16px;
|
|
font-weight: 700;
|
|
color: var(--text-primary, #2f3640);
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.warning-text {
|
|
font-size: 14px;
|
|
color: var(--text-secondary, #64748b);
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.warning-list {
|
|
margin-top: 12px;
|
|
padding-left: 20px;
|
|
}
|
|
|
|
.warning-list li {
|
|
font-size: 13px;
|
|
color: var(--text-secondary, #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: var(--danger-text, #dc3545);
|
|
color: white;
|
|
}
|
|
|
|
.btn-danger:hover {
|
|
background: var(--danger-hover, #c82333);
|
|
box-shadow: 0 4px 12px var(--danger-shadow, rgba(220,53,69,0.3));
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.btn-danger:disabled {
|
|
background: var(--text-disabled, #ccc);
|
|
cursor: not-allowed;
|
|
transform: none;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: var(--bg-hover, #f8f9ff);
|
|
color: var(--accent-color, #5b5fcf);
|
|
border: 1px solid var(--border-color, #e8e9ff);
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background: var(--accent-bg, #eef0ff);
|
|
border-color: var(--accent-color, #5b5fcf);
|
|
}
|
|
|
|
/* Confirmation section */
|
|
.confirmation-section {
|
|
background: var(--danger-bg, #ffebee);
|
|
border: 1px solid var(--danger-border, #ffcdd2);
|
|
border-radius: 10px;
|
|
padding: 25px;
|
|
margin-top: 25px;
|
|
text-align: center;
|
|
display: none;
|
|
}
|
|
|
|
.confirmation-icon {
|
|
font-size: 48px;
|
|
color: var(--danger-text, #dc3545);
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.confirmation-title {
|
|
font-size: 20px;
|
|
font-weight: 700;
|
|
color: var(--text-primary, #2f3640);
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.confirmation-text {
|
|
font-size: 14px;
|
|
color: var(--text-secondary, #64748b);
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.confirmation-database {
|
|
font-size: 18px;
|
|
font-weight: 700;
|
|
color: var(--danger-text, #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: var(--danger-bg, #ffebee);
|
|
border: 1px solid var(--danger-border, #ffcdd2);
|
|
color: var(--danger-text, #c62828);
|
|
}
|
|
|
|
.alert-success {
|
|
background: var(--success-bg, #e8f5e9);
|
|
border: 1px solid var(--success-border, #c8e6c9);
|
|
color: var(--success-text, #2e7d32);
|
|
}
|
|
|
|
/* Loading spinner */
|
|
.loading-spinner {
|
|
display: inline-block;
|
|
width: 16px;
|
|
height: 16px;
|
|
border: 2px solid var(--border-light, #f3f3f3);
|
|
border-top: 2px solid var(--danger-text, #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 var(--border-color, #e8e9ff);
|
|
}
|
|
|
|
/* Empty state */
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 40px;
|
|
color: var(--text-secondary, #8893a7);
|
|
}
|
|
|
|
.empty-state i {
|
|
font-size: 48px;
|
|
color: var(--border-color, #e8e9ff);
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.empty-state-text {
|
|
font-size: 14px;
|
|
color: var(--text-secondary, #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 %} |