mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-01-16 04:22:05 +01:00
704 lines
23 KiB
HTML
704 lines
23 KiB
HTML
{% extends "baseTemplate/index.html" %}
|
|
{% load i18n %}
|
|
{% block title %}{% trans "List Databases - CyberPanel" %}{% endblock %}
|
|
|
|
{% block header_scripts %}
|
|
<style>
|
|
/* Modern page styles matching new design */
|
|
.page-wrapper {
|
|
background: transparent;
|
|
padding: 20px;
|
|
}
|
|
|
|
.page-container {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.page-header {
|
|
margin-bottom: 30px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.page-header-content {
|
|
flex: 1;
|
|
}
|
|
|
|
.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(--accent-color, #5b5fcf);
|
|
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(--accent-color, #5b5fcf);
|
|
}
|
|
|
|
.form-control:focus {
|
|
outline: none;
|
|
border-color: var(--accent-color, #5b5fcf);
|
|
box-shadow: 0 0 0 3px rgba(91,95,207,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='%232f3640' 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-hover, #f8f9ff);
|
|
border: 1px solid var(--border-color, #e8e9ff);
|
|
border-radius: 10px;
|
|
padding: 20px;
|
|
margin-bottom: 25px;
|
|
}
|
|
|
|
/* Table styles */
|
|
.modern-table {
|
|
width: 100%;
|
|
background: var(--bg-secondary, white);
|
|
border-radius: 10px;
|
|
overflow: hidden;
|
|
box-shadow: 0 1px 3px var(--shadow-color, rgba(0,0,0,0.05));
|
|
border: 1px solid var(--border-color, #e8e9ff);
|
|
}
|
|
|
|
.modern-table thead {
|
|
background: var(--bg-hover, #f8f9ff);
|
|
}
|
|
|
|
.modern-table th {
|
|
padding: 16px 20px;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: var(--text-secondary, #64748b);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
border-bottom: 1px solid var(--border-color, #e8e9ff);
|
|
text-align: left;
|
|
}
|
|
|
|
.modern-table td {
|
|
padding: 16px 20px;
|
|
font-size: 14px;
|
|
color: var(--text-primary, #2f3640);
|
|
border-bottom: 1px solid var(--border-color, #f0f0f0);
|
|
}
|
|
|
|
.modern-table tbody tr:last-child td {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.modern-table tbody tr:hover {
|
|
background: var(--bg-hover, #fafbff);
|
|
}
|
|
|
|
/* Database name styles */
|
|
.db-name {
|
|
font-family: 'Courier New', monospace;
|
|
font-weight: 600;
|
|
color: var(--accent-color, #5b5fcf);
|
|
}
|
|
|
|
/* Button styles */
|
|
.btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
padding: 10px 20px;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.btn-primary {
|
|
background: var(--accent-color, #5b5fcf);
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background: var(--accent-hover, #4a4fc4);
|
|
box-shadow: 0 4px 12px rgba(91,95,207,0.3);
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: var(--bg-hover, #f8f9ff);
|
|
color: var(--accent-color, #5b5fcf);
|
|
border: 1px solid var(--border-color, #e8e9ff);
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background: var(--bg-hover, #eef0ff);
|
|
border-color: var(--accent-color, #5b5fcf);
|
|
}
|
|
|
|
.btn-success {
|
|
background: var(--success-text, #10b981);
|
|
color: white;
|
|
}
|
|
|
|
.btn-success:hover {
|
|
background: var(--success-text, #059669);
|
|
box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.btn-sm {
|
|
padding: 6px 14px;
|
|
font-size: 13px;
|
|
}
|
|
|
|
.btn-lg {
|
|
padding: 12px 24px;
|
|
font-size: 16px;
|
|
}
|
|
|
|
/* Action buttons */
|
|
.action-buttons {
|
|
display: flex;
|
|
gap: 8px;
|
|
}
|
|
|
|
.btn-action {
|
|
padding: 6px 14px;
|
|
font-size: 13px;
|
|
}
|
|
|
|
/* Password change section */
|
|
.password-change-section {
|
|
background: var(--bg-hover, #f8f9ff);
|
|
border: 1px solid var(--border-color, #e8e9ff);
|
|
border-radius: 10px;
|
|
padding: 25px;
|
|
margin-bottom: 25px;
|
|
/* Removed display: none - let Angular control visibility */
|
|
}
|
|
|
|
.password-change-title {
|
|
font-size: 16px;
|
|
font-weight: 700;
|
|
color: var(--text-primary, #2f3640);
|
|
margin-bottom: 20px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
.password-change-title i {
|
|
color: var(--accent-color, #5b5fcf);
|
|
}
|
|
|
|
/* Password input group */
|
|
.password-group {
|
|
display: flex;
|
|
gap: 10px;
|
|
align-items: start;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.password-input-wrapper {
|
|
flex: 1;
|
|
}
|
|
|
|
/* Generated password box */
|
|
.generated-password-box {
|
|
background: var(--success-bg, #e8f5e9);
|
|
border: 1px solid var(--success-text, #c8e6c9);
|
|
border-radius: 8px;
|
|
padding: 16px;
|
|
margin-bottom: 20px;
|
|
/* Removed display: none - let Angular control visibility */
|
|
}
|
|
|
|
.generated-password-label {
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
color: var(--success-text, #2e7d32);
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.generated-password-value {
|
|
font-family: 'Courier New', monospace;
|
|
font-size: 14px;
|
|
color: var(--success-text, #1b5e20);
|
|
font-weight: 600;
|
|
word-break: break-all;
|
|
}
|
|
|
|
/* Modal styles */
|
|
.modal-content {
|
|
border-radius: 12px;
|
|
border: none;
|
|
box-shadow: 0 8px 32px var(--shadow-color, rgba(0,0,0,0.1));
|
|
}
|
|
|
|
.modal-header {
|
|
background: var(--bg-hover, #f8f9ff);
|
|
border-bottom: 1px solid var(--border-color, #e8e9ff);
|
|
border-radius: 12px 12px 0 0;
|
|
padding: 20px 25px;
|
|
}
|
|
|
|
.modal-title {
|
|
font-size: 18px;
|
|
font-weight: 700;
|
|
color: var(--text-primary, #2f3640);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
.modal-body {
|
|
padding: 25px;
|
|
}
|
|
|
|
.modal-footer {
|
|
background: var(--bg-hover, #f8f9ff);
|
|
border-top: 1px solid var(--border-color, #e8e9ff);
|
|
border-radius: 0 0 12px 12px;
|
|
padding: 15px 25px;
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
gap: 10px;
|
|
}
|
|
|
|
/* IP Access table in modal */
|
|
.ip-access-table {
|
|
margin-top: 20px;
|
|
}
|
|
|
|
/* Help text styles */
|
|
.help-text {
|
|
color: var(--text-secondary, #64748b);
|
|
font-size: 12px;
|
|
}
|
|
|
|
/* Password group button wrapper */
|
|
.password-btn-wrapper {
|
|
margin-top: 28px;
|
|
}
|
|
|
|
/* Generated password button wrapper */
|
|
.generated-password-btn {
|
|
margin-top: 10px;
|
|
}
|
|
|
|
/* Modal separator */
|
|
.modal-separator {
|
|
margin: 25px 0;
|
|
border-color: var(--border-color, #e8e9ff);
|
|
}
|
|
|
|
/* Current access title */
|
|
.current-access-title {
|
|
font-weight: 600;
|
|
margin-bottom: 15px;
|
|
color: var(--text-primary, #2f3640);
|
|
}
|
|
|
|
/* 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-text, #ffcdd2);
|
|
color: var(--danger-text, #c62828);
|
|
}
|
|
|
|
.alert-success {
|
|
background: var(--success-bg, #e8f5e9);
|
|
border: 1px solid var(--success-text, #c8e6c9);
|
|
color: var(--success-text, #2e7d32);
|
|
}
|
|
|
|
/* Loading spinner */
|
|
.loading-spinner {
|
|
display: inline-block;
|
|
width: 16px;
|
|
height: 16px;
|
|
border: 2px solid var(--border-color, #f3f3f3);
|
|
border-top: 2px solid var(--accent-color, #5b5fcf);
|
|
border-radius: 50%;
|
|
animation: spin 1s linear infinite;
|
|
margin-left: 10px;
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% { transform: rotate(0deg); }
|
|
100% { transform: rotate(360deg); }
|
|
}
|
|
|
|
/* Hide elements by default */
|
|
#notificationsBox {
|
|
display: none;
|
|
}
|
|
|
|
/* Removed these rules - they were hiding elements incorrectly
|
|
#changePasswordBox {
|
|
display: none;
|
|
}
|
|
|
|
#dbAccounts {
|
|
display: none;
|
|
}
|
|
*/
|
|
|
|
#generatedPasswordView {
|
|
display: none;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.page-header {
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
gap: 16px;
|
|
}
|
|
|
|
.modern-table {
|
|
display: block;
|
|
overflow-x: auto;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.action-buttons {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.password-group {
|
|
flex-direction: column;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
{% load static %}
|
|
{% get_current_language as LANGUAGE_CODE %}
|
|
|
|
<div class="page-wrapper" ng-controller="listDBs">
|
|
<div class="page-container">
|
|
<div class="page-header">
|
|
<div class="page-header-content">
|
|
<h1 class="page-title">{% trans "List Databases" %}</h1>
|
|
<p class="page-subtitle">{% trans "Manage databases and their access credentials" %}</p>
|
|
</div>
|
|
<a href="{% url 'createDatabase' %}" class="btn btn-primary">
|
|
<i class="fas fa-plus"></i>
|
|
{% trans "Create Database" %}
|
|
</a>
|
|
</div>
|
|
|
|
<div class="content-card">
|
|
<h2 class="card-title">
|
|
{% trans "Select Website" %}
|
|
<span ng-hide="dbLoading" class="loading-spinner"></span>
|
|
</h2>
|
|
|
|
<div class="website-selector-card">
|
|
<div class="form-group">
|
|
<label class="form-label">{% trans "Select Domain" %}</label>
|
|
<select ng-change="fetchDBs()" ng-model="selectedDomain" class="form-control">
|
|
<option value="">-- {% trans "Select a domain" %} --</option>
|
|
{% for items in AllWebsites %}
|
|
<option>{{ items }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Notifications -->
|
|
<div ng-show="!notificationsBox">
|
|
<div ng-hide="recordsFetched" class="alert alert-success">
|
|
<i class="fas fa-check-circle"></i>
|
|
<span>{% trans "Records successfully fetched for" %} <strong>{$ domainFeteched $}</strong></span>
|
|
</div>
|
|
|
|
<div ng-hide="passwordChanged" class="alert alert-success">
|
|
<i class="fas fa-check-circle"></i>
|
|
<span>{% trans "Password changed for:" %} <strong>{$ dbUsername $}</strong></span>
|
|
</div>
|
|
|
|
<div ng-hide="canNotChangePassword" class="alert alert-danger">
|
|
<i class="fas fa-exclamation-circle"></i>
|
|
<span>{% trans "Cannot change password for" %} <strong>{$ dbUsername $}</strong>, {% trans "Error message:" %} {$ errorMessage $}</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>
|
|
|
|
<!-- Password Change Section -->
|
|
<div class="password-change-section" ng-show="!changePasswordBox">
|
|
<div class="password-change-title">
|
|
<i class="fas fa-key"></i>
|
|
{% trans "Change Password for" %} {$ dbUsername $}
|
|
</div>
|
|
|
|
<div class="password-group">
|
|
<div class="password-input-wrapper">
|
|
<label class="form-label">{% trans "New Password" %}</label>
|
|
<input type="password" class="form-control" ng-model="dbPassword"
|
|
placeholder="{% trans 'Enter new password' %}" required>
|
|
</div>
|
|
<div class="password-btn-wrapper">
|
|
<button type="button" ng-click="generatePassword()" class="btn btn-secondary">
|
|
<i class="fas fa-sync"></i>
|
|
{% trans "Generate" %}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="generated-password-box" ng-show="!generatedPasswordView">
|
|
<div class="generated-password-label">{% trans "Generated Password" %}</div>
|
|
<div class="generated-password-value">{$ dbPassword $}</div>
|
|
<button type="button" ng-click="usePassword()" class="btn btn-success btn-sm generated-password-btn">
|
|
<i class="fas fa-check"></i>
|
|
{% trans "Use This Password" %}
|
|
</button>
|
|
</div>
|
|
|
|
<button type="button" ng-click="changePasswordBtn()" class="btn btn-primary btn-lg">
|
|
<i class="fas fa-save"></i>
|
|
{% trans "Change Password" %}
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Database List -->
|
|
<div class="content-card" ng-show="!dbAccounts">
|
|
<h2 class="card-title">{% trans "Database Accounts" %}</h2>
|
|
|
|
<div class="table-responsive">
|
|
<table class="modern-table">
|
|
<thead>
|
|
<tr>
|
|
<th>{% trans "ID" %}</th>
|
|
<th>{% trans "Database Name" %}</th>
|
|
<th>{% trans "Database User" %}</th>
|
|
<th>{% trans "Password" %}</th>
|
|
<th>{% trans "Remote Access" %}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr ng-repeat="record in records track by $index">
|
|
<td ng-bind="record.id"></td>
|
|
<td class="db-name" ng-bind="record.dbName"></td>
|
|
<td class="db-name" ng-bind="record.dbUser"></td>
|
|
<td>
|
|
<button type="button" ng-click="changePassword(record.dbUser)"
|
|
class="btn btn-secondary btn-action">
|
|
<i class="fas fa-key"></i>
|
|
{% trans "Change" %}
|
|
</button>
|
|
</td>
|
|
<td>
|
|
<button ng-click="remoteAccess(record.dbUser)"
|
|
data-toggle="modal"
|
|
data-target="#remoteAccess{$ $index $}"
|
|
type="button"
|
|
class="btn btn-primary btn-action">
|
|
<i class="fas fa-network-wired"></i>
|
|
{% trans "Manage" %}
|
|
</button>
|
|
|
|
<!-- Remote Access Modal - Unique ID for each row -->
|
|
<div id="remoteAccess{$ $index $}" class="modal fade" role="dialog">
|
|
<div class="modal-dialog modal-lg">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
|
<h4 class="modal-title">
|
|
{% trans "Remote Access" %}
|
|
<span ng-hide="dbLoading" class="loading-spinner"></span>
|
|
</h4>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form name="remoteAccessForm" class="form-horizontal">
|
|
<div class="form-group">
|
|
<label class="form-label">{% trans "Allow Remote Access from IP" %}</label>
|
|
<input placeholder="{% trans 'Enter IP Address' %}"
|
|
name="remoteIP"
|
|
type="text"
|
|
class="form-control"
|
|
ng-model="$parent.remoteIP"
|
|
required>
|
|
<div class="help-text">
|
|
{% trans "Use % for wildcard (e.g., 192.168.1.% for subnet)" %}
|
|
</div>
|
|
</div>
|
|
|
|
<button type="button" ng-click="allowRemoteIP()" class="btn btn-primary">
|
|
<i class="fas fa-save"></i>
|
|
{% trans "Save Changes" %}
|
|
</button>
|
|
</form>
|
|
|
|
<hr class="modal-separator">
|
|
|
|
<h5 class="current-access-title">{% trans "Current Access" %}</h5>
|
|
<table class="modern-table ip-access-table">
|
|
<thead>
|
|
<tr>
|
|
<th>{% trans "Username" %}</th>
|
|
<th>{% trans "Host" %}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td class="db-name">{$ dbUsername $}</td>
|
|
<td>{$ dbHost $}</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% endblock %}
|
|
|
|
{% block footer_scripts %}
|
|
<script>
|
|
// Hide password change section when change password is successful
|
|
$(document).ready(function() {
|
|
var scope = angular.element($('[ng-controller="listDBs"]')).scope();
|
|
if (scope) {
|
|
// Override changePasswordBtn to hide the section after success
|
|
var originalChangePasswordBtn = scope.changePasswordBtn;
|
|
scope.changePasswordBtn = function() {
|
|
if (originalChangePasswordBtn) {
|
|
originalChangePasswordBtn();
|
|
}
|
|
// Hide the password change section after a delay
|
|
setTimeout(function() {
|
|
if (!scope.changePasswordBox) {
|
|
scope.changePasswordBox = true;
|
|
scope.$apply();
|
|
}
|
|
}, 2000);
|
|
};
|
|
}
|
|
});
|
|
</script>
|
|
{% endblock %} |