From f55348f0b9a3ce0c06ab98bee93e819916c87471 Mon Sep 17 00:00:00 2001 From: bionickatana Date: Tue, 28 Jul 2026 11:34:00 -0600 Subject: [PATCH] updated interface --- app/controllers/dashboard_controller.rb | 18 ++- app/views/dashboard/index.html.erb | 170 +++++++++++++++++------- 2 files changed, 131 insertions(+), 57 deletions(-) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index c03d033..585ea9a 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,27 +1,25 @@ class DashboardController < ApplicationController def index joint_column = 'joint' - # Grab distinct values for dropdown filters @available_joints = Joint.distinct.pluck(joint_column) - - # Fetch initial records + @available_data @records = filter_records respond_to do |format| - format.html # Renders app/views/dashboards/index.html.erb - format.json { render json: @records } # Returns filtered data as JSON for JS + format.html + format.json { render json: @records } end end private def filter_records - if params.include?(:joint) - records = Joint.all - records = records.where(joint: params[:joint]) - records + # Using .where(joint: params[:joint]) handles both present and nil values gracefully + if params[:joint].present? + Joint.where(joint: params[:joint]) else - [] + # Return empty array if no joint selected to avoid loading thousands of records + [] end end end diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index b1024df..d69079b 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -1,88 +1,164 @@ -

Excel Replacement Dashboard

+

Excel Replacement Dashboard

- + <%= form_with url: dashboard_path, method: :get, id: "filter-form" do |f| %> -
- <%= f.label :joint, "Select Joint:" %> +
+ <%= f.label :joint, "Select Joint:", style: "font-weight: bold;" %> <%= f.select :joint, options_for_select(@available_joints, params[:joint]), include_blank: "Select a joint", id: "joint" %>
<% end %>
-

Dashboard Results

-
- - - - - - - - - -
+

Dashboard Results

+ + +
+
+ +