| 1 | <template> |
| 2 | <ConfigSection title="Health Check" collapsible :readonly="readonly" :has-value="!!form.healthCheckType"> |
| 3 | <div class="field-row two-col"> |
| 4 | <ConfigField label="Type" type="select" v-model="form.healthCheckType" |
| 5 | :options="[{ label: 'Disabled', value: '' }, { label: 'TCP', value: 'tcp' }, { label: 'HTTP', value: 'http' }]" :readonly="readonly" /> |
| 6 | <div></div> |
| 7 | </div> |
| 8 |
| <template v-if="form.healthCheckType"> |
| 9 | <div class="field-row three-col"> |
| 10 | <ConfigField label="Timeout (s)" type="number" v-model="form.healthCheckTimeoutSeconds" :min="1" :readonly="readonly" /> |
| 11 | <ConfigField label="Max Failed" type="number" v-model="form.healthCheckMaxFailed" :min="1" :readonly="readonly" /> |
| 12 | <ConfigField label="Interval (s)" type="number" v-model="form.healthCheckIntervalSeconds" :min="1" :readonly="readonly" /> |
| 13 | </div> |
| 14 | <template v-if="form.healthCheckType === 'http'"> |
| 15 | <ConfigField label="Path" type="text" v-model="form.healthCheckPath" prop="healthCheckPath" placeholder="/health" :readonly="readonly" /> |
| 16 | <ConfigField label="HTTP Headers" type="kv" v-model="healthCheckHeaders" key-placeholder="Header" value-placeholder="Value" :readonly="readonly" /> |
| 17 | </template> |
| 18 | </template> |
| 19 | </ConfigSection> |
| 20 | </template> |
| 21 |
| 22 | <script setup lang="ts"> |
| 23 | import { computed } from 'vue' |
| 24 | import type { ProxyFormData } from '../../types' |
| 25 | import ConfigSection from '../ConfigSection.vue' |
| 26 | import ConfigField from '../ConfigField.vue' |
| 27 |
| 28 | const props = withDefaults(defineProps<{ |
| 29 | modelValue: ProxyFormData |
| 30 | readonly?: boolean |
| 31 | }>(), { readonly: false }) |
| 32 |
| 33 | const emit = defineEmits<{ 'update:modelValue': [value: ProxyFormData] }>() |
| 34 |
| 35 | const form = computed({ |
| 36 | get: () => props.modelValue, |
| 37 | set: (val) => emit('update:modelValue', val), |
| 38 | }) |
| 39 |
| 40 | const healthCheckHeaders = computed({ |
| 41 | get() { |
| 42 | return form.value.healthCheckHTTPHeaders.map((h) => ({ key: h.name, value: h.value })) |
| 43 | }, |
| 44 | set(val: Array<{ key: string; value: string }>) { |
| 45 | form.value.healthCheckHTTPHeaders = val.map((h) => ({ name: h.key, value: h.value })) |
| 46 | }, |
| 47 | }) |
| 48 | </script> |
| 49 |
| 50 | <style scoped lang="scss"> |
| 51 | @use '@/assets/css/form-layout'; |
| 52 | </style> |