Add failover setting step controls
This commit is contained in:
@@ -76,17 +76,19 @@ function pulseNumber(event: FormEvent<HTMLInputElement>) {
|
||||
], { duration: 320, easing: 'cubic-bezier(0.16, 1, 0.3, 1)' });
|
||||
}
|
||||
|
||||
function FailoverNumberSetting({ before, after, value, min, max, disabled, ariaLabel, onChange }: {
|
||||
function FailoverNumberSetting({ before, after, value, min, max, step = 10, disabled, ariaLabel, onChange }: {
|
||||
before: string;
|
||||
after: string;
|
||||
value: number;
|
||||
min: number;
|
||||
max: number;
|
||||
step?: number;
|
||||
disabled?: boolean;
|
||||
ariaLabel: string;
|
||||
onChange: (value: number) => void;
|
||||
}) {
|
||||
return <label className="client-failover-number-setting">
|
||||
const set = (next: number) => onChange(Math.min(max, Math.max(min, next)));
|
||||
return <div className="client-failover-number-setting">
|
||||
<span>{before}</span>
|
||||
<input
|
||||
className="client-failover-number-input"
|
||||
@@ -104,7 +106,11 @@ function FailoverNumberSetting({ before, after, value, min, max, disabled, ariaL
|
||||
}}
|
||||
/>
|
||||
<span>{after}</span>
|
||||
</label>;
|
||||
<span className="client-failover-number-steps">
|
||||
<button type="button" aria-label={`${ariaLabel}: уменьшить на ${step}`} disabled={disabled || value <= min} onClick={() => set(value - step)}>−{step}</button>
|
||||
<button type="button" aria-label={`${ariaLabel}: увеличить на ${step}`} disabled={disabled || value >= max} onClick={() => set(value + step)}>+{step}</button>
|
||||
</span>
|
||||
</div>;
|
||||
}
|
||||
|
||||
const reasonLabel = (reason: string | null) => ({
|
||||
@@ -513,6 +519,7 @@ export function FailoverPanel({
|
||||
after="секунд"
|
||||
min={2}
|
||||
max={30}
|
||||
step={1}
|
||||
ariaLabel={`Время ожидания ответа: ${service?.label || 'сервис недоступен'}`}
|
||||
value={seconds(check.timeoutMs)}
|
||||
disabled={blocked || !draft.enabled}
|
||||
@@ -587,8 +594,8 @@ export function FailoverPanel({
|
||||
</header>
|
||||
<div className="client-failover-protection-options">
|
||||
<FailoverNumberSetting before="Оставаться на резервном не меньше" after="секунд" min={60} max={86400} ariaLabel="Минимальное время на резервном канале" value={seconds(draft.minimumReserveMs)} disabled={blocked || !draft.enabled} onChange={(value) => update({ minimumReserveMs: value * 1_000 })} />
|
||||
<FailoverNumberSetting before="Отправлять основной в карантин после" after="повторных сбоев" min={2} max={10} ariaLabel="Количество повторных сбоев" value={draft.flapProtection.count} disabled={blocked || !draft.enabled} onChange={(value) => update({ flapProtection: { ...draft.flapProtection, count: value } })} />
|
||||
<FailoverNumberSetting before="Считать повторными сбои за последние" after="часов" min={1} max={72} ariaLabel="Период повторных сбоев" value={Math.round(draft.flapProtection.windowMs / 3_600_000)} disabled={blocked || !draft.enabled} onChange={(value) => update({ flapProtection: { ...draft.flapProtection, windowMs: value * 3_600_000 } })} />
|
||||
<FailoverNumberSetting before="Отправлять основной в карантин после" after="повторных сбоев" min={2} max={10} step={1} ariaLabel="Количество повторных сбоев" value={draft.flapProtection.count} disabled={blocked || !draft.enabled} onChange={(value) => update({ flapProtection: { ...draft.flapProtection, count: value } })} />
|
||||
<FailoverNumberSetting before="Считать повторными сбои за последние" after="часов" min={1} max={72} step={1} ariaLabel="Период повторных сбоев" value={Math.round(draft.flapProtection.windowMs / 3_600_000)} disabled={blocked || !draft.enabled} onChange={(value) => update({ flapProtection: { ...draft.flapProtection, windowMs: value * 3_600_000 } })} />
|
||||
<FailoverNumberSetting before="Не возвращаться на основной после карантина" after="минут" min={10} max={10080} ariaLabel="Длительность карантина основного канала" value={Math.round(draft.flapProtection.quarantineMs / 60_000)} disabled={blocked || !draft.enabled} onChange={(value) => update({ flapProtection: { ...draft.flapProtection, quarantineMs: value * 60_000 } })} />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -41,8 +41,11 @@
|
||||
.client-failover-picker-list button[aria-disabled='true'] { color: color-mix(in oklch, var(--client-muted) 58%, transparent); cursor: default; text-shadow: none; }
|
||||
.client-failover-number-setting { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .55ch; min-height: 42px; color: var(--client-muted); font: var(--type-body); letter-spacing: var(--type-body-tracking); text-transform: var(--type-body-transform); cursor: text; }
|
||||
.client-failover-number-setting input { flex: 0 0 auto; min-width: 2ch; min-height: 1.35em; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--client-text); font: var(--type-item-title); font-variant-numeric: var(--numeric-tabular); letter-spacing: var(--type-item-title-tracking); text-align: center; text-transform: var(--type-item-title-transform); appearance: textfield; transition: color 220ms ease, text-shadow 220ms ease; }
|
||||
.client-failover-number-setting input::-webkit-inner-spin-button, .client-failover-number-setting input::-webkit-outer-spin-button { margin: 0; -webkit-appearance: none; }
|
||||
.client-failover-number-setting input:disabled { color: var(--client-muted); opacity: .45; }
|
||||
.client-failover-global-actions > button:disabled { color: var(--client-muted); cursor: default; opacity: .42; }
|
||||
.client-failover-number-steps { display: inline-flex; align-items: baseline; gap: 10px; margin-left: .65ch; }
|
||||
.client-failover-number-steps button { min-width: 34px; padding: 5px 0; border: 0; background: transparent; color: var(--client-accent); font: var(--type-control); font-variant-numeric: var(--numeric-tabular); letter-spacing: var(--type-control-tracking); text-transform: var(--type-control-transform); cursor: pointer; }
|
||||
.client-failover-number-steps button:disabled, .client-failover-global-actions > button:disabled { color: var(--client-muted); cursor: default; opacity: .42; }
|
||||
.client-failover-services { display: grid; gap: 9px; margin: 0; padding: 0; border: 0; }
|
||||
.client-failover-services legend { width: 100%; margin-bottom: 14px; padding: 0; }
|
||||
.client-failover-section-header { display: grid; gap: 4px; margin-bottom: 12px; }
|
||||
@@ -84,7 +87,7 @@
|
||||
.client-failover-actions button { padding: 7px 0; border: 0; background: transparent; color: var(--client-accent); font: var(--type-control); letter-spacing: var(--type-control-tracking); text-transform: var(--type-control-transform); cursor: pointer; }
|
||||
.client-failover-actions small { flex-basis: 100%; margin-top: -14px; color: var(--client-muted); font: var(--type-label); letter-spacing: var(--type-label-tracking); text-transform: var(--type-label-transform); }
|
||||
.client-failover-actions button:disabled { color: var(--client-muted); cursor: default; opacity: .45; }
|
||||
.client-failover-actions button:focus-visible, .client-failover-service-editor button:focus-visible, .client-failover-discard button:focus-visible, .client-failover-global-actions > button:focus-visible { outline: 2px solid var(--client-accent); outline-offset: 2px; }
|
||||
.client-failover-actions button:focus-visible, .client-failover-service-editor button:focus-visible, .client-failover-discard button:focus-visible, .client-failover-global-actions > button:focus-visible, .client-failover-number-steps button:focus-visible { outline: 2px solid var(--client-accent); outline-offset: 2px; }
|
||||
.client-failover-form input:not(.client-failover-number-input):focus-visible { outline: 0; border-bottom-color: var(--client-accent); box-shadow: 0 1px 0 color-mix(in oklch, var(--client-accent) 60%, transparent); text-shadow: 0 0 9px color-mix(in oklch, var(--client-accent) 34%, transparent); }
|
||||
.client-failover-number-input:focus-visible { outline: 0; color: var(--client-accent); text-shadow: 0 0 9px color-mix(in oklch, var(--client-accent) 38%, transparent); }
|
||||
@keyframes failover-service-in { from { opacity: 0; filter: blur(5px); transform: translateY(-4px); } to { opacity: 1; filter: blur(0); transform: translateY(0); } }
|
||||
|
||||
Reference in New Issue
Block a user