Merge branch 'master' into cute-little-statistics
This commit is contained in:
commit
8f55d915e8
12 changed files with 128 additions and 93 deletions
|
@ -21,11 +21,14 @@
|
|||
//= require_tree .
|
||||
|
||||
ready = function() {
|
||||
$(".select2-selector").select2({
|
||||
$.each($(".select2-selector"), function(index, val) {
|
||||
$(val).select2({
|
||||
width: 'resolve',
|
||||
placeholder: "Ontvanger"
|
||||
placeholder: $(".select2-selector")
|
||||
});
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
$(document).ready(ready)
|
||||
$(document).on('page:load', ready)
|
||||
|
|
|
@ -5,6 +5,70 @@ ready = function() {
|
|||
panel_ul = $(errors).find(".panel-body ul")
|
||||
flash_success = $("#transaction_success")
|
||||
|
||||
var table = $('#transactions').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
searching: true,
|
||||
lengthChange: false,
|
||||
ordering: false,
|
||||
ajax: $('#transactions').data('source'),
|
||||
pagingType: 'full_numbers',
|
||||
autoWidth: false,
|
||||
responsive: true,
|
||||
columns: [
|
||||
{ data: 'time', name: 'Time', width: "15%", className: 'min-tablet-l'},
|
||||
{ data: 'amount', name: 'Amount', width: "10%", className: 'min-mobile'},
|
||||
{ data: 'peer', name: 'Peer', width: "15%", className: 'min-mobile'},
|
||||
{ data: 'issuer', name: 'Issuer', width: "15%", className: 'min-desktop'},
|
||||
{ data: 'message', name: 'Message', width: "45%", className: 'min-tablet-p'}
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
targets: 0,
|
||||
render: function(data, type, full, meta) {
|
||||
return $.format.date(data, 'E dd/MM/yyyy HH:mm');
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: 1,
|
||||
render: function(data, type, full, meta) {
|
||||
return (data/100).toFixed(2);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
$('.dataTables_filter').hide();
|
||||
|
||||
$('.input-listen').each(function(index, element) {
|
||||
var filter = $(element);
|
||||
var type = filter.attr('data-input-type');
|
||||
var column = table.column(filter.attr('data-filter-name') + ':name');
|
||||
console.log(column);
|
||||
filter.find('input').on('keyup change', function() {
|
||||
var value = null
|
||||
if(filter.hasClass('bound')) {
|
||||
var lower = filter.find('.lower-bound');
|
||||
var upper = filter.find('.upper-bound');
|
||||
value = lower.val() + '~' + upper.val();
|
||||
} else {
|
||||
value = $(this).val();
|
||||
}
|
||||
value = filter.attr('data-input-type') + ':' + value;
|
||||
if(column.search() !== value) {
|
||||
column.search(value).draw();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// filters
|
||||
filters = $("#transactions-filters");
|
||||
filters_body = filters.find(".panel-body");
|
||||
filters.find(".panel-heading").click( function() {
|
||||
filters_body.slideToggle();
|
||||
});
|
||||
filters_body.hide();
|
||||
|
||||
$(form).on("ajax:before", function(xhr, settings) {
|
||||
$(flash_success).addClass("hidden")
|
||||
$(submit_button).val("Processing")
|
||||
|
@ -22,9 +86,11 @@ ready = function() {
|
|||
}).on("ajax:complete", function(xhr, status) {
|
||||
$(submit_button).val("Send it")
|
||||
$(submit_button).attr('disabled', false);
|
||||
table.ajax.reload();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
$.ajaxSetup({
|
||||
dataType: 'text'
|
||||
})
|
||||
|
|
|
@ -30,7 +30,10 @@ table.pure-table-striped {
|
|||
}
|
||||
}
|
||||
|
||||
.data-table-filters {
|
||||
#transactions-filters {
|
||||
.panel-heading {
|
||||
cursor: pointer;
|
||||
}
|
||||
.row {
|
||||
padding: 10px;
|
||||
padding-top: 20px;
|
||||
|
@ -42,3 +45,7 @@ table.pure-table-striped {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#s2id_transaction_creditor {
|
||||
min-width: 150px;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def current_client
|
||||
@current_client ||= Client.find_by key: request.headers["X-API-KEY"]
|
||||
Client.find_by key: request.headers.inspect.to_s
|
||||
@current_client ||= Client.find_by key: (request.headers["X_API_KEY"] || request.headers["HTTP_X_API_KEY"])
|
||||
end
|
||||
|
||||
def current_ability
|
||||
|
@ -23,4 +24,8 @@ class ApplicationController < ActionController::Base
|
|||
current_client.try { |c| ClientAbility.new(c) } ||
|
||||
UserAbility.new(current_user)
|
||||
end
|
||||
|
||||
def after_sign_in_path_for(resource)
|
||||
current_user
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,13 +16,11 @@ class DataTable
|
|||
end
|
||||
private
|
||||
def data
|
||||
run_query(paginated_query.project(Arel.star)).map do |record|
|
||||
record.reject! {|k,v| k.is_a? Numeric} # Remove unneeded query results
|
||||
end
|
||||
run_query(paginated_query.project(Arel.star))
|
||||
end
|
||||
|
||||
def count
|
||||
run_query(query.project(Arel.star.count)).first[0]
|
||||
run_query(query.project(Arel.star.count)).first["COUNT(*)"]
|
||||
end
|
||||
|
||||
def paginated_query
|
||||
|
@ -64,7 +62,7 @@ class DataTable
|
|||
end
|
||||
|
||||
def run_query query
|
||||
ActiveRecord::Base.connection.execute(query.to_sql)
|
||||
ActiveRecord::Base.connection.exec_query(query.to_sql)
|
||||
end
|
||||
|
||||
def sanitize_params(params)
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
- if current_user
|
||||
%li.pure-menu-item
|
||||
= link_to current_user.name.capitalize, current_user, class: "pure-menu-link"
|
||||
- if current_user.penning
|
||||
%li.pure-menu-item
|
||||
=link_to "Zeus", User.zeus, class: "pure-menu-link"
|
||||
- else
|
||||
= link_to "Sign in", user_omniauth_authorize_path(:zeuswpi), class: "pure-menu-link" unless current_user
|
||||
.pure-u-1
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
= f.select :creditor,
|
||||
options_from_collection_for_select(User.all.order(:name), :name, :name),
|
||||
{ include_blank: true },
|
||||
{ class: 'select2-selector form-control', size: 50, required: true }
|
||||
{ class: 'select2-selector', size: 50, required: true, data: { placeholder: "Creditor" } }
|
||||
= f.text_field :message, placeholder: "Message", size: 75, class: "form-control", required: true
|
||||
.input-group
|
||||
%span.input-group-addon
|
||||
|
@ -15,4 +15,4 @@
|
|||
= f.number_field :euros, value: amount(@transaction.amount),
|
||||
placeholder: "Bedrag", step: 0.01, min: (0.01 unless current_user.penning),
|
||||
class: "form-control", size: 20, required: true
|
||||
= f.submit "Send it!", class: "pure-button pure-button-primary"
|
||||
= f.submit "Send it!", class: "pure-button pure-button-primary btn"
|
||||
|
|
|
@ -2,46 +2,57 @@
|
|||
|
||||
= render 'transactions/new'
|
||||
|
||||
.panel.panel-default.data-table-filters
|
||||
#transactions-filters.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title Filters
|
||||
.panel-body
|
||||
.row
|
||||
.col-md-8.col-md-offset-2
|
||||
.bound.input-listen{ 'data-input-type': 'date-range', 'data-filter-name': 'Time' }
|
||||
.bound.input-listen{ 'data-input-type': 'date-range',
|
||||
'data-filter-name': 'Time' }
|
||||
.row
|
||||
.col-md-6
|
||||
.input-group
|
||||
%span.input-group-addon
|
||||
%span.glyphicon.glyphicon-calendar
|
||||
%input.lower-bound.form-control.filter-align{type: 'date', placeholder: 'After', class: 'pure-group-addon'}
|
||||
%input.lower-bound.form-control.filter-align{type: 'date',
|
||||
placeholder: 'After', class: 'pure-group-addon'}
|
||||
.col-md-6
|
||||
.input-group
|
||||
%span.input-group-addon
|
||||
%span.glyphicon.glyphicon-calendar
|
||||
%input.upper-bound.form-control.filter-align{type: 'date', placeholder: 'Before', class: 'pure-group-addon'}
|
||||
.bound.input-listen.pure-u-1{ 'data-input-type': 'number-range', 'data-filter-name': 'Amount' }
|
||||
%input.upper-bound.form-control.filter-align{type: 'date',
|
||||
placeholder: 'Before', class: 'pure-group-addon'}
|
||||
.bound.input-listen.pure-u-1{ 'data-input-type': 'number-range',
|
||||
'data-filter-name': 'Amount' }
|
||||
.row
|
||||
.col-md-6
|
||||
.input-group
|
||||
%span.input-group-addon
|
||||
%span.glyphicon.glyphicon-euro
|
||||
%input.lower-bound.form-control.filter-align{type: 'number', placeholder: 'Minimum'}
|
||||
%input.lower-bound.form-control.filter-align{type: 'number',
|
||||
placeholder: 'Minimum'}
|
||||
.col-md-6
|
||||
.input-group
|
||||
%span.input-group-addon
|
||||
%span.glyphicon.glyphicon-euro
|
||||
%input.upper-bound.form-control.filter-align{type: 'number', placeholder: 'Maximum'}
|
||||
%input.upper-bound.form-control.filter-align{type: 'number',
|
||||
placeholder: 'Maximum'}
|
||||
.row
|
||||
.col-md-4
|
||||
.input-listen{ 'data-input-type': 'text', 'data-filter-name': 'Issuer' }
|
||||
%input{type: 'text', placeholder: 'Filter on Issuer', class: "form-control" }
|
||||
= grouped_collection_select nil, nil, [User, Client], :all, :name, :name, :name,
|
||||
{ include_blank: true },
|
||||
{ data: { placeholder: "Filter on Issuer" }, class: "select2-selector form-control" }
|
||||
.col-md-4
|
||||
.input-listen{ 'data-input-type': 'text', 'data-filter-name': 'Peer' }
|
||||
%input{type: 'text', placeholder: 'Filter on Peer', class: "form-control" }
|
||||
= select_tag nil,
|
||||
options_from_collection_for_select(User.all.order(:name), :name, :name),
|
||||
include_blank: true, class: "select2-selector form-control", data: { placeholder: "Filter on Peer" }
|
||||
.col-md-4
|
||||
.input-listen{ 'data-input-type': 'text', 'data-filter-name': 'Message' }
|
||||
%input{type: 'text', placeholder: 'Filter on Message', class: "form-control" }
|
||||
%input{type: 'text', placeholder: 'Filter on Message',
|
||||
class: "form-control" }
|
||||
|
||||
%table#transactions.pure-table.pure-table-striped{data: { source: user_path(@user) }}
|
||||
%thead
|
||||
|
@ -52,62 +63,3 @@
|
|||
%th Issuer
|
||||
%th Message
|
||||
%tbody
|
||||
|
||||
:javascript
|
||||
$(document).ready(function() {
|
||||
var table = $('#transactions').DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
searching: true,
|
||||
lengthChange: false,
|
||||
ordering: false,
|
||||
ajax: $('#transactions').data('source'),
|
||||
pagingType: 'full_numbers',
|
||||
autoWidth: false,
|
||||
responsive: true,
|
||||
columns: [
|
||||
{ data: 'time', name: 'Time', width: "15%", className: 'min-tablet-l'},
|
||||
{ data: 'amount', name: 'Amount', width: "10%", className: 'min-mobile'},
|
||||
{ data: 'peer', name: 'Peer', width: "15%", className: 'min-mobile'},
|
||||
{ data: 'issuer', name: 'Issuer', width: "15%", className: 'min-desktop'},
|
||||
{ data: 'message', name: 'Message', width: "45%", className: 'min-tablet-p'}
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
targets: 0,
|
||||
render: function(data, type, full, meta) {
|
||||
return $.format.date(data, 'E dd/MM/yyyy HH:mm');
|
||||
}
|
||||
},
|
||||
{
|
||||
targets: 1,
|
||||
render: function(data, type, full, meta) {
|
||||
return (data/100).toFixed(2);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
$('.dataTables_filter').hide();
|
||||
|
||||
$('.input-listen').each(function(index, element) {
|
||||
var filter = $(element);
|
||||
var type = filter.attr('data-input-type');
|
||||
var column = table.column(filter.attr('data-filter-name') + ':name');
|
||||
console.log(column);
|
||||
filter.find('input').on('keyup change', function() {
|
||||
var value = null
|
||||
if(filter.hasClass('bound')) {
|
||||
var lower = filter.find('.lower-bound');
|
||||
var upper = filter.find('.upper-bound');
|
||||
value = lower.val() + '~' + upper.val();
|
||||
} else {
|
||||
value = $(this).val();
|
||||
}
|
||||
value = filter.attr('data-input-type') + ':' + value;
|
||||
if(column.search() !== value) {
|
||||
column.search(value).draw();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -29,7 +29,7 @@ set :deploy_to, '/home/tab/production'
|
|||
set :linked_files, %w{config/database.yml config/secrets.yml}
|
||||
|
||||
# Default value for linked_dirs is []
|
||||
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
|
||||
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
|
||||
|
||||
# Default value for default_env is {}
|
||||
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
||||
|
|
|
@ -7,3 +7,4 @@ server 'zeus.ugent.be', user: 'tab', roles: %w{web app db}, ssh_options: {
|
|||
set :rails_env, 'production'
|
||||
set :rbenv_type, :system
|
||||
set :rbenv_ruby, File.read('.ruby-version').strip
|
||||
set :default_env, 'RAILS_RELATIVE_URL_ROOT' => '/tab'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
server 'king.ugent.be', user: 'tap', roles: %w{web app db}, ssh_options: {
|
||||
server 'king.ugent.be', user: 'tab', roles: %w{web app db}, ssh_options: {
|
||||
forward_agent: true,
|
||||
auth_methods: ['publickey'],
|
||||
port: 2222
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
unless Rails.env.production?
|
||||
require 'factory_girl'
|
||||
require 'faker'
|
||||
|
||||
task :sow => :environment do
|
||||
users = FactoryGirl.create_list(:user, 20)
|
||||
100.times do
|
||||
|
@ -8,4 +8,4 @@ task :sow => :environment do
|
|||
FactoryGirl.create :transaction, debtor: sample_users[0], creditor: sample_users[1], amount: 1 + rand(100)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue