Skip to content

Commit

Permalink
Fixes bug with copy button when in proxy mode
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kastl <[email protected]>
  • Loading branch information
dkastl committed Jun 11, 2024
1 parent 065e254 commit ae20bbd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 6 additions & 2 deletions app/views/subscription_templates/_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@
var detail = event.detail;
var data = detail[0], status = detail[1], xhr = detail[2];

// Update the subscription templates list with the response data
document.getElementById('subscriptionTemplateList').innerHTML = xhr.responseText;
// Check if event.target has the class 'copy-command-link'
if (!event.target.classList.contains('copy-command-link')) {
// Update the subscription templates list with the response data
document.getElementById('subscriptionTemplateList').innerHTML = xhr.responseText;
}

showNotification(xhr.getResponseHeader('X-Redmine-Message'));
});

Expand Down
5 changes: 4 additions & 1 deletion app/views/subscription_templates/copy.js.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// Build the cURL command with line breaks and formatted JSON
var jsonPayload = JSON.parse('<%= @json_payload.html_safe %>');
var prettifiedJson = JSON.stringify(jsonPayload, null, 2);

var command = "curl -i -X POST '<%= @broker_url %>' \\\n" +
"-H 'Content-Type: application/json' \\\n" +
<% if @subscription_template&.fiware_service&.present? %>
Expand All @@ -7,7 +10,7 @@ var command = "curl -i -X POST '<%= @broker_url %>' \\\n" +
<% if @subscription_template&.fiware_servicepath&.present? %>
"-H 'Fiware-ServicePath: <%= @subscription_template.fiware_servicepath %>' \\\n" +
<% end %>
"--data-binary '" + '<%= @json_payload.html_safe %>' + "'";
"--data-binary '" + prettifiedJson + "'";

var authToken = document.getElementById('subscription_auth_token').value;
if (authToken) {
Expand Down

0 comments on commit ae20bbd

Please sign in to comment.