flask-deck 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flask_deck/__init__.py +184 -0
- flask_deck/adapters/__init__.py +23 -0
- flask_deck/adapters/sqlalchemy.py +272 -0
- flask_deck/audit.py +363 -0
- flask_deck/auth.py +462 -0
- flask_deck/branding.py +217 -0
- flask_deck/charts.py +514 -0
- flask_deck/cli.py +135 -0
- flask_deck/config.py +81 -0
- flask_deck/dashboard.py +416 -0
- flask_deck/deck.py +4153 -0
- flask_deck/demo.py +1066 -0
- flask_deck/events.py +309 -0
- flask_deck/exceptions.py +34 -0
- flask_deck/exporter.py +240 -0
- flask_deck/formatters.py +386 -0
- flask_deck/i18n.py +399 -0
- flask_deck/icons.py +92 -0
- flask_deck/importer.py +612 -0
- flask_deck/introspection.py +376 -0
- flask_deck/jobs.py +382 -0
- flask_deck/mfa.py +670 -0
- flask_deck/model_view.py +1097 -0
- flask_deck/py.typed +0 -0
- flask_deck/query.py +1220 -0
- flask_deck/schema_graph.py +137 -0
- flask_deck/security.py +373 -0
- flask_deck/sql_console.py +391 -0
- flask_deck/sso.py +293 -0
- flask_deck/static/css/deck.css +1333 -0
- flask_deck/static/js/deck.js +1433 -0
- flask_deck/storage.py +669 -0
- flask_deck/templates/flask_deck/audit_list.html +117 -0
- flask_deck/templates/flask_deck/base.html +454 -0
- flask_deck/templates/flask_deck/custom_page.html +12 -0
- flask_deck/templates/flask_deck/dashboard.html +32 -0
- flask_deck/templates/flask_deck/diagnostics.html +80 -0
- flask_deck/templates/flask_deck/error.html +15 -0
- flask_deck/templates/flask_deck/import_wizard.html +143 -0
- flask_deck/templates/flask_deck/jobs_list.html +95 -0
- flask_deck/templates/flask_deck/login.html +93 -0
- flask_deck/templates/flask_deck/login_mfa.html +59 -0
- flask_deck/templates/flask_deck/mfa_setup.html +121 -0
- flask_deck/templates/flask_deck/model_detail.html +124 -0
- flask_deck/templates/flask_deck/model_form.html +389 -0
- flask_deck/templates/flask_deck/model_list.html +489 -0
- flask_deck/templates/flask_deck/partials/drawer_detail.html +93 -0
- flask_deck/templates/flask_deck/partials/widget_grid.html +207 -0
- flask_deck/templates/flask_deck/rbac_matrix.html +59 -0
- flask_deck/templates/flask_deck/record_history.html +102 -0
- flask_deck/templates/flask_deck/schema_inspector.html +83 -0
- flask_deck/templates/flask_deck/sql_console.html +87 -0
- flask_deck-0.3.0.dist-info/METADATA +382 -0
- flask_deck-0.3.0.dist-info/RECORD +57 -0
- flask_deck-0.3.0.dist-info/WHEEL +4 -0
- flask_deck-0.3.0.dist-info/entry_points.txt +5 -0
- flask_deck-0.3.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
<div class="dk-grid">
|
|
2
|
+
{% for w in widgets %}
|
|
3
|
+
{% if w.kind == 'callout' %}
|
|
4
|
+
<div class="{{ w.span_class }}">
|
|
5
|
+
<div class="dk-callout dk-callout-{{ w.normalized_tone }}" role="status">
|
|
6
|
+
<div class="dk-callout-body">
|
|
7
|
+
<strong>{{ w.title }}</strong>
|
|
8
|
+
{% if w.message %}<span class="dk-muted">{{ w.message }}</span>{% endif %}
|
|
9
|
+
</div>
|
|
10
|
+
{% if w.safe_action_href and w.action_label %}
|
|
11
|
+
<a href="{{ w.safe_action_href }}" class="dk-btn dk-btn-sm">{{ w.action_label }} {{ deck_icon("arrow-right", 12) }}</a>
|
|
12
|
+
{% endif %}
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
{% elif w.kind == 'kpi' %}
|
|
17
|
+
<div class="{{ w.span_class }}">
|
|
18
|
+
{% if w.safe_href %}<a href="{{ w.safe_href }}" class="dk-kpi">{% else %}<div class="dk-kpi">{% endif %}
|
|
19
|
+
<div class="dk-kpi-top">
|
|
20
|
+
<span>{{ w.title }}</span>
|
|
21
|
+
{{ deck_icon(w.icon, 14) }}
|
|
22
|
+
</div>
|
|
23
|
+
<div class="dk-kpi-mid">
|
|
24
|
+
<div>
|
|
25
|
+
<div class="dk-kpi-val dk-tabular">{{ w.value }}</div>
|
|
26
|
+
{% if w.delta %}
|
|
27
|
+
<div class="dk-kpi-delta dk-mono{% if w.trend == 'up' %} is-up{% elif w.trend == 'down' %} is-down{% endif %}">{{ w.delta }}</div>
|
|
28
|
+
{% endif %}
|
|
29
|
+
</div>
|
|
30
|
+
{% if w.sparkline %}
|
|
31
|
+
{{ w.sparkline_svg }}
|
|
32
|
+
{% endif %}
|
|
33
|
+
</div>
|
|
34
|
+
{% if w.safe_href %}</a>{% else %}</div>{% endif %}
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
{% elif w.kind == 'chart' %}
|
|
38
|
+
<section class="dk-panel {{ w.span_class }}">
|
|
39
|
+
<div class="dk-panel-head">
|
|
40
|
+
<div>
|
|
41
|
+
<h2 class="dk-panel-title">{{ w.title }}</h2>
|
|
42
|
+
{% if w.subtitle %}<p class="dk-panel-sub">{{ w.subtitle }}</p>{% endif %}
|
|
43
|
+
</div>
|
|
44
|
+
<span class="dk-badge dk-badge-neutral dk-mono">{{ w.chart_type | upper }}</span>
|
|
45
|
+
</div>
|
|
46
|
+
<div class="dk-panel-body">{{ w.chart_svg }}</div>
|
|
47
|
+
</section>
|
|
48
|
+
|
|
49
|
+
{% elif w.kind == 'heatmap' %}
|
|
50
|
+
<section class="dk-panel {{ w.span_class }}">
|
|
51
|
+
<div class="dk-panel-head">
|
|
52
|
+
<div>
|
|
53
|
+
<h2 class="dk-panel-title">{{ w.title }}</h2>
|
|
54
|
+
{% if w.subtitle %}<p class="dk-panel-sub">{{ w.subtitle }}</p>{% endif %}
|
|
55
|
+
</div>
|
|
56
|
+
<span class="dk-badge dk-badge-neutral dk-mono">91D GRID</span>
|
|
57
|
+
</div>
|
|
58
|
+
<div class="dk-panel-body">{{ w.heatmap_svg }}</div>
|
|
59
|
+
</section>
|
|
60
|
+
|
|
61
|
+
{% elif w.kind == 'statbars' %}
|
|
62
|
+
<section class="dk-panel {{ w.span_class }}">
|
|
63
|
+
<div class="dk-panel-head">
|
|
64
|
+
<div>
|
|
65
|
+
<h2 class="dk-panel-title">{{ w.title }}</h2>
|
|
66
|
+
{% if w.subtitle %}<p class="dk-panel-sub">{{ w.subtitle }}</p>{% endif %}
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
<div class="dk-panel-body">{{ w.bars_svg }}</div>
|
|
70
|
+
</section>
|
|
71
|
+
|
|
72
|
+
{% elif w.kind == 'gauge' %}
|
|
73
|
+
<section class="dk-panel {{ w.span_class }}">
|
|
74
|
+
<div class="dk-panel-head">
|
|
75
|
+
<div>
|
|
76
|
+
<h2 class="dk-panel-title">{{ w.title }}</h2>
|
|
77
|
+
{% if w.subtitle %}<p class="dk-panel-sub">{{ w.subtitle }}</p>{% endif %}
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
<div class="dk-panel-body">
|
|
81
|
+
{{ w.gauge_svg }}
|
|
82
|
+
{% if w.details %}
|
|
83
|
+
<div class="dk-gauge-meta">
|
|
84
|
+
{% for k, v in w.details %}
|
|
85
|
+
<div class="dk-donut-row">
|
|
86
|
+
<span class="dk-muted">{{ k }}</span>
|
|
87
|
+
<span class="dk-mono dk-tabular">{{ v }}</span>
|
|
88
|
+
</div>
|
|
89
|
+
{% endfor %}
|
|
90
|
+
</div>
|
|
91
|
+
{% endif %}
|
|
92
|
+
</div>
|
|
93
|
+
</section>
|
|
94
|
+
|
|
95
|
+
{% elif w.kind == 'timeline' %}
|
|
96
|
+
<section class="dk-panel {{ w.span_class }}">
|
|
97
|
+
<div class="dk-panel-head">
|
|
98
|
+
<div>
|
|
99
|
+
<h2 class="dk-panel-title">{{ w.title }}</h2>
|
|
100
|
+
{% if w.subtitle %}<p class="dk-panel-sub">{{ w.subtitle }}</p>{% endif %}
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
<div class="dk-panel-body">
|
|
104
|
+
<ol class="dk-timeline">
|
|
105
|
+
{% for ev in w.safe_events %}
|
|
106
|
+
<li class="dk-tl-item">
|
|
107
|
+
<span class="dk-tl-dot dk-tl-{{ ev.tone or 'neutral' }}" aria-hidden="true"></span>
|
|
108
|
+
<div class="dk-tl-content">
|
|
109
|
+
<div class="dk-tl-top">
|
|
110
|
+
{% if ev.href %}<a href="{{ ev.href }}" class="dk-tl-title">{{ ev.title }}</a>{% else %}<strong class="dk-tl-title">{{ ev.title }}</strong>{% endif %}
|
|
111
|
+
<span class="dk-mono dk-subtle dk-tabular">{{ ev.time }}</span>
|
|
112
|
+
</div>
|
|
113
|
+
{% if ev.detail %}<div class="dk-muted">{{ ev.detail }}</div>{% endif %}
|
|
114
|
+
</div>
|
|
115
|
+
</li>
|
|
116
|
+
{% else %}
|
|
117
|
+
<li class="dk-chart-empty">No timeline events.</li>
|
|
118
|
+
{% endfor %}
|
|
119
|
+
</ol>
|
|
120
|
+
</div>
|
|
121
|
+
</section>
|
|
122
|
+
|
|
123
|
+
{% elif w.kind == 'table' %}
|
|
124
|
+
<section class="dk-panel {{ w.span_class }}">
|
|
125
|
+
<div class="dk-panel-head">
|
|
126
|
+
<div>
|
|
127
|
+
<h2 class="dk-panel-title">{{ w.title }}</h2>
|
|
128
|
+
{% if w.subtitle %}<p class="dk-panel-sub">{{ w.subtitle }}</p>{% endif %}
|
|
129
|
+
</div>
|
|
130
|
+
{% if w.safe_href %}<a href="{{ w.safe_href }}" class="dk-btn dk-btn-sm">{{ w.href_label }}</a>{% endif %}
|
|
131
|
+
</div>
|
|
132
|
+
<div class="dk-table-wrap">
|
|
133
|
+
<table class="dk-table">
|
|
134
|
+
<thead>
|
|
135
|
+
<tr>
|
|
136
|
+
{% for h in w.headers %}<th>{{ h }}</th>{% endfor %}
|
|
137
|
+
</tr>
|
|
138
|
+
</thead>
|
|
139
|
+
<tbody>
|
|
140
|
+
{% for row in w.rows %}
|
|
141
|
+
<tr>
|
|
142
|
+
{% for cell in row %}<td>{{ cell }}</td>{% endfor %}
|
|
143
|
+
</tr>
|
|
144
|
+
{% else %}
|
|
145
|
+
<tr><td colspan="{{ w.headers | length }}" class="dk-chart-empty">No records</td></tr>
|
|
146
|
+
{% endfor %}
|
|
147
|
+
</tbody>
|
|
148
|
+
</table>
|
|
149
|
+
</div>
|
|
150
|
+
</section>
|
|
151
|
+
|
|
152
|
+
{% elif w.kind == 'activity' %}
|
|
153
|
+
<section class="dk-panel {{ w.span_class }}">
|
|
154
|
+
<div class="dk-panel-head">
|
|
155
|
+
<div>
|
|
156
|
+
<h2 class="dk-panel-title">{{ w.title }}</h2>
|
|
157
|
+
{% if w.subtitle %}<p class="dk-panel-sub">{{ w.subtitle }}</p>{% endif %}
|
|
158
|
+
</div>
|
|
159
|
+
{% if can_view_audit %}
|
|
160
|
+
<a href="{{ url_for(bp_name ~ '.audit_list') }}" class="dk-btn dk-btn-sm">Full Ledger</a>
|
|
161
|
+
{% endif %}
|
|
162
|
+
</div>
|
|
163
|
+
<div>
|
|
164
|
+
{% for entry in w.entries %}
|
|
165
|
+
<div class="dk-activity-row">
|
|
166
|
+
<div class="dk-activity-main">
|
|
167
|
+
<div>
|
|
168
|
+
<span class="dk-badge dk-badge-{{ 'ok' if entry.action == 'create' else ('danger' if entry.action == 'delete' else ('warn' if entry.action in ['update','inline_edit','revert'] else 'info')) }} dk-mono">{{ entry.action }}</span>
|
|
169
|
+
<strong>{{ entry.model_label }}</strong>
|
|
170
|
+
<span class="dk-muted">{{ entry.record_repr }}</span>
|
|
171
|
+
</div>
|
|
172
|
+
{% if entry.changes %}
|
|
173
|
+
<div class="dk-diff-list">
|
|
174
|
+
{% for field, delta in (entry.changes.items() | list)[:3] %}
|
|
175
|
+
<div class="dk-diff-row">
|
|
176
|
+
<span class="dk-diff-key">{{ field }}:</span>
|
|
177
|
+
{% if delta.old is not none %}<span class="dk-diff-old">{{ delta.old }}</span>{% endif %}
|
|
178
|
+
<span class="dk-subtle">→</span>
|
|
179
|
+
<span class="dk-diff-new">{{ delta.new }}</span>
|
|
180
|
+
</div>
|
|
181
|
+
{% endfor %}
|
|
182
|
+
</div>
|
|
183
|
+
{% endif %}
|
|
184
|
+
</div>
|
|
185
|
+
<div class="dk-mono dk-subtle dk-tabular">
|
|
186
|
+
<div>{{ entry.actor_name }}</div>
|
|
187
|
+
<div>{{ format_dt(entry.timestamp, '%m-%d %H:%M') }}</div>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
{% else %}
|
|
191
|
+
<div class="dk-chart-empty">No audit events recorded yet.</div>
|
|
192
|
+
{% endfor %}
|
|
193
|
+
</div>
|
|
194
|
+
</section>
|
|
195
|
+
|
|
196
|
+
{% elif w.kind == 'notes' %}
|
|
197
|
+
<section class="dk-panel {{ w.span_class }}">
|
|
198
|
+
<div class="dk-panel-head">
|
|
199
|
+
<h2 class="dk-panel-title">{{ w.title }}</h2>
|
|
200
|
+
</div>
|
|
201
|
+
<div class="dk-panel-body">
|
|
202
|
+
{% for line in w.lines %}<p class="dk-muted">{{ line }}</p>{% endfor %}
|
|
203
|
+
</div>
|
|
204
|
+
</section>
|
|
205
|
+
{% endif %}
|
|
206
|
+
{% endfor %}
|
|
207
|
+
</div>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{% extends "flask_deck/base.html" %}
|
|
2
|
+
{% block content %}
|
|
3
|
+
<div class="dk-page-head">
|
|
4
|
+
<div>
|
|
5
|
+
<h1 class="dk-page-title">RBAC Policy Matrix</h1>
|
|
6
|
+
<p class="dk-page-sub">Deny-by-default 4-level authorization: model actions, field masking, read-only guards, and row scoping.</p>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div class="dk-content">
|
|
11
|
+
{% for block in matrix %}
|
|
12
|
+
<section class="dk-panel">
|
|
13
|
+
<div class="dk-panel-head">
|
|
14
|
+
<div>
|
|
15
|
+
<h2 class="dk-panel-title">{{ block.role.display_label }} <code class="dk-code">{{ block.role.name }}</code></h2>
|
|
16
|
+
{% if block.role.description %}<p class="dk-panel-sub">{{ block.role.description }}</p>{% endif %}
|
|
17
|
+
</div>
|
|
18
|
+
<div class="dk-page-actions">
|
|
19
|
+
<span class="dk-badge dk-badge-{{ 'ok' if block.audit_view else 'neutral' }} dk-mono">audit:view {{ 'ON' if block.audit_view else 'OFF' }}</span>
|
|
20
|
+
<span class="dk-badge dk-badge-{{ 'warn' if block.audit_revert else 'neutral' }} dk-mono">audit:revert {{ 'ON' if block.audit_revert else 'OFF' }}</span>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="dk-table-wrap">
|
|
24
|
+
<table class="dk-table">
|
|
25
|
+
<thead>
|
|
26
|
+
<tr>
|
|
27
|
+
<th>Model</th>
|
|
28
|
+
{% for act in actions %}<th>{{ act | upper }}</th>{% endfor %}
|
|
29
|
+
<th>Field Controls (Hidden / Read-Only / Masked)</th>
|
|
30
|
+
</tr>
|
|
31
|
+
</thead>
|
|
32
|
+
<tbody>
|
|
33
|
+
{% for row in block.models %}
|
|
34
|
+
<tr>
|
|
35
|
+
<td><strong>{{ row.label }}</strong></td>
|
|
36
|
+
{% for act in actions %}
|
|
37
|
+
<td>
|
|
38
|
+
{% if row.grants[act] %}
|
|
39
|
+
<span class="dk-badge dk-badge-ok dk-mono">ALLOW</span>
|
|
40
|
+
{% else %}
|
|
41
|
+
<span class="dk-badge dk-badge-neutral dk-mono">DENY</span>
|
|
42
|
+
{% endif %}
|
|
43
|
+
</td>
|
|
44
|
+
{% endfor %}
|
|
45
|
+
<td class="dk-mono">
|
|
46
|
+
{% if row.hidden %}<span class="dk-badge dk-badge-danger">hide: {{ row.hidden | join(",") }}</span> {% endif %}
|
|
47
|
+
{% if row.readonly %}<span class="dk-badge dk-badge-warn">ro: {{ row.readonly | join(",") }}</span> {% endif %}
|
|
48
|
+
{% if row.masked %}<span class="dk-badge dk-badge-info">mask: {{ row.masked | join(",") }}</span>{% endif %}
|
|
49
|
+
{% if not row.hidden and not row.readonly and not row.masked %}<span class="dk-subtle">Full field access</span>{% endif %}
|
|
50
|
+
</td>
|
|
51
|
+
</tr>
|
|
52
|
+
{% endfor %}
|
|
53
|
+
</tbody>
|
|
54
|
+
</table>
|
|
55
|
+
</div>
|
|
56
|
+
</section>
|
|
57
|
+
{% endfor %}
|
|
58
|
+
</div>
|
|
59
|
+
{% endblock %}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{% extends "flask_deck/base.html" %}
|
|
2
|
+
{% block breadcrumbs %}
|
|
3
|
+
<span class="dk-crumb-sep">/</span>
|
|
4
|
+
<a href="{{ url_for(bp_name ~ '.model_list', slug=view.meta.slug) }}" class="dk-crumb">{{ view.plural_label }}</a>
|
|
5
|
+
<span class="dk-crumb-sep">/</span>
|
|
6
|
+
<a href="{{ url_for(bp_name ~ '.model_detail', slug=view.meta.slug, raw_pk=pk_str) }}" class="dk-crumb">{{ record_repr }}</a>
|
|
7
|
+
<span class="dk-crumb-sep">/</span>
|
|
8
|
+
<span class="dk-crumb dk-crumb-cur">{{ _("History") }}</span>
|
|
9
|
+
{% endblock %}
|
|
10
|
+
|
|
11
|
+
{% block content %}
|
|
12
|
+
<div class="dk-page-head">
|
|
13
|
+
<div>
|
|
14
|
+
<h1 class="dk-page-title">Revision Diff · {{ record_repr }}</h1>
|
|
15
|
+
<p class="dk-page-sub dk-mono">{{ entries | length }} recorded revision(s) · Side-by-side field inspection</p>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="dk-page-actions">
|
|
18
|
+
<a href="{{ url_for(bp_name ~ '.model_detail', slug=view.meta.slug, raw_pk=pk_str) }}" class="dk-btn">{{ deck_icon("arrow-left", 13) }} {{ _("Back") }}</a>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div class="dk-content">
|
|
23
|
+
<div class="dk-grid">
|
|
24
|
+
<section class="dk-panel dk-span-4">
|
|
25
|
+
<div class="dk-panel-head">
|
|
26
|
+
<h2 class="dk-panel-title">Revisions</h2>
|
|
27
|
+
<span class="dk-mono dk-subtle">{{ entries | length }}</span>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="dk-rev-list">
|
|
30
|
+
{% for entry in entries %}
|
|
31
|
+
{% set is_sel = selected_entry and selected_entry.id == entry.id %}
|
|
32
|
+
<a href="{{ url_for(bp_name ~ '.model_history', slug=view.meta.slug, raw_pk=pk_str, rev=entry.id) }}"
|
|
33
|
+
class="dk-rev-item{% if is_sel %} is-active{% endif %}">
|
|
34
|
+
<div class="dk-rev-top">
|
|
35
|
+
<span class="dk-badge dk-badge-{{ 'ok' if entry.action in ['create', 'restore'] else ('danger' if 'delete' in entry.action else 'warn') }} dk-mono">{{ entry.action }}</span>
|
|
36
|
+
<span class="dk-mono dk-subtle dk-tabular">{{ format_dt(entry.timestamp, '%m-%d %H:%M') }}</span>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="dk-rev-meta">
|
|
39
|
+
<strong>{{ entry.actor_name }}</strong>
|
|
40
|
+
<span class="dk-subtle dk-mono">{{ entry.changes | length }} field(s)</span>
|
|
41
|
+
</div>
|
|
42
|
+
</a>
|
|
43
|
+
{% else %}
|
|
44
|
+
<div class="dk-chart-empty">No revision snapshots recorded for this record.</div>
|
|
45
|
+
{% endfor %}
|
|
46
|
+
</div>
|
|
47
|
+
</section>
|
|
48
|
+
|
|
49
|
+
<section class="dk-panel dk-span-8">
|
|
50
|
+
{% if selected_entry %}
|
|
51
|
+
<div class="dk-panel-head">
|
|
52
|
+
<div>
|
|
53
|
+
<h2 class="dk-panel-title">Revision #{{ selected_entry.id[:8] }} · {{ selected_entry.action }}</h2>
|
|
54
|
+
<p class="dk-panel-sub dk-mono">Actor: {{ selected_entry.actor_name }} ({{ selected_entry.actor_ip }}) · {{ format_dt(selected_entry.timestamp, '%Y-%m-%d %H:%M:%S') }}</p>
|
|
55
|
+
</div>
|
|
56
|
+
{% if can_revert and selected_entry.is_revertible %}
|
|
57
|
+
<form method="post" action="{{ url_for(bp_name ~ '.audit_revert', entry_id=selected_entry.id) }}">
|
|
58
|
+
<input type="hidden" name="{{ csrf_field }}" value="{{ csrf_token }}">
|
|
59
|
+
<button type="submit"
|
|
60
|
+
class="dk-btn dk-btn-sm dk-btn-danger"
|
|
61
|
+
data-deck-confirm-form
|
|
62
|
+
data-confirm-title="Restore Revision"
|
|
63
|
+
data-confirm-msg="Revert changed fields back to their pre-mutation values?"
|
|
64
|
+
{% if config.environment == 'production' and config.require_confirm_text_in_prod %}data-confirm-phrase="REVERT"{% endif %}>
|
|
65
|
+
{{ deck_icon("rotate-ccw", 12) }} Restore Revision
|
|
66
|
+
</button>
|
|
67
|
+
</form>
|
|
68
|
+
{% endif %}
|
|
69
|
+
</div>
|
|
70
|
+
<div class="dk-table-wrap">
|
|
71
|
+
<table class="dk-table dk-sbs-table">
|
|
72
|
+
<thead>
|
|
73
|
+
<tr>
|
|
74
|
+
<th>Field</th>
|
|
75
|
+
<th>Before</th>
|
|
76
|
+
<th>After (Revision)</th>
|
|
77
|
+
<th>Current Live</th>
|
|
78
|
+
</tr>
|
|
79
|
+
</thead>
|
|
80
|
+
<tbody>
|
|
81
|
+
{% for row in diff_rows %}
|
|
82
|
+
<tr>
|
|
83
|
+
<td class="dk-mono"><strong>{{ row.label }}</strong></td>
|
|
84
|
+
<td><span class="dk-diff-old">{{ row.old if row.old is not none else "—" }}</span></td>
|
|
85
|
+
<td><span class="dk-diff-new">{{ row.new if row.new is not none else "—" }}</span></td>
|
|
86
|
+
<td class="dk-mono dk-muted">{{ row.live if row.live is not none else "—" }}</td>
|
|
87
|
+
</tr>
|
|
88
|
+
{% else %}
|
|
89
|
+
<tr>
|
|
90
|
+
<td colspan="4" class="dk-chart-empty">No scalar field diffs in this revision.</td>
|
|
91
|
+
</tr>
|
|
92
|
+
{% endfor %}
|
|
93
|
+
</tbody>
|
|
94
|
+
</table>
|
|
95
|
+
</div>
|
|
96
|
+
{% else %}
|
|
97
|
+
<div class="dk-chart-empty">Select a revision from the timeline to inspect field-level diffs.</div>
|
|
98
|
+
{% endif %}
|
|
99
|
+
</section>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
{% endblock %}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{% extends "flask_deck/base.html" %}
|
|
2
|
+
{% block content %}
|
|
3
|
+
<div class="dk-page-head">
|
|
4
|
+
<div>
|
|
5
|
+
<h1 class="dk-page-title">Schema ERD & Index Inspector</h1>
|
|
6
|
+
<p class="dk-page-sub dk-mono">{{ views | length }} registered SQLAlchemy 2.0 models · zero per-request reflection</p>
|
|
7
|
+
</div>
|
|
8
|
+
<div class="dk-page-actions">
|
|
9
|
+
{% if can_view_diagnostics %}
|
|
10
|
+
<a href="{{ url_for(bp_name ~ '.diagnostics') }}" class="dk-btn">{{ deck_icon("heart-pulse", 13) }} Diagnostics</a>
|
|
11
|
+
{% endif %}
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<div class="dk-content">
|
|
16
|
+
<section class="dk-panel">
|
|
17
|
+
<div class="dk-panel-head">
|
|
18
|
+
<div>
|
|
19
|
+
<h2 class="dk-panel-title">Entity-Relationship Diagram</h2>
|
|
20
|
+
<p class="dk-panel-sub">Pure SSR SVG graph generated from frozen ModelMeta & ForeignKey constraints</p>
|
|
21
|
+
</div>
|
|
22
|
+
<span class="dk-badge dk-badge-neutral dk-mono">SVG ERD</span>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="dk-panel-body">{{ erd_svg }}</div>
|
|
25
|
+
</section>
|
|
26
|
+
|
|
27
|
+
{% for v in views %}
|
|
28
|
+
<section class="dk-panel">
|
|
29
|
+
<div class="dk-panel-head">
|
|
30
|
+
<div>
|
|
31
|
+
<h2 class="dk-panel-title">{{ v.meta.name }} <code class="dk-code">{{ v.meta.table_name }}</code></h2>
|
|
32
|
+
<p class="dk-panel-sub dk-mono">{{ "{:,}".format(row_counts.get(v.meta.slug, 0)) }} rows · {{ v.meta.fields | length }} columns · {{ v.meta.indexed_fields | length }} indexed</p>
|
|
33
|
+
</div>
|
|
34
|
+
<a href="{{ url_for(bp_name ~ '.model_list', slug=v.meta.slug) }}" class="dk-btn dk-btn-sm">Open Table</a>
|
|
35
|
+
</div>
|
|
36
|
+
<div class="dk-table-wrap">
|
|
37
|
+
<table class="dk-table">
|
|
38
|
+
<thead>
|
|
39
|
+
<tr>
|
|
40
|
+
<th>Column</th>
|
|
41
|
+
<th>Type</th>
|
|
42
|
+
<th>Constraints</th>
|
|
43
|
+
<th>Index Health</th>
|
|
44
|
+
<th>Privacy</th>
|
|
45
|
+
<th>Foreign Key</th>
|
|
46
|
+
</tr>
|
|
47
|
+
</thead>
|
|
48
|
+
<tbody>
|
|
49
|
+
{% for f in v.meta.fields %}
|
|
50
|
+
<tr>
|
|
51
|
+
<td><code class="dk-code">{{ f.name }}</code></td>
|
|
52
|
+
<td class="dk-mono dk-muted">{{ f.field_type }}{% if f.max_length %}({{ f.max_length }}){% endif %}</td>
|
|
53
|
+
<td class="dk-mono">
|
|
54
|
+
{% if f.primary_key %}<span class="dk-badge dk-badge-info">PK</span> {% endif %}
|
|
55
|
+
{% if f.unique %}<span class="dk-badge dk-badge-neutral">UNIQUE</span> {% endif %}
|
|
56
|
+
{% if not f.nullable %}<span class="dk-badge dk-badge-neutral">NOT NULL</span>{% else %}<span class="dk-subtle">nullable</span>{% endif %}
|
|
57
|
+
</td>
|
|
58
|
+
<td>
|
|
59
|
+
{% if f.indexed %}
|
|
60
|
+
<span class="dk-badge dk-badge-ok dk-mono">INDEXED</span>
|
|
61
|
+
{% elif f.name in v.resolved_searchable %}
|
|
62
|
+
<span class="dk-badge dk-badge-warn dk-mono">SEARCHABLE · NO INDEX</span>
|
|
63
|
+
{% else %}
|
|
64
|
+
<span class="dk-subtle dk-mono">unindexed</span>
|
|
65
|
+
{% endif %}
|
|
66
|
+
</td>
|
|
67
|
+
<td>
|
|
68
|
+
{% if f.is_sensitive %}
|
|
69
|
+
<span class="dk-badge dk-badge-danger dk-mono">AUTO-REDACTED</span>
|
|
70
|
+
{% else %}
|
|
71
|
+
<span class="dk-subtle dk-mono">visible</span>
|
|
72
|
+
{% endif %}
|
|
73
|
+
</td>
|
|
74
|
+
<td class="dk-mono dk-muted">{{ f.fk_column or '—' }}</td>
|
|
75
|
+
</tr>
|
|
76
|
+
{% endfor %}
|
|
77
|
+
</tbody>
|
|
78
|
+
</table>
|
|
79
|
+
</div>
|
|
80
|
+
</section>
|
|
81
|
+
{% endfor %}
|
|
82
|
+
</div>
|
|
83
|
+
{% endblock %}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{% extends "flask_deck/base.html" %}
|
|
2
|
+
{% block content %}
|
|
3
|
+
<div class="dk-page-head">
|
|
4
|
+
<div>
|
|
5
|
+
<h1 class="dk-page-title">Read-Only SQL Console</h1>
|
|
6
|
+
<p class="dk-page-sub dk-mono">SELECT / WITH / EXPLAIN only · rolled-back transaction · auto-redacts sensitive columns · max {{ config.sql_console_max_rows }} rows</p>
|
|
7
|
+
</div>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div class="dk-content">
|
|
11
|
+
<section class="dk-panel">
|
|
12
|
+
<div class="dk-panel-head">
|
|
13
|
+
<div class="dk-toolbar-left">
|
|
14
|
+
<span class="dk-badge dk-badge-ok dk-mono"><span class="dk-dot"></span>READ-ONLY GUARD</span>
|
|
15
|
+
{% if sql_presets %}
|
|
16
|
+
<span class="dk-subtle dk-mono">Presets:</span>
|
|
17
|
+
{% for plabel, psql in sql_presets %}
|
|
18
|
+
<button type="button" class="dk-btn dk-btn-sm" data-deck-sql-preset="{{ psql }}">{{ plabel }}</button>
|
|
19
|
+
{% endfor %}
|
|
20
|
+
{% endif %}
|
|
21
|
+
</div>
|
|
22
|
+
<div class="dk-chip-group dk-mono">
|
|
23
|
+
{% for tbl in tables[:6] %}
|
|
24
|
+
<button type="button" class="dk-chip" data-deck-sql-preset="SELECT * FROM {{ tbl }} LIMIT 25">{{ tbl }}</button>
|
|
25
|
+
{% endfor %}
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<form method="post" class="dk-panel-body">
|
|
30
|
+
<input type="hidden" name="{{ csrf_field }}" value="{{ csrf_token }}">
|
|
31
|
+
<div class="dk-field">
|
|
32
|
+
<textarea id="dk-sql-editor" name="sql" class="dk-textarea dk-mono dk-sql-editor" rows="5" placeholder="SELECT id, name FROM ... LIMIT 25">{{ sql_text }}</textarea>
|
|
33
|
+
</div>
|
|
34
|
+
<div class="dk-form-actions">
|
|
35
|
+
<button type="submit" name="output" value="table" class="dk-btn dk-btn-primary">{{ deck_icon("play", 12) }} Run Query</button>
|
|
36
|
+
<button type="submit" name="output" value="csv" class="dk-btn">{{ deck_icon("download", 13) }} Run & Export CSV</button>
|
|
37
|
+
<span class="dk-subtle dk-mono">Every execution is audited in the Audit Ledger.</span>
|
|
38
|
+
</div>
|
|
39
|
+
</form>
|
|
40
|
+
</section>
|
|
41
|
+
|
|
42
|
+
{% if result %}
|
|
43
|
+
{% if result.error %}
|
|
44
|
+
<div class="dk-alert dk-alert-danger dk-mono" role="alert">{{ result.error }}</div>
|
|
45
|
+
{% else %}
|
|
46
|
+
<section class="dk-panel">
|
|
47
|
+
<div class="dk-panel-head">
|
|
48
|
+
<div class="dk-toolbar-left dk-mono">
|
|
49
|
+
<strong>{{ result.row_count }} row(s)</strong>
|
|
50
|
+
<span class="dk-subtle">· {{ "%.2f"|format(result.duration_ms) }} ms</span>
|
|
51
|
+
{% if result.truncated %}<span class="dk-badge dk-badge-warn">TRUNCATED AT {{ config.sql_console_max_rows }}</span>{% endif %}
|
|
52
|
+
{% if result.redacted_columns %}<span class="dk-badge dk-badge-ok">REDACTED: {{ result.redacted_columns | join(", ") }}</span>{% endif %}
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<div class="dk-table-wrap">
|
|
56
|
+
<table class="dk-table dk-mono">
|
|
57
|
+
<thead>
|
|
58
|
+
<tr>
|
|
59
|
+
{% for col in result.columns %}<th>{{ col }}</th>{% endfor %}
|
|
60
|
+
</tr>
|
|
61
|
+
</thead>
|
|
62
|
+
<tbody>
|
|
63
|
+
{% for row in result.rows %}
|
|
64
|
+
<tr>
|
|
65
|
+
{% for cell in row %}
|
|
66
|
+
<td>
|
|
67
|
+
{% if cell == '[REDACTED]' %}
|
|
68
|
+
<span class="dk-masked">[REDACTED]</span>
|
|
69
|
+
{% elif cell is none %}
|
|
70
|
+
<span class="dk-null">NULL</span>
|
|
71
|
+
{% else %}
|
|
72
|
+
{{ cell }}
|
|
73
|
+
{% endif %}
|
|
74
|
+
</td>
|
|
75
|
+
{% endfor %}
|
|
76
|
+
</tr>
|
|
77
|
+
{% else %}
|
|
78
|
+
<tr><td colspan="{{ result.columns | length or 1 }}" class="dk-chart-empty">Query returned 0 rows.</td></tr>
|
|
79
|
+
{% endfor %}
|
|
80
|
+
</tbody>
|
|
81
|
+
</table>
|
|
82
|
+
</div>
|
|
83
|
+
</section>
|
|
84
|
+
{% endif %}
|
|
85
|
+
{% endif %}
|
|
86
|
+
</div>
|
|
87
|
+
{% endblock %}
|