diff --git a/expenses_manager/expenses/static/expenses/css/base.css b/expenses_manager/expenses/static/expenses/css/base.css index 533ca0a..a1ee0ca 100644 --- a/expenses_manager/expenses/static/expenses/css/base.css +++ b/expenses_manager/expenses/static/expenses/css/base.css @@ -65,9 +65,22 @@ a.danger { padding: 24px; } +.dashboard-context { + margin-bottom: 1rem; +} + +.dashboard-context h2 { + margin: 0; +} + +.muted { + color: #6b7280; + font-size: 0.85rem; +} + .dashboard-grid { display: grid; - grid-template-columns: repeat(auto-fit, minmax(300px, 500px)); + grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px } @@ -79,7 +92,7 @@ a.danger { } .card-chart { - max-width: 500px; + max-width: 300px; } .card-chart canvas { @@ -87,6 +100,11 @@ a.danger { height: 220px !important; } +.chart-box { + height: 300px; + margin-bottom: 2rem; +} + .tag{ display: inline-block; padding: 2px 6px; @@ -104,7 +122,7 @@ a.danger { .kpi-grid { display: grid; - grid-template-columns: repeat(auto-file, minmax(180px, 1fr)); + grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin: 1.5rem 0; } @@ -128,6 +146,18 @@ a.danger { margin-top: 0.25rem; } +/* .comparison strong { + color:#b91c1c; +} */ + +.comparison strong.positive { + color: #166534; +} + +.comparison strong.negative { + color:#b91c1c; +} + table { width: 100%; border-collapse: collapse; @@ -205,4 +235,52 @@ tbody tr:hover { .message.warning { background: #fef3c7; color: #92400e; +} + +.dashboard-filters { + margin: 1rem 0 1.5rem; + padding: 1rem; + background: #f9fafb; + border-radius: 8px; +} + +.dashboard-filters form { + display: flex; + flex-wrap: wrap; + gap: 0.75rem; + align-items: center; +} + +.dashboard-filters select, +.dashboard-filters button { + padding: 0.4rem 0.6rem; +} + +.dashboard-filters .checkbox { + display: flex; + gap: 0.3rem; + align-items: center; +} + +.dashboard-presets { + display: flex; + gap: 0.5rem; +} + +.preset { + padding: 0.35rem 0.6rem; + border-radius: 6px; + background: #e5e7eb; + text-decoration: none; + color: #111827; + font-size: 0.85rem; +} + +.preset:hover { + background: #d1d5db; +} + +.preset.active { + background: #2563eb; + color: white; } \ No newline at end of file diff --git a/expenses_manager/expenses/templates/expenses/dashboard.html b/expenses_manager/expenses/templates/expenses/dashboard.html index aeebbf4..f08cfd5 100644 --- a/expenses_manager/expenses/templates/expenses/dashboard.html +++ b/expenses_manager/expenses/templates/expenses/dashboard.html @@ -3,45 +3,70 @@ {% block title %}Dashboard{% endblock %} {% block content %} - + +
+

+ {% if selected_account_obj %} + {{ selected_account_obj.name }} + {% else %} + Todas las cuentas + {% endif %} +

-

- Dashboard - {% if selected_account_obj %} - — {{ selected_account_obj.name }} - {% endif %} -

+

+ {% if selected_month %} + {{ selected_month }}/{{ selected_year}} + {% else %} + Año {{ selected_year }} + {% endif %} +

+
-
- Este mes | - Mes anterior | - Este año -
- -
+
+
+ + Este mes + + + + Mes anterior + + + + Este año + +
+ +
+ +
+ - - - - - + - - + +
- - +
-

- Mostrando: - {{ selected_year }} - {% if selected_month %}/{{ selected_month }}{% endif %} -

-

Comparado con el periodo inmediatamente anterior

+ -
@@ -111,145 +132,15 @@
- {% if compare_enabled %} -
-

Comparación con periodo anterior

- - {% if kpi_previous_total == 0 %} -

No hay datos en el periodo anterior

- {% else %} -

- Total anterior: {{ kpi_previous_total|floatformat:2 }} -

- {% endif %} - -
- Diferencia: - {% if kpi_trend == "up" %} - ▲ {{ kpi_difference|floatformat:2 }}€ - {% elif kpi_trend == "down" %} - ▼ {{ kpi_difference_abs|floatformat:2 }}€ - {% else %} - 0€ - {% endif %} -
-

- Variación: - {% if kpi_percentage is not None %} - {{ kpi_percentage|floatformat:2 }}% - {% else %} - Variación: N/D - {% endif %} -

-
- {% endif %} - - + -

Gastos por categoría

- - {% if not by_category %} -

No hay gastos para este periodo.

- {% else %} - - - - - - - - - {% for row in by_category %} - - - - - {% empty %} - - - - {% endfor %} - -
CategoríaTotal
{{ row.category__name }}{{ row.total }}
Sin datos
- {% endif %} - - {% if compare_enabled %} -

Comparativa por categoría

+
+ +
- - - - - - - - - - - {% for row in category_comparison %} - - - - - - - {% endfor %} - -
CategoríaActualAnteriorDiferencia
{{ row.category }}{{ row.current|floatformat:2 }}€{{ row.previous }} - {% if row.difference > 0 %} - ▲ {{ row.difference|floatformat:2 }}€ - {% elif row.difference < 0 %} - ▼ {{ row.difference_abs|floatformat:2 }}€ - {% else %} - = - {% endif %} -
- {% endif %} -
- - - - - -

Gastos por mes

- - - - - - - -

Distribución mensual (año completo)

- - - - - -
- -

Evolución anual por cuenta ({{ selected_year }})

+

Evolución anual por cuenta ({{ selected_year }})

{% for acc in accounts_charts %} @@ -262,6 +153,23 @@ {% endfor %}
+ + {% if compare_enabled %} +
+

Comparativa

+ +

+ Diferencia: + + {% if kpi_trend == "up" %}+{% endif %} + {{ kpi_difference_abs|floatformat:2 }} € + + {% if kpi_percentage %} + ({{ kpi_percentage|floatformat:1 }}%) + {% endif %} +

+
+ {% endif %} + + + + + + + + + + {% for row in by_category %} + + + + + {% endfor %} + +
CategoríaTotal
{{ row.category__name }}{{ row.total|floatformat:2 }} €
+ {% endblock %} \ No newline at end of file diff --git a/expenses_manager/expenses/views.py b/expenses_manager/expenses/views.py index 2bdb1c0..0095547 100644 --- a/expenses_manager/expenses/views.py +++ b/expenses_manager/expenses/views.py @@ -530,6 +530,7 @@ def dashboard(request): 'selected_account_obj': selected_account_obj, 'kpi_balance': kpi_balance, 'accounts_charts': accounts_charts, + 'period':period, })