Add DeviceDetector and postres_cursor
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= form_with(model: @waf_policy, local: true, class: "space-y-6") do |form| %>
|
||||
<%= form_with(model: @waf_policy, local: true, class: "space-y-6", data: { controller: "waf-policy-form" }) do |form| %>
|
||||
<!-- Basic Information -->
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<div class="px-4 py-5 sm:p-6 space-y-4">
|
||||
@@ -35,14 +35,14 @@
|
||||
placeholder: "Explain why this policy is needed..." %>
|
||||
</div>
|
||||
|
||||
<!-- Action -->
|
||||
<!-- Policy Action -->
|
||||
<div>
|
||||
<%= form.label :action, "Action", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.select :action,
|
||||
options_for_select(@actions.map { |action| [action.humanize, action] }, @waf_policy.action),
|
||||
<%= form.label :policy_action, "Policy Action", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.select :policy_action,
|
||||
options_for_select(@actions.map { |action| [action.humanize, action] }, @waf_policy.policy_action),
|
||||
{ prompt: "Select action" },
|
||||
{ class: "block w-full border-gray-300 rounded-md shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm",
|
||||
id: "action-select" } %>
|
||||
data: { "waf-policy-form-target": "policyActionSelect", "action": "change->waf-policy-form#updateActionConfig" } } %>
|
||||
</div>
|
||||
|
||||
<!-- Status -->
|
||||
@@ -164,7 +164,7 @@
|
||||
<h3 class="text-lg leading-6 font-medium text-gray-900">⚙️ Additional Configuration</h3>
|
||||
|
||||
<!-- Redirect Settings (for redirect action) -->
|
||||
<div id="redirect-config" class="space-y-3 <%= 'hidden' unless @waf_policy.redirect_action? %>">
|
||||
<div id="redirect-config" class="space-y-3 <%= 'hidden' unless @waf_policy.redirect_action? %>" data-waf-policy-form-target="redirectConfig">
|
||||
<div>
|
||||
<%= label_tag "additional_data[redirect_url]", "Redirect URL", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= text_field_tag "additional_data[redirect_url]", @waf_policy.additional_data&.dig('redirect_url'),
|
||||
@@ -180,7 +180,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Challenge Settings (for challenge action) -->
|
||||
<div id="challenge-config" class="space-y-3 <%= 'hidden' unless @waf_policy.challenge_action? %>">
|
||||
<div id="challenge-config" class="space-y-3 <%= 'hidden' unless @waf_policy.challenge_action? %>" data-waf-policy-form-target="challengeConfig">
|
||||
<div>
|
||||
<%= label_tag "additional_data[challenge_type]", "Challenge Type", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= select_tag "additional_data[challenge_type]",
|
||||
@@ -205,36 +205,4 @@
|
||||
class: "inline-flex items-center px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const actionSelect = document.getElementById('action-select');
|
||||
const redirectConfig = document.getElementById('redirect-config');
|
||||
const challengeConfig = document.getElementById('challenge-config');
|
||||
|
||||
function updateActionConfig() {
|
||||
const selectedAction = actionSelect.value;
|
||||
|
||||
// Hide all config sections
|
||||
redirectConfig.classList.add('hidden');
|
||||
challengeConfig.classList.add('hidden');
|
||||
|
||||
// Show relevant config section
|
||||
switch(selectedAction) {
|
||||
case 'redirect':
|
||||
redirectConfig.classList.remove('hidden');
|
||||
break;
|
||||
case 'challenge':
|
||||
challengeConfig.classList.remove('hidden');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Add event listener
|
||||
actionSelect.addEventListener('change', updateActionConfig);
|
||||
|
||||
// Initial update
|
||||
updateActionConfig();
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
Reference in New Issue
Block a user