Merge branch 'pam' of github.com:jumpserver/jumpserver into pam

pull/14806/head
ibuler 2025-01-13 11:18:33 +08:00
commit 39f266eb71
7 changed files with 898 additions and 460 deletions

View File

@ -37,41 +37,54 @@ class PamDashboardApi(APIView):
return result return result
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
data = {}
monday_time = local_monday() monday_time = local_monday()
query_params = self.request.query_params query_params = self.request.query_params
account_stats = Account.objects.aggregate(
total_count=Count('id'),
privileged_count=Count('id', filter=Q(privileged=True)),
connectivity_ok_count=Count('id', filter=Q(connectivity='ok')),
secret_reset_count=Count('id', filter=Q(secret_reset=True)),
unavailable_count=Count('id', filter=Q(is_active=False)),
week_add_count=Count('id', filter=Q(date_created__gte=monday_time)),
)
_all = query_params.get('all') _all = query_params.get('all')
if _all or query_params.get('total_accounts'): agg_map = {
data['total_accounts'] = account_stats['total_count'] 'total_accounts': (
'total_count',
Count('id')
),
'total_privileged_accounts': (
'privileged_count',
Count('id', filter=Q(privileged=True))
),
'total_connectivity_ok_accounts': (
'connectivity_ok_count',
Count('id', filter=Q(connectivity='ok'))
),
'total_secret_reset_accounts': (
'secret_reset_count',
Count('id', filter=Q(secret_reset=True))
),
'total_unavailable_accounts': (
'unavailable_count',
Count('id', filter=Q(is_active=False))
),
'total_week_add_accounts': (
'week_add_count',
Count('id', filter=Q(date_created__gte=monday_time))
),
}
if _all or query_params.get('total_week_add_accounts'): aggregations = {}
data['total_week_add_accounts'] = account_stats['week_add_count'] for param_key, (agg_key, agg_expr) in agg_map.items():
if _all or query_params.get(param_key):
aggregations[agg_key] = agg_expr
if _all or query_params.get('total_privileged_accounts'): data = {}
data['total_privileged_accounts'] = account_stats['privileged_count'] if aggregations:
account_stats = Account.objects.aggregate(**aggregations)
for param_key, (agg_key, __) in agg_map.items():
if agg_key in account_stats:
data[param_key] = account_stats[agg_key]
if _all or query_params.get('total_connectivity_ok_accounts'): if (_all or query_params.get('total_ordinary_accounts')):
data['total_connectivity_ok_accounts'] = account_stats['connectivity_ok_count'] if 'total_count' in account_stats and 'privileged_count' in account_stats:
data['total_ordinary_accounts'] = \
if _all or query_params.get('total_secret_reset_accounts'): account_stats['total_count'] - account_stats['privileged_count']
data['total_secret_reset_accounts'] = account_stats['secret_reset_count']
if _all or query_params.get('total_ordinary_accounts'):
data['total_ordinary_accounts'] = account_stats['total_count'] - account_stats['privileged_count']
if _all or query_params.get('total_unavailable_accounts'):
data['total_unavailable_accounts'] = account_stats['unavailable_count']
if _all or query_params.get('total_unmanaged_accounts'): if _all or query_params.get('total_unmanaged_accounts'):
data['total_unmanaged_accounts'] = Account.get_risks( data['total_unmanaged_accounts'] = Account.get_risks(
@ -89,6 +102,14 @@ class PamDashboardApi(APIView):
data['total_long_time_change_password_accounts'] = Account.get_risks( data['total_long_time_change_password_accounts'] = Account.get_risks(
risk_type=RiskChoice.long_time_password).count() risk_type=RiskChoice.long_time_password).count()
if _all or query_params.get('total_leaked_password_accounts'):
data['total_leaked_password_accounts'] = Account.get_risks(
risk_type=RiskChoice.leaked_password).count()
if _all or query_params.get('total_repeated_password_accounts'):
data['total_repeated_password_accounts'] = Account.get_risks(
risk_type=RiskChoice.repeated_password).count()
if _all or query_params.get('total_count_type_to_accounts'): if _all or query_params.get('total_count_type_to_accounts'):
data.update({ data.update({
'total_count_type_to_accounts': self.get_type_to_accounts(), 'total_count_type_to_accounts': self.get_type_to_accounts(),

View File

@ -47,6 +47,8 @@ def migrate_account_backup(apps, schema_editor):
automation_id = backup_id_old_new_map.get(str(execution.plan_id)) automation_id = backup_id_old_new_map.get(str(execution.plan_id))
if not automation_id: if not automation_id:
continue continue
snapshot = execution.snapshot
snapshot['type'] = "backup_account"
data = { data = {
'automation_id': automation_id, 'automation_id': automation_id,
'date_start': execution.date_start, 'date_start': execution.date_start,

View File

@ -1,18 +1,21 @@
{% load i18n %} {% load i18n %}
<div class='summary'> <div class="report-container">
<p>{% trans 'The following is a summary of account backup tasks, please review and handle them' %}</p> <div class="summary-section">
<table> <h2>
{% trans 'The following is a summary of account backup tasks, please review and handle them' %}
</h2>
<table class="summary-table">
<caption></caption> <caption></caption>
<thead> <thead>
<tr> <tr>
<th colspan='2'>任务汇总:</th> <th colspan="2">{% trans 'Task Summary' %}:</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>{% trans 'Task name' %}:</td> <td>{% trans 'Task name' %}:</td>
<td>{{ execution.automation.name }} </td> <td>{{ execution.automation.name }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Date start' %}:</td> <td>{% trans 'Date start' %}:</td>
@ -36,43 +39,75 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div>
</div> </div>
<style> <style>
.report-container {
max-width: 1200px;
margin: 20px auto;
padding: 20px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
Ubuntu, Cantarell, sans-serif;
}
h2,
h3 {
color: #2c3e50;
margin-bottom: 20px;
}
.section-header {
display: flex;
align-items: center;
margin-bottom: 15px;
}
table { table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
max-width: 100%; margin-bottom: 30px;
text-align: left; background-color: white;
margin-top: 10px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
padding: 20px; border-radius: 8px;
}
.summary-table td:first-child {
width: 30%;
font-weight: 500;
} }
th { th {
background: #f2f2f2; background-color: #f8f9fa;
font-size: 14px; padding: 12px 15px;
padding: 5px; text-align: left;
border: 1px solid #ddd; font-weight: 600;
} color: #2c3e50;
border-bottom: 2px solid #eee;
tr :first-child {
width: 30%;
} }
td { td {
border: 1px solid #ddd; padding: 12px 15px;
padding: 5px; border-bottom: 1px solid #eee;
font-size: 12px; color: #34495e;
} }
.result { tr:last-child td {
margin-top: 20px; border-bottom: none;
} }
.result tr :first-child { tr:hover {
width: 10%; background-color: #f8f9fa;
} }
@media (max-width: 768px) {
.report-container {
padding: 10px;
}
td,
th {
padding: 8px;
}
}
</style> </style>

View File

@ -1,18 +1,21 @@
{% load i18n %} {% load i18n %}
<div class='summary'> <div class="report-container">
<p>{% trans 'The following is a summary of account change secret tasks, please read and process' %}</p> <div class="summary-section">
<table> <h2>
{% trans 'The following is a summary of account change secret tasks, please read and process' %}
</h2>
<table class="summary-table">
<caption></caption> <caption></caption>
<thead> <thead>
<tr> <tr>
<th colspan='2'>任务汇总:</th> <th colspan="2">{% trans 'Task Summary' %}:</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>{% trans 'Task name' %}:</td> <td>{% trans 'Task name' %}:</td>
<td>{{ execution.automation.name }} </td> <td>{{ execution.automation.name }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Date start' %}:</td> <td>{% trans 'Date start' %}:</td>
@ -32,24 +35,29 @@
</tr> </tr>
<tr> <tr>
<td>{% trans 'Asset success count' %}:</td> <td>{% trans 'Asset success count' %}:</td>
<td>{{ summary.ok_assets }}</td> <td class="success">{{ summary.ok_assets }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Asset failed count' %}:</td> <td>{% trans 'Asset failed count' %}:</td>
<td>{{ summary.fail_assets }}</td> <td class="error">{{ summary.fail_assets }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Asset not support count' %}:</td> <td>{% trans 'Asset not support count' %}:</td>
<td>{{ summary.error_assets }}</td> <td class="warning">{{ summary.error_assets }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div class='result'> <div class="result-section">
{% if summary.ok_accounts %} {% if summary.ok_accounts %}
<p>{% trans 'Success accounts' %}: {{ summary.ok_accounts }}</p> <div class="section-header">
<table> <h3>
{% trans 'Success accounts' %}:
<span class="badge badge-success">{{ summary.ok_accounts }}</span>
</h3>
</div>
<table class="data-table">
<caption></caption> <caption></caption>
<thead> <thead>
<tr> <tr>
@ -69,11 +77,17 @@
</tbody> </tbody>
</table> </table>
{% endif %} {% endif %}
</div> </div>
<div class='result'>
<div class="result-section">
{% if summary.fail_accounts %} {% if summary.fail_accounts %}
<p>{% trans 'Failed accounts' %}: {{ summary.fail_accounts }}</p> <div class="section-header">
<table> <h3>
{% trans 'Failed accounts' %}:
<span class="badge badge-error">{{ summary.fail_accounts }}</span>
</h3>
</div>
<table class="data-table">
<caption></caption> <caption></caption>
<thead> <thead>
<tr> <tr>
@ -93,41 +107,115 @@
</tbody> </tbody>
</table> </table>
{% endif %} {% endif %}
</div>
</div> </div>
<style> <style>
.report-container {
max-width: 1200px;
margin: 20px auto;
padding: 20px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
Ubuntu, Cantarell, sans-serif;
}
h2,
h3 {
color: #2c3e50;
margin-bottom: 20px;
}
.section-header {
display: flex;
align-items: center;
margin-bottom: 15px;
}
.badge {
background-color: #3498db;
color: white;
padding: 3px 10px;
border-radius: 12px;
font-size: 14px;
margin-left: 10px;
}
.badge-success {
background-color: #27ae60;
}
.badge-error {
background-color: #e74c3c;
}
table { table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
max-width: 100%; margin-bottom: 30px;
text-align: left; background-color: white;
margin-top: 10px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
padding: 20px; border-radius: 8px;
}
.summary-table td:first-child {
width: 30%;
font-weight: 500;
}
.data-table td:first-child {
width: 80px;
} }
th { th {
background: #f2f2f2; background-color: #f8f9fa;
font-size: 14px; padding: 12px 15px;
padding: 5px; text-align: left;
border: 1px solid #ddd; font-weight: 600;
} color: #2c3e50;
border-bottom: 2px solid #eee;
tr :first-child {
width: 30%;
} }
td { td {
border: 1px solid #ddd; padding: 12px 15px;
padding: 5px; border-bottom: 1px solid #eee;
font-size: 12px; color: #34495e;
} }
.result { tr:last-child td {
margin-top: 20px; border-bottom: none;
} }
.result tr :first-child { .success {
width: 10%; color: #27ae60;
font-weight: 500;
} }
.error {
color: #e74c3c;
font-weight: 500;
}
.warning {
color: #f39c12;
font-weight: 500;
}
.result-section {
margin-top: 30px;
}
tr:hover {
background-color: #f8f9fa;
}
@media (max-width: 768px) {
.report-container {
padding: 10px;
}
td,
th {
padding: 8px;
}
}
</style> </style>

View File

@ -1,18 +1,21 @@
{% load i18n %} {% load i18n %}
<div class='summary'> <div class="report-container">
<p>{% trans 'The following is a summary of the account check tasks. Please review and handle them' %}</p> <div class="summary-section">
<table> <h2>
{% trans 'The following is a summary of the account check tasks. Please review and handle them' %}
</h2>
<table class="summary-table">
<caption></caption> <caption></caption>
<thead> <thead>
<tr> <tr>
<th colspan='2'>任务汇总:</th> <th colspan="2">{% trans 'Task Summary' %}:</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>{% trans 'Task name' %}:</td> <td>{% trans 'Task name' %}:</td>
<td>{{ execution.automation.name }} </td> <td>{{ execution.automation.name }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Date start' %}:</td> <td>{% trans 'Date start' %}:</td>
@ -28,42 +31,46 @@
</tr> </tr>
<tr> <tr>
<td>{% trans 'Assets count' %}:</td> <td>{% trans 'Assets count' %}:</td>
<td>{{ summary.assets }}</td> <td><span class="badge">{{ summary.assets }}</span></td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Asset success count' %}:</td> <td>{% trans 'Asset success count' %}:</td>
<td>{{ summary.ok_assets }}</td> <td class="success">{{ summary.ok_assets }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Asset failed count' %}:</td> <td>{% trans 'Asset failed count' %}:</td>
<td>{{ summary.fail_assets }}</td> <td class="error">{{ summary.fail_assets }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Asset not support count' %}:</td> <td>{% trans 'Asset not support count' %}:</td>
<td>{{ summary.error_assets }}</td> <td class="warning">{{ summary.error_assets }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Account count' %}:</td> <td>{% trans 'Account count' %}:</td>
<td>{{ summary.accounts }}</td> <td><span class="badge">{{ summary.accounts }}</span></td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Ok count' %}:</td> <td>{% trans 'Ok count' %}:</td>
<td>{{ summary.ok }}</td> <td class="success">{{ summary.ok }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'No password count' %}:</td> <td>{% trans 'No password count' %}:</td>
<td>{{ summary.no_secret }}</td> <td class="warning">{{ summary.no_secret }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div class='result'> <div class="result-section">
{% if summary.weak_password %} {% if summary.weak_password %}
<p>{% trans 'Week password' %}: {{ summary.weak_password }}</p> <div class="section-header">
<p>{% trans 'Account check details' %}:</p> <h3>
<table> {% trans 'Week password' %}:
<span class="badge badge-error">{{ summary.weak_password }}</span>
</h3>
</div>
<p class="section-desc">{% trans 'Account check details' %}:</p >
<table class="data-table">
<caption></caption> <caption></caption>
<thead> <thead>
<tr> <tr>
@ -79,46 +86,132 @@
<td>{{ forloop.counter }}</td> <td>{{ forloop.counter }}</td>
<td>{{ account.asset }}</td> <td>{{ account.asset }}</td>
<td>{{ account.username }}</td> <td>{{ account.username }}</td>
<td style="color: red">{% trans 'Week password' %}</td> <td class="error">{% trans 'Week password' %}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% else %} {% else %}
<p>{% trans 'No weak password' %}</p> <p class="no-data">{% trans 'No weak password' %}</p >
{% endif %} {% endif %}
</div>
</div> </div>
<style> <style>
.report-container {
max-width: 1200px;
margin: 20px auto;
padding: 20px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
Ubuntu, Cantarell, sans-serif;
}
h2,
h3 {
color: #2c3e50;
margin-bottom: 20px;
}
.section-header {
display: flex;
align-items: center;
margin-bottom: 15px;
}
.section-desc {
color: #7f8c8d;
margin-bottom: 15px;
}
.badge {
background-color: #3498db;
color: white;
padding: 3px 10px;
border-radius: 12px;
font-size: 14px;
margin-left: 10px;
}
.badge-error {
background-color: #e74c3c;
}
table { table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
max-width: 100%; margin-bottom: 30px;
text-align: left; background-color: white;
margin-top: 20px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
padding: 20px; border-radius: 8px;
}
.summary-table td:first-child {
width: 30%;
font-weight: 500;
}
.data-table td:first-child {
width: 80px;
} }
th { th {
background: #f2f2f2; background-color: #f8f9fa;
font-size: 14px; padding: 12px 15px;
padding: 5px; text-align: left;
border: 1px solid #ddd; font-weight: 600;
} color: #2c3e50;
border-bottom: 2px solid #eee;
tr :first-child {
width: 30%;
} }
td { td {
border: 1px solid #ddd; padding: 12px 15px;
padding: 5px; border-bottom: 1px solid #eee;
font-size: 12px; color: #34495e;
} }
.result tr :first-child { tr:last-child td {
width: 10%; border-bottom: none;
} }
.success {
color: #27ae60;
font-weight: 500;
}
.error {
color: #e74c3c;
font-weight: 500;
}
.warning {
color: #f39c12;
font-weight: 500;
}
.no-data {
text-align: center;
color: #7f8c8d;
padding: 20px;
background-color: #f8f9fa;
border-radius: 8px;
}
.result-section {
margin-top: 30px;
}
tr:hover {
background-color: #f8f9fa;
}
@media (max-width: 768px) {
.report-container {
padding: 10px;
}
td,
th {
padding: 8px;
}
}
</style> </style>

View File

@ -1,18 +1,21 @@
{% load i18n %} {% load i18n %}
<div class='summary'> <div class="report-container">
<p>{% trans 'The following is a summary of the account check tasks. Please review and handle them' %}</p> <div class="summary-section">
<table> <h2>
{% trans 'The following is a summary of the account check tasks. Please review and handle them' %}
</h2>
<table class="summary-table">
<caption></caption> <caption></caption>
<thead> <thead>
<tr> <tr>
<th colspan='2'>任务汇总:</th> <th colspan="2">{% trans 'Task Summary' %}:</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>{% trans 'Task name' %}:</td> <td>{% trans 'Task name' %}:</td>
<td>{{ execution.automation.name }} </td> <td>{{ execution.automation.name }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Date start' %}:</td> <td>{% trans 'Date start' %}:</td>
@ -32,24 +35,29 @@
</tr> </tr>
<tr> <tr>
<td>{% trans 'Asset success count' %}:</td> <td>{% trans 'Asset success count' %}:</td>
<td>{{ summary.ok_assets }}</td> <td class="success">{{ summary.ok_assets }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Asset failed count' %}:</td> <td>{% trans 'Asset failed count' %}:</td>
<td>{{ summary.fail_assets }}</td> <td class="error">{{ summary.fail_assets }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Asset not support count' %}:</td> <td>{% trans 'Asset not support count' %}:</td>
<td>{{ summary.error_assets }}</td> <td class="warning">{{ summary.error_assets }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div class='result'> <div class="result-section">
{% if summary.new_accounts %} {% if summary.new_accounts %}
<p>{% trans 'New found accounts' %}: {{ summary.new_accounts }}</p> <div class="section-header">
<table> <h3>
{% trans 'New found accounts' %}:
<span class="badge">{{ summary.new_accounts }}</span>
</h3>
</div>
<table class="data-table">
<caption></caption> <caption></caption>
<thead> <thead>
<tr> <tr>
@ -69,13 +77,19 @@
</tbody> </tbody>
</table> </table>
{% else %} {% else %}
<p>{% trans 'No new accounts found' %}</p> <p class="no-data">{% trans 'No new accounts found' %}</p >
{% endif %} {% endif %}
</div> </div>
<div class='result'>
<div class="result-section">
{% if summary.lost_accounts %} {% if summary.lost_accounts %}
<p>{% trans 'Lost accounts' %}: {{ summary.lost_accounts }}</p> <div class="section-header">
<table> <h3>
{% trans 'Lost accounts' %}:
<span class="badge">{{ summary.lost_accounts }}</span>
</h3>
</div>
<table class="data-table">
<caption></caption> <caption></caption>
<thead> <thead>
<tr> <tr>
@ -95,70 +109,115 @@
</tbody> </tbody>
</table> </table>
{% endif %} {% endif %}
</div>
</div> </div>
{#<div class='result'>#}
{# <p>{% trans 'New found risks' %}: {{ summary.new_risks }}</p>#}
{# {% if summary.new_risks %}#}
{# <table>#}
{# <caption></caption>#}
{# <thead>#}
{# <tr>#}
{# <th>{% trans 'No.' %}</th>#}
{# <th>{% trans 'Asset' %}</th>#}
{# <th>{% trans 'Username' %}</th>#}
{# <th>{% trans 'Result' %}</th>#}
{# </tr>#}
{# </thead>#}
{# <tbody>#}
{# {% for risk in result.risks %}#}
{# <tr>#}
{# <td>{{ forloop.counter }}</td>#}
{# <td>{{ risk.asset }}</td>#}
{# <td>{{ risk.username }}</td>#}
{# <td>{{ risk.risk }}</td>#}
{# </tr>#}
{# {% endfor %}#}
{# </tbody>#}
{# </table>#}
{# {% endif %}#}
{#</div>#}
<style> <style>
.report-container {
max-width: 1200px;
margin: 20px auto;
padding: 20px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
Ubuntu, Cantarell, sans-serif;
}
h2,
h3 {
color: #2c3e50;
margin-bottom: 20px;
}
.section-header {
display: flex;
align-items: center;
margin-bottom: 15px;
}
.badge {
background-color: #3498db;
color: white;
padding: 3px 10px;
border-radius: 12px;
font-size: 14px;
margin-left: 10px;
}
table { table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
max-width: 100%; margin-bottom: 30px;
text-align: left; background-color: white;
margin-top: 10px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
padding: 20px; border-radius: 8px;
}
.summary-table td:first-child {
width: 30%;
font-weight: 500;
}
.data-table td:first-child {
width: 80px;
} }
th { th {
background: #f2f2f2; background-color: #f8f9fa;
font-size: 14px; padding: 12px 15px;
padding: 5px; text-align: left;
border: 1px solid #ddd; font-weight: 600;
} color: #2c3e50;
border-bottom: 2px solid #eee;
tr :first-child {
width: 30%;
} }
td { td {
border: 1px solid #ddd; padding: 12px 15px;
padding: 5px; border-bottom: 1px solid #eee;
font-size: 12px; color: #34495e;
} }
.result { tr:last-child td {
margin-top: 20px; border-bottom: none;
} }
.result tr :first-child { .success {
width: 10%; color: #27ae60;
font-weight: 500;
} }
.error {
color: #e74c3c;
font-weight: 500;
}
.warning {
color: #f39c12;
font-weight: 500;
}
.no-data {
text-align: center;
color: #7f8c8d;
padding: 20px;
background-color: #f8f9fa;
border-radius: 8px;
}
.result-section {
margin-top: 30px;
}
tr:hover {
background-color: #f8f9fa;
}
@media (max-width: 768px) {
.report-container {
padding: 10px;
}
td,
th {
padding: 8px;
}
}
</style> </style>

View File

@ -1,18 +1,21 @@
{% load i18n %} {% load i18n %}
<div class='summary'> <div class="report-container">
<p>{% trans 'The following is a summary of account push tasks, please read and process' %}</p> <div class="summary-section">
<table> <h2>
{% trans 'The following is a summary of the account check tasks. Please review and handle them' %}
</h2>
<table class="summary-table">
<caption></caption> <caption></caption>
<thead> <thead>
<tr> <tr>
<th colspan='2'>任务汇总:</th> <th colspan="2">{% trans 'Task Summary' %}:</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td>{% trans 'Task name' %}:</td> <td>{% trans 'Task name' %}:</td>
<td>{{ execution.automation.name }} </td> <td>{{ execution.automation.name }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Date start' %}:</td> <td>{% trans 'Date start' %}:</td>
@ -28,50 +31,187 @@
</tr> </tr>
<tr> <tr>
<td>{% trans 'Assets count' %}:</td> <td>{% trans 'Assets count' %}:</td>
<td>{{ summary.total_assets }}</td> <td><span class="badge">{{ summary.assets }}</span></td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Asset success count' %}:</td> <td>{% trans 'Asset success count' %}:</td>
<td>{{ summary.ok_assets }}</td> <td class="success">{{ summary.ok_assets }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Asset failed count' %}:</td> <td>{% trans 'Asset failed count' %}:</td>
<td>{{ summary.fail_assets }}</td> <td class="error">{{ summary.fail_assets }}</td>
</tr> </tr>
<tr> <tr>
<td>{% trans 'Asset not support count' %}:</td> <td>{% trans 'Asset not support count' %}:</td>
<td>{{ summary.error_assets }}</td> <td class="warning">{{ summary.error_assets }}</td>
</tr>
<tr>
<td>{% trans 'Account count' %}:</td>
<td><span class="badge">{{ summary.accounts }}</span></td>
</tr>
<tr>
<td>{% trans 'Ok count' %}:</td>
<td class="success">{{ summary.ok }}</td>
</tr>
<tr>
<td>{% trans 'No password count' %}:</td>
<td class="warning">{{ summary.no_secret }}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div>
<div class="result-section">
{% if summary.weak_password %}
<div class="section-header">
<h3>
{% trans 'Week password' %}:
<span class="badge badge-error">{{ summary.weak_password }}</span>
</h3>
</div>
<p class="section-desc">{% trans 'Account check details' %}:</p>
<table class="data-table">
<caption></caption>
<thead>
<tr>
<th>{% trans 'No.' %}</th>
<th>{% trans 'Asset' %}</th>
<th>{% trans 'Username' %}</th>
<th>{% trans 'Result' %}</th>
</tr>
</thead>
<tbody>
{% for account in result.weak_password %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ account.asset }}</td>
<td>{{ account.username }}</td>
<td class="error">{% trans 'Week password' %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="no-data">{% trans 'No weak password' %}</p>
{% endif %}
</div>
</div> </div>
<style> <style>
.report-container {
max-width: 1200px;
margin: 20px auto;
padding: 20px;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
Ubuntu, Cantarell, sans-serif;
}
h2,
h3 {
color: #2c3e50;
margin-bottom: 20px;
}
.section-header {
display: flex;
align-items: center;
margin-bottom: 15px;
}
.section-desc {
color: #7f8c8d;
margin-bottom: 15px;
}
.badge {
background-color: #3498db;
color: white;
padding: 3px 10px;
border-radius: 12px;
font-size: 14px;
margin-left: 10px;
}
.badge-error {
background-color: #e74c3c;
}
table { table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;
max-width: 100%; margin-bottom: 30px;
text-align: left; background-color: white;
margin-top: 10px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
padding: 20px; border-radius: 8px;
}
.summary-table td:first-child {
width: 30%;
font-weight: 500;
}
.data-table td:first-child {
width: 80px;
} }
th { th {
background: #f2f2f2; background-color: #f8f9fa;
font-size: 14px; padding: 12px 15px;
padding: 5px; text-align: left;
border: 1px solid #ddd; font-weight: 600;
} color: #2c3e50;
border-bottom: 2px solid #eee;
tr :first-child {
width: 30%;
} }
td { td {
border: 1px solid #ddd; padding: 12px 15px;
padding: 5px; border-bottom: 1px solid #eee;
font-size: 12px; color: #34495e;
} }
tr:last-child td {
border-bottom: none;
}
.success {
color: #27ae60;
font-weight: 500;
}
.error {
color: #e74c3c;
font-weight: 500;
}
.warning {
color: #f39c12;
font-weight: 500;
}
.no-data {
text-align: center;
color: #7f8c8d;
padding: 20px;
background-color: #f8f9fa;
border-radius: 8px;
}
.result-section {
margin-top: 30px;
}
tr:hover {
background-color: #f8f9fa;
}
@media (max-width: 768px) {
.report-container {
padding: 10px;
}
td,
th {
padding: 8px;
}
}
</style> </style>