mirror of
https://github.com/oonyeje/Pearlception_Website_RoR.git
synced 2025-12-25 03:37:40 +00:00
Merged branch master into User-Sign-In-Sign-Up
This commit is contained in:
commit
64b26077d2
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -13,3 +13,5 @@
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require turbolinks
|
||||
//= require bootstrap/bootstrap-rails-tooltip
|
||||
//= require bootstrap/bootstrap-rails-popover
|
||||
|
||||
3
Pearlception/app/assets/javascripts/oysters.coffee
Normal file
3
Pearlception/app/assets/javascripts/oysters.coffee
Normal file
@ -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/
|
||||
3
Pearlception/app/assets/javascripts/oysters.js
Normal file
3
Pearlception/app/assets/javascripts/oysters.js
Normal file
@ -0,0 +1,3 @@
|
||||
$(function () {
|
||||
$('[data-toggle="popover"]').popover();
|
||||
})
|
||||
@ -12,4 +12,6 @@
|
||||
*
|
||||
*= require_tree .
|
||||
*= require_self
|
||||
*= require bootstrap/bootstrap-rails-tooltip
|
||||
*= require bootstrap/bootstrap-rails-popover
|
||||
*/
|
||||
|
||||
3
Pearlception/app/assets/stylesheets/oysters.scss
Normal file
3
Pearlception/app/assets/stylesheets/oysters.scss
Normal file
@ -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/
|
||||
10
Pearlception/app/controllers/oysters_controller.rb
Normal file
10
Pearlception/app/controllers/oysters_controller.rb
Normal file
@ -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
|
||||
2
Pearlception/app/helpers/oysters_helper.rb
Normal file
2
Pearlception/app/helpers/oysters_helper.rb
Normal file
@ -0,0 +1,2 @@
|
||||
module OystersHelper
|
||||
end
|
||||
@ -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
|
||||
|
||||
@ -89,127 +89,138 @@
|
||||
<% else %>
|
||||
<h2 class="sub-header">Recent Results</h2>
|
||||
<% end %>
|
||||
<div class="table-responsive">
|
||||
<div class="table-responsive panel panel-primary">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<% if current_user.admin? %>
|
||||
<th>Company</th>
|
||||
<% end %>
|
||||
<th>Run Date</th>
|
||||
<th>Location</th>
|
||||
<th>Harvest Time</th>
|
||||
<th>Supplier</th>
|
||||
<th>Distributor</th>
|
||||
<th>Total Processed</th>
|
||||
<th>Other</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if current_user.admin? %>
|
||||
<% @results.each_slice(1) do |row| %>
|
||||
<tr>
|
||||
<% row.each do |result|
|
||||
run = Run.find(result.id)
|
||||
#company = Company.find(run.company_id)
|
||||
%>
|
||||
|
||||
<!-- company name -->
|
||||
<td>
|
||||
<%= #company.company_name
|
||||
"Fake Industries" %>
|
||||
</td>
|
||||
|
||||
<!-- run date -->
|
||||
<td>
|
||||
<%= run.runDate %>
|
||||
</td>
|
||||
|
||||
<!-- location -->
|
||||
<td>
|
||||
<%= run.location ? run.location : "" %>
|
||||
</td>
|
||||
|
||||
<!-- harvest time -->
|
||||
<td>
|
||||
<%= "" %>
|
||||
</td>
|
||||
|
||||
<!-- supplier -->
|
||||
<td>
|
||||
|
||||
<%= run.supplier ? run.supplier : "" %>
|
||||
</td>
|
||||
|
||||
<!-- distributor -->
|
||||
<td>
|
||||
<%= run.distributor ? run.distributor : "" %>
|
||||
</td>
|
||||
|
||||
<!-- total processed -->
|
||||
<td>
|
||||
<%= result.total %>
|
||||
</td>
|
||||
|
||||
<!-- other -->
|
||||
<td>
|
||||
<%= run.other ? run.other : "" %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% @results.each_slice(1) do |row| %>
|
||||
<tr>
|
||||
<% row.each do |result|
|
||||
run = Run.find(result.id) %>
|
||||
<!-- run date -->
|
||||
<td>
|
||||
<%= run.runDate %>
|
||||
</td>
|
||||
|
||||
<!-- location -->
|
||||
<td>
|
||||
<%= run.location ? run.location : "" %>
|
||||
</td>
|
||||
|
||||
<!-- harvest time -->
|
||||
<td>
|
||||
<%= "" %>
|
||||
</td>
|
||||
|
||||
<!-- supplier -->
|
||||
<td>
|
||||
|
||||
<%= run.supplier ? run.supplier : "" %>
|
||||
</td>
|
||||
|
||||
<!-- distributor -->
|
||||
<td>
|
||||
<%= run.distributor ? run.distributor : "" %>
|
||||
</td>
|
||||
|
||||
<!-- total processed -->
|
||||
<td>
|
||||
<%= result.total %>
|
||||
</td>
|
||||
|
||||
<!-- other -->
|
||||
<td>
|
||||
<%= run.other ? run.other : "" %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="center-block">
|
||||
<div class="col-sm-6 panel panel-primary" align="center">
|
||||
<%= paginate @results %><br>
|
||||
<%= page_entries_info @results %>
|
||||
<div class="panel-heading">
|
||||
<thead>
|
||||
<tr>
|
||||
<% if current_user.admin? %>
|
||||
<th>Company</th>
|
||||
<% end %>
|
||||
<th>Run Date</th>
|
||||
<th>Location</th>
|
||||
<th>Harvest Time</th>
|
||||
<th>Supplier</th>
|
||||
<th>Distributor</th>
|
||||
<th>Total Processed</th>
|
||||
<th>Other</th>
|
||||
<th>Oyster Info</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<tbody>
|
||||
<% if current_user.admin? %>
|
||||
<% @results.each_slice(1) do |row| %>
|
||||
<tr>
|
||||
<% row.each do |result|
|
||||
run = Run.find(result.id)
|
||||
#company = Company.find(run.company_id)
|
||||
%>
|
||||
|
||||
<!-- company name -->
|
||||
<td>
|
||||
<%= #company.company_name
|
||||
"Fake Industries" %>
|
||||
</td>
|
||||
|
||||
<!-- run date -->
|
||||
<td>
|
||||
<%= run.runDate %>
|
||||
</td>
|
||||
|
||||
<!-- location -->
|
||||
<td>
|
||||
<%= run.location ? run.location : "" %>
|
||||
</td>
|
||||
|
||||
<!-- harvest time -->
|
||||
<td>
|
||||
<%= "" %>
|
||||
</td>
|
||||
|
||||
<!-- supplier -->
|
||||
<td>
|
||||
|
||||
<%= run.supplier ? run.supplier : "" %>
|
||||
</td>
|
||||
|
||||
<!-- distributor -->
|
||||
<td>
|
||||
<%= run.distributor ? run.distributor : "" %>
|
||||
</td>
|
||||
|
||||
<!-- total processed -->
|
||||
<td>
|
||||
<%= result.total %>
|
||||
</td>
|
||||
|
||||
<!-- other -->
|
||||
<td>
|
||||
<%= run.other ? run.other : "" %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% @results.each_slice(1) do |row| %>
|
||||
<tr>
|
||||
<% row.each do |result|
|
||||
run = Run.find(result.id) %>
|
||||
<!-- run date -->
|
||||
<td>
|
||||
<%= run.runDate %>
|
||||
</td>
|
||||
|
||||
<!-- location -->
|
||||
<td>
|
||||
<%= run.location ? run.location : "" %>
|
||||
</td>
|
||||
|
||||
<!-- harvest time -->
|
||||
<td>
|
||||
<%= "" %>
|
||||
</td>
|
||||
|
||||
<!-- supplier -->
|
||||
<td>
|
||||
|
||||
<%= run.supplier ? run.supplier : "" %>
|
||||
</td>
|
||||
|
||||
<!-- distributor -->
|
||||
<td>
|
||||
<%= run.distributor ? run.distributor : "" %>
|
||||
</td>
|
||||
|
||||
<!-- total processed -->
|
||||
<td>
|
||||
<%= result.total %>
|
||||
</td>
|
||||
|
||||
<!-- other -->
|
||||
<td>
|
||||
<%= run.other ? run.other : "" %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to "Show", oysters_index_path( :result_id => result.id, :page_num => params[:page]), :class => "btn btn-primary" %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</div>
|
||||
</table>
|
||||
</div>
|
||||
<div class="center-block">
|
||||
<div class="col-sm-6 col-sm-offset-3 panel panel-primary" align="center">
|
||||
<%= paginate @results %></br>
|
||||
<%= page_entries_info @results %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
<%= debug(params) if Rails.env.development? %>
|
||||
<!-- <%= debug(params) if Rails.env.development? %> -->
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
132
Pearlception/app/views/oysters/index.html.erb
Normal file
132
Pearlception/app/views/oysters/index.html.erb
Normal file
@ -0,0 +1,132 @@
|
||||
<%= stylesheet_link_tag "dashboard" %>_
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/">Pearlception</a>
|
||||
</div>
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<!-- <li><a href="#">Dashboard</a></li> -->
|
||||
<!-- <li><a href="#">Settings</a></li>
|
||||
<li><a href="#">Profile</a></li>
|
||||
<li><a href="#">Help</a></li> -->
|
||||
<li>
|
||||
<%= link_to(destroy_user_session_path, class: 'logout-link', :method => :delete) do %>
|
||||
<i class="fa fa-external-link"></i> Logout
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- <form class="navbar-form navbar-right">
|
||||
<input type="text" class="form-control" placeholder="Search...">
|
||||
</form> -->
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-sm-3 col-md-2 sidebar">
|
||||
<ul class="nav nav-sidebar">
|
||||
<li class="active"><a href="/">Overview <span class="sr-only">(current)</span></a></li>
|
||||
<% if current_user.admin? %>
|
||||
<li><a href="companies#index">Companies</a></li>
|
||||
<% else %>
|
||||
<!-- <li><a href="#">Reports</a></li>
|
||||
<li><a href="#">Analytics</a></li>
|
||||
<li><a href="#">Export</a></li> -->
|
||||
<% end %>
|
||||
</ul>
|
||||
<!-- <ul class="nav nav-sidebar">
|
||||
<li><a href="">Nav item</a></li>
|
||||
<li><a href="">Nav item again</a></li>
|
||||
<li><a href="">One more nav</a></li>
|
||||
<li><a href="">Another nav item</a></li>
|
||||
<li><a href="">More navigation</a></li>
|
||||
</ul>
|
||||
<ul class="nav nav-sidebar">
|
||||
<li><a href="">Nav item again</a></li>
|
||||
<li><a href="">One more nav</a></li>
|
||||
<li><a href="">Another nav item</a></li>
|
||||
</ul> -->
|
||||
</div>
|
||||
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
|
||||
<%= link_to "Back", root_path( :page => params[:page_num]), :class => "btn btn-primary" %>
|
||||
<h1 class="page-header">Results of <%= Run.find(params[:result_id]).runDate %></h1>
|
||||
<h2 class="sub-header">Processed Oysters: <%= @oysters_count %> </h2>
|
||||
<% if @oysters.empty? %>
|
||||
<div class="panel panel-primary">
|
||||
<p>No Oysters Processed</p>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="panel panel-primary table-responsive">
|
||||
<table class="table table-striped">
|
||||
<div class="panel-heading">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Oyster Grade</th>
|
||||
<th>Volume</th>
|
||||
<th>Length</th>
|
||||
<th>Width</th>
|
||||
<th>Height</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<tbody>
|
||||
<% @oysters.each_slice(1) do |row| %>
|
||||
<tr>
|
||||
<% row.each do |oyster|%>
|
||||
|
||||
<!-- grade -->
|
||||
<td>
|
||||
<%= oyster.grade %>
|
||||
</td>
|
||||
|
||||
<!-- volume -->
|
||||
<td>
|
||||
<%= oyster.volume %>
|
||||
</td>
|
||||
|
||||
<!-- length -->
|
||||
<td>
|
||||
<%= oyster.length %>
|
||||
</td>
|
||||
|
||||
<!-- width -->
|
||||
<td>
|
||||
<%= oyster.width %>
|
||||
</td>
|
||||
|
||||
<!-- height -->
|
||||
<td>
|
||||
<%= oyster.height %>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</div>
|
||||
</table>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if !@oysters.empty? %>
|
||||
<div class="center-block">
|
||||
<div class="col-sm-6 col-sm-offset-3 panel panel-primary" align="center">
|
||||
<%= paginate @oysters %><br>
|
||||
<%= page_entries_info @oysters %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%= javascript_include_tag "bootstrap.min" %>_
|
||||
</body>
|
||||
1
Pearlception/app/views/oysters/show.html.erb
Normal file
1
Pearlception/app/views/oysters/show.html.erb
Normal file
@ -0,0 +1 @@
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
Rails.application.routes.draw do
|
||||
|
||||
get 'oysters/show'
|
||||
get 'oysters/index'
|
||||
|
||||
root "dashboard#index"
|
||||
resources :runs
|
||||
resources :companies
|
||||
|
||||
9
Pearlception/test/controllers/oysters_controller_test.rb
Normal file
9
Pearlception/test/controllers/oysters_controller_test.rb
Normal file
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user