diff --git a/Pearlception/Gemfile b/Pearlception/Gemfile index 882f710..9db7abe 100644 --- a/Pearlception/Gemfile +++ b/Pearlception/Gemfile @@ -38,6 +38,8 @@ gem 'bcrypt', '~> 3.1.7' gem 'devise' #for pagination gem 'kaminari' +#for popovers and tooltips +gem 'bootstrap-popover-rails' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console diff --git a/Pearlception/Gemfile.lock b/Pearlception/Gemfile.lock index e375e40..e1dd0bc 100644 --- a/Pearlception/Gemfile.lock +++ b/Pearlception/Gemfile.lock @@ -47,6 +47,7 @@ GEM bcrypt (3.1.11) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) + bootstrap-popover-rails (0.1.0) builder (3.2.2) byebug (9.0.6) coderay (1.1.1) @@ -206,6 +207,7 @@ PLATFORMS DEPENDENCIES awesome_rails_console bcrypt (~> 3.1.7) + bootstrap-popover-rails byebug coffee-rails (~> 4.2) devise diff --git a/Pearlception/app/assets/javascripts/application.js b/Pearlception/app/assets/javascripts/application.js index 159326e..fe47c91 100644 --- a/Pearlception/app/assets/javascripts/application.js +++ b/Pearlception/app/assets/javascripts/application.js @@ -13,3 +13,5 @@ //= require jquery //= require jquery_ujs //= require turbolinks +//= require bootstrap/bootstrap-rails-tooltip +//= require bootstrap/bootstrap-rails-popover diff --git a/Pearlception/app/assets/javascripts/oysters.coffee b/Pearlception/app/assets/javascripts/oysters.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/Pearlception/app/assets/javascripts/oysters.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/Pearlception/app/assets/javascripts/oysters.js b/Pearlception/app/assets/javascripts/oysters.js new file mode 100644 index 0000000..7208817 --- /dev/null +++ b/Pearlception/app/assets/javascripts/oysters.js @@ -0,0 +1,3 @@ +$(function () { + $('[data-toggle="popover"]').popover(); +}) diff --git a/Pearlception/app/assets/stylesheets/application.css b/Pearlception/app/assets/stylesheets/application.css index 0ebd7fe..a75d597 100644 --- a/Pearlception/app/assets/stylesheets/application.css +++ b/Pearlception/app/assets/stylesheets/application.css @@ -12,4 +12,6 @@ * *= require_tree . *= require_self + *= require bootstrap/bootstrap-rails-tooltip + *= require bootstrap/bootstrap-rails-popover */ diff --git a/Pearlception/app/assets/stylesheets/oysters.scss b/Pearlception/app/assets/stylesheets/oysters.scss new file mode 100644 index 0000000..fd42caa --- /dev/null +++ b/Pearlception/app/assets/stylesheets/oysters.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Oysters controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/Pearlception/app/controllers/oysters_controller.rb b/Pearlception/app/controllers/oysters_controller.rb new file mode 100644 index 0000000..a62305a --- /dev/null +++ b/Pearlception/app/controllers/oysters_controller.rb @@ -0,0 +1,10 @@ +class OystersController < ApplicationController + def show + end + + def index + @oysters = Oyster.where(:run_id => params[:result_id]) + @oysters_count = @oysters.count + @oysters = @oysters.page(params[:page]).per(5) + end +end diff --git a/Pearlception/app/helpers/oysters_helper.rb b/Pearlception/app/helpers/oysters_helper.rb new file mode 100644 index 0000000..9b44a08 --- /dev/null +++ b/Pearlception/app/helpers/oysters_helper.rb @@ -0,0 +1,2 @@ +module OystersHelper +end diff --git a/Pearlception/app/models/oyster.rb b/Pearlception/app/models/oyster.rb index 3514394..cfe3ccb 100644 --- a/Pearlception/app/models/oyster.rb +++ b/Pearlception/app/models/oyster.rb @@ -8,4 +8,5 @@ class Oyster < ApplicationRecord :password => ENV['STATS_DB_PASS'], :database => "main" ) + scope :run_id, -> (id) { where run_id: id.to_i } end diff --git a/Pearlception/app/views/dashboard/index.html.erb b/Pearlception/app/views/dashboard/index.html.erb index accc7ef..150e22e 100644 --- a/Pearlception/app/views/dashboard/index.html.erb +++ b/Pearlception/app/views/dashboard/index.html.erb @@ -89,127 +89,138 @@ <% else %>

Recent Results

