codex-fastapi-cabinet 0.1.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.
Files changed (39) hide show
  1. codex_fastapi_cabinet-0.1.0.dist-info/METADATA +182 -0
  2. codex_fastapi_cabinet-0.1.0.dist-info/RECORD +39 -0
  3. codex_fastapi_cabinet-0.1.0.dist-info/WHEEL +4 -0
  4. codex_fastapi_cabinet-0.1.0.dist-info/licenses/LICENSE +190 -0
  5. fastapi_cabinet/__init__.py +90 -0
  6. fastapi_cabinet/contracts/__init__.py +86 -0
  7. fastapi_cabinet/contracts/admin.py +50 -0
  8. fastapi_cabinet/contracts/layout.py +22 -0
  9. fastapi_cabinet/contracts/navigation.py +29 -0
  10. fastapi_cabinet/contracts/pages.py +164 -0
  11. fastapi_cabinet/contracts/permissions.py +16 -0
  12. fastapi_cabinet/contracts/providers.py +9 -0
  13. fastapi_cabinet/contracts/widgets.py +102 -0
  14. fastapi_cabinet/exceptions.py +18 -0
  15. fastapi_cabinet/fastapi.py +36 -0
  16. fastapi_cabinet/loader.py +68 -0
  17. fastapi_cabinet/registry.py +31 -0
  18. fastapi_cabinet/rendering/__init__.py +5 -0
  19. fastapi_cabinet/rendering/layout_mapper.py +88 -0
  20. fastapi_cabinet/rendering/page_mapper.py +44 -0
  21. fastapi_cabinet/rendering/widget_mapper.py +59 -0
  22. fastapi_cabinet/runtime.py +58 -0
  23. fastapi_cabinet/site.py +262 -0
  24. fastapi_cabinet/static/css/cabinet.css +126 -0
  25. fastapi_cabinet/static/js/cabinet.js +6 -0
  26. fastapi_cabinet/templates/cabinet/base.html +21 -0
  27. fastapi_cabinet/templates/cabinet/dashboard.html +14 -0
  28. fastapi_cabinet/templates/cabinet/includes/sidebar.html +20 -0
  29. fastapi_cabinet/templates/cabinet/includes/topbar.html +21 -0
  30. fastapi_cabinet/templates/cabinet/includes/widget_frame.html +3 -0
  31. fastapi_cabinet/templates/cabinet/module.html +18 -0
  32. fastapi_cabinet/templates/cabinet/pages/detail.html +39 -0
  33. fastapi_cabinet/templates/cabinet/pages/form.html +47 -0
  34. fastapi_cabinet/templates/cabinet/pages/list.html +81 -0
  35. fastapi_cabinet/templates/cabinet/pages/operation.html +29 -0
  36. fastapi_cabinet/templates/cabinet/widgets/chart.html +20 -0
  37. fastapi_cabinet/templates/cabinet/widgets/list.html +8 -0
  38. fastapi_cabinet/templates/cabinet/widgets/metric.html +9 -0
  39. fastapi_cabinet/templates/cabinet/widgets/table.html +43 -0
