From 7532b938ed6ac59bfaf136a8a657f7a4741de16a Mon Sep 17 00:00:00 2001 From: bionickatana Date: Mon, 27 Jul 2026 20:06:15 -0600 Subject: [PATCH] Super basic version --- app/controllers/dashboard_controller.rb | 29 ++++++++ app/models/joint.rb | 3 + app/models/joints_info.rb | 3 + app/models/special_test.rb | 3 + app/views/dashboard/index.html.erb | 88 +++++++++++++++++++++++++ config/database.yml | 7 +- config/routes.rb | 2 + 7 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 app/views/dashboard/index.html.erb diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index e1192e4..eca156d 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,2 +1,31 @@ class DashboardController < ApplicationController + def index + joint_column = 'joint' + # Grab distinct values for dropdown filters + @available_joints = Joint.distinct.pluck(joint_column) + + # Fetch initial records + @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 + end + end + + private + + def filter_records + records = Joint.all + records = records.where(joint: params[:joint]) if params[:joint].present? + records + end + + # old broken: def index + # old broken: @joint = Joint.distinct.pluck(:Joint) + # old broken: + # old broken: @records = Joint.all + # old broken: + # old broken: @records = @records.where(Joint: params[joint]) if params[:joint].present? + # old broken: end end diff --git a/app/models/joint.rb b/app/models/joint.rb index e4645c4..1e7e135 100644 --- a/app/models/joint.rb +++ b/app/models/joint.rb @@ -1,2 +1,5 @@ class Joint < ApplicationRecord + def readonly? + true + end end diff --git a/app/models/joints_info.rb b/app/models/joints_info.rb index c8ef247..eceaad6 100644 --- a/app/models/joints_info.rb +++ b/app/models/joints_info.rb @@ -1,2 +1,5 @@ class JointsInfo < ApplicationRecord + def readonly? + true + end end diff --git a/app/models/special_test.rb b/app/models/special_test.rb index 55ce1b6..6d1f5a9 100644 --- a/app/models/special_test.rb +++ b/app/models/special_test.rb @@ -1,2 +1,5 @@ class SpecialTest < ApplicationRecord + def readonly? + true + end end diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb new file mode 100644 index 0000000..6ef7f0e --- /dev/null +++ b/app/views/dashboard/index.html.erb @@ -0,0 +1,88 @@ +

Excel Replacement Dashboard

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

Dashboard Results

+
+ + + + + + + + + +
+
+ + diff --git a/config/database.yml b/config/database.yml index 302d638..5da8bc0 100644 --- a/config/database.yml +++ b/config/database.yml @@ -10,8 +10,11 @@ default: &default timeout: 5000 development: - <<: *default - database: storage/development.sqlite3 + adapter: sqlite3 + max_connections: 5 + timeout: 5000 + database: storage/anat_proj.db + #readonly: true # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". diff --git a/config/routes.rb b/config/routes.rb index 48254e8..638ed7c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,4 +11,6 @@ Rails.application.routes.draw do # Defines the root path route ("/") # root "posts#index" + root "dashboard#index" + get "dashboard", to: "dashboard#index" end