<% end %> -
+
- - - <% if current_user.admin? %> - - <% end %> - - - - - - - - - - - <% if current_user.admin? %> - <% @results.each_slice(1) do |row| %> - - <% row.each do |result| - run = Run.find(result.id) - #company = Company.find(run.company_id) - %> - - - - - - - - - - - - - - - - - - - - - - - - - <% end %> - - <% end %> - <% else %> - <% @results.each_slice(1) do |row| %> - - <% row.each do |result| - run = Run.find(result.id) %> - - - - - - - - - - - - - - - - - - - - - <% end %> - - <% end %> - <% end %> - -
CompanyRun DateLocationHarvest TimeSupplierDistributorTotal ProcessedOther
- <%= #company.company_name - "Fake Industries" %> - - <%= run.runDate %> - - <%= run.location ? run.location : "" %> - - <%= "" %> - - - <%= run.supplier ? run.supplier : "" %> - - <%= run.distributor ? run.distributor : "" %> - - <%= result.total %> - - <%= run.other ? run.other : "" %> -
- <%= run.runDate %> - - <%= run.location ? run.location : "" %> - - <%= "" %> - - - <%= run.supplier ? run.supplier : "" %> - - <%= run.distributor ? run.distributor : "" %> - - <%= result.total %> - - <%= run.other ? run.other : "" %> -
-
-
- <%= paginate @results %>
- <%= page_entries_info @results %> +
+ + + <% if current_user.admin? %> + Company + <% end %> + Run Date + Location + Harvest Time + Supplier + Distributor + Total Processed + Other + Oyster Info + +
-
+
+ + <% if current_user.admin? %> + <% @results.each_slice(1) do |row| %> + + <% row.each do |result| + run = Run.find(result.id) + #company = Company.find(run.company_id) + %> + + + + <%= #company.company_name + "Fake Industries" %> + + + + + <%= run.runDate %> + + + + + <%= run.location ? run.location : "" %> + + + + + <%= "" %> + + + + + + <%= run.supplier ? run.supplier : "" %> + + + + + <%= run.distributor ? run.distributor : "" %> + + + + + <%= result.total %> + + + + + <%= run.other ? run.other : "" %> + + + <%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %> + + <% end %> + + <% end %> + <% else %> + <% @results.each_slice(1) do |row| %> + + <% row.each do |result| + run = Run.find(result.id) %> + + + <%= run.runDate %> + + + + + <%= run.location ? run.location : "" %> + + + + + <%= "" %> + + + + + + <%= run.supplier ? run.supplier : "" %> + + + + + <%= run.distributor ? run.distributor : "" %> + + + + + <%= result.total %> + + + + + <%= run.other ? run.other : "" %> + + + <%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %> + + <% end %> + + <% end %> + <% end %> + +
+ +
+
+
+ <%= paginate @results %>
+ <%= page_entries_info @results %> +
diff --git a/Pearlception/app/views/layouts/application.html.erb b/Pearlception/app/views/layouts/application.html.erb index 5978e7f..2dc8dbc 100644 --- a/Pearlception/app/views/layouts/application.html.erb +++ b/Pearlception/app/views/layouts/application.html.erb @@ -16,7 +16,7 @@ <%= yield %> - <%= debug(params) if Rails.env.development? %> + diff --git a/Pearlception/app/views/oysters/index.html.erb b/Pearlception/app/views/oysters/index.html.erb new file mode 100644 index 0000000..81bee88 --- /dev/null +++ b/Pearlception/app/views/oysters/index.html.erb @@ -0,0 +1,132 @@ +<%= stylesheet_link_tag "dashboard" %>_ + + + + +
+
+ +
+ <%= link_to "Back", root_path( :page => params[:page_num]), :class => "btn btn-primary" %> +

Results of <%= Run.find(params[:result_id]).runDate %>

+

Processed Oysters: <%= @oysters_count %>

+ <% if @oysters.empty? %> +
+

No Oysters Processed

+
+ <% else %> +
+ +
+
+ + + + + + + + + +
+
+ <% @oysters.each_slice(1) do |row| %> + + <% row.each do |oyster|%> + + + + + + + + + + + + + + + + <% end %> + + <% end %> + + +
Oyster GradeVolumeLengthWidthHeight
+ <%= oyster.grade %> + + <%= oyster.volume %> + + <%= oyster.length %> + + <%= oyster.width %> + + <%= oyster.height %> +
+
+ <% end %> + <% if !@oysters.empty? %> +
+
+ <%= paginate @oysters %>
+ <%= page_entries_info @oysters %> +
+
+ <% end %> +
+
+
+ <%= javascript_include_tag "bootstrap.min" %>_ + diff --git a/Pearlception/app/views/oysters/show.html.erb b/Pearlception/app/views/oysters/show.html.erb new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Pearlception/app/views/oysters/show.html.erb @@ -0,0 +1 @@ + diff --git a/Pearlception/config/routes.rb b/Pearlception/config/routes.rb index 1a1ae89..17e3991 100644 --- a/Pearlception/config/routes.rb +++ b/Pearlception/config/routes.rb @@ -1,5 +1,8 @@ Rails.application.routes.draw do + get 'oysters/show' + get 'oysters/index' + root "dashboard#index" resources :runs resources :companies diff --git a/Pearlception/test/controllers/oysters_controller_test.rb b/Pearlception/test/controllers/oysters_controller_test.rb new file mode 100644 index 0000000..eece1f2 --- /dev/null +++ b/Pearlception/test/controllers/oysters_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class OystersControllerTest < ActionDispatch::IntegrationTest + test "should get show" do + get oysters_show_url + assert_response :success + end + +end