diff --git a/app/views/kaui/queues/index.html.erb b/app/views/kaui/queues/index.html.erb index b1026881f..cf471bdc8 100644 --- a/app/views/kaui/queues/index.html.erb +++ b/app/views/kaui/queues/index.html.erb @@ -4,9 +4,22 @@ <%= render :template => 'kaui/layouts/kaui_account_sidebar' %>
-
-

Queues

-

View and monitor bus events and notifications.

+
+
+

Queues

+

View and monitor bus events and notifications.

+
+ <%= render "kaui/components/button/button", { + label: "Download JSON", + icon: 'kaui/download.svg', + html_class: "kaui-button custom-hover", + variant: "btn-outline-secondary d-inline-flex align-items-center gap-1", + type: "button", + html_options: { + id: "queuesDownloadButton", + onclick: "downloadActiveQueuesTab()" + } + } %>
@@ -139,7 +152,7 @@ <%= truncate_millis(bus_event['createdDate']) %> - <%= truncate_class_name(bus_event['className'], false) %> + <%= truncate_class_name(bus_event['className'], false) %> <%= "
#{JSON.pretty_generate(bus_event['event'])}
".html_safe %> <%= bus_event['userToken'] %> <% if @account_id.blank? %> @@ -278,6 +291,62 @@
<%= javascript_tag do %> + function downloadActiveQueuesTab() { + var activeTab = $('#queuesNavTabs .nav-link.active').attr('id'); + var tableId, filename; + if (activeTab === 'notifications-tab') { + tableId = '#notifications-table'; + filename = 'notifications-' + new Date().toISOString().split('T')[0] + '.json'; + } else { + tableId = '#bus-table'; + filename = 'bus-events-' + new Date().toISOString().split('T')[0] + '.json'; + } + + var table = $(tableId).DataTable(); + var headers = []; + var visibleColumnIndexes = []; + + $(tableId + ' thead th').each(function(index) { + if (index === 0) return; // skip timeline dot column + var column = table.column(index); + if (column.visible()) { + var headerText = $(this).find('.header-text').text().trim(); + headers.push(headerText); + visibleColumnIndexes.push(index); + } + }); + + var jsonRows = []; + + table.rows({ search: 'applied' }).nodes().each(function(row) { + var cells = $(row).find('td'); + var obj = {}; + visibleColumnIndexes.forEach(function(colIdx, i) { + var $cell = $(cells[colIdx]); + var fullValue = $cell.data('full-value'); + var cellText = fullValue !== undefined ? String(fullValue) : $cell.text().trim(); + var key = headers[i]; + try { + obj[key] = JSON.parse(cellText); + } catch (e) { + obj[key] = cellText; + } + }); + jsonRows.push(obj); + }); + + var jsonContent = JSON.stringify(jsonRows, null, 2); + var blob = new Blob([jsonContent], { type: 'application/json;charset=utf-8;' }); + var url = URL.createObjectURL(blob); + var a = document.createElement('a'); + a.href = url; + a.download = filename; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + } + $(document).ready(function() { var busTable = $('#bus-table').DataTable({ "dom": "t<'row dt-footer-row'<'col-md-6'i><'col-md-6'p>>", diff --git a/app/views/kaui/subscriptions/edit_bcd.erb b/app/views/kaui/subscriptions/edit_bcd.erb index 983b0f900..46ee8da9a 100644 --- a/app/views/kaui/subscriptions/edit_bcd.erb +++ b/app/views/kaui/subscriptions/edit_bcd.erb @@ -31,7 +31,7 @@ - +
diff --git a/test/functional/kaui/accounts_controller_test.rb b/test/functional/kaui/accounts_controller_test.rb index c6173b719..6340963bf 100644 --- a/test/functional/kaui/accounts_controller_test.rb +++ b/test/functional/kaui/accounts_controller_test.rb @@ -165,8 +165,8 @@ class AccountsControllerTest < Kaui::FunctionalTestHelper } post :trigger_invoice, params: parameters - assert_equal 'Nothing to generate for target date today', flash[:notice] - assert_redirected_to account_path(account.account_id) + assert_match(/Generated invoice.*for target date.*|Nothing to generate for target date today/, flash[:notice]) + assert_response :redirect today_next_month = (Date.parse(@kb_clock['localDate']) + 31).to_s # generate a dry run invoice diff --git a/test/functional/kaui/subscriptions_controller_test.rb b/test/functional/kaui/subscriptions_controller_test.rb index 75c0d797c..32fcf4be7 100644 --- a/test/functional/kaui/subscriptions_controller_test.rb +++ b/test/functional/kaui/subscriptions_controller_test.rb @@ -306,7 +306,7 @@ class SubscriptionsControllerTest < Kaui::FunctionalTestHelper assert_response :success assert_equal extract_value_from_input_field('subscription_account_id'), @bundle.subscriptions.first.account_id assert_equal extract_value_from_input_field('subscription_bill_cycle_day_local'), @bundle.subscriptions.first.bill_cycle_day_local.to_s - assert_equal extract_value_from_input_field('effective_from_date'), Date.parse(Time.zone.now.to_s).to_s + assert_equal extract_value_from_input_field('effective_from_date'), Time.zone.today.strftime('%Y-%m-%d') end test 'should update bcd' do diff --git a/test/killbill_test_helper.rb b/test/killbill_test_helper.rb index 3189d97b4..4088e0eba 100644 --- a/test/killbill_test_helper.rb +++ b/test/killbill_test_helper.rb @@ -125,7 +125,7 @@ def create_bundle(account = nil, tenant = nil, username = USERNAME, password = P product_category: 'BASE', billing_period: 'MONTHLY', price_list: 'DEFAULT') - entitlement = entitlement.create(user, reason, comment, nil, false, build_options(tenant, username, password)) + entitlement = entitlement.create(user, reason, comment, nil, true, build_options(tenant, username, password)) KillBillClient::Model::Bundle.find_by_id(entitlement.bundle_id, build_options(tenant, username, password)) end