From 22aee542071638bcefae5a244bcabf76f794d7c3 Mon Sep 17 00:00:00 2001 From: feng <1304903146@qq.com> Date: Fri, 10 Jan 2025 11:32:02 +0800 Subject: [PATCH] perf: automation report --- .../0019_backupaccountautomation_and_more.py | 2 + .../accounts/backup_account_report.html | 143 +++++--- .../accounts/change_secret_report.html | 288 ++++++++++------ .../accounts/check_account_report.html | 269 ++++++++++----- .../accounts/gather_account_report.html | 319 +++++++++++------- .../accounts/push_account_report.html | 262 ++++++++++---- 6 files changed, 850 insertions(+), 433 deletions(-) diff --git a/apps/accounts/migrations/0019_backupaccountautomation_and_more.py b/apps/accounts/migrations/0019_backupaccountautomation_and_more.py index 47dbab646..ab98841f7 100644 --- a/apps/accounts/migrations/0019_backupaccountautomation_and_more.py +++ b/apps/accounts/migrations/0019_backupaccountautomation_and_more.py @@ -47,6 +47,8 @@ def migrate_account_backup(apps, schema_editor): automation_id = backup_id_old_new_map.get(str(execution.plan_id)) if not automation_id: continue + snapshot = execution.snapshot + snapshot['type'] = "backup_account" data = { 'automation_id': automation_id, 'date_start': execution.date_start, diff --git a/apps/accounts/templates/accounts/backup_account_report.html b/apps/accounts/templates/accounts/backup_account_report.html index 80d71e7ef..79b0cc19e 100644 --- a/apps/accounts/templates/accounts/backup_account_report.html +++ b/apps/accounts/templates/accounts/backup_account_report.html @@ -1,78 +1,113 @@ {% load i18n %} -<div class='summary'> - <p>{% trans 'The following is a summary of account backup tasks, please review and handle them' %}</p> - <table> - <caption></caption> - <thead> +<div class="report-container"> + <div class="summary-section"> + <h2> + {% trans 'The following is a summary of account backup tasks, please review and handle them' %} + </h2> + <table class="summary-table"> + <caption></caption> + <thead> <tr> - <th colspan='2'>任务汇总:</th> + <th colspan="2">{% trans 'Task Summary' %}:</th> </tr> - </thead> - <tbody> + </thead> + <tbody> <tr> - <td>{% trans 'Task name' %}:</td> - <td>{{ execution.automation.name }} </td> + <td>{% trans 'Task name' %}:</td> + <td>{{ execution.automation.name }}</td> </tr> <tr> - <td>{% trans 'Date start' %}:</td> - <td>{{ execution.date_start | date:"Y/m/d H:i:s" }}</td> + <td>{% trans 'Date start' %}:</td> + <td>{{ execution.date_start | date:"Y/m/d H:i:s" }}</td> </tr> <tr> - <td>{% trans 'Date end' %}:</td> - <td>{{ execution.date_finished | date:"Y/m/d H:i:s" }}</td> + <td>{% trans 'Date end' %}:</td> + <td>{{ execution.date_finished | date:"Y/m/d H:i:s" }}</td> </tr> <tr> - <td>{% trans 'Time using' %}:</td> - <td>{{ execution.duration }}s</td> + <td>{% trans 'Time using' %}:</td> + <td>{{ execution.duration }}s</td> </tr> <tr> - <td>{% trans 'Account count' %}:</td> - <td>{{ summary.total_accounts }}</td> + <td>{% trans 'Account count' %}:</td> + <td>{{ summary.total_accounts }}</td> </tr> <tr> - <td>{% trans 'Type count' %}:</td> - <td>{{ summary.total_types }}</td> + <td>{% trans 'Type count' %}:</td> + <td>{{ summary.total_types }}</td> </tr> - </tbody> + </tbody> </table> + </div> </div> - <style> - table { - width: 100%; - border-collapse: collapse; - max-width: 100%; - text-align: left; - margin-top: 10px; - padding: 20px; + .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 { + width: 100%; + border-collapse: collapse; + margin-bottom: 30px; + background-color: white; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + border-radius: 8px; + } + + .summary-table td:first-child { + width: 30%; + font-weight: 500; + } + + th { + background-color: #f8f9fa; + padding: 12px 15px; + text-align: left; + font-weight: 600; + color: #2c3e50; + border-bottom: 2px solid #eee; + } + + td { + padding: 12px 15px; + border-bottom: 1px solid #eee; + color: #34495e; + } + + tr:last-child td { + border-bottom: none; + } + + tr:hover { + background-color: #f8f9fa; + } + + @media (max-width: 768px) { + .report-container { + padding: 10px; } + td, th { - background: #f2f2f2; - font-size: 14px; - padding: 5px; - border: 1px solid #ddd; + padding: 8px; } - - tr :first-child { - width: 30%; - } - - td { - border: 1px solid #ddd; - padding: 5px; - font-size: 12px; - } - - .result { - margin-top: 20px; - } - - .result tr :first-child { - width: 10%; - } - - -</style> + } +</style> \ No newline at end of file diff --git a/apps/accounts/templates/accounts/change_secret_report.html b/apps/accounts/templates/accounts/change_secret_report.html index a6fa25f8d..8a6919d79 100644 --- a/apps/accounts/templates/accounts/change_secret_report.html +++ b/apps/accounts/templates/accounts/change_secret_report.html @@ -1,133 +1,221 @@ {% load i18n %} -<div class='summary'> - <p>{% trans 'The following is a summary of account change secret tasks, please read and process' %}</p> - <table> - <caption></caption> - <thead> +<div class="report-container"> + <div class="summary-section"> + <h2> + {% trans 'The following is a summary of account change secret tasks, please read and process' %} + </h2> + <table class="summary-table"> + <caption></caption> + <thead> <tr> - <th colspan='2'>任务汇总:</th> + <th colspan="2">{% trans 'Task Summary' %}:</th> </tr> - </thead> - <tbody> + </thead> + <tbody> <tr> - <td>{% trans 'Task name' %}:</td> - <td>{{ execution.automation.name }} </td> + <td>{% trans 'Task name' %}:</td> + <td>{{ execution.automation.name }}</td> </tr> <tr> - <td>{% trans 'Date start' %}:</td> - <td>{{ execution.date_start | date:"Y/m/d H:i:s" }}</td> + <td>{% trans 'Date start' %}:</td> + <td>{{ execution.date_start | date:"Y/m/d H:i:s" }}</td> </tr> <tr> - <td>{% trans 'Date end' %}:</td> - <td>{{ execution.date_finished | date:"Y/m/d H:i:s" }}</td> + <td>{% trans 'Date end' %}:</td> + <td>{{ execution.date_finished | date:"Y/m/d H:i:s" }}</td> </tr> <tr> - <td>{% trans 'Time using' %}:</td> - <td>{{ execution.duration }}s</td> + <td>{% trans 'Time using' %}:</td> + <td>{{ execution.duration }}s</td> </tr> <tr> - <td>{% trans 'Assets count' %}:</td> - <td>{{ summary.total_assets }}</td> + <td>{% trans 'Assets count' %}:</td> + <td>{{ summary.total_assets }}</td> </tr> <tr> - <td>{% trans 'Asset success count' %}:</td> - <td>{{ summary.ok_assets }}</td> + <td>{% trans 'Asset success count' %}:</td> + <td class="success">{{ summary.ok_assets }}</td> </tr> <tr> - <td>{% trans 'Asset failed count' %}:</td> - <td>{{ summary.fail_assets }}</td> + <td>{% trans 'Asset failed count' %}:</td> + <td class="error">{{ summary.fail_assets }}</td> </tr> <tr> - <td>{% trans 'Asset not support count' %}:</td> - <td>{{ summary.error_assets }}</td> + <td>{% trans 'Asset not support count' %}:</td> + <td class="warning">{{ summary.error_assets }}</td> </tr> - </tbody> + </tbody> </table> -</div> + </div> -<div class='result'> + <div class="result-section"> {% if summary.ok_accounts %} - <p>{% trans 'Success accounts' %}: {{ summary.ok_accounts }}</p> - <table> - <caption></caption> - <thead> - <tr> - <th>{% trans 'No.' %}</th> - <th>{% trans 'Asset' %}</th> - <th>{% trans 'Username' %}</th> - </tr> - </thead> - <tbody> - {% for account in result.ok_accounts %} - <tr> - <td>{{ forloop.counter }}</td> - <td>{{ account.asset }}</td> - <td>{{ account.username }}</td> - </tr> - {% endfor %} - </tbody> - </table> + <div class="section-header"> + <h3> + {% trans 'Success accounts' %}: + <span class="badge badge-success">{{ summary.ok_accounts }}</span> + </h3> + </div> + <table class="data-table"> + <caption></caption> + <thead> + <tr> + <th>{% trans 'No.' %}</th> + <th>{% trans 'Asset' %}</th> + <th>{% trans 'Username' %}</th> + </tr> + </thead> + <tbody> + {% for account in result.ok_accounts %} + <tr> + <td>{{ forloop.counter }}</td> + <td>{{ account.asset }}</td> + <td>{{ account.username }}</td> + </tr> + {% endfor %} + </tbody> + </table> {% endif %} -</div> -<div class='result'> + </div> + + <div class="result-section"> {% if summary.fail_accounts %} - <p>{% trans 'Failed accounts' %}: {{ summary.fail_accounts }}</p> - <table> - <caption></caption> - <thead> - <tr> - <th>{% trans 'No.' %}</th> - <th>{% trans 'Asset' %}</th> - <th>{% trans 'Username' %}</th> - </tr> - </thead> - <tbody> - {% for account in result.fail_accounts %} - <tr> - <td>{{ forloop.counter }}</td> - <td>{{ account.asset }}</td> - <td>{{ account.username }}</td> - </tr> - {% endfor %} - </tbody> - </table> + <div class="section-header"> + <h3> + {% trans 'Failed accounts' %}: + <span class="badge badge-error">{{ summary.fail_accounts }}</span> + </h3> + </div> + <table class="data-table"> + <caption></caption> + <thead> + <tr> + <th>{% trans 'No.' %}</th> + <th>{% trans 'Asset' %}</th> + <th>{% trans 'Username' %}</th> + </tr> + </thead> + <tbody> + {% for account in result.fail_accounts %} + <tr> + <td>{{ forloop.counter }}</td> + <td>{{ account.asset }}</td> + <td>{{ account.username }}</td> + </tr> + {% endfor %} + </tbody> + </table> {% endif %} + </div> </div> <style> - table { - width: 100%; - border-collapse: collapse; - max-width: 100%; - text-align: left; - margin-top: 10px; - padding: 20px; + .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 { + width: 100%; + border-collapse: collapse; + margin-bottom: 30px; + background-color: white; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + border-radius: 8px; + } + + .summary-table td:first-child { + width: 30%; + font-weight: 500; + } + + .data-table td:first-child { + width: 80px; + } + + th { + background-color: #f8f9fa; + padding: 12px 15px; + text-align: left; + font-weight: 600; + color: #2c3e50; + border-bottom: 2px solid #eee; + } + + td { + padding: 12px 15px; + border-bottom: 1px solid #eee; + 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; + } + + .result-section { + margin-top: 30px; + } + + tr:hover { + background-color: #f8f9fa; + } + + @media (max-width: 768px) { + .report-container { + padding: 10px; } + td, th { - background: #f2f2f2; - font-size: 14px; - padding: 5px; - border: 1px solid #ddd; + padding: 8px; } - - tr :first-child { - width: 30%; - } - - td { - border: 1px solid #ddd; - padding: 5px; - font-size: 12px; - } - - .result { - margin-top: 20px; - } - - .result tr :first-child { - width: 10%; - } - -</style> + } +</style> \ No newline at end of file diff --git a/apps/accounts/templates/accounts/check_account_report.html b/apps/accounts/templates/accounts/check_account_report.html index 6444f7f92..28bbdeb81 100644 --- a/apps/accounts/templates/accounts/check_account_report.html +++ b/apps/accounts/templates/accounts/check_account_report.html @@ -1,124 +1,217 @@ {% load i18n %} -<div class='summary'> - <p>{% trans 'The following is a summary of the account check tasks. Please review and handle them' %}</p> - <table> - <caption></caption> - <thead> +<div class="report-container"> + <div class="summary-section"> + <h2> + {% trans 'The following is a summary of the account check tasks. Please review and handle them' %} + </h2> + <table class="summary-table"> + <caption></caption> + <thead> <tr> - <th colspan='2'>任务汇总:</th> + <th colspan="2">{% trans 'Task Summary' %}:</th> </tr> - </thead> - <tbody> + </thead> + <tbody> <tr> - <td>{% trans 'Task name' %}:</td> - <td>{{ execution.automation.name }} </td> + <td>{% trans 'Task name' %}:</td> + <td>{{ execution.automation.name }}</td> </tr> <tr> - <td>{% trans 'Date start' %}:</td> - <td>{{ execution.date_start | date:"Y/m/d H:i:s" }}</td> + <td>{% trans 'Date start' %}:</td> + <td>{{ execution.date_start | date:"Y/m/d H:i:s" }}</td> </tr> <tr> - <td>{% trans 'Date end' %}:</td> - <td>{{ execution.date_finished | date:"Y/m/d H:i:s" }}</td> + <td>{% trans 'Date end' %}:</td> + <td>{{ execution.date_finished | date:"Y/m/d H:i:s" }}</td> </tr> <tr> - <td>{% trans 'Time using' %}:</td> - <td>{{ execution.duration }}s</td> + <td>{% trans 'Time using' %}:</td> + <td>{{ execution.duration }}s</td> </tr> <tr> - <td>{% trans 'Assets count' %}:</td> - <td>{{ summary.assets }}</td> + <td>{% trans 'Assets count' %}:</td> + <td><span class="badge">{{ summary.assets }}</span></td> </tr> <tr> - <td>{% trans 'Asset success count' %}:</td> - <td>{{ summary.ok_assets }}</td> + <td>{% trans 'Asset success count' %}:</td> + <td class="success">{{ summary.ok_assets }}</td> </tr> <tr> - <td>{% trans 'Asset failed count' %}:</td> - <td>{{ summary.fail_assets }}</td> + <td>{% trans 'Asset failed count' %}:</td> + <td class="error">{{ summary.fail_assets }}</td> </tr> <tr> - <td>{% trans 'Asset not support count' %}:</td> - <td>{{ summary.error_assets }}</td> - </tr> - - <tr> - <td>{% trans 'Account count' %}:</td> - <td>{{ summary.accounts }}</td> + <td>{% trans 'Asset not support count' %}:</td> + <td class="warning">{{ summary.error_assets }}</td> </tr> <tr> - <td>{% trans 'Ok count' %}:</td> - <td>{{ summary.ok }}</td> + <td>{% trans 'Account count' %}:</td> + <td><span class="badge">{{ summary.accounts }}</span></td> </tr> <tr> - <td>{% trans 'No password count' %}:</td> - <td>{{ summary.no_secret }}</td> + <td>{% trans 'Ok count' %}:</td> + <td class="success">{{ summary.ok }}</td> </tr> - </tbody> + <tr> + <td>{% trans 'No password count' %}:</td> + <td class="warning">{{ summary.no_secret }}</td> + </tr> + </tbody> </table> -</div> + </div> -<div class='result'> + <div class="result-section"> {% if summary.weak_password %} - <p>{% trans 'Week password' %}: {{ summary.weak_password }}</p> - <p>{% trans 'Account check details' %}:</p> - <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 style="color: red">{% trans 'Week password' %}</td> - </tr> - {% endfor %} - </tbody> - </table> + <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>{% trans 'No weak password' %}</p> + <p class="no-data">{% trans 'No weak password' %}</p > {% endif %} + </div> </div> <style> - table { - width: 100%; - border-collapse: collapse; - max-width: 100%; - text-align: left; - margin-top: 20px; - padding: 20px; + .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 { + width: 100%; + border-collapse: collapse; + margin-bottom: 30px; + background-color: white; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + border-radius: 8px; + } + + .summary-table td:first-child { + width: 30%; + font-weight: 500; + } + + .data-table td:first-child { + width: 80px; + } + + th { + background-color: #f8f9fa; + padding: 12px 15px; + text-align: left; + font-weight: 600; + color: #2c3e50; + border-bottom: 2px solid #eee; + } + + td { + padding: 12px 15px; + border-bottom: 1px solid #eee; + 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 { - background: #f2f2f2; - font-size: 14px; - padding: 5px; - border: 1px solid #ddd; + padding: 8px; } - - tr :first-child { - width: 30%; - } - - td { - border: 1px solid #ddd; - padding: 5px; - font-size: 12px; - } - - .result tr :first-child { - width: 10%; - } - - -</style> + } +</style> \ No newline at end of file diff --git a/apps/accounts/templates/accounts/gather_account_report.html b/apps/accounts/templates/accounts/gather_account_report.html index 9a0e3e76d..a98b11734 100644 --- a/apps/accounts/templates/accounts/gather_account_report.html +++ b/apps/accounts/templates/accounts/gather_account_report.html @@ -1,164 +1,223 @@ {% load i18n %} -<div class='summary'> - <p>{% trans 'The following is a summary of the account check tasks. Please review and handle them' %}</p> - <table> - <caption></caption> - <thead> +<div class="report-container"> + <div class="summary-section"> + <h2> + {% trans 'The following is a summary of the account check tasks. Please review and handle them' %} + </h2> + <table class="summary-table"> + <caption></caption> + <thead> <tr> - <th colspan='2'>任务汇总:</th> + <th colspan="2">{% trans 'Task Summary' %}:</th> </tr> - </thead> - <tbody> + </thead> + <tbody> <tr> - <td>{% trans 'Task name' %}:</td> - <td>{{ execution.automation.name }} </td> + <td>{% trans 'Task name' %}:</td> + <td>{{ execution.automation.name }}</td> </tr> <tr> - <td>{% trans 'Date start' %}:</td> - <td>{{ execution.date_start | date:"Y/m/d H:i:s" }}</td> + <td>{% trans 'Date start' %}:</td> + <td>{{ execution.date_start | date:"Y/m/d H:i:s" }}</td> </tr> <tr> - <td>{% trans 'Date end' %}:</td> - <td>{{ execution.date_finished | date:"Y/m/d H:i:s" }}</td> + <td>{% trans 'Date end' %}:</td> + <td>{{ execution.date_finished | date:"Y/m/d H:i:s" }}</td> </tr> <tr> - <td>{% trans 'Time using' %}:</td> - <td>{{ execution.duration }}s</td> + <td>{% trans 'Time using' %}:</td> + <td>{{ execution.duration }}s</td> </tr> <tr> - <td>{% trans 'Assets count' %}:</td> - <td>{{ summary.total_assets }}</td> + <td>{% trans 'Assets count' %}:</td> + <td>{{ summary.total_assets }}</td> </tr> <tr> - <td>{% trans 'Asset success count' %}:</td> - <td>{{ summary.ok_assets }}</td> + <td>{% trans 'Asset success count' %}:</td> + <td class="success">{{ summary.ok_assets }}</td> </tr> <tr> - <td>{% trans 'Asset failed count' %}:</td> - <td>{{ summary.fail_assets }}</td> + <td>{% trans 'Asset failed count' %}:</td> + <td class="error">{{ summary.fail_assets }}</td> </tr> <tr> - <td>{% trans 'Asset not support count' %}:</td> - <td>{{ summary.error_assets }}</td> + <td>{% trans 'Asset not support count' %}:</td> + <td class="warning">{{ summary.error_assets }}</td> </tr> - </tbody> + </tbody> </table> -</div> + </div> -<div class='result'> + <div class="result-section"> {% if summary.new_accounts %} - <p>{% trans 'New found accounts' %}: {{ summary.new_accounts }}</p> - <table> - <caption></caption> - <thead> - <tr> - <th>{% trans 'No.' %}</th> - <th>{% trans 'Asset' %}</th> - <th>{% trans 'Username' %}</th> - </tr> - </thead> - <tbody> - {% for account in result.new_accounts %} - <tr> - <td>{{ forloop.counter }}</td> - <td>{{ account.asset }}</td> - <td>{{ account.username }}</td> - </tr> - {% endfor %} - </tbody> - </table> + <div class="section-header"> + <h3> + {% trans 'New found accounts' %}: + <span class="badge">{{ summary.new_accounts }}</span> + </h3> + </div> + <table class="data-table"> + <caption></caption> + <thead> + <tr> + <th>{% trans 'No.' %}</th> + <th>{% trans 'Asset' %}</th> + <th>{% trans 'Username' %}</th> + </tr> + </thead> + <tbody> + {% for account in result.new_accounts %} + <tr> + <td>{{ forloop.counter }}</td> + <td>{{ account.asset }}</td> + <td>{{ account.username }}</td> + </tr> + {% endfor %} + </tbody> + </table> {% else %} - <p>{% trans 'No new accounts found' %}</p> + <p class="no-data">{% trans 'No new accounts found' %}</p > {% endif %} -</div> -<div class='result'> + </div> + + <div class="result-section"> {% if summary.lost_accounts %} - <p>{% trans 'Lost accounts' %}: {{ summary.lost_accounts }}</p> - <table> - <caption></caption> - <thead> - <tr> - <th>{% trans 'No.' %}</th> - <th>{% trans 'Asset' %}</th> - <th>{% trans 'Username' %}</th> - </tr> - </thead> - <tbody> - {% for account in result.lost_accounts %} - <tr> - <td>{{ forloop.counter }}</td> - <td>{{ account.asset }}</td> - <td>{{ account.username }}</td> - </tr> - {% endfor %} - </tbody> - </table> + <div class="section-header"> + <h3> + {% trans 'Lost accounts' %}: + <span class="badge">{{ summary.lost_accounts }}</span> + </h3> + </div> + <table class="data-table"> + <caption></caption> + <thead> + <tr> + <th>{% trans 'No.' %}</th> + <th>{% trans 'Asset' %}</th> + <th>{% trans 'Username' %}</th> + </tr> + </thead> + <tbody> + {% for account in result.lost_accounts %} + <tr> + <td>{{ forloop.counter }}</td> + <td>{{ account.asset }}</td> + <td>{{ account.username }}</td> + </tr> + {% endfor %} + </tbody> + </table> {% endif %} + </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> - table { - width: 100%; - border-collapse: collapse; - max-width: 100%; - text-align: left; - margin-top: 10px; - padding: 20px; + .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 { + width: 100%; + border-collapse: collapse; + margin-bottom: 30px; + background-color: white; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + border-radius: 8px; + } + + .summary-table td:first-child { + width: 30%; + font-weight: 500; + } + + .data-table td:first-child { + width: 80px; + } + + th { + background-color: #f8f9fa; + padding: 12px 15px; + text-align: left; + font-weight: 600; + color: #2c3e50; + border-bottom: 2px solid #eee; + } + + td { + padding: 12px 15px; + border-bottom: 1px solid #eee; + 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 { - background: #f2f2f2; - font-size: 14px; - padding: 5px; - border: 1px solid #ddd; + padding: 8px; } - - tr :first-child { - width: 30%; - } - - td { - border: 1px solid #ddd; - padding: 5px; - font-size: 12px; - } - - .result { - margin-top: 20px; - } - - .result tr :first-child { - width: 10%; - } - - -</style> + } +</style> \ No newline at end of file diff --git a/apps/accounts/templates/accounts/push_account_report.html b/apps/accounts/templates/accounts/push_account_report.html index c04a55f3f..cc0e689ec 100644 --- a/apps/accounts/templates/accounts/push_account_report.html +++ b/apps/accounts/templates/accounts/push_account_report.html @@ -1,77 +1,217 @@ {% load i18n %} -<div class='summary'> - <p>{% trans 'The following is a summary of account push tasks, please read and process' %}</p> - <table> - <caption></caption> - <thead> - <tr> - <th colspan='2'>任务汇总:</th> - </tr> - </thead> - <tbody> - <tr> - <td>{% trans 'Task name' %}:</td> - <td>{{ execution.automation.name }} </td> - </tr> - <tr> - <td>{% trans 'Date start' %}:</td> - <td>{{ execution.date_start | date:"Y/m/d H:i:s" }}</td> - </tr> - <tr> - <td>{% trans 'Date end' %}:</td> - <td>{{ execution.date_finished | date:"Y/m/d H:i:s" }}</td> - </tr> - <tr> - <td>{% trans 'Time using' %}:</td> - <td>{{ execution.duration }}s</td> - </tr> - <tr> - <td>{% trans 'Assets count' %}:</td> - <td>{{ summary.total_assets }}</td> - </tr> - <tr> - <td>{% trans 'Asset success count' %}:</td> - <td>{{ summary.ok_assets }}</td> - </tr> - <tr> - <td>{% trans 'Asset failed count' %}:</td> - <td>{{ summary.fail_assets }}</td> - </tr> - <tr> - <td>{% trans 'Asset not support count' %}:</td> - <td>{{ summary.error_assets }}</td> - </tr> - </tbody> - </table> +<div class="report-container"> + <div class="summary-section"> + <h2> + {% trans 'The following is a summary of the account check tasks. Please review and handle them' %} + </h2> + <table class="summary-table"> + <caption></caption> + <thead> + <tr> + <th colspan="2">{% trans 'Task Summary' %}:</th> + </tr> + </thead> + <tbody> + <tr> + <td>{% trans 'Task name' %}:</td> + <td>{{ execution.automation.name }}</td> + </tr> + <tr> + <td>{% trans 'Date start' %}:</td> + <td>{{ execution.date_start | date:"Y/m/d H:i:s" }}</td> + </tr> + <tr> + <td>{% trans 'Date end' %}:</td> + <td>{{ execution.date_finished | date:"Y/m/d H:i:s" }}</td> + </tr> + <tr> + <td>{% trans 'Time using' %}:</td> + <td>{{ execution.duration }}s</td> + </tr> + <tr> + <td>{% trans 'Assets count' %}:</td> + <td><span class="badge">{{ summary.assets }}</span></td> + </tr> + <tr> + <td>{% trans 'Asset success count' %}:</td> + <td class="success">{{ summary.ok_assets }}</td> + </tr> + <tr> + <td>{% trans 'Asset failed count' %}:</td> + <td class="error">{{ summary.fail_assets }}</td> + </tr> + <tr> + <td>{% trans 'Asset not support count' %}:</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> + </tbody> + </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> - <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 { width: 100%; border-collapse: collapse; - max-width: 100%; - text-align: left; - margin-top: 10px; - padding: 20px; + margin-bottom: 30px; + background-color: white; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); + border-radius: 8px; + } + + .summary-table td:first-child { + width: 30%; + font-weight: 500; + } + + .data-table td:first-child { + width: 80px; } th { - background: #f2f2f2; - font-size: 14px; - padding: 5px; - border: 1px solid #ddd; - } - - tr :first-child { - width: 30%; + background-color: #f8f9fa; + padding: 12px 15px; + text-align: left; + font-weight: 600; + color: #2c3e50; + border-bottom: 2px solid #eee; } td { - border: 1px solid #ddd; - padding: 5px; - font-size: 12px; + padding: 12px 15px; + border-bottom: 1px solid #eee; + color: #34495e; } -</style> + 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> \ No newline at end of file