Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
77 changes: 73 additions & 4 deletions app/views/kaui/queues/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,22 @@
<%= render :template => 'kaui/layouts/kaui_account_sidebar' %>
<div class="queues w-100">

<div class="queues-main-header mb-4">
<h1 class="queues-title">Queues</h1>
<p class="queues-subtitle">View and monitor bus events and notifications.</p>
<div class="queues-main-header mb-4 d-flex justify-content-between align-items-start">
<div>
<h1 class="queues-title">Queues</h1>
<p class="queues-subtitle">View and monitor bus events and notifications.</p>
</div>
<%= 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()"
}
} %>
</div>

<div class="queues-card">
Expand Down Expand Up @@ -139,7 +152,7 @@
<span class="dot"></span>
</td>
<td><span><%= truncate_millis(bus_event['createdDate']) %></span></td>
<td><%= truncate_class_name(bus_event['className'], false) %></td>
<td data-full-value="<%= bus_event['className'] %>"><%= truncate_class_name(bus_event['className'], false) %></td>
<td><%= "<pre>#{JSON.pretty_generate(bus_event['event'])}</pre>".html_safe %></td>
<td><%= bus_event['userToken'] %></td>
<% if @account_id.blank? %>
Expand Down Expand Up @@ -278,6 +291,62 @@
</div>

<%= 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);
Comment thread
tungleduyxyz marked this conversation as resolved.
} 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>>",
Expand Down
2 changes: 1 addition & 1 deletion app/views/kaui/subscriptions/edit_bcd.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<path d="M17.8333 10.8333V4.99992C17.8333 4.07944 17.0871 3.33325 16.1666 3.33325H4.49992C3.57944 3.33325 2.83325 4.07944 2.83325 4.99992V16.6666C2.83325 17.5871 3.57944 18.3333 4.49992 18.3333H10.3333" stroke="#A4A7AE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M2.83325 8.33325H17.8333" stroke="#A4A7AE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<input class="form-control" value="<%=Date.parse(Time.now.to_s).to_s%>" id="effective_from_date" name="effective_from_date" type="text" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-today-highlight="true">
<input class="form-control" value="<%= Time.zone.today.strftime('%Y-%m-%d') %>" id="effective_from_date" name="effective_from_date" type="text" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-today-highlight="true">
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions test/functional/kaui/accounts_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/functional/kaui/subscriptions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/killbill_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading