Merge branch 'master' into cute-little-statistics
This commit is contained in:
commit
8f55d915e8
12 changed files with 128 additions and 93 deletions
|
@ -21,10 +21,13 @@
|
||||||
//= require_tree .
|
//= require_tree .
|
||||||
|
|
||||||
ready = function() {
|
ready = function() {
|
||||||
$(".select2-selector").select2({
|
$.each($(".select2-selector"), function(index, val) {
|
||||||
width: 'resolve',
|
$(val).select2({
|
||||||
placeholder: "Ontvanger"
|
width: 'resolve',
|
||||||
});
|
placeholder: $(".select2-selector")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(ready)
|
$(document).ready(ready)
|
||||||
|
|
|
@ -5,6 +5,70 @@ ready = function() {
|
||||||
panel_ul = $(errors).find(".panel-body ul")
|
panel_ul = $(errors).find(".panel-body ul")
|
||||||
flash_success = $("#transaction_success")
|
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) {
|
$(form).on("ajax:before", function(xhr, settings) {
|
||||||
$(flash_success).addClass("hidden")
|
$(flash_success).addClass("hidden")
|
||||||
$(submit_button).val("Processing")
|
$(submit_button).val("Processing")
|
||||||
|
@ -22,9 +86,11 @@ ready = function() {
|
||||||
}).on("ajax:complete", function(xhr, status) {
|
}).on("ajax:complete", function(xhr, status) {
|
||||||
$(submit_button).val("Send it")
|
$(submit_button).val("Send it")
|
||||||
$(submit_button).attr('disabled', false);
|
$(submit_button).attr('disabled', false);
|
||||||
|
table.ajax.reload();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
dataType: 'text'
|
dataType: 'text'
|
||||||
})
|
})
|
||||||
|
|
|
@ -30,7 +30,10 @@ table.pure-table-striped {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.data-table-filters {
|
#transactions-filters {
|
||||||
|
.panel-heading {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
.row {
|
.row {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
padding-top: 20px;
|
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
|
end
|
||||||
|
|
||||||
def current_client
|
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
|
end
|
||||||
|
|
||||||
def current_ability
|
def current_ability
|
||||||
|
@ -23,4 +24,8 @@ class ApplicationController < ActionController::Base
|
||||||
current_client.try { |c| ClientAbility.new(c) } ||
|
current_client.try { |c| ClientAbility.new(c) } ||
|
||||||
UserAbility.new(current_user)
|
UserAbility.new(current_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def after_sign_in_path_for(resource)
|
||||||
|
current_user
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,13 +16,11 @@ class DataTable
|
||||||
end
|
end
|
||||||
private
|
private
|
||||||
def data
|
def data
|
||||||
run_query(paginated_query.project(Arel.star)).map do |record|
|
run_query(paginated_query.project(Arel.star))
|
||||||
record.reject! {|k,v| k.is_a? Numeric} # Remove unneeded query results
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def count
|
def count
|
||||||
run_query(query.project(Arel.star.count)).first[0]
|
run_query(query.project(Arel.star.count)).first["COUNT(*)"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def paginated_query
|
def paginated_query
|
||||||
|
@ -64,7 +62,7 @@ class DataTable
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_query query
|
def run_query query
|
||||||
ActiveRecord::Base.connection.execute(query.to_sql)
|
ActiveRecord::Base.connection.exec_query(query.to_sql)
|
||||||
end
|
end
|
||||||
|
|
||||||
def sanitize_params(params)
|
def sanitize_params(params)
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
- if current_user
|
- if current_user
|
||||||
%li.pure-menu-item
|
%li.pure-menu-item
|
||||||
= link_to current_user.name.capitalize, current_user, class: "pure-menu-link"
|
= 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
|
- else
|
||||||
= link_to "Sign in", user_omniauth_authorize_path(:zeuswpi), class: "pure-menu-link" unless current_user
|
= link_to "Sign in", user_omniauth_authorize_path(:zeuswpi), class: "pure-menu-link" unless current_user
|
||||||
.pure-u-1
|
.pure-u-1
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
= f.select :creditor,
|
= f.select :creditor,
|
||||||
options_from_collection_for_select(User.all.order(:name), :name, :name),
|
options_from_collection_for_select(User.all.order(:name), :name, :name),
|
||||||
{ include_blank: true },
|
{ 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
|
= f.text_field :message, placeholder: "Message", size: 75, class: "form-control", required: true
|
||||||
.input-group
|
.input-group
|
||||||
%span.input-group-addon
|
%span.input-group-addon
|
||||||
|
@ -15,4 +15,4 @@
|
||||||
= f.number_field :euros, value: amount(@transaction.amount),
|
= f.number_field :euros, value: amount(@transaction.amount),
|
||||||
placeholder: "Bedrag", step: 0.01, min: (0.01 unless current_user.penning),
|
placeholder: "Bedrag", step: 0.01, min: (0.01 unless current_user.penning),
|
||||||
class: "form-control", size: 20, required: true
|
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'
|
= render 'transactions/new'
|
||||||
|
|
||||||
.panel.panel-default.data-table-filters
|
#transactions-filters.panel.panel-default
|
||||||
.panel-heading
|
.panel-heading
|
||||||
%h3.panel-title Filters
|
%h3.panel-title Filters
|
||||||
.panel-body
|
.panel-body
|
||||||
.row
|
.row
|
||||||
.col-md-8.col-md-offset-2
|
.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
|
.row
|
||||||
.col-md-6
|
.col-md-6
|
||||||
.input-group
|
.input-group
|
||||||
%span.input-group-addon
|
%span.input-group-addon
|
||||||
%span.glyphicon.glyphicon-calendar
|
%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
|
.col-md-6
|
||||||
.input-group
|
.input-group
|
||||||
%span.input-group-addon
|
%span.input-group-addon
|
||||||
%span.glyphicon.glyphicon-calendar
|
%span.glyphicon.glyphicon-calendar
|
||||||
%input.upper-bound.form-control.filter-align{type: 'date', placeholder: 'Before', class: 'pure-group-addon'}
|
%input.upper-bound.form-control.filter-align{type: 'date',
|
||||||
.bound.input-listen.pure-u-1{ 'data-input-type': 'number-range', 'data-filter-name': 'Amount' }
|
placeholder: 'Before', class: 'pure-group-addon'}
|
||||||
|
.bound.input-listen.pure-u-1{ 'data-input-type': 'number-range',
|
||||||
|
'data-filter-name': 'Amount' }
|
||||||
.row
|
.row
|
||||||
.col-md-6
|
.col-md-6
|
||||||
.input-group
|
.input-group
|
||||||
%span.input-group-addon
|
%span.input-group-addon
|
||||||
%span.glyphicon.glyphicon-euro
|
%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
|
.col-md-6
|
||||||
.input-group
|
.input-group
|
||||||
%span.input-group-addon
|
%span.input-group-addon
|
||||||
%span.glyphicon.glyphicon-euro
|
%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
|
.row
|
||||||
.col-md-4
|
.col-md-4
|
||||||
.input-listen{ 'data-input-type': 'text', 'data-filter-name': 'Issuer' }
|
.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
|
.col-md-4
|
||||||
.input-listen{ 'data-input-type': 'text', 'data-filter-name': 'Peer' }
|
.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
|
.col-md-4
|
||||||
.input-listen{ 'data-input-type': 'text', 'data-filter-name': 'Message' }
|
.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) }}
|
%table#transactions.pure-table.pure-table-striped{data: { source: user_path(@user) }}
|
||||||
%thead
|
%thead
|
||||||
|
@ -52,62 +63,3 @@
|
||||||
%th Issuer
|
%th Issuer
|
||||||
%th Message
|
%th Message
|
||||||
%tbody
|
%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}
|
set :linked_files, %w{config/database.yml config/secrets.yml}
|
||||||
|
|
||||||
# Default value for linked_dirs is []
|
# 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 {}
|
# Default value for default_env is {}
|
||||||
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
# 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 :rails_env, 'production'
|
||||||
set :rbenv_type, :system
|
set :rbenv_type, :system
|
||||||
set :rbenv_ruby, File.read('.ruby-version').strip
|
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,
|
forward_agent: true,
|
||||||
auth_methods: ['publickey'],
|
auth_methods: ['publickey'],
|
||||||
port: 2222
|
port: 2222
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
require 'factory_girl'
|
unless Rails.env.production?
|
||||||
require 'faker'
|
require 'factory_girl'
|
||||||
|
require 'faker'
|
||||||
task :sow => :environment do
|
task :sow => :environment do
|
||||||
users = FactoryGirl.create_list(:user, 20)
|
users = FactoryGirl.create_list(:user, 20)
|
||||||
100.times do
|
100.times do
|
||||||
sample_users = users.sample(2)
|
sample_users = users.sample(2)
|
||||||
FactoryGirl.create :transaction, debtor: sample_users[0], creditor: sample_users[1], amount: 1 + rand(100)
|
FactoryGirl.create :transaction, debtor: sample_users[0], creditor: sample_users[1], amount: 1 + rand(100)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue