kaui 0.15.3 → 0.15.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28ef571db6b75b46644076075d33cb15e11a3dd8
4
- data.tar.gz: 99e00ae3e2183b20bf86572c406fffc8eafa7430
3
+ metadata.gz: 640b0cf3c6014bcee7e66e2d8c41b65f0a12daa5
4
+ data.tar.gz: bb749feea622246695e1b323c7b4b6fb5a66f09d
5
5
  SHA512:
6
- metadata.gz: 32268720a72836539a2c3bf0ea790c0296518d655827201c18811bd65f27efc4bfc1b4fd6623b0e866cd7296356d7195a99530dadb0e22a1d4bfe9e59b4763dd
7
- data.tar.gz: fa8f0bddaf0be5b1ed46b279615abd31266ebf6fe6d9573ce3c1f3331918c2d2ca7e6dbdf927ad13875ecf7fc0d54f54031e46eb16c180c619c563ff974e1c76
6
+ metadata.gz: bd63327cffa882058a5344d1e2df1f6d69f80fe237031436a6d2a08bd3d4c584e6599076d72ed78d775bd4b520cfd92ce7b625340dd53daaa6e789f283b62cab
7
+ data.tar.gz: ef9411ec7d175aaf73287eb40413d532452748272aba16a74367a61302c7010495491cce0e89e080ed001fae9e30d4c8ccba18a1534e25025c399ea8dd32272d
data/Gemfile CHANGED
@@ -2,5 +2,5 @@ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'killbill-client', :path => '../killbill-client-ruby'
5
+ #gem 'killbill-client', :path => '../killbill-client-ruby'
6
6
  #gem 'killbill-client', :git => 'https://github.com/killbill/killbill-client-ruby.git'
@@ -13,15 +13,11 @@ class Kaui::AccountsController < Kaui::EngineController
13
13
  end
14
14
  end
15
15
 
16
- @limit = 50
17
- if @search_query.blank?
18
- max_nb_records = Kaui::Account.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records
19
- @offset = [0, max_nb_records - @limit].max
20
- @ordering = 'desc'
21
- else
22
- @offset = 0
23
- @ordering = 'asc'
24
- end
16
+ @ordering = params[:ordering] || (@search_query.blank? ? 'desc' : 'asc')
17
+ @offset = params[:offset] || 0
18
+ @limit = params[:limit] || 50
19
+
20
+ @max_nb_records = @search_query.blank? ? Kaui::Account.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records : 0
25
21
  end
26
22
 
27
23
  def pagination
@@ -17,6 +17,7 @@ class Kaui::AdminAllowedUsersController < Kaui::EngineController
17
17
  existing_user = Kaui::AllowedUser.find_by_kb_username(@allowed_user.kb_username)
18
18
  if existing_user
19
19
  flash[:error] = "User with name #{@allowed_user.kb_username} already exists!"
20
+ @roles = roles_for_user(existing_user)
20
21
  render :new and return
21
22
  else
22
23
  roles = params[:roles].split(',')
@@ -31,7 +32,7 @@ class Kaui::AdminAllowedUsersController < Kaui::EngineController
31
32
  @allowed_user = Kaui::AllowedUser.find(params.require(:id))
32
33
  raise ActiveRecord::RecordNotFound.new("Could not find user #{@allowed_user.id}") unless (current_user.root? || @allowed_user.kb_username == current_user.kb_username)
33
34
 
34
- @roles = Kaui::UserRole.find_roles_by_username(@allowed_user.kb_username, options_for_klient).map(&:presence).compact || []
35
+ @roles = roles_for_user(@allowed_user)
35
36
 
36
37
  tenants_for_current_user = retrieve_tenants_for_current_user
37
38
  @tenants = Kaui::Tenant.all.select { |tenant| tenants_for_current_user.include?(tenant.kb_tenant_id) }
@@ -40,7 +41,7 @@ class Kaui::AdminAllowedUsersController < Kaui::EngineController
40
41
  def edit
41
42
  @allowed_user = Kaui::AllowedUser.find(params.require(:id))
42
43
 
43
- @roles = Kaui::UserRole.find_roles_by_username(@allowed_user.kb_username, options_for_klient).map(&:presence).compact || []
44
+ @roles = roles_for_user(@allowed_user)
44
45
  end
45
46
 
46
47
  def update
@@ -101,4 +102,8 @@ class Kaui::AdminAllowedUsersController < Kaui::EngineController
101
102
  allowed_user.require(:kb_username)
102
103
  allowed_user
103
104
  end
105
+
106
+ def roles_for_user(allowed_user)
107
+ Kaui::UserRole.find_roles_by_username(allowed_user.kb_username, options_for_klient).map(&:presence).compact || []
108
+ end
104
109
  end
@@ -1,6 +1,13 @@
1
1
  class Kaui::CustomFieldsController < Kaui::EngineController
2
2
 
3
3
  def index
4
+ @search_query = params[:q]
5
+
6
+ @ordering = params[:ordering] || (@search_query.blank? ? 'desc' : 'asc')
7
+ @offset = params[:offset] || 0
8
+ @limit = params[:limit] || 50
9
+
10
+ @max_nb_records = @search_query.blank? ? Kaui::CustomField.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records : 0
4
11
  end
5
12
 
6
13
  def pagination
@@ -1,5 +1,8 @@
1
1
  module Kaui::EngineControllerUtil
2
2
 
3
+ # See DefaultPaginationSqlDaoHelper.java
4
+ SIMPLE_PAGINATION_THRESHOLD = 20000
5
+
3
6
  protected
4
7
 
5
8
  def get_layout
@@ -11,8 +14,7 @@ module Kaui::EngineControllerUtil
11
14
  offset = (params[:start] || 0).to_i
12
15
  limit = (params[:length] || 10).to_i
13
16
 
14
- limit = 2147483647 if limit == -1
15
-
17
+ limit = -limit if params[:ordering] == 'desc'
16
18
  begin
17
19
  pages = searcher.call(search_key, offset, limit)
18
20
  rescue => e
@@ -21,8 +23,9 @@ module Kaui::EngineControllerUtil
21
23
 
22
24
  json = {
23
25
  :draw => (params[:draw] || 0).to_i,
24
- :recordsTotal => pages.nil? ? 0 : pages.pagination_max_nb_records,
25
- :recordsFiltered => pages.nil? ? 0 : pages.pagination_total_nb_records,
26
+ # We need to fill-in a number to make DataTables happy
27
+ :recordsTotal => pages.nil? ? 0 : (pages.pagination_max_nb_records || SIMPLE_PAGINATION_THRESHOLD),
28
+ :recordsFiltered => pages.nil? ? 0 : (pages.pagination_total_nb_records || SIMPLE_PAGINATION_THRESHOLD),
26
29
  :data => []
27
30
  }
28
31
  json[:error] = error unless error.nil?
@@ -39,7 +42,7 @@ module Kaui::EngineControllerUtil
39
42
  sort = a <=> b
40
43
  sort.nil? ? -1 : sort
41
44
  end unless search_key.nil? # Keep DB ordering when listing all entries
42
- pages.reverse! if ordering_dir == 'desc'
45
+ pages.reverse! if ordering_dir == 'desc' && limit >= 0 || ordering_dir == 'asc' && limit < 0
43
46
 
44
47
  pages.each { |page| json[:data] << formatter.call(page) }
45
48
 
@@ -3,15 +3,11 @@ class Kaui::InvoicesController < Kaui::EngineController
3
3
  def index
4
4
  @search_query = params[:account_id]
5
5
 
6
- @limit = 50
7
- if @search_query.blank?
8
- max_nb_records = Kaui::Invoice.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records
9
- @offset = [0, max_nb_records - @limit].max
10
- @ordering = 'desc'
11
- else
12
- @offset = 0
13
- @ordering = 'asc'
14
- end
6
+ @ordering = params[:ordering] || (@search_query.blank? ? 'desc' : 'asc')
7
+ @offset = params[:offset] || 0
8
+ @limit = params[:limit] || 50
9
+
10
+ @max_nb_records = @search_query.blank? ? Kaui::Invoice.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records : 0
15
11
  end
16
12
 
17
13
  def pagination
@@ -3,15 +3,11 @@ class Kaui::PaymentsController < Kaui::EngineController
3
3
  def index
4
4
  @search_query = params[:q] || params[:account_id]
5
5
 
6
- @limit = 50
7
- if @search_query.blank?
8
- max_nb_records = Kaui::Payment.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records
9
- @offset = [0, max_nb_records - @limit].max
10
- @ordering = 'desc'
11
- else
12
- @offset = 0
13
- @ordering = 'asc'
14
- end
6
+ @ordering = params[:ordering] || (@search_query.blank? ? 'desc' : 'asc')
7
+ @offset = params[:offset] || 0
8
+ @limit = params[:limit] || 50
9
+
10
+ @max_nb_records = @search_query.blank? ? Kaui::Payment.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records : 0
15
11
  end
16
12
 
17
13
  def pagination
@@ -4,8 +4,9 @@ class Kaui::QueuesController < Kaui::EngineController
4
4
  @account_id = params[:account_id]
5
5
  @now = Kaui::Admin.get_clock(nil, options_for_klient)['currentUtcTime'].to_datetime
6
6
 
7
- min_date = params[:min_date]
7
+ min_date = params[:min_date] || '1970-01-01'
8
+ max_date = params[:max_date] || '2100-01-01'
8
9
  with_history = params[:with_history] || false
9
- @queues_entries = Kaui::Admin.get_queues_entries(@account_id, options_for_klient.merge(:withHistory => with_history, :minDate => min_date))
10
+ @queues_entries = Kaui::Admin.get_queues_entries(@account_id, options_for_klient.merge(:withHistory => with_history, :minDate => min_date, :maxDate => max_date))
10
11
  end
11
12
  end
@@ -3,15 +3,11 @@ class Kaui::TagsController < Kaui::EngineController
3
3
  def index
4
4
  @search_query = params[:q]
5
5
 
6
- @limit = 50
7
- if @search_query.blank?
8
- max_nb_records = Kaui::Tag.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records
9
- @offset = [0, max_nb_records - @limit].max
10
- @ordering = 'desc'
11
- else
12
- @offset = 0
13
- @ordering = 'asc'
14
- end
6
+ @ordering = params[:ordering] || (@search_query.blank? ? 'desc' : 'asc')
7
+ @offset = params[:offset] || 0
8
+ @limit = params[:limit] || 50
9
+
10
+ @max_nb_records = @search_query.blank? ? Kaui::Tag.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records : 0
15
11
  end
16
12
 
17
13
  def pagination
@@ -11,7 +11,8 @@ class Kaui::Admin < KillBillClient::Model::Resource
11
11
  {
12
12
  :accountId => account_id,
13
13
  :withHistory => options[:withHistory],
14
- :minDate => options[:minDate]
14
+ :minDate => options[:minDate],
15
+ :maxDate => options[:maxDate]
15
16
  },
16
17
  options
17
18
  JSON.parse res.body
@@ -32,9 +32,13 @@
32
32
 
33
33
  <%= javascript_tag do %>
34
34
  $(document).ready(function() {
35
- $('#accounts-table').dataTable({
35
+ var table = $('#accounts-table').DataTable({
36
36
  "dom": "<'row'r>t<'row'<'col-md-6'i><'col-md-6'p>>",
37
- "pagingType": "full_numbers",
37
+ "pagingType": <% if @max_nb_records.nil? -%>"simple"<% else -%>"full_numbers"<% end -%>,
38
+ "language": {
39
+ <!-- See DefaultPaginationSqlDaoHelper.java -->
40
+ "info": <% if @max_nb_records.nil? -%>"Showing _START_ to _END_ of <%= number_with_delimiter(Kaui::EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD) -%>+ entries"<% else -%>"Showing _START_ to _END_ of _TOTAL_ entries"<% end -%>
41
+ },
38
42
  "pageLength": <%= @limit %>,
39
43
  "displayStart": <%= @offset %>,
40
44
  <% unless @ordering.blank? %>
@@ -43,7 +47,18 @@ $(document).ready(function() {
43
47
  "processing": true,
44
48
  "serverSide": true,
45
49
  "search": {"search": "<%= @search_query %>"},
46
- "ajax": "<%= accounts_pagination_path :format => :json %>"
50
+ "ajax": "<%= accounts_pagination_path(:ordering => @ordering, :format => :json) %>"
47
51
  });
52
+
53
+ <!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
54
+ <% if @max_nb_records.nil? %>
55
+ $('#accounts-table').on('draw.dt', function() {
56
+ var noMoreData = table.column(0)
57
+ .data()
58
+ .length == 0;
59
+ $(".next.paginate_button").toggleClass("disabled", noMoreData);
60
+ $(".dataTables_info").toggle(!noMoreData);
61
+ });
62
+ <% end %>
48
63
  });
49
64
  <% end %>
@@ -30,12 +30,32 @@
30
30
 
31
31
  <%= javascript_tag do %>
32
32
  $(document).ready(function() {
33
- $('#custom_fields-table').dataTable({
33
+ var table = $('#custom_fields-table').DataTable({
34
34
  "dom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
35
- "pagingType": "full_numbers",
35
+ "pagingType": <% if @max_nb_records.nil? -%>"simple"<% else -%>"full_numbers"<% end -%>,
36
+ "language": {
37
+ <!-- See DefaultPaginationSqlDaoHelper.java -->
38
+ "info": <% if @max_nb_records.nil? -%>"Showing _START_ to _END_ of <%= number_with_delimiter(Kaui::EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD) -%>+ entries"<% else -%>"Showing _START_ to _END_ of _TOTAL_ entries"<% end -%>
39
+ },
40
+ "pageLength": <%= @limit %>,
41
+ "displayStart": <%= @offset %>,
42
+ <% unless @ordering.blank? %>
43
+ "order": [[ 0, "<%= @ordering %>" ]],
44
+ <% end %>
36
45
  "processing": true,
37
46
  "serverSide": true,
38
- "ajax": "<%= custom_fields_pagination_path :format => :json %>"
47
+ "ajax": "<%= custom_fields_pagination_path(:ordering => @ordering, :format => :json) %>"
39
48
  });
49
+
50
+ <!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
51
+ <% if @max_nb_records.nil? %>
52
+ $('#custom_fields-table').on('draw.dt', function() {
53
+ var noMoreData = table.column(0)
54
+ .data()
55
+ .length == 0;
56
+ $(".next.paginate_button").toggleClass("disabled", noMoreData);
57
+ $(".dataTables_info").toggle(!noMoreData);
58
+ });
59
+ <% end %>
40
60
  });
41
61
  <% end %>
@@ -26,16 +26,22 @@
26
26
 
27
27
  <%= javascript_tag do %>
28
28
  $(document).ready(function() {
29
- $('#invoices-table').dataTable({
29
+ var table = $('#invoices-table').DataTable({
30
30
  <% if @account.account_id.blank? %>
31
31
  "dom": "<'row'r>t<'row'<'col-md-6'i><'col-md-6'p>>",
32
- "pagingType": "full_numbers",
32
+ "pagingType": <% if @max_nb_records.nil? -%>"simple"<% else -%>"full_numbers"<% end -%>,
33
+ "language": {
34
+ <!-- See DefaultPaginationSqlDaoHelper.java -->
35
+ "info": <% if @max_nb_records.nil? -%>"Showing _START_ to _END_ of <%= number_with_delimiter(Kaui::EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD) -%>+ entries"<% else -%>"Showing _START_ to _END_ of _TOTAL_ entries"<% end -%>
36
+ },
33
37
  "pageLength": <%= @limit %>,
34
38
  "displayStart": <%= @offset %>,
39
+ "ajax": "<%= invoices_pagination_path(:ordering => @ordering, :format => :json) %>",
35
40
  <% else %>
36
41
  // No paging for per-account listings
37
42
  "dom": "t",
38
43
  "paging": false,
44
+ "ajax": "<%= invoices_pagination_path :format => :json %>",
39
45
  <% end %>
40
46
  <% unless @ordering.blank? %>
41
47
  "order": [[ 0, "<%= @ordering %>" ]],
@@ -43,7 +49,17 @@ $(document).ready(function() {
43
49
  "processing": true,
44
50
  "serverSide": true,
45
51
  "search": {"search": "<%= @search_query %>"},
46
- "ajax": "<%= invoices_pagination_path :format => :json %>"
47
52
  });
53
+
54
+ <!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
55
+ <% if @max_nb_records.nil? %>
56
+ $('#invoices-table').on('draw.dt', function() {
57
+ var noMoreData = table.column(0)
58
+ .data()
59
+ .length == 0;
60
+ $(".next.paginate_button").toggleClass("disabled", noMoreData);
61
+ $(".dataTables_info").toggle(!noMoreData);
62
+ });
63
+ <% end %>
48
64
  });
49
65
  <% end %>
@@ -28,16 +28,22 @@
28
28
 
29
29
  <%= javascript_tag do %>
30
30
  $(document).ready(function() {
31
- $('#payments-table').dataTable({
31
+ var table = $('#payments-table').DataTable({
32
32
  <% if @account.account_id.blank? %>
33
33
  "dom": "<'row'r>t<'row'<'col-md-6'i><'col-md-6'p>>",
34
- "pagingType": "full_numbers",
34
+ "pagingType": <% if @max_nb_records.nil? -%>"simple"<% else -%>"full_numbers"<% end -%>,
35
+ "language": {
36
+ <!-- See DefaultPaginationSqlDaoHelper.java -->
37
+ "info": <% if @max_nb_records.nil? -%>"Showing _START_ to _END_ of <%= number_with_delimiter(Kaui::EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD) -%>+ entries"<% else -%>"Showing _START_ to _END_ of _TOTAL_ entries"<% end -%>
38
+ },
35
39
  "pageLength": <%= @limit %>,
36
40
  "displayStart": <%= @offset %>,
41
+ "ajax": "<%= payments_pagination_path(:ordering => @ordering, :format => :json) %>",
37
42
  <% else %>
38
43
  // No paging for per-account listings
39
44
  "dom": "t",
40
45
  "paging": false,
46
+ "ajax": "<%= payments_pagination_path :format => :json %>",
41
47
  <% end %>
42
48
  <% unless @ordering.blank? %>
43
49
  "order": [[ 0, "<%= @ordering %>" ]],
@@ -45,7 +51,17 @@ $(document).ready(function() {
45
51
  "processing": true,
46
52
  "serverSide": true,
47
53
  "search": {"search": "<%= @search_query %>"},
48
- "ajax": "<%= payments_pagination_path :format => :json %>"
49
54
  });
55
+
56
+ <!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
57
+ <% if @max_nb_records.nil? %>
58
+ $('#payments-table').on('draw.dt', function() {
59
+ var noMoreData = table.column(0)
60
+ .data()
61
+ .length == 0;
62
+ $(".next.paginate_button").toggleClass("disabled", noMoreData);
63
+ $(".dataTables_info").toggle(!noMoreData);
64
+ });
65
+ <% end %>
50
66
  });
51
67
  <% end %>
@@ -1,8 +1,10 @@
1
1
  <p class="text-center">
2
- <%= link_to 'Current or future entries', kaui_engine.queues_path(params.merge(:with_history => false)) %> /
3
- <%= link_to 'Historical entries (last week)', kaui_engine.queues_path(params.merge(:with_history => true, :min_date => @now - 1.week)) %> /
4
- <%= link_to 'Historical entries (last month)', kaui_engine.queues_path(params.merge(:with_history => true, :min_date => @now - 1.month)) %> /
5
- <%= link_to 'All historical entries', kaui_engine.queues_path(params.merge(:with_history => true, :min_date => '1970-01-01')) %>
2
+ <%= link_to 'Current or future entries', kaui_engine.queues_path(params.merge(:with_history => false, :max_date => @now + 1.week)) %> /
3
+ <% unless params[:account_id].present? -%>
4
+ <%= link_to 'Historical entries (last week)', kaui_engine.queues_path(params.merge(:with_history => true, :min_date => @now - 1.week, :max_date => @now + 1.week)) %> /
5
+ <%= link_to 'Historical entries (last month)', kaui_engine.queues_path(params.merge(:with_history => true, :min_date => @now - 1.month, :max_date => @now + 1.week)) %> /
6
+ <% end -%>
7
+ <%= link_to 'All historical entries', kaui_engine.queues_path(params.merge(:with_history => true)) %>
6
8
  </p>
7
9
 
8
10
  <div class="search">
@@ -26,9 +26,13 @@
26
26
 
27
27
  <%= javascript_tag do %>
28
28
  $(document).ready(function() {
29
- $('#tags-table').dataTable({
29
+ var table = $('#tags-table').DataTable({
30
30
  "dom": "<'row'r>t<'row'<'col-md-6'i><'col-md-6'p>>",
31
- "pagingType": "full_numbers",
31
+ "pagingType": <% if @max_nb_records.nil? -%>"simple"<% else -%>"full_numbers"<% end -%>,
32
+ "language": {
33
+ <!-- See DefaultPaginationSqlDaoHelper.java -->
34
+ "info": <% if @max_nb_records.nil? -%>"Showing _START_ to _END_ of <%= number_with_delimiter(Kaui::EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD) -%>+ entries"<% else -%>"Showing _START_ to _END_ of _TOTAL_ entries"<% end -%>
35
+ },
32
36
  "pageLength": <%= @limit %>,
33
37
  "displayStart": <%= @offset %>,
34
38
  <% unless @ordering.blank? %>
@@ -37,7 +41,18 @@ $(document).ready(function() {
37
41
  "processing": true,
38
42
  "serverSide": true,
39
43
  "search": {"search": "<%= @search_query %>"},
40
- "ajax": "<%= tags_pagination_path :format => :json %>"
44
+ "ajax": "<%= tags_pagination_path(:ordering => @ordering, :format => :json) %>"
41
45
  });
46
+
47
+ <!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
48
+ <% if @max_nb_records.nil? %>
49
+ $('#tags-table').on('draw.dt', function() {
50
+ var noMoreData = table.column(0)
51
+ .data()
52
+ .length == 0;
53
+ $(".next.paginate_button").toggleClass("disabled", noMoreData);
54
+ $(".dataTables_info").toggle(!noMoreData);
55
+ });
56
+ <% end %>
42
57
  });
43
58
  <% end %>
data/lib/kaui/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaui
2
- VERSION = '0.15.3'
2
+ VERSION = '0.15.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.3
4
+ version: 0.15.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Killbill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-15 00:00:00.000000000 Z
11
+ date: 2017-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement