Add DeviceDetector and postres_cursor

This commit is contained in:
Dan Milne
2025-11-13 08:35:00 +11:00
parent cc8213f87a
commit 2c7b801ed5
15 changed files with 472 additions and 158 deletions

View File

@@ -0,0 +1,55 @@
import { Controller } from "@hotwired/stimulus"
export default class WafPolicyFormController extends Controller {
static targets = ["policyTypeSelect", "policyActionSelect", "countryTargets", "asnTargets",
"companyTargets", "networkTypeTargets", "redirectConfig", "challengeConfig"]
connect() {
this.updateTargetsVisibility()
this.updateActionConfig()
}
updateTargetsVisibility() {
const selectedType = this.policyTypeSelectTarget.value
// Hide all target sections
this.countryTargetsTarget.classList.add('hidden')
this.asnTargetsTarget.classList.add('hidden')
this.companyTargetsTarget.classList.add('hidden')
this.networkTypeTargetsTarget.classList.add('hidden')
// Show relevant target section
switch(selectedType) {
case 'country':
this.countryTargetsTarget.classList.remove('hidden')
break
case 'asn':
this.asnTargetsTarget.classList.remove('hidden')
break
case 'company':
this.companyTargetsTarget.classList.remove('hidden')
break
case 'network_type':
this.networkTypeTargetsTarget.classList.remove('hidden')
break
}
}
updateActionConfig() {
const selectedAction = this.policyActionSelectTarget.value
// Hide all config sections
this.redirectConfigTarget.classList.add('hidden')
this.challengeConfigTarget.classList.add('hidden')
// Show relevant config section
switch(selectedAction) {
case 'redirect':
this.redirectConfigTarget.classList.remove('hidden')
break
case 'challenge':
this.challengeConfigTarget.classList.remove('hidden')
break
}
}
}