mirror of
https://github.com/gnmyt/myspeed.git
synced 2026-02-10 15:49:42 -06:00
Add scheduleOffset to FrequencyDialog.jsx
This commit is contained in:
@@ -34,6 +34,7 @@ export const FrequencyDialog = ({open, onClose}) => {
|
||||
return preset ? preset.id : "custom";
|
||||
});
|
||||
const [customCron, setCustomCron] = useState(config.cron || "0 * * * *");
|
||||
const [scheduleOffset, setScheduleOffset] = useState(config.scheduleOffset === "true");
|
||||
const [showAdvanced, setShowAdvanced] = useState(isCustomPreset);
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
@@ -47,10 +48,11 @@ export const FrequencyDialog = ({open, onClose}) => {
|
||||
if (!cronValue || !getNextRun(cronValue)) return;
|
||||
|
||||
setSaving(true);
|
||||
const res = await patchRequest("/config/cron", {value: cronValue});
|
||||
const cronRes = await patchRequest("/config/cron", {value: cronValue});
|
||||
const offsetRes = await patchRequest("/config/scheduleOffset", {value: scheduleOffset ? "true" : "false"});
|
||||
setSaving(false);
|
||||
|
||||
if (res.ok) {
|
||||
if (cronRes.ok && offsetRes.ok) {
|
||||
updateToast(t("dropdown.changes_applied"), "green", faCheck);
|
||||
reloadConfig();
|
||||
close();
|
||||
@@ -106,6 +108,16 @@ export const FrequencyDialog = ({open, onClose}) => {
|
||||
{nextRun && <p className="frequency-next-run">{t("update.cron_next_test")} {nextRun}</p>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="frequency-option" onClick={() => setScheduleOffset(!scheduleOffset)}>
|
||||
<div className={`frequency-toggle${scheduleOffset ? " frequency-toggle-active" : ""}`}>
|
||||
<div className="frequency-toggle-knob"/>
|
||||
</div>
|
||||
<div className="frequency-option-text">
|
||||
<h3>{t("update.schedule_offset")}</h3>
|
||||
<p>{t("update.schedule_offset_desc")}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DialogBody>
|
||||
<DialogFooter>
|
||||
|
||||
@@ -125,3 +125,57 @@
|
||||
font-size: 0.85rem
|
||||
color: $subtext
|
||||
text-align: center
|
||||
|
||||
.frequency-option
|
||||
display: flex
|
||||
align-items: center
|
||||
gap: 0.875rem
|
||||
margin-top: 1rem
|
||||
padding: 0.875rem 1rem
|
||||
border-radius: 0.75rem
|
||||
border: 1px solid $light-gray
|
||||
cursor: pointer
|
||||
transition: all 0.15s ease
|
||||
|
||||
&:hover
|
||||
background-color: $darker-gray
|
||||
|
||||
.frequency-option-text
|
||||
flex: 1
|
||||
|
||||
h3
|
||||
margin: 0
|
||||
font-size: 0.95rem
|
||||
font-weight: 500
|
||||
color: $subtext
|
||||
|
||||
p
|
||||
margin: 0.15rem 0 0
|
||||
font-size: 0.8rem
|
||||
color: $subtext
|
||||
opacity: 0.7
|
||||
|
||||
.frequency-toggle
|
||||
width: 42px
|
||||
height: 24px
|
||||
background-color: $light-gray
|
||||
border-radius: 12px
|
||||
position: relative
|
||||
transition: background-color 0.2s ease
|
||||
flex-shrink: 0
|
||||
|
||||
.frequency-toggle-knob
|
||||
width: 20px
|
||||
height: 20px
|
||||
background-color: $white
|
||||
border-radius: 50%
|
||||
position: absolute
|
||||
top: 2px
|
||||
left: 2px
|
||||
transition: transform 0.2s ease
|
||||
|
||||
.frequency-toggle-active
|
||||
background-color: $accent-primary
|
||||
|
||||
.frequency-toggle-knob
|
||||
transform: translateX(18px)
|
||||
|
||||
Reference in New Issue
Block a user