Compare commits
3 Commits
secrets-mc
...
secrets-mc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a42db62702 | ||
|
|
2edb970cba | ||
|
|
17f8ac0dbc |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1949,7 +1949,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "secrets-mcp"
|
name = "secrets-mcp"
|
||||||
version = "0.1.7"
|
version = "0.1.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"askama",
|
"askama",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "secrets-mcp"
|
name = "secrets-mcp"
|
||||||
version = "0.1.7"
|
version = "0.1.8"
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use askama::Template;
|
use askama::Template;
|
||||||
|
use chrono::SecondsFormat;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
@@ -61,7 +62,8 @@ struct AuditPageTemplate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct AuditEntryView {
|
struct AuditEntryView {
|
||||||
created_at: String,
|
/// RFC3339 UTC for `<time datetime>`; rendered as browser-local in audit.html.
|
||||||
|
created_at_iso: String,
|
||||||
action: String,
|
action: String,
|
||||||
target: String,
|
target: String,
|
||||||
detail: String,
|
detail: String,
|
||||||
@@ -408,7 +410,7 @@ async fn audit_page(
|
|||||||
let entries = rows
|
let entries = rows
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|row| AuditEntryView {
|
.map(|row| AuditEntryView {
|
||||||
created_at: row.created_at.format("%Y-%m-%d %H:%M:%S UTC").to_string(),
|
created_at_iso: row.created_at.to_rfc3339_opts(SecondsFormat::Secs, true),
|
||||||
action: row.action,
|
action: row.action,
|
||||||
target: format_audit_target(&row.namespace, &row.kind, &row.name),
|
target: format_audit_target(&row.namespace, &row.kind, &row.name),
|
||||||
detail: serde_json::to_string_pretty(&row.detail).unwrap_or_else(|_| "{}".to_string()),
|
detail: serde_json::to_string_pretty(&row.detail).unwrap_or_else(|_| "{}".to_string()),
|
||||||
|
|||||||
@@ -108,7 +108,7 @@
|
|||||||
<main class="main">
|
<main class="main">
|
||||||
<section class="card">
|
<section class="card">
|
||||||
<div class="card-title">我的审计</div>
|
<div class="card-title">我的审计</div>
|
||||||
<div class="card-subtitle">展示最近 100 条与当前用户相关的新审计记录。</div>
|
<div class="card-subtitle">展示最近 100 条与当前用户相关的新审计记录。时间为浏览器本地时区。</div>
|
||||||
|
|
||||||
{% if entries.is_empty() %}
|
{% if entries.is_empty() %}
|
||||||
<div class="empty">暂无审计记录。</div>
|
<div class="empty">暂无审计记录。</div>
|
||||||
@@ -125,7 +125,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for entry in entries %}
|
{% for entry in entries %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="col-time mono">{{ entry.created_at }}</td>
|
<td class="col-time mono"><time class="audit-local-time" datetime="{{ entry.created_at_iso }}">{{ entry.created_at_iso }}</time></td>
|
||||||
<td class="col-action mono">{{ entry.action }}</td>
|
<td class="col-action mono">{{ entry.action }}</td>
|
||||||
<td class="col-target mono">{{ entry.target }}</td>
|
<td class="col-target mono">{{ entry.target }}</td>
|
||||||
<td class="col-detail"><pre class="detail">{{ entry.detail }}</pre></td>
|
<td class="col-detail"><pre class="detail">{{ entry.detail }}</pre></td>
|
||||||
@@ -138,5 +138,17 @@
|
|||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
document.querySelectorAll('time.audit-local-time[datetime]').forEach(function (el) {
|
||||||
|
var raw = el.getAttribute('datetime');
|
||||||
|
var d = raw ? new Date(raw) : null;
|
||||||
|
if (d && !isNaN(d.getTime())) {
|
||||||
|
el.textContent = d.toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'medium' });
|
||||||
|
el.title = raw + ' (UTC)';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user