Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2019 Dashboards Changes #307

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Revert "Revert "Dashboards (#293)""
This reverts commit 16b1f71.
  • Loading branch information
Bo Tembunkiart committed Apr 17, 2019
commit 960d9ceb5e0cb47e2dddae0f1613516519f905c8
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ gem 'sass-rails'
gem 'uglifier'
gem 'coffee-rails'
gem 'jquery-rails'
gem 'jquery-datatables'
gem 'jbuilder'
gem 'bootstrap-sass'
gem 'simple_form'
gem 'therubyracer', :platform=>:ruby
gem 'omniauth'
gem 'omniauth-shibboleth'
gem 'materialize-sass'

# User and role management
gem 'cancancan'
Expand Down
6 changes: 5 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ GEM
jbuilder (2.4.1)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
jquery-datatables (1.10.19.1)
jquery-rails (4.1.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
Expand All @@ -171,6 +172,8 @@ GEM
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
materialize-sass (1.0.0)
autoprefixer-rails (>= 6.0.3)
mime-types (2.99.1)
mini_portile2 (2.0.0)
minitest (5.8.4)
Expand Down Expand Up @@ -358,6 +361,7 @@ DEPENDENCIES
factory_girl_rails
highline
jbuilder
jquery-datatables
jquery-rails
mysql2 (~> 0.4.10)
newrelic_rpm
Expand Down Expand Up @@ -396,4 +400,4 @@ RUBY VERSION
ruby 2.3.0p0

BUNDLED WITH
1.14.5
1.17.3
8 changes: 7 additions & 1 deletion app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require datatables
//= require_tree .

$(document).on("ready page:change", function(){
Expand Down Expand Up @@ -57,4 +58,9 @@ function _toggleText(el, opt1, opt2){
var $el = $(el);
if($el.html().trim() == opt1.trim()) $el.html(opt2);
else if($el.html().trim() == opt2.trim()) $el.html(opt1);
}
}

$(document).ready(function () {
$('#tasks').DataTable();
});

65 changes: 65 additions & 0 deletions app/assets/javascripts/datatables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//= require datatables/jquery.dataTables

// optional change '//' --> '//=' to enable

// require datatables/extensions/AutoFill/dataTables.autoFill
// require datatables/extensions/Buttons/dataTables.buttons
// require datatables/extensions/Buttons/buttons.html5
// require datatables/extensions/Buttons/buttons.print
// require datatables/extensions/Buttons/buttons.colVis
// require datatables/extensions/Buttons/buttons.flash
// require datatables/extensions/ColReorder/dataTables.colReorder
// require datatables/extensions/FixedColumns/dataTables.fixedColumns
// require datatables/extensions/FixedHeader/dataTables.fixedHeader
// require datatables/extensions/KeyTable/dataTables.keyTable
// require datatables/extensions/Responsive/dataTables.responsive
// require datatables/extensions/RowGroup/dataTables.rowGroup
// require datatables/extensions/RowReorder/dataTables.rowReorder
// require datatables/extensions/Scroller/dataTables.scroller
// require datatables/extensions/Select/dataTables.select

//= require datatables/dataTables.bootstrap4
// require datatables/extensions/AutoFill/autoFill.bootstrap4
// require datatables/extensions/Buttons/buttons.bootstrap4
// require datatables/extensions/Responsive/responsive.bootstrap4


//Global setting and initializer

$.extend( $.fn.dataTable.defaults, {
responsive: true,
pagingType: 'full',
//dom:
// "<'row'<'col-sm-4 text-left'f><'right-action col-sm-8 text-right'<'buttons'B> <'select-info'> >>" +
// "<'row'<'dttb col-12 px-0'tr>>" +
// "<'row'<'col-sm-12 table-footer'lip>>"
});


$(document).on('preInit.dt', function(e, settings) {
var api, table_id, url;
api = new $.fn.dataTable.Api(settings);
table_id = "#" + api.table().node().id;
url = $(table_id).data('source');
if (url) {
return api.ajax.url(url);
}
});


// init on turbolinks load
$(document).on('turbolinks:load', function() {
if (!$.fn.DataTable.isDataTable("table[id^=dttb-]")) {
$("table[id^=dttb-]").DataTable();
}
});

// turbolinks cache fix
$(document).on('turbolinks:before-cache', function() {
var dataTable = $($.fn.dataTable.tables(true)).DataTable();
if (dataTable !== null) {
dataTable.clear();
dataTable.destroy();
return dataTable = null;
}
});
18 changes: 10 additions & 8 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,43 @@
*
*= require_self
*= require_tree .
*= require datatables
*/

@import "bootstrap";
@import 'bootstrap';
@import 'datatables';

body {
padding-bottom: 30px;
}

.alert-inline{
.alert-inline {
margin: 4px;
padding: 10px;
}

.full-width{
.full-width {
width: 100%;
}

.cart-item{
.cart-item {
padding: 8px 4px 8px 4px;
border-top: 1px solid lightgrey;
width: 100%;
margin: 0;
}

.cart-item div{
.cart-item div {
padding: 0;
}

.cart-warning{
.cart-warning {
background-color: #fcf3dd;
}

.cart-button{
.cart-button {
width: 33%;
white-space: normal;
height: 55px;
border-color: #1d4b97;
}
}
15 changes: 15 additions & 0 deletions app/assets/stylesheets/datatables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@import 'datatables/dataTables.bootstrap4';

// optional remove '//=' to enable

//@import 'datatables/extensions/AutoFill/autoFill.bootstrap4';
//@import 'datatables/extensions/Buttons/buttons.bootstrap4';
//@import 'datatables/extensions/ColReorder/colReorder.bootstrap4';
//@import 'datatables/extensions/FixedColumns/fixedColumns.bootstrap4';
//@import 'datatables/extensions/FixedHeader/fixedHeader.bootstrap4';
//@import 'datatables/extensions/KeyTable/keyTable.bootstrap4';
//@import 'datatables/extensions/Responsive/responsive.bootstrap4';
//@import 'datatables/extensions/RowGroup/rowGroup.bootstrap4';
//@import 'datatables/extensions/RowReorder/rowReorder.bootstrap4';
//@import 'datatables/extensions/Scroller/scroller.bootstrap4';
//@import 'datatables/extensions/Select/select.bootstrap4';
97 changes: 61 additions & 36 deletions app/views/home/_quick_links.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h1>Welcome to Binder!</h1>
</div>

<div class="col-xs-10 col-sm-6">
<div>
<% if !user_signed_in? then %>
<% if Rails.env.staging? or Rails.env.production? %>
<p><%= link_to "Login to Begin", main_app.user_omniauth_authorize_path(:shibboleth), :class => "btn btn-success" %></p>
Expand All @@ -11,45 +11,70 @@
<p>Please login to continue.</p>
<% end %>
<% elsif user_signed_in? and !current_user.participant.has_signed_waiver? then %>
<p><%= link_to "Sign Waiver", new_waiver_path, :class => "btn btn-success" %></p>
<br>
<%= link_to "Sign Waiver", new_waiver_path, :class => "btn btn-success" %>
<% end %>

<% if can?(:read, Charge) %>
<p><%= link_to "Charges", charges_path, :class => "btn btn-primary" %></p>
<% end %>
<% if can?(:downtime, OrganizationTimelineEntry) %>
<p><%= link_to "Downtime", downtime_index_path, :class => "btn btn-primary" %></p>
<% end %>
<% if can?(:read, Faq) %>
<p><%= link_to "FAQs", faqs_path, :class => "btn btn-primary" %></p>
<% end %>
<% if can?(:read, Shift) %>
<p><%= link_to "Shifts", shifts_path, :class => "btn btn-primary" %></p>
<% if can?(:read, Faq) && %>
<%= link_to "FAQs", faqs_path, :class => "btn btn-primary" %>
<% end %>

<% if can?(:read, Task) %>
<p><%= link_to "Tasks", tasks_path, :class => "btn btn-primary" %></p>
<% end %>
<% if can?(:structural, OrganizationTimelineEntry) %>
<p><%= link_to "Structural Queue", structural_path, :class => "btn btn-primary" %></p>
<% end %>
<% if can?(:electrical, OrganizationTimelineEntry) %>
<p><%= link_to "Electrical Queue", electrical_path, :class => "btn btn-primary" %></p>
<% end %>
</div> <br>

<div class="row">

<% if user_signed_in? %>
<% if current_user.participant.is_scc? %>

<%# Change to true to enable queues %>
<div class = "col col-sm-3">
<% if true %>
<%= render 'organization_timeline_entries/queue_sidebar' %>
<% end %>
</div>

<%# Change to true to enable downtime %>
<div class = "col col-sm-3">
<% if true %>
<%= render 'organization_timeline_entries/downtime_sidebar' %>
<% end %>
</div>

<div class= "col col-sm-3">
<%= render 'store_cart/store_cart' %>
</div>

<br>

<% if user_signed_in? then %>
<%= form_tag(search_path, class: 'form-inline', role: 'search') do %>
<div class="form-group">
<div class="input-group">
<%= text_field_tag('query', '', :size => 10, :class => 'form-control col-md-6') %>
<span class="input-group-btn">
<%= submit_tag('Search', :class => 'btn btn-default') %>
</span>
</div>
<div class = "col col-sm-3">
<%= render 'tool_cart/tool_cart' %>
</div>

</div>


<div class="row">

<div class= "col col-sm-6">
<% if !@tasks_sidebar.blank? %>
<% cache ['tasks_sidebar', @tasks_sidebar] do %>
<%= render 'tasks/tasks_sidebar' %>
<% end %>
<% end %>
</div>

<div class= "col col-sm-6">
<% if !@current_shifts_sidebar.blank? or !@upcoming_shifts_sidebar.blank? %>
<% cache ['shift_sidebar', 'current', @current_shifts_sidebar, 'upcoming', @upcoming_shifts_sidebar] do%>
<%= render 'shifts/shifts_sidebar' %>
<% end %>
<% end %>
</div>

</div>

<%# Change to true to enable event sidebar %>
<% if true %>
<%= render 'events/events_sidebar' %>
<% end %>


<% end %>
<% end %>
</div>
<% end %>
8 changes: 1 addition & 7 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,10 @@
<%= render 'layouts/navigation' %>
<div class="container" role="main">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9" id='main-content-div'>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" id='main-content-div'>
<%= render 'layouts/messages' %>
<%= yield %>
</div>
<div class="col-xs-12 col-md-3 col-lg-3">
<% if user_signed_in? %>
<br class="hidden-lg">
<%= render 'layouts/sidebar' %>
<% end %>
</div>
</div>
</div>
</body>
Expand Down
4 changes: 2 additions & 2 deletions app/views/shifts/_shifts_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<div class='col-xs-9'>Shifts</div>
<div class='col-xs-3'>
<a href="#sidebar-shifts-widget" onclick='_toggleText(this, "Show", "Hide")'
class="btn btn-info btn-xs" data-toggle="collapse">Show</a>
class="btn btn-info btn-xs" data-toggle="collapse">Hide</a>
</div>
</div>
</div>
<div id='sidebar-shifts-widget' class="collapse panel-body">
<div id='sidebar-shifts-widget' class="collapse in panel-body">
<table class="table table-condensed" style="margin-bottom: 5px;">
<thead>
<th>Current</th>
Expand Down
6 changes: 6 additions & 0 deletions app/views/store/items/_cart_widget.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<tr>
<td><%= cart_widget.store_item.name %></td>
<td><%= number_to_currency (cart_widget.quantity_purchased * cart_widget.price_at_purchase) %></td>
<td><%= link_to t('.remove_from_cart', :default => t("helpers.links.remove_from_cart")),
remove_from_cart_store_item_path(cart_widget), :class => 'btn btn-danger btn-xs', method: :post %></td>
</tr>
39 changes: 39 additions & 0 deletions app/views/store_cart/_store_cart.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<div class="panel panel-default">
<div class="panel-heading">
<div class='row'>
<div class='col-xs-9'>Store Cart</div>
<div class='col-xs-3'>
<a href="#sc_actions" onclick='_toggleText(this, "Show", "Hide")'
class="btn btn-info btn-xs" data-toggle="collapse">Hide</a>
</div>
</div>
</div>

<div id='sc_actions' class="collapse in panel-body">

<% if show_cart? %>
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Total</th>
<th>Actions</th>
</tr>
</thead>

<tbody>

<%= render partial: 'store/items/cart_widget', collection: StorePurchase.items_in_cart %>

</tbody>
</table>

<% end %>

<% if can?(:create, StoreItem) and @organization.blank? %>
<%= link_to t('.new_item', :default => t("helpers.links.new_item")),
new_store_item_path,
:class => 'btn btn-primary', :style => "width: 100%" %>
<% end %>
</div>
</div>
Loading