1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-25 08:09:38 +02:00
Maybe/app/views/pages/dashboard.html.erb

139 lines
5.8 KiB
Text
Raw Normal View History

<div class="space-y-4">
<header class="flex items-center justify-between">
<div>
<h1 class="sr-only">Dashboard</h1>
<p class="text-xl font-medium text-gray-900 mb-1"><%= t(".greeting", name: Current.user.first_name ) %></p>
<p class="text-gray-500 text-sm"><%= t(".subtitle") %></p>
</div>
<%= link_to new_account_path, class: "flex text-white text-sm font-medium items-center gap-1 bg-gray-900 rounded-lg p-2", data: { turbo_frame: "modal" } do %>
<%= lucide_icon("plus", class: "w-5 h-5") %>
<span><%= t(".new") %></span>
<% end %>
</header>
<section class="flex gap-4">
<div class="bg-white border border-alpha-black-25 shadow-xs rounded-xl w-3/4 min-h-48 flex flex-col">
<div class="flex justify-between p-4">
<div>
<%= render partial: "shared/value_heading", locals: {
label: t(".net_worth"),
period: @period,
value: Current.family.net_worth,
trend: @net_worth_series.trend
} %>
</div>
<%= form_with url: root_path, method: :get, class: "flex items-center gap-4", data: { controller: "auto-submit-form" } do %>
<%= render partial: "shared/period_select", locals: { value: @period.name } %>
<% end %>
</div>
<%= render partial: "pages/dashboard/net_worth_chart", locals: { series: @net_worth_series } %>
</div>
<div class="bg-white p-4 border border-alpha-black-25 shadow-xs rounded-xl w-1/4">
<%= render partial: "pages/dashboard/allocation_chart", locals: { account_groups: @account_groups } %>
</div>
</section>
<section class="grid grid-cols-2 gap-4">
<div class="bg-white p-4 border border-alpha-black-25 shadow-xs rounded-xl">
<div class="flex gap-4 h-full">
<div class="grow">
<%= render partial: "shared/value_heading", locals: {
label: t(".income"),
period: @period,
value: @income_series.last.value,
trend: @income_series.trend
} %>
</div>
<div
Flesh out D3 time series charts (#657) * Reindent TimeSeries classes * Fix spacing in time series tests * Remove trend tests where current is nil I think if we've gotten this far with a nil value for current, there's a data integrity problem. If we allow this, we'll have to be very defensive in our code. Best to raise and fix early. * Reindent Money class * Refactor TimeSeries artifacts * Use as_json in TimeSeries * Bring back tests for trends where current is nil * Bring back trend test * Correctly enumerate trend test * Use favorable_direction for trend_styles helper * Make trend public in TimeSeries::Value * Allow nil current values in trends I think I might've gotten it wrong before, nils might appear in trends if values are unavailable for snapshots * Clean up TimeSeries::Trend * Skip trend values same class validations if any values are nil * Refactor Money * Remove object parsing in TimeSeries::Value We're only every passing hashes * Refactor trendline chart controller into a time series chart controller * Replace trendline controller * Implement empty state * Port line-chart controller into time-series-chart * Split out methods * Group similar time series chart functionality * Fix indicator color * Fix empty state in time series chart * Replace line-chart controller with time-series-chart controller * Draw empty time series chart if less than 2 data points * Fix favorable direction serialization * Handle integers as well as money * Fix favorable direction serialization * Replace chart types with optional elements * Prevent double-renders when displaying turbo caches of time series charts * Remove ambiguities between time series and series data * Improve time series chart property names * Clean up tooltip template * Match tooltip designs * Apply trendline gradient * Implement trendline split behavior * Use same stroke width on all trend lines * Sort time series data by date * Support percentages * Use data color for guideline circles * Revert "Use data color for guideline circles" This reverts commit f239a1e00f84ae28e32f48315d67cf990e541a8a. * Use expected defaults for time series chart * Include day in time-series chart x-axis labels * favorableDirection -> favorable_direction * data -> datum where appropriate * Hide change data in tooltip for percentages
2024-04-22 11:44:26 -06:00
id="incomeChart"
class="h-full w-2/5"
Flesh out D3 time series charts (#657) * Reindent TimeSeries classes * Fix spacing in time series tests * Remove trend tests where current is nil I think if we've gotten this far with a nil value for current, there's a data integrity problem. If we allow this, we'll have to be very defensive in our code. Best to raise and fix early. * Reindent Money class * Refactor TimeSeries artifacts * Use as_json in TimeSeries * Bring back tests for trends where current is nil * Bring back trend test * Correctly enumerate trend test * Use favorable_direction for trend_styles helper * Make trend public in TimeSeries::Value * Allow nil current values in trends I think I might've gotten it wrong before, nils might appear in trends if values are unavailable for snapshots * Clean up TimeSeries::Trend * Skip trend values same class validations if any values are nil * Refactor Money * Remove object parsing in TimeSeries::Value We're only every passing hashes * Refactor trendline chart controller into a time series chart controller * Replace trendline controller * Implement empty state * Port line-chart controller into time-series-chart * Split out methods * Group similar time series chart functionality * Fix indicator color * Fix empty state in time series chart * Replace line-chart controller with time-series-chart controller * Draw empty time series chart if less than 2 data points * Fix favorable direction serialization * Handle integers as well as money * Fix favorable direction serialization * Replace chart types with optional elements * Prevent double-renders when displaying turbo caches of time series charts * Remove ambiguities between time series and series data * Improve time series chart property names * Clean up tooltip template * Match tooltip designs * Apply trendline gradient * Implement trendline split behavior * Use same stroke width on all trend lines * Sort time series data by date * Support percentages * Use data color for guideline circles * Revert "Use data color for guideline circles" This reverts commit f239a1e00f84ae28e32f48315d67cf990e541a8a. * Use expected defaults for time series chart * Include day in time-series chart x-axis labels * favorableDirection -> favorable_direction * data -> datum where appropriate * Hide change data in tooltip for percentages
2024-04-22 11:44:26 -06:00
data-controller="time-series-chart"
data-time-series-chart-data-value="<%= @income_series.to_json %>"
data-time-series-chart-use-labels-value="false"></div>
</div>
</div>
<div class="bg-white p-4 border border-alpha-black-25 shadow-xs rounded-xl">
<div class="flex gap-4 h-full">
<div class="grow">
<%= render partial: "shared/value_heading", locals: {
label: t(".spending"),
period: @period,
value: @spending_series.last.value,
trend: @spending_series.trend
} %>
</div>
<div
Flesh out D3 time series charts (#657) * Reindent TimeSeries classes * Fix spacing in time series tests * Remove trend tests where current is nil I think if we've gotten this far with a nil value for current, there's a data integrity problem. If we allow this, we'll have to be very defensive in our code. Best to raise and fix early. * Reindent Money class * Refactor TimeSeries artifacts * Use as_json in TimeSeries * Bring back tests for trends where current is nil * Bring back trend test * Correctly enumerate trend test * Use favorable_direction for trend_styles helper * Make trend public in TimeSeries::Value * Allow nil current values in trends I think I might've gotten it wrong before, nils might appear in trends if values are unavailable for snapshots * Clean up TimeSeries::Trend * Skip trend values same class validations if any values are nil * Refactor Money * Remove object parsing in TimeSeries::Value We're only every passing hashes * Refactor trendline chart controller into a time series chart controller * Replace trendline controller * Implement empty state * Port line-chart controller into time-series-chart * Split out methods * Group similar time series chart functionality * Fix indicator color * Fix empty state in time series chart * Replace line-chart controller with time-series-chart controller * Draw empty time series chart if less than 2 data points * Fix favorable direction serialization * Handle integers as well as money * Fix favorable direction serialization * Replace chart types with optional elements * Prevent double-renders when displaying turbo caches of time series charts * Remove ambiguities between time series and series data * Improve time series chart property names * Clean up tooltip template * Match tooltip designs * Apply trendline gradient * Implement trendline split behavior * Use same stroke width on all trend lines * Sort time series data by date * Support percentages * Use data color for guideline circles * Revert "Use data color for guideline circles" This reverts commit f239a1e00f84ae28e32f48315d67cf990e541a8a. * Use expected defaults for time series chart * Include day in time-series chart x-axis labels * favorableDirection -> favorable_direction * data -> datum where appropriate * Hide change data in tooltip for percentages
2024-04-22 11:44:26 -06:00
id="spendingChart"
class="h-full w-2/5"
Flesh out D3 time series charts (#657) * Reindent TimeSeries classes * Fix spacing in time series tests * Remove trend tests where current is nil I think if we've gotten this far with a nil value for current, there's a data integrity problem. If we allow this, we'll have to be very defensive in our code. Best to raise and fix early. * Reindent Money class * Refactor TimeSeries artifacts * Use as_json in TimeSeries * Bring back tests for trends where current is nil * Bring back trend test * Correctly enumerate trend test * Use favorable_direction for trend_styles helper * Make trend public in TimeSeries::Value * Allow nil current values in trends I think I might've gotten it wrong before, nils might appear in trends if values are unavailable for snapshots * Clean up TimeSeries::Trend * Skip trend values same class validations if any values are nil * Refactor Money * Remove object parsing in TimeSeries::Value We're only every passing hashes * Refactor trendline chart controller into a time series chart controller * Replace trendline controller * Implement empty state * Port line-chart controller into time-series-chart * Split out methods * Group similar time series chart functionality * Fix indicator color * Fix empty state in time series chart * Replace line-chart controller with time-series-chart controller * Draw empty time series chart if less than 2 data points * Fix favorable direction serialization * Handle integers as well as money * Fix favorable direction serialization * Replace chart types with optional elements * Prevent double-renders when displaying turbo caches of time series charts * Remove ambiguities between time series and series data * Improve time series chart property names * Clean up tooltip template * Match tooltip designs * Apply trendline gradient * Implement trendline split behavior * Use same stroke width on all trend lines * Sort time series data by date * Support percentages * Use data color for guideline circles * Revert "Use data color for guideline circles" This reverts commit f239a1e00f84ae28e32f48315d67cf990e541a8a. * Use expected defaults for time series chart * Include day in time-series chart x-axis labels * favorableDirection -> favorable_direction * data -> datum where appropriate * Hide change data in tooltip for percentages
2024-04-22 11:44:26 -06:00
data-controller="time-series-chart"
data-time-series-chart-data-value="<%= @spending_series.to_json %>"
data-time-series-chart-use-labels-value="false"></div>
</div>
</div>
<div class="bg-white p-4 border border-alpha-black-25 shadow-xs rounded-xl">
<div class="flex gap-4 h-full">
<div class="grow">
<%= render partial: "shared/value_heading", locals: {
label: t(".savings_rate"),
period: @period,
value: @savings_rate_series.last.value,
trend: @savings_rate_series.trend,
is_percentage: true
} %>
</div>
<div
Flesh out D3 time series charts (#657) * Reindent TimeSeries classes * Fix spacing in time series tests * Remove trend tests where current is nil I think if we've gotten this far with a nil value for current, there's a data integrity problem. If we allow this, we'll have to be very defensive in our code. Best to raise and fix early. * Reindent Money class * Refactor TimeSeries artifacts * Use as_json in TimeSeries * Bring back tests for trends where current is nil * Bring back trend test * Correctly enumerate trend test * Use favorable_direction for trend_styles helper * Make trend public in TimeSeries::Value * Allow nil current values in trends I think I might've gotten it wrong before, nils might appear in trends if values are unavailable for snapshots * Clean up TimeSeries::Trend * Skip trend values same class validations if any values are nil * Refactor Money * Remove object parsing in TimeSeries::Value We're only every passing hashes * Refactor trendline chart controller into a time series chart controller * Replace trendline controller * Implement empty state * Port line-chart controller into time-series-chart * Split out methods * Group similar time series chart functionality * Fix indicator color * Fix empty state in time series chart * Replace line-chart controller with time-series-chart controller * Draw empty time series chart if less than 2 data points * Fix favorable direction serialization * Handle integers as well as money * Fix favorable direction serialization * Replace chart types with optional elements * Prevent double-renders when displaying turbo caches of time series charts * Remove ambiguities between time series and series data * Improve time series chart property names * Clean up tooltip template * Match tooltip designs * Apply trendline gradient * Implement trendline split behavior * Use same stroke width on all trend lines * Sort time series data by date * Support percentages * Use data color for guideline circles * Revert "Use data color for guideline circles" This reverts commit f239a1e00f84ae28e32f48315d67cf990e541a8a. * Use expected defaults for time series chart * Include day in time-series chart x-axis labels * favorableDirection -> favorable_direction * data -> datum where appropriate * Hide change data in tooltip for percentages
2024-04-22 11:44:26 -06:00
id="savingsRateChart"
class="h-full w-2/5"
Flesh out D3 time series charts (#657) * Reindent TimeSeries classes * Fix spacing in time series tests * Remove trend tests where current is nil I think if we've gotten this far with a nil value for current, there's a data integrity problem. If we allow this, we'll have to be very defensive in our code. Best to raise and fix early. * Reindent Money class * Refactor TimeSeries artifacts * Use as_json in TimeSeries * Bring back tests for trends where current is nil * Bring back trend test * Correctly enumerate trend test * Use favorable_direction for trend_styles helper * Make trend public in TimeSeries::Value * Allow nil current values in trends I think I might've gotten it wrong before, nils might appear in trends if values are unavailable for snapshots * Clean up TimeSeries::Trend * Skip trend values same class validations if any values are nil * Refactor Money * Remove object parsing in TimeSeries::Value We're only every passing hashes * Refactor trendline chart controller into a time series chart controller * Replace trendline controller * Implement empty state * Port line-chart controller into time-series-chart * Split out methods * Group similar time series chart functionality * Fix indicator color * Fix empty state in time series chart * Replace line-chart controller with time-series-chart controller * Draw empty time series chart if less than 2 data points * Fix favorable direction serialization * Handle integers as well as money * Fix favorable direction serialization * Replace chart types with optional elements * Prevent double-renders when displaying turbo caches of time series charts * Remove ambiguities between time series and series data * Improve time series chart property names * Clean up tooltip template * Match tooltip designs * Apply trendline gradient * Implement trendline split behavior * Use same stroke width on all trend lines * Sort time series data by date * Support percentages * Use data color for guideline circles * Revert "Use data color for guideline circles" This reverts commit f239a1e00f84ae28e32f48315d67cf990e541a8a. * Use expected defaults for time series chart * Include day in time-series chart x-axis labels * favorableDirection -> favorable_direction * data -> datum where appropriate * Hide change data in tooltip for percentages
2024-04-22 11:44:26 -06:00
data-controller="time-series-chart"
data-time-series-chart-data-value="<%= @savings_rate_series.to_json %>"
data-time-series-chart-use-labels-value="false"></div>
</div>
</div>
<div class="bg-white p-4 border border-alpha-black-25 shadow-xs rounded-xl">
<div class="flex gap-4 h-full">
<div class="grow">
<%= render partial: "shared/value_heading", locals: {
label: t(".investing"),
period: @period,
value: @investing_series.last.value,
trend: @investing_series.trend
} %>
</div>
<div
Flesh out D3 time series charts (#657) * Reindent TimeSeries classes * Fix spacing in time series tests * Remove trend tests where current is nil I think if we've gotten this far with a nil value for current, there's a data integrity problem. If we allow this, we'll have to be very defensive in our code. Best to raise and fix early. * Reindent Money class * Refactor TimeSeries artifacts * Use as_json in TimeSeries * Bring back tests for trends where current is nil * Bring back trend test * Correctly enumerate trend test * Use favorable_direction for trend_styles helper * Make trend public in TimeSeries::Value * Allow nil current values in trends I think I might've gotten it wrong before, nils might appear in trends if values are unavailable for snapshots * Clean up TimeSeries::Trend * Skip trend values same class validations if any values are nil * Refactor Money * Remove object parsing in TimeSeries::Value We're only every passing hashes * Refactor trendline chart controller into a time series chart controller * Replace trendline controller * Implement empty state * Port line-chart controller into time-series-chart * Split out methods * Group similar time series chart functionality * Fix indicator color * Fix empty state in time series chart * Replace line-chart controller with time-series-chart controller * Draw empty time series chart if less than 2 data points * Fix favorable direction serialization * Handle integers as well as money * Fix favorable direction serialization * Replace chart types with optional elements * Prevent double-renders when displaying turbo caches of time series charts * Remove ambiguities between time series and series data * Improve time series chart property names * Clean up tooltip template * Match tooltip designs * Apply trendline gradient * Implement trendline split behavior * Use same stroke width on all trend lines * Sort time series data by date * Support percentages * Use data color for guideline circles * Revert "Use data color for guideline circles" This reverts commit f239a1e00f84ae28e32f48315d67cf990e541a8a. * Use expected defaults for time series chart * Include day in time-series chart x-axis labels * favorableDirection -> favorable_direction * data -> datum where appropriate * Hide change data in tooltip for percentages
2024-04-22 11:44:26 -06:00
id="investingChart"
class="h-full w-2/5"
Flesh out D3 time series charts (#657) * Reindent TimeSeries classes * Fix spacing in time series tests * Remove trend tests where current is nil I think if we've gotten this far with a nil value for current, there's a data integrity problem. If we allow this, we'll have to be very defensive in our code. Best to raise and fix early. * Reindent Money class * Refactor TimeSeries artifacts * Use as_json in TimeSeries * Bring back tests for trends where current is nil * Bring back trend test * Correctly enumerate trend test * Use favorable_direction for trend_styles helper * Make trend public in TimeSeries::Value * Allow nil current values in trends I think I might've gotten it wrong before, nils might appear in trends if values are unavailable for snapshots * Clean up TimeSeries::Trend * Skip trend values same class validations if any values are nil * Refactor Money * Remove object parsing in TimeSeries::Value We're only every passing hashes * Refactor trendline chart controller into a time series chart controller * Replace trendline controller * Implement empty state * Port line-chart controller into time-series-chart * Split out methods * Group similar time series chart functionality * Fix indicator color * Fix empty state in time series chart * Replace line-chart controller with time-series-chart controller * Draw empty time series chart if less than 2 data points * Fix favorable direction serialization * Handle integers as well as money * Fix favorable direction serialization * Replace chart types with optional elements * Prevent double-renders when displaying turbo caches of time series charts * Remove ambiguities between time series and series data * Improve time series chart property names * Clean up tooltip template * Match tooltip designs * Apply trendline gradient * Implement trendline split behavior * Use same stroke width on all trend lines * Sort time series data by date * Support percentages * Use data color for guideline circles * Revert "Use data color for guideline circles" This reverts commit f239a1e00f84ae28e32f48315d67cf990e541a8a. * Use expected defaults for time series chart * Include day in time-series chart x-axis labels * favorableDirection -> favorable_direction * data -> datum where appropriate * Hide change data in tooltip for percentages
2024-04-22 11:44:26 -06:00
data-controller="time-series-chart"
data-time-series-chart-data-value="<%= @investing_series.to_json %>"
data-time-series-chart-use-labels-value="false"></div>
</div>
</div>
</section>
<section class="grid grid-cols-2 gap-4 items-baseline">
<div class="bg-white p-4 border border-alpha-black-25 shadow-xs rounded-xl space-y-4">
<h2 class="text-lg font-medium text-gray-900"><%= t(".transactions") %></h2>
<% if @transactions.empty? %>
<div class="text-gray-500 flex items-center justify-center py-12">
<p><%= t(".no_transactions") %></p>
</div>
<% else %>
<div class="text-gray-500 flex items-center justify-center flex-col bg-gray-25 rounded-md">
<%= render partial: "transactions/transaction_group", collection: @transactions.group_by(&:date), as: :transaction_group %>
<p class="py-2 text-sm"><%= link_to t(".view_all"), transactions_path %></p>
</div>
<% end %>
</div>
<div class="space-y-4">
<div class="bg-white p-4 border border-alpha-black-25 shadow-xs rounded-xl space-y-4">
<h2 class="text-lg font-medium text-gray-900"><%= t(".recurring") %></h2>
<div class="text-gray-500 flex items-center justify-center py-12">
<p>Coming soon...</p>
</div>
</div>
<div class="bg-white p-4 border border-alpha-black-25 shadow-xs rounded-xl space-y-4">
<h2 class="text-lg font-medium text-gray-900"><%= t(".categories") %></h2>
<div class="text-gray-500 flex items-center justify-center py-12">
<p>Coming soon...</p>
</div>
</div>
</div>
</section>
</div>