@@ -0,0 +1,81 @@
1
+ {% extends "cabinet/base.html" %}
2
+ {% block content %}
3
+ <header class="fc-page-header">
4
+ <div>
5
+ <p class="fc-eyebrow">{{ module.label }}</p>
6
+ <h1>{{ page.title }}</h1>
7
+ {% if page.subtitle %}<p class="fc-muted">{{ page.subtitle }}</p>{% endif %}
8
+ </div>
9
+ {% if page.create_url %}<a class="fc-button is-primary" href="{{ page.create_url }}">{{ page.create_label }}</a>{% endif %}
10
+ </header>
11
+ {% if page.filters %}
12
+ <form class="fc-card fc-filters" method="get">
13
+ {% for field in page.filters %}
14
+ <label>
15
+ <span>{{ field.label }}</span>
16
+ {% if field.input_type == "select" %}
17
+ <select name="{{ field.name }}">
18
+ {% for choice in field.choices %}
19
+ <option value="{{ choice.value }}"{% if choice.selected %} selected{% endif %}>{{ choice.label }}</option>
20
+ {% endfor %}
21
+ </select>
22
+ {% elif field.input_type == "checkbox" %}
23
+ <input type="checkbox" name="{{ field.name }}" value="1"{% if field.value %} checked{% endif %}>
24
+ {% else %}
25
+ <input type="{{ field.input_type }}" name="{{ field.name }}" value="{{ field.value }}">
26
+ {% endif %}
27
+ </label>
28
+ {% endfor %}
29
+ <button class="fc-button" type="submit">Filter</button>
30
+ </form>
31
+ {% endif %}
32
+ <section class="fc-card">
33
+ {% if page.rows %}
34
+ <div class="fc-table-wrap">
35
+ <table class="fc-table">
36
+ <thead>
37
+ <tr>
38
+ {% for column in page.columns %}<th class="is-{{ column.align }}">{{ column.label }}</th>{% endfor %}
39
+ {% if page.actions %}<th>Actions</th>{% endif %}
40
+ </tr>
41
+ </thead>
42
+ <tbody>
43
+ {% for row in page.rows %}
44
+ <tr>
45
+ {% for column in page.columns %}
46
+ <td class="is-{{ column.align }}">
47
+ {% if page.row_href_key and row.get(page.row_href_key) %}
48
+ <a href="{{ row.get(page.row_href_key) }}">{{ row.get(column.key, "") }}</a>
49
+ {% else %}
50
+ {{ row.get(column.key, "") }}
51
+ {% endif %}
52
+ </td>
53
+ {% endfor %}
54
+ {% if page.actions %}
55
+ <td class="fc-actions">
56
+ {% for action in page.actions %}
57
+ <form action="{{ action.action_url }}" method="post">
58
+ <input type="hidden" name="_method" value="{{ action.method }}">
59
+ <input type="hidden" name="csrf_token" value="{{ csrf_token }}">
60
+ <button class="fc-button {{ action.css_class }}" type="submit">{{ action.label }}</button>
61
+ </form>
62
+ {% endfor %}
63
+ </td>
64
+ {% endif %}
65
+ </tr>
66
+ {% endfor %}
67
+ </tbody>
68
+ </table>
69
+ </div>
70
+ {% else %}
71
+ <p class="fc-empty">{{ page.empty_message }}</p>
72
+ {% endif %}
73
+ </section>
74
+ {% if page.pagination %}
75
+ <nav class="fc-pagination" aria-label="Pagination">
76
+ {% if page.pagination.previous_url %}<a class="fc-button" href="{{ page.pagination.previous_url }}">Previous</a>{% endif %}
77
+ <span>Page {{ page.pagination.page }} of {{ page.pagination.pages }} · {{ page.pagination.total }} total</span>
78
+ {% if page.pagination.next_url %}<a class="fc-button" href="{{ page.pagination.next_url }}">Next</a>{% endif %}
79
+ </nav>
80
+ {% endif %}
81
+ {% endblock %}
@@ -0,0 +1,29 @@
1
+ {% extends "cabinet/base.html" %}
2
+ {% block content %}
3
+ <header class="fc-page-header">
4
+ <div>
5
+ <p class="fc-eyebrow">{{ module.label }}</p>
6
+ <h1>{{ page.title }}</h1>
7
+ {% if page.subtitle %}<p class="fc-muted">{{ page.subtitle }}</p>{% endif %}
8
+ </div>
9
+ </header>
10
+ {% if page.description %}<p>{{ page.description }}</p>{% endif %}
11
+ {% for notice in page.notices %}<div class="fc-alert">{{ notice }}</div>{% endfor %}
12
+ <div class="fc-operation-grid">
13
+ {% for action in page.actions %}
14
+ <section class="fc-card">
15
+ <h2 class="fc-card-title">{{ action.label }}</h2>
16
+ {% if action.description %}<p>{{ action.description }}</p>{% endif %}
17
+ <form action="{{ action.action_url }}" method="post">
18
+ <input type="hidden" name="_method" value="{{ action.method }}">
19
+ <input type="hidden" name="csrf_token" value="{{ csrf_token }}">
20
+ <button
21
+ class="fc-button {{ action.css_class }}"
22
+ type="submit"
23
+ {% if action.confirmation %}data-confirm="{{ action.confirmation }}"{% endif %}
24
+ >{{ action.label }}</button>
25
+ </form>
26
+ </section>
27
+ {% endfor %}
28
+ </div>
29
+ {% endblock %}
@@ -0,0 +1,20 @@
1
+ <h2 class="fc-card-title">{{ widget.title }}</h2>
2
+ <div class="fc-chart" data-chart-type="{{ widget.chart_type }}" style="min-height: {{ widget.height }}px">
3
+ {% if widget.datasets and widget.labels %}
4
+ {% for dataset in widget.datasets %}
5
+ <section class="fc-chart-series">
6
+ <h3>{{ dataset.label }}</h3>
7
+ <dl>
8
+ {% for value in dataset.data %}
9
+ <div class="fc-chart-point">
10
+ <dt>{{ widget.labels[loop.index0] if loop.index0 < widget.labels|length else loop.index }}</dt>
11
+ <dd style="--fc-value: {{ value }}">{{ value }}</dd>
12
+ </div>
13
+ {% endfor %}
14
+ </dl>
15
+ </section>
16
+ {% endfor %}
17
+ {% else %}
18
+ <p class="fc-empty">No chart data.</p>
19
+ {% endif %}
20
+ </div>
@@ -0,0 +1,8 @@
1
+ <h2 class="fc-card-title">{{ widget.title }}</h2>
2
+ {% if widget.items %}
3
+ <ul class="fc-list">
4
+ {% for item in widget.items %}<li>{{ item }}</li>{% endfor %}
5
+ </ul>
6
+ {% else %}
7
+ <p class="fc-empty">{{ widget.empty_message }}</p>
8
+ {% endif %}
@@ -0,0 +1,9 @@
1
+ <div class="fc-metric">
2
+ <div>
3
+ <p class="fc-card-title">{{ widget.title }}</p>
4
+ <p class="fc-metric-value">{{ widget.value }}</p>
5
+ </div>
6
+ {% if widget.icon %}<span class="fc-metric-icon" aria-hidden="true">{{ widget.icon }}</span>{% endif %}
7
+ </div>
8
+ {% if widget.subtitle %}<p class="fc-muted">{{ widget.subtitle }}</p>{% endif %}
9
+ {% if widget.trend %}<p class="fc-trend">{{ widget.trend }}</p>{% endif %}
@@ -0,0 +1,43 @@
1
+ <h2 class="fc-card-title">{{ widget.title }}</h2>
2
+ {% if widget.rows %}
3
+ <div class="fc-table-wrap">
4
+ <table class="fc-table">
5
+ <thead>
6
+ <tr>
7
+ {% for column in widget.columns %}
8
+ <th class="is-{{ column.align }}">{{ column.label }}</th>
9
+ {% endfor %}
10
+ {% if widget.actions %}<th>Actions</th>{% endif %}
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ {% for row in widget.rows %}
15
+ <tr>
16
+ {% for column in widget.columns %}
17
+ <td class="is-{{ column.align }}">
18
+ {% if widget.row_href_key and row.get(widget.row_href_key) %}
19
+ <a href="{{ row.get(widget.row_href_key) }}">{{ row.get(column.key, "") }}</a>
20
+ {% else %}
21
+ {{ row.get(column.key, "") }}
22
+ {% endif %}
23
+ </td>
24
+ {% endfor %}
25
+ {% if widget.actions %}
26
+ <td class="fc-actions">
27
+ {% for action in widget.actions %}
28
+ <form action="{{ action.action_url }}" method="post">
29
+ <input type="hidden" name="_method" value="{{ action.method }}">
30
+ <input type="hidden" name="csrf_token" value="{{ csrf_token }}">
31
+ <button class="fc-button {{ action.css_class }}" type="submit">{{ action.label }}</button>
32
+ </form>
33
+ {% endfor %}
34
+ </td>
35
+ {% endif %}
36
+ </tr>
37
+ {% endfor %}
38
+ </tbody>
39
+ </table>
40
+ </div>
41
+ {% else %}
42
+ <p class="fc-empty">{{ widget.empty_message }}</p>
43
+ {% endif %}