Add DeviceDetector and postres_cursor
This commit is contained in:
@@ -14,6 +14,31 @@
|
||||
</div>
|
||||
|
||||
<%= form_with(url: create_country_waf_policies_path, method: :post, local: true, class: "space-y-6") do |form| %>
|
||||
<!-- Display validation errors -->
|
||||
<% if defined?(@waf_policy) && @waf_policy&.errors&.any? %>
|
||||
<div class="rounded-md bg-red-50 p-4 border border-red-200">
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<h3 class="text-sm font-medium text-red-800">
|
||||
<%= pluralize(@waf_policy.errors.count, "error") %> prohibited this policy from being saved:
|
||||
</h3>
|
||||
<div class="mt-2 text-sm text-red-700">
|
||||
<ul class="list-disc pl-5 space-y-1">
|
||||
<% @waf_policy.errors.full_messages.each do |message| %>
|
||||
<li><%= message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Popular Countries Quick Selection -->
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<div class="px-4 py-5 sm:p-6">
|
||||
@@ -67,28 +92,28 @@
|
||||
|
||||
<!-- Action Selection -->
|
||||
<div>
|
||||
<%= form.label :action, "What should happen to traffic from selected countries?", class: "block text-sm font-medium text-gray-700" %>
|
||||
<%= form.label :policy_action, "What should happen to traffic from selected countries?", class: "block text-sm font-medium text-gray-700" %>
|
||||
<div class="mt-2 space-y-2">
|
||||
<label class="flex items-center">
|
||||
<%= radio_button_tag "action", "deny", true, class: "h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300" %>
|
||||
<%= radio_button_tag "policy_action", "deny", true, class: "h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300" %>
|
||||
<span class="ml-2 text-sm text-gray-700">
|
||||
<span class="font-medium">🚫 Block (Deny)</span> - Show 403 Forbidden error
|
||||
</span>
|
||||
</label>
|
||||
<label class="flex items-center">
|
||||
<%= radio_button_tag "action", "challenge", false, class: "h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300" %>
|
||||
<%= radio_button_tag "policy_action", "challenge", false, class: "h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300" %>
|
||||
<span class="ml-2 text-sm text-gray-700">
|
||||
<span class="font-medium">🛡️ Challenge</span> - Present CAPTCHA challenge
|
||||
</span>
|
||||
</label>
|
||||
<label class="flex items-center">
|
||||
<%= radio_button_tag "action", "redirect", false, class: "h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300" %>
|
||||
<%= radio_button_tag "policy_action", "redirect", false, class: "h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300" %>
|
||||
<span class="ml-2 text-sm text-gray-700">
|
||||
<span class="font-medium">🔄 Redirect</span> - Redirect to compliance page
|
||||
</span>
|
||||
</label>
|
||||
<label class="flex items-center">
|
||||
<%= radio_button_tag "action", "allow", false, class: "h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300" %>
|
||||
<%= radio_button_tag "policy_action", "allow", false, class: "h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300" %>
|
||||
<span class="ml-2 text-sm text-gray-700">
|
||||
<span class="font-medium">✅ Allow</span> - Explicitly allow traffic
|
||||
</span>
|
||||
@@ -138,14 +163,14 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Show/hide redirect settings based on action selection
|
||||
// Show/hide redirect settings based on policy action selection
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const actionRadios = document.querySelectorAll('input[name="action"]');
|
||||
const actionRadios = document.querySelectorAll('input[name="policy_action"]');
|
||||
const redirectSettings = document.getElementById('redirect-settings');
|
||||
const previewText = document.getElementById('preview-text');
|
||||
|
||||
function updateVisibility() {
|
||||
const selectedAction = document.querySelector('input[name="action"]:checked')?.value;
|
||||
const selectedAction = document.querySelector('input[name="policy_action"]:checked')?.value;
|
||||
|
||||
if (selectedAction === 'redirect') {
|
||||
redirectSettings.classList.remove('hidden');
|
||||
@@ -158,7 +183,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
function updatePreview() {
|
||||
const selectedCountries = document.querySelectorAll('input[name="countries[]"]:checked');
|
||||
const selectedAction = document.querySelector('input[name="action"]:checked')?.value || 'deny';
|
||||
const selectedAction = document.querySelector('input[name="policy_action"]:checked')?.value || 'deny';
|
||||
const actionText = {
|
||||
'deny': '🚫 Block',
|
||||
'challenge': '🛡️ Challenge',
|
||||
|
||||
Reference in New Issue
Block a user