@xeplr/ui-jobs 1.6.9 → 1.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/package.json +1 -1
- package/src/pages/Jobs.css +24 -0
- package/src/pages/Jobs.jsx +31 -0
- package/src/pages/multiPick.js +22 -0
package/README.md
CHANGED
|
@@ -121,6 +121,8 @@ Every call goes through `authFetch`, which prefixes the base URL `@xeplr/ui-acco
|
|
|
121
121
|
- **Recent runs** — the 12 latest runs across all jobs, with duration, trigger and error message.
|
|
122
122
|
- **Live updates** (on by default) — polls `GET /jobs/active` every **2 s** while anything runs and every **15 s** otherwise, so a cron run that starts by itself appears; when the last run finishes, the page reloads once to pick up the final status. Rows show rows read and when the run last made progress (`1.2K rows · last seen 8 s ago`); a run with no progress for **5 minutes** (`SILENT_MS`) reads "Not responding", because the work beats on every batch it moves. Uncheck to stop polling.
|
|
123
123
|
|
|
124
|
+
**On a phone** (below 640px) the search, sort and **New job** wrap onto their own lines instead of running off the edge, the table keeps scrolling sideways inside its own box, row buttons and the run-history expander become thumb-sized (40px / 32px), and the search and sort are 16px so iOS does not zoom the page. A job's description and raw cron are still in the row's tooltip, which a phone cannot show — open the job to read them.
|
|
125
|
+
|
|
124
126
|
State shows **Running** over **Paused**: a pause takes effect at the next pick, and "paused" over a live run invites starting a second one. A job with no schedule has its switch off and disabled — there is nothing for the scheduler to pick.
|
|
125
127
|
|
|
126
128
|
### The editor
|
|
@@ -185,6 +187,7 @@ registerJobsUI({
|
|
|
185
187
|
|
|
186
188
|
- **A kind with no source gets a plain text input.** An empty dropdown looks broken; a text box is what you have without a catalogue.
|
|
187
189
|
- A field with `dependsOn: 'connectionInfoId'` stays disabled until that field has a value, then requests `?connectionInfoId=<value>` and keeps only rows whose `connectionId` equals it.
|
|
190
|
+
- A field of `type: 'array'` with `optionsFrom` is **ticks**: several chosen at once, saved as a list (`["taskie", "taskie_jobs"]`), in the options' order. A saved value the source no longer offers stays ticked, marked "not offered now", so a save never drops it silently.
|
|
188
191
|
- A failed fetch says "Could not load the list" rather than showing an empty one.
|
|
189
192
|
|
|
190
193
|
## Other exports
|
package/package.json
CHANGED
package/src/pages/Jobs.css
CHANGED
|
@@ -422,3 +422,27 @@
|
|
|
422
422
|
.jb-caret { padding: 0; }
|
|
423
423
|
.jb-caret .jb-icon { transition: none; }
|
|
424
424
|
.jb-linkish { padding: 0; font: inherit; color: var(--accent, #2563eb); background: none; border: 0; cursor: pointer; text-decoration: underline; }
|
|
425
|
+
|
|
426
|
+
/* ── on a phone ──────────────────────────────────────────────────────────
|
|
427
|
+
The search, sort and New button wrap instead of running off the edge; the
|
|
428
|
+
table keeps scrolling sideways in its own box; every row button becomes a
|
|
429
|
+
target a thumb can hit; and fields are 16px, or iOS zooms the page on focus. */
|
|
430
|
+
@media (max-width: 640px) {
|
|
431
|
+
.jb-head h1 { font-size: 22px; }
|
|
432
|
+
.jb-head-tools { flex-wrap: wrap; }
|
|
433
|
+
.jb-search { flex: 1 1 100%; min-width: 0; }
|
|
434
|
+
.jb-search, .jb-sort { font-size: 16px; min-height: 44px; }
|
|
435
|
+
.jb-primary { min-height: 44px; }
|
|
436
|
+
.jb-row-actions button { width: 40px; height: 40px; }
|
|
437
|
+
.jb-caret { width: 32px; height: 32px; }
|
|
438
|
+
.jb-editor { padding: 16px; }
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/* A list chosen from the host's options (an 'array' input with optionsFrom): ticks. */
|
|
442
|
+
.jb-picks { border: 0; padding: 0; min-width: 0; }
|
|
443
|
+
.jb-picks legend { padding: 0; margin-bottom: 5px; }
|
|
444
|
+
.jb-picks-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 16px; max-height: 240px; overflow: auto; }
|
|
445
|
+
.jb-pick { display: flex; align-items: center; gap: 8px; min-width: 0; cursor: pointer; }
|
|
446
|
+
.jb-pick span { overflow-wrap: anywhere; }
|
|
447
|
+
.jb-pick input[type="checkbox"] { width: 16px; height: 16px; padding: 0; margin: 0; flex: none; accent-color: var(--accent, #2563eb); }
|
|
448
|
+
.jb-pick { font-weight: 400; }
|
package/src/pages/Jobs.jsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pickedOf, toggled } from './multiPick.js'
|
|
1
2
|
import { Fragment, useCallback, useEffect, useMemo, useState } from 'react'
|
|
2
3
|
import { fieldLabel, raiseConfirm, raiseSnackbar } from '@xeplr/ui-utils'
|
|
3
4
|
import { relativeTime } from './relativeTime.js'
|
|
@@ -399,6 +400,36 @@ function RemoteSelect({ field, value, onChange, dependsOnValue }) {
|
|
|
399
400
|
return () => { alive = false }
|
|
400
401
|
}, [field.optionsFrom, field.dependsOn, dependsOnValue])
|
|
401
402
|
|
|
403
|
+
// A LIST from the host's options (type 'array'): ticks, several at once.
|
|
404
|
+
if (field.type === 'array') {
|
|
405
|
+
const picked = pickedOf(value)
|
|
406
|
+
const waiting = field.dependsOn && !dependsOnValue
|
|
407
|
+
const shown = (options || []).concat(picked.filter((v) => !(options || []).some((o) => String(o.value) === v)).map((v) => ({ value: v, label: v + ' (not offered now)' })))
|
|
408
|
+
return (
|
|
409
|
+
<fieldset className="jb-field jb-field--wide jb-picks" id={id}>
|
|
410
|
+
<legend>{fieldLabel(field)}{field.required && <span className="jb-req"> *</span>}
|
|
411
|
+
{picked.length ? <span className="jb-type"> · {picked.length} chosen</span> : null}</legend>
|
|
412
|
+
{waiting ? <span className="jb-help">{`Choose ${field.dependsOn} first…`}</span>
|
|
413
|
+
: options === null ? <span className="jb-help">Loading…</span>
|
|
414
|
+
: !shown.length ? <span className="jb-help">Nothing to choose from</span>
|
|
415
|
+
: (
|
|
416
|
+
<div className="jb-picks-list">
|
|
417
|
+
{shown.map((o) => (
|
|
418
|
+
<label key={o.value} className="jb-pick">
|
|
419
|
+
<input type="checkbox" checked={picked.includes(String(o.value))}
|
|
420
|
+
onChange={() => onChange(toggled(picked, String(o.value), options))} />
|
|
421
|
+
<span>{o.label}</span>
|
|
422
|
+
</label>
|
|
423
|
+
))}
|
|
424
|
+
</div>
|
|
425
|
+
)}
|
|
426
|
+
{failed
|
|
427
|
+
? <span className="jb-help jb-warn">Could not load the list.</span>
|
|
428
|
+
: field.description && <span className="jb-help">{field.description}</span>}
|
|
429
|
+
</fieldset>
|
|
430
|
+
)
|
|
431
|
+
}
|
|
432
|
+
|
|
402
433
|
return (
|
|
403
434
|
<div className="jb-field">
|
|
404
435
|
<label htmlFor={id}>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// A LIST INPUT CHOSEN FROM A HOST'S OPTIONS — an action's field of type
|
|
2
|
+
// 'array' with `optionsFrom` (several databases for one backup job) is a set
|
|
3
|
+
// of ticks, not JSON to type. Pure: what is ticked, and ticking one.
|
|
4
|
+
|
|
5
|
+
/** What is ticked: the saved list, the form's JSON text of it, or nothing. */
|
|
6
|
+
export function pickedOf(value) {
|
|
7
|
+
if (Array.isArray(value)) return value.map(String)
|
|
8
|
+
if (typeof value !== 'string' || !value.trim()) return []
|
|
9
|
+
try {
|
|
10
|
+
const v = JSON.parse(value)
|
|
11
|
+
return Array.isArray(v) ? v.map(String) : []
|
|
12
|
+
} catch (e) {
|
|
13
|
+
return []
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Tick or untick one, keeping the options' order. */
|
|
18
|
+
export function toggled(picked, value, options) {
|
|
19
|
+
const on = picked.includes(value) ? picked.filter((v) => v !== value) : picked.concat([value])
|
|
20
|
+
const order = (options || []).map((o) => String(o.value))
|
|
21
|
+
return on.slice().sort((a, b) => (order.indexOf(a) + 1 || Infinity) - (order.indexOf(b) + 1 || Infinity))
|
|
22
|
+
}
|