@biolibs/bionet-panels 0.0.0-stage → 0.1.0
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 +55 -2
- package/dist/freezer.d.ts +21 -0
- package/dist/freezer.d.ts.map +1 -0
- package/dist/freezer.js +31 -0
- package/dist/freezer.js.map +1 -0
- package/dist/history.d.ts +14 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +47 -0
- package/dist/history.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/parts.d.ts +36 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +60 -0
- package/dist/parts.js.map +1 -0
- package/dist/people.d.ts +3 -0
- package/dist/people.d.ts.map +1 -0
- package/dist/people.js +14 -0
- package/dist/people.js.map +1 -0
- package/dist/sharing.d.ts +12 -0
- package/dist/sharing.d.ts.map +1 -0
- package/dist/sharing.js +34 -0
- package/dist/sharing.js.map +1 -0
- package/dist/window.d.ts +21 -0
- package/dist/window.d.ts.map +1 -0
- package/dist/window.js +71 -0
- package/dist/window.js.map +1 -0
- package/package.json +54 -4
- package/panels.css +55 -0
- package/src/freezer.tsx +99 -0
- package/src/history.tsx +68 -0
- package/src/index.ts +25 -0
- package/src/parts.tsx +78 -0
- package/src/people.tsx +50 -0
- package/src/sharing.tsx +69 -0
- package/src/window.tsx +134 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window.js","sourceRoot":"","sources":["../src/window.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAA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rB,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC;IACvB,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO,CACL,mBAAS,SAAS,EAAC,aAAa,aAC9B,gDAA6B,EAC7B,mLAA+J,EAC/J,KAAC,SAAS,IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAI,EACnC,KAAC,UAAU,IAAC,IAAI,EAAE,KAAK,CAAC,IAAI,GAAI,EAC/B,KAAK,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,IAAI,YAAG,SAAS,EAAC,WAAW,YAAE,KAAK,CAAC,IAAI,CAAC,OAAO,GAAK,IACzE,CACX,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
|
+
"bugs": {
|
|
3
|
+
"url": "https://github.com/matthewlovestocode/biolibs/issues"
|
|
4
|
+
},
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@biolibs/bionet": "^1.2.0",
|
|
7
|
+
"@biolibs/bionet-client": "^0.1.0",
|
|
8
|
+
"@biolibs/bionet-react": "^0.1.0"
|
|
9
|
+
},
|
|
10
|
+
"description": "The parts of a Bionet lab application, ready to place: the freezer, the people, the history, what other labs are shown, and a whole window that puts them together, in a light theme and a dark one",
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=20"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./panels.css": "./panels.css"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"src",
|
|
24
|
+
"panels.css"
|
|
25
|
+
],
|
|
26
|
+
"homepage": "https://github.com/matthewlovestocode/biolibs/tree/main/packages/bionet-panels#readme",
|
|
27
|
+
"keywords": [
|
|
28
|
+
"bionet",
|
|
29
|
+
"react",
|
|
30
|
+
"components",
|
|
31
|
+
"inventory",
|
|
32
|
+
"local-first",
|
|
33
|
+
"biology"
|
|
34
|
+
],
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"main": "dist/index.js",
|
|
2
37
|
"name": "@biolibs/bionet-panels",
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@biolibs/bionet-theme": "^0.1.0",
|
|
40
|
+
"react": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/matthewlovestocode/biolibs.git",
|
|
48
|
+
"directory": "packages/bionet-panels"
|
|
49
|
+
},
|
|
50
|
+
"sideEffects": [
|
|
51
|
+
"*.css"
|
|
52
|
+
],
|
|
53
|
+
"type": "module",
|
|
54
|
+
"types": "dist/index.d.ts",
|
|
55
|
+
"version": "0.1.0"
|
|
56
|
+
}
|
package/panels.css
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* The panels' styles. Every rule is inside .bionet, so nothing here reaches the page around it, and
|
|
2
|
+
every colour is one of the theme's variables, so it follows a light or dark theme. */
|
|
3
|
+
.bionet { background: var(--bionet-ground); color: var(--bionet-ink); height: 100%;
|
|
4
|
+
font: 14px/1.5 "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
|
|
5
|
+
.bionet * { box-sizing: border-box }
|
|
6
|
+
.bionet h1 { font-size: 1.35rem; margin: 0 } .bionet h2 { font-size: 1.02rem; margin: 0 0 .35rem }
|
|
7
|
+
.bionet p { margin: .35rem 0 .8rem }
|
|
8
|
+
.bionet code { font-family: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em }
|
|
9
|
+
.bionet .dim { color: var(--bionet-dim) } .bionet .small { font-size: .86rem } .bionet .nowrap { white-space: nowrap }
|
|
10
|
+
.bionet .wrap { display: block; overflow-wrap: anywhere }
|
|
11
|
+
.bionet .shell { display: flex; flex-direction: column; height: 100% }
|
|
12
|
+
.bionet header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.5rem .6rem }
|
|
13
|
+
.bionet header p { margin: .1rem 0 0 }
|
|
14
|
+
.bionet .title { display: flex; align-items: center; gap: .8rem } .bionet .title svg { display: block; flex: none }
|
|
15
|
+
.bionet nav { display: flex; gap: .25rem; padding: 0 1.5rem; border-bottom: 1px solid var(--bionet-rule) }
|
|
16
|
+
.bionet .tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--bionet-dim); padding: .55rem .8rem; font: inherit; cursor: pointer; border-radius: 0 }
|
|
17
|
+
.bionet .tab.on { color: var(--bionet-ink); border-bottom-color: var(--bionet-yours); font-weight: 600 }
|
|
18
|
+
.bionet main { flex: 1; overflow: auto; padding: 1.25rem 1.5rem 3rem }
|
|
19
|
+
.bionet main.centre { display: grid; place-content: center; justify-items: center; gap: 1rem; padding: 2rem; min-height: 100% }
|
|
20
|
+
.bionet .card { background: var(--bionet-surface); border: 1px solid var(--bionet-rule); border-radius: 10px; padding: 1.1rem 1.25rem; margin: 0 0 1rem }
|
|
21
|
+
.bionet .card.narrow { max-width: 34rem } .bionet .pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem; max-width: 60rem; width: 100% }
|
|
22
|
+
.bionet .empty { color: var(--bionet-dim); padding: 1.5rem 0; text-align: center }
|
|
23
|
+
.bionet fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: contents }
|
|
24
|
+
.bionet form.stack { display: grid; gap: .7rem; margin-top: .6rem }
|
|
25
|
+
.bionet form.row, .bionet .row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .6rem }
|
|
26
|
+
.bionet .row.tight { margin-top: 0; gap: .35rem; flex-wrap: nowrap }
|
|
27
|
+
.bionet label { display: grid; gap: .25rem; font-size: .86rem; color: var(--bionet-dim) }
|
|
28
|
+
.bionet label.check { display: flex; align-items: center; gap: .4rem; color: var(--bionet-ink) }
|
|
29
|
+
.bionet input, .bionet textarea, .bionet select { font: inherit; color: var(--bionet-ink); background: var(--bionet-field); border: 1px solid var(--bionet-rule); border-radius: 6px; padding: .4rem .55rem; min-width: 0 }
|
|
30
|
+
.bionet form.row input:not(.num):not([type=checkbox]) { flex: 1 }
|
|
31
|
+
.bionet textarea { font-family: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; resize: vertical }
|
|
32
|
+
.bionet input.num { width: 5.2rem } .bionet input[type=checkbox] { width: auto; accent-color: var(--bionet-yours) }
|
|
33
|
+
.bionet input:focus-visible, .bionet textarea:focus-visible, .bionet select:focus-visible, .bionet button:focus-visible { outline: 2px solid var(--bionet-yours); outline-offset: 1px }
|
|
34
|
+
.bionet button { font: inherit; border-radius: 6px; padding: .42rem .8rem; border: 1px solid var(--bionet-action); background: var(--bionet-action); color: var(--bionet-on-action); cursor: pointer; white-space: nowrap }
|
|
35
|
+
.bionet button.quiet { background: transparent; color: var(--bionet-ink); border-color: var(--bionet-rule) }
|
|
36
|
+
.bionet button.quiet:hover { border-color: var(--bionet-dim) }
|
|
37
|
+
.bionet button.plain { background: none; border: 0; color: var(--bionet-dim); text-decoration: underline; padding: 0 .3rem }
|
|
38
|
+
.bionet button:disabled, .bionet fieldset:disabled button { opacity: .55; cursor: default }
|
|
39
|
+
.bionet table { width: 100%; border-collapse: collapse; margin: .5rem 0 .2rem }
|
|
40
|
+
.bionet th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bionet-dim); font-weight: 600; padding: .3rem .5rem .3rem 0; border-bottom: 1px solid var(--bionet-rule) }
|
|
41
|
+
.bionet td { padding: .45rem .5rem .45rem 0; border-bottom: 1px solid var(--bionet-rule); vertical-align: middle }
|
|
42
|
+
.bionet tr:last-child td { border-bottom: 0 } .bionet tr.gone td { color: var(--bionet-dim) }
|
|
43
|
+
.bionet tr.flagged td { background: color-mix(in srgb, var(--bionet-attention) 9%, transparent) }
|
|
44
|
+
.bionet .parthead { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem } .bionet .parthead p { margin: 0 }
|
|
45
|
+
.bionet .badge { display: inline-block; margin-left: .5rem; padding: .05rem .45rem; border-radius: 999px; font-size: .74rem; border: 1px solid var(--bionet-attention); color: var(--bionet-attention) }
|
|
46
|
+
.bionet .badge.calm { border-color: var(--bionet-rule); color: var(--bionet-dim) }
|
|
47
|
+
.bionet .keybox { border: 1px dashed var(--bionet-rule); border-radius: 8px; padding: .7rem .8rem; margin: .8rem 0 }
|
|
48
|
+
.bionet .keybox > div { display: flex; justify-content: space-between; align-items: center; margin-bottom: .35rem } .bionet .keybox p { margin: .4rem 0 0 }
|
|
49
|
+
.bionet .label { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bionet-dim); font-weight: 600 }
|
|
50
|
+
.bionet .sync { display: flex; align-items: center; gap: .5rem; font-size: .86rem; color: var(--bionet-dim); white-space: nowrap }
|
|
51
|
+
.bionet .dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--bionet-dim) }
|
|
52
|
+
.bionet .dot.synced { background: var(--bionet-good) } .bionet .dot.syncing, .bionet .dot.connecting { background: var(--bionet-yours) }
|
|
53
|
+
.bionet .dot.waiting { background: var(--bionet-held) }
|
|
54
|
+
.bionet .trouble { background: color-mix(in srgb, var(--bionet-attention) 12%, transparent); border: 1px solid var(--bionet-attention); border-radius: 8px; padding: .55rem .8rem; display: flex; justify-content: space-between; gap: 1rem }
|
|
55
|
+
.bionet .note { border-left: 3px solid var(--bionet-held); padding: .1rem 0 .1rem .7rem; font-size: .9rem }
|
package/src/freezer.tsx
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/** The freezer: every part, its tubes, and what can be done to them. */
|
|
2
|
+
import type { ItemState, PartState } from "@biolibs/bionet";
|
|
3
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
4
|
+
import { Ask } from "./parts.js";
|
|
5
|
+
|
|
6
|
+
const whole = (data: FormData, name: string): number => Number(String(data.get(name) ?? "").trim());
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* How much of an item there is, with its unit.
|
|
10
|
+
*
|
|
11
|
+
* @param item - The item.
|
|
12
|
+
* @returns Something like `7 µL`.
|
|
13
|
+
*/
|
|
14
|
+
export const amountOf = (item: Pick<ItemState, "amount" | "unit">): string => `${item.amount}${item.unit === null ? "" : ` ${item.unit}`}`;
|
|
15
|
+
|
|
16
|
+
/** Every part with its tubes, and a form to add a part. Draws nothing until the lab has arrived. */
|
|
17
|
+
export function Freezer() {
|
|
18
|
+
const lab = useLab()?.lab;
|
|
19
|
+
const act = useAct();
|
|
20
|
+
if (lab === null || lab === undefined) return null;
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
{lab.parts.length === 0 && <p className="empty">Nothing in the freezer yet. Add the first part below.</p>}
|
|
24
|
+
{lab.parts.map((part) => <PartCard key={part.checksum} part={part} items={lab.items.filter((item) => item.part === part.checksum)} />)}
|
|
25
|
+
<section className="card">
|
|
26
|
+
<h2>Add a part</h2>
|
|
27
|
+
<p className="dim small">A part is a molecule, known by the checksum of its sequence. Two people adding the same sequence get the same part, whatever each calls it.</p>
|
|
28
|
+
<Ask onAsk={(data) => act("addPart", { name: String(data.get("name") ?? ""), sequence: String(data.get("sequence") ?? ""), circular: data.get("circular") === "on" })} className="stack">
|
|
29
|
+
<label>Name<input name="name" placeholder="pUC19" required maxLength={200} /></label>
|
|
30
|
+
<label>Sequence<textarea name="sequence" placeholder="GGATCACAGTCTACACTGCTCACTCC…" required rows={3} spellCheck={false} /></label>
|
|
31
|
+
<label className="check"><input type="checkbox" name="circular" /> It is a circle</label>
|
|
32
|
+
<button type="submit">Add part</button>
|
|
33
|
+
</Ask>
|
|
34
|
+
</section>
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** One part and its tubes. */
|
|
40
|
+
export function PartCard({ part, items }: { part: PartState; items: ItemState[] }) {
|
|
41
|
+
const act = useAct();
|
|
42
|
+
const live = items.filter((item) => !item.retired);
|
|
43
|
+
return (
|
|
44
|
+
<section className="card part">
|
|
45
|
+
<div className="parthead">
|
|
46
|
+
<div>
|
|
47
|
+
<h2>{part.name}</h2>
|
|
48
|
+
<p className="dim small">{part.length} bp{part.circular ? " · circular" : ""} · <code>{part.checksum.slice(0, 26)}…</code></p>
|
|
49
|
+
</div>
|
|
50
|
+
<label className="check" title="Whether other labs are told this part can be asked for">
|
|
51
|
+
<input type="checkbox" checked={part.offered} onChange={(event) => void act("offer", { part: part.checksum, available: event.target.checked })} />
|
|
52
|
+
On offer to other labs
|
|
53
|
+
</label>
|
|
54
|
+
</div>
|
|
55
|
+
{live.length === 0 ? <p className="dim small">No tubes of this.</p> : (
|
|
56
|
+
<table>
|
|
57
|
+
<thead><tr><th>Tube</th><th>Amount</th><th>Use or add</th><th>Count</th><th /></tr></thead>
|
|
58
|
+
<tbody>{live.map((item) => <ItemRow key={item.item} item={item} />)}</tbody>
|
|
59
|
+
</table>
|
|
60
|
+
)}
|
|
61
|
+
<Ask onAsk={(data) => act("addItem", { part: part.checksum, amount: whole(data, "amount"), unit: String(data.get("unit") ?? "") })} className="row tight">
|
|
62
|
+
<input name="amount" type="number" min={0} step={1} placeholder="Amount" required />
|
|
63
|
+
<input name="unit" placeholder="Unit, e.g. µL" maxLength={20} />
|
|
64
|
+
<button type="submit" className="quiet">Add a tube</button>
|
|
65
|
+
</Ask>
|
|
66
|
+
</section>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** One tube: how much there is, and the ways to change that. */
|
|
71
|
+
export function ItemRow({ item }: { item: ItemState }) {
|
|
72
|
+
const act = useAct();
|
|
73
|
+
return (
|
|
74
|
+
<tr className={item.needsRecount ? "flagged" : undefined}>
|
|
75
|
+
<td><code>{item.item.slice(0, 10)}…</code></td>
|
|
76
|
+
<td>
|
|
77
|
+
<strong>{amountOf(item)}</strong>
|
|
78
|
+
{item.needsRecount && <span className="badge" title="The log has lost track of this tube: it went below zero, or two people counted it at once.">needs a count</span>}
|
|
79
|
+
</td>
|
|
80
|
+
<td>
|
|
81
|
+
<div className="row tight">
|
|
82
|
+
<button type="button" className="quiet" onClick={() => void act("adjust", { item: item.item, by: -1 })}>−1</button>
|
|
83
|
+
<button type="button" className="quiet" onClick={() => void act("adjust", { item: item.item, by: 1 })}>+1</button>
|
|
84
|
+
<Ask onAsk={(data) => act("adjust", { item: item.item, by: whole(data, "by") })} className="row tight">
|
|
85
|
+
<input name="by" type="number" step={1} placeholder="±" required className="num" aria-label="Change by" />
|
|
86
|
+
<button type="submit" className="quiet">Apply</button>
|
|
87
|
+
</Ask>
|
|
88
|
+
</div>
|
|
89
|
+
</td>
|
|
90
|
+
<td>
|
|
91
|
+
<Ask onAsk={(data) => act("recount", { item: item.item, amount: whole(data, "amount") })} className="row tight">
|
|
92
|
+
<input name="amount" type="number" min={0} step={1} placeholder="There is" required className="num" aria-label="Amount there is" />
|
|
93
|
+
<button type="submit" className="quiet">Set</button>
|
|
94
|
+
</Ask>
|
|
95
|
+
</td>
|
|
96
|
+
<td><button type="button" className="plain" onClick={() => void act("retire", { item: item.item })}>retire</button></td>
|
|
97
|
+
</tr>
|
|
98
|
+
);
|
|
99
|
+
}
|
package/src/history.tsx
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** The history: every signed change, and what became of it. */
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import type { EntryView, LabView } from "@biolibs/bionet-client";
|
|
4
|
+
import { useLab } from "@biolibs/bionet-react";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What one change was, in words.
|
|
8
|
+
*
|
|
9
|
+
* @param entry - The change.
|
|
10
|
+
* @param lab - The lab, to name the parts, tubes and people it refers to.
|
|
11
|
+
* @returns A phrase that follows the name of whoever made it, like `used 2 µL of a tube of f1`.
|
|
12
|
+
*/
|
|
13
|
+
export function describeEntry(entry: Pick<EntryView, "op">, lab: Pick<LabView, "parts" | "items" | "roster">): string {
|
|
14
|
+
const op = entry.op;
|
|
15
|
+
const part = (checksum: unknown): string => lab.parts.find((one) => one.checksum === checksum)?.name ?? "a part";
|
|
16
|
+
const tube = (id: unknown): string => {
|
|
17
|
+
const item = lab.items.find((one) => one.item === id);
|
|
18
|
+
return item === undefined ? "a tube" : `a tube of ${part(item.part)}`;
|
|
19
|
+
};
|
|
20
|
+
const unit = (id: unknown): string => lab.items.find((one) => one.item === id)?.unit ?? "";
|
|
21
|
+
const who = (key: unknown): string => lab.roster.find((one) => one.key === key)?.person ?? "a device";
|
|
22
|
+
const tidy = (words: string): string => words.replace(/\s+/g, " ").trim();
|
|
23
|
+
switch (op.type) {
|
|
24
|
+
case "roster.found": return `founded ${String(op["name"])}`;
|
|
25
|
+
case "roster.add": return `added ${String(op["person"])} as a ${String(op["role"])}`;
|
|
26
|
+
case "roster.remove": return `removed ${who(op["key"])}`;
|
|
27
|
+
case "roster.role": return `made ${who(op["key"])} a ${String(op["role"])}`;
|
|
28
|
+
case "part.add": return `added the part ${String(op["name"])}`;
|
|
29
|
+
case "part.offer": return op["available"] === true ? `put ${part(op["part"])} on offer` : `took ${part(op["part"])} off offer`;
|
|
30
|
+
case "item.add": return tidy(`added ${tube(op["item"])}, ${String(op["amount"])} ${String(op["unit"] ?? "")}`);
|
|
31
|
+
case "item.adjust": return tidy(`${Number(op["by"]) < 0 ? "used" : "added"} ${Math.abs(Number(op["by"]))} ${unit(op["item"])} ${Number(op["by"]) < 0 ? "of" : "to"} ${tube(op["item"])}`);
|
|
32
|
+
case "item.recount": return tidy(`counted ${String(op["amount"])} ${unit(op["item"])} in ${tube(op["item"])}`);
|
|
33
|
+
case "item.retire": return `retired ${tube(op["item"])}`;
|
|
34
|
+
case "field.set": return `set ${String(op["field"])} to ${String(op["value"])}`;
|
|
35
|
+
default: return `did something this version does not know (${op.type})`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Every change, newest first, with what became of each. Draws nothing until the lab has arrived. */
|
|
40
|
+
export function History({ first = 40 }: { first?: number }) {
|
|
41
|
+
const lab = useLab()?.lab;
|
|
42
|
+
const [all, setAll] = useState(false);
|
|
43
|
+
if (lab === null || lab === undefined) return null;
|
|
44
|
+
const newest = [...lab.entries].reverse();
|
|
45
|
+
const shown = all ? newest : newest.slice(0, first);
|
|
46
|
+
return (
|
|
47
|
+
<section className="card">
|
|
48
|
+
<h2>Everything that has happened</h2>
|
|
49
|
+
<p className="dim small">Each line is one signed change. The time is what the signer's computer said, which is a claim; the order is worked out from what each person had seen.</p>
|
|
50
|
+
{lab.overlaps.length > 0 && <p className="note">{lab.overlaps.length} {lab.overlaps.length === 1 ? "pair of changes was" : "pairs of changes were"} made without knowledge of each other. One of each stood; both are below.</p>}
|
|
51
|
+
{lab.waiting > 0 && <p className="note">{lab.waiting} {lab.waiting === 1 ? "change is" : "changes are"} waiting on others that have not arrived yet.</p>}
|
|
52
|
+
<table>
|
|
53
|
+
<thead><tr><th>When</th><th>Who</th><th>What</th><th /></tr></thead>
|
|
54
|
+
<tbody>
|
|
55
|
+
{shown.map((entry) => (
|
|
56
|
+
<tr key={entry.id} className={entry.status === "applied" ? undefined : "gone"}>
|
|
57
|
+
<td className="dim nowrap">{new Date(entry.signedAt).toLocaleString(undefined, { dateStyle: "medium", timeStyle: "short" })}</td>
|
|
58
|
+
<td>{entry.signer ?? lab.roster.find((one) => one.key === entry.author)?.person ?? "unknown"}</td>
|
|
59
|
+
<td>{describeEntry(entry, lab)}</td>
|
|
60
|
+
<td>{entry.status !== "applied" && <span className="badge" title={entry.reason ?? ""}>{entry.status}</span>}</td>
|
|
61
|
+
</tr>
|
|
62
|
+
))}
|
|
63
|
+
</tbody>
|
|
64
|
+
</table>
|
|
65
|
+
{!all && newest.length > shown.length && <button type="button" className="quiet" onClick={() => setAll(true)}>Show all {newest.length}</button>}
|
|
66
|
+
</section>
|
|
67
|
+
);
|
|
68
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* `@biolibs/bionet-panels`: the parts of a Bionet lab application, ready to place.
|
|
4
|
+
*
|
|
5
|
+
* Each panel reads the lab through `@biolibs/bionet-react`, so it goes anywhere inside a
|
|
6
|
+
* `LabProvider`, and takes its colours from `@biolibs/bionet-theme`, so it follows a light or dark
|
|
7
|
+
* theme. `LabWindow` is all of them put together: a whole application in one component.
|
|
8
|
+
*
|
|
9
|
+
* Import `@biolibs/bionet-theme/theme.css` and `@biolibs/bionet-panels/panels.css` once. The panels'
|
|
10
|
+
* styles apply only inside an element with the class `bionet`, which `LabWindow` supplies; put a
|
|
11
|
+
* panel used on its own inside one.
|
|
12
|
+
*
|
|
13
|
+
* - `window.tsx` — `LabWindow`, and the screens before there is a lab
|
|
14
|
+
* - `freezer.tsx` — parts, tubes, amounts
|
|
15
|
+
* - `people.tsx` — the roster, and letting somebody in
|
|
16
|
+
* - `history.tsx` — every signed change, and what became of it
|
|
17
|
+
* - `sharing.tsx` — what other labs are shown, and the lab's web peer
|
|
18
|
+
* - `parts.tsx` — the small pieces they are made of
|
|
19
|
+
*/
|
|
20
|
+
export * from "./window.js";
|
|
21
|
+
export * from "./freezer.js";
|
|
22
|
+
export * from "./people.js";
|
|
23
|
+
export * from "./history.js";
|
|
24
|
+
export * from "./sharing.js";
|
|
25
|
+
export * from "./parts.js";
|
package/src/parts.tsx
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** The small pieces the panels are made of. */
|
|
2
|
+
import { createContext, useContext, useState, type FormEvent, type ReactNode } from "react";
|
|
3
|
+
import type { LabSnapshot, PeerView } from "@biolibs/bionet-client";
|
|
4
|
+
import { useTrouble } from "@biolibs/bionet-react";
|
|
5
|
+
|
|
6
|
+
/** How to put words on the clipboard. A host that cannot use the browser's own way supplies one. */
|
|
7
|
+
export const CopyContext = createContext<(words: string) => Promise<void>>((words) => navigator.clipboard.writeText(words));
|
|
8
|
+
|
|
9
|
+
/** A form that asks for one thing and clears itself if it worked. */
|
|
10
|
+
export function Ask({ onAsk, children, className }: { onAsk: (data: FormData) => Promise<{ ok: boolean }>; children: ReactNode; className?: string }) {
|
|
11
|
+
const [busy, setBusy] = useState(false);
|
|
12
|
+
const submit = async (event: FormEvent<HTMLFormElement>) => {
|
|
13
|
+
event.preventDefault();
|
|
14
|
+
const form = event.currentTarget;
|
|
15
|
+
setBusy(true);
|
|
16
|
+
const { ok } = await onAsk(new FormData(form));
|
|
17
|
+
setBusy(false);
|
|
18
|
+
if (ok) form.reset();
|
|
19
|
+
};
|
|
20
|
+
return <form className={className} onSubmit={submit} aria-busy={busy}><fieldset disabled={busy}>{children}</fieldset></form>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A button that copies some words and says that it did. */
|
|
24
|
+
export function Copy({ words, label = "Copy" }: { words: string; label?: string }) {
|
|
25
|
+
const copy = useContext(CopyContext);
|
|
26
|
+
const [done, setDone] = useState(false);
|
|
27
|
+
return (
|
|
28
|
+
<button type="button" className="quiet" onClick={() => { void copy(words).then(() => { setDone(true); setTimeout(() => setDone(false), 1500); }); }}>
|
|
29
|
+
{done ? "Copied" : label}
|
|
30
|
+
</button>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The last change that was refused, with a way to put it away. Draws nothing when there is none. */
|
|
35
|
+
export function Trouble() {
|
|
36
|
+
const { trouble, dismiss } = useTrouble();
|
|
37
|
+
if (trouble === null) return null;
|
|
38
|
+
return <p role="alert" className="trouble">{trouble}<button type="button" className="plain" onClick={dismiss}>dismiss</button></p>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* How the connection to the lab's peer is going, in the words a person would want.
|
|
43
|
+
*
|
|
44
|
+
* @param peer - The connection.
|
|
45
|
+
* @returns One line.
|
|
46
|
+
*/
|
|
47
|
+
export function syncWords(peer: PeerView): string {
|
|
48
|
+
const waiting = peer.pending === 0 ? "" : ` · ${peer.pending} ${peer.pending === 1 ? "change" : "changes"} to send`;
|
|
49
|
+
if (peer.url === null) return "No peer set · working on this device only";
|
|
50
|
+
switch (peer.status) {
|
|
51
|
+
case "synced": return "In step with the lab";
|
|
52
|
+
case "syncing": return "Syncing…";
|
|
53
|
+
case "connecting": return `Reaching the lab's peer…${waiting}`;
|
|
54
|
+
case "waiting": return "Waiting to be let in";
|
|
55
|
+
default: return `Offline${waiting}`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A dot and a line saying how the connection to the lab's peer is going. */
|
|
60
|
+
export function SyncStatus({ peer }: { peer: PeerView }) {
|
|
61
|
+
return (
|
|
62
|
+
<div className="sync" title={peer.problem ?? peer.url ?? ""}>
|
|
63
|
+
<span className={`dot ${peer.url === null ? "offline" : peer.status}`} />
|
|
64
|
+
<span>{syncWords(peer)}</span>
|
|
65
|
+
</div>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** This device's key, to be sent to a keeper. */
|
|
70
|
+
export function DeviceKey({ device }: { device: LabSnapshot["device"] }) {
|
|
71
|
+
return (
|
|
72
|
+
<div className="keybox">
|
|
73
|
+
<div><span className="label">This device's key</span><Copy words={device.key} label="Copy key" /></div>
|
|
74
|
+
<code className="wrap">{device.key}</code>
|
|
75
|
+
<p className="dim small">Fingerprint <code>{device.fingerprint}</code>. It is safe to send: it lets a lab recognise this device, and nothing else.</p>
|
|
76
|
+
</div>
|
|
77
|
+
);
|
|
78
|
+
}
|
package/src/people.tsx
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** The people: who is in the lab, and letting somebody in. */
|
|
2
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
3
|
+
import { Ask, Copy } from "./parts.js";
|
|
4
|
+
|
|
5
|
+
/** The roster, and for a keeper the way to add somebody. Draws nothing until the lab has arrived. */
|
|
6
|
+
export function People() {
|
|
7
|
+
const state = useLab();
|
|
8
|
+
const act = useAct();
|
|
9
|
+
const lab = state?.lab;
|
|
10
|
+
if (state === null || lab === null || lab === undefined) return null;
|
|
11
|
+
return (
|
|
12
|
+
<>
|
|
13
|
+
<section className="card">
|
|
14
|
+
<h2>Who is in the lab</h2>
|
|
15
|
+
<table>
|
|
16
|
+
<thead><tr><th>Person</th><th>Role</th><th>Device</th><th /></tr></thead>
|
|
17
|
+
<tbody>
|
|
18
|
+
{lab.roster.map((one) => (
|
|
19
|
+
<tr key={one.key} className={one.removed === null ? undefined : "gone"}>
|
|
20
|
+
<td>{one.person}{one.you && <span className="badge calm">this device</span>}</td>
|
|
21
|
+
<td>{one.removed !== null ? "removed" : one.founder ? "keeper · founder" : one.role}</td>
|
|
22
|
+
<td><code>{one.fingerprint}</code></td>
|
|
23
|
+
<td>{one.removed !== null && <span className="dim small">log kept up to entry {one.removed.cutoff + 1}</span>}</td>
|
|
24
|
+
</tr>
|
|
25
|
+
))}
|
|
26
|
+
</tbody>
|
|
27
|
+
</table>
|
|
28
|
+
<p className="dim small">A device is known by its key. One person with two computers appears twice, once for each.</p>
|
|
29
|
+
</section>
|
|
30
|
+
{lab.keeper ? (
|
|
31
|
+
<section className="card">
|
|
32
|
+
<h2>Add somebody</h2>
|
|
33
|
+
<p className="dim small">Ask them for their device's key, add it here, and send them the invitation. Their app fills in once this change has reached the lab's peer.</p>
|
|
34
|
+
<Ask onAsk={(data) => act("addMember", { key: String(data.get("key") ?? ""), person: String(data.get("person") ?? ""), role: String(data.get("role") ?? "member") })} className="stack">
|
|
35
|
+
<label>Their device's key<input name="key" placeholder="43 letters and digits" required spellCheck={false} /></label>
|
|
36
|
+
<label>Their name<input name="person" required maxLength={200} /></label>
|
|
37
|
+
<label>As<select name="role"><option value="member">a member, who can change the freezer</option><option value="keeper">a keeper, who can also change who is in the lab</option></select></label>
|
|
38
|
+
<button type="submit">Add to the lab</button>
|
|
39
|
+
</Ask>
|
|
40
|
+
{state.peer.invite !== null ? (
|
|
41
|
+
<div className="keybox">
|
|
42
|
+
<div><span className="label">Invitation to send them</span><Copy words={state.peer.invite} label="Copy invitation" /></div>
|
|
43
|
+
<code className="wrap">{state.peer.invite}</code>
|
|
44
|
+
</div>
|
|
45
|
+
) : <p className="dim small">Set the lab's web peer under Sharing to have an invitation to send.</p>}
|
|
46
|
+
</section>
|
|
47
|
+
) : <p className="dim small">Only a keeper can change who is in the lab.</p>}
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
50
|
+
}
|
package/src/sharing.tsx
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** Sharing: what other labs are shown, and the lab's web peer. */
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import type { ItemState, PartState } from "@biolibs/bionet";
|
|
4
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
5
|
+
import { Ask, Copy } from "./parts.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The parts other labs would be shown: those with a tube that has not been retired and is not empty.
|
|
9
|
+
*
|
|
10
|
+
* @param parts - Every part.
|
|
11
|
+
* @param items - Every item.
|
|
12
|
+
* @returns The parts that would be listed, in order.
|
|
13
|
+
*/
|
|
14
|
+
export function listedParts(parts: readonly PartState[], items: readonly ItemState[]): PartState[] {
|
|
15
|
+
const inStock = new Set(items.filter((item) => !item.retired && item.amount > 0).map((item) => item.part));
|
|
16
|
+
return parts.filter((part) => inStock.has(part.checksum));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** What would be published, a button to publish it, and the peer's settings. Draws nothing until the lab has arrived. */
|
|
20
|
+
export function Sharing() {
|
|
21
|
+
const state = useLab();
|
|
22
|
+
const act = useAct();
|
|
23
|
+
const [said, setSaid] = useState<string | null>(null);
|
|
24
|
+
const lab = state?.lab;
|
|
25
|
+
if (state === null || lab === null || lab === undefined) return null;
|
|
26
|
+
const listed = listedParts(lab.parts, lab.items);
|
|
27
|
+
const publish = async () => {
|
|
28
|
+
setSaid("Publishing…");
|
|
29
|
+
const answer = await act("publish");
|
|
30
|
+
const result = answer.ok ? (answer.result as { ok: boolean; reason: string | null; parts: number }) : { ok: false, reason: answer.error, parts: 0 };
|
|
31
|
+
setSaid(result.ok ? `Published: ${result.parts} ${result.parts === 1 ? "part" : "parts"}, signed by this device.` : `Not published. ${result.reason ?? ""}`);
|
|
32
|
+
};
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
<section className="card">
|
|
36
|
+
<h2>What other labs are shown</h2>
|
|
37
|
+
<p className="dim small">Only this: which parts the lab has in stock, and whether each can be asked for. Tubes, amounts and who did what stay inside the lab.</p>
|
|
38
|
+
{listed.length === 0 ? <p className="dim">Nothing would be listed: no part has a tube with anything in it.</p> : (
|
|
39
|
+
<table>
|
|
40
|
+
<thead><tr><th>Part</th><th>Length</th><th>Other labs may ask for it</th></tr></thead>
|
|
41
|
+
<tbody>{listed.map((part) => <tr key={part.checksum}><td>{part.name}</td><td>{part.length} bp</td><td>{part.offered ? "yes" : "no"}</td></tr>)}</tbody>
|
|
42
|
+
</table>
|
|
43
|
+
)}
|
|
44
|
+
<div className="row">
|
|
45
|
+
<button type="button" onClick={() => void publish()} disabled={state.peer.url === null}>Publish this</button>
|
|
46
|
+
{said !== null && <span className="small">{said}</span>}
|
|
47
|
+
</div>
|
|
48
|
+
<p className="dim small">
|
|
49
|
+
{state.peer.origin === null ? "Set the lab's web peer below to have somewhere to publish." : <>Published at <code>{state.peer.origin}/.well-known/bionet.json</code>, signed by this device's key.</>}
|
|
50
|
+
{state.published !== null && <> Last published from this device {new Date(state.published).toLocaleString()}.</>}
|
|
51
|
+
</p>
|
|
52
|
+
</section>
|
|
53
|
+
<section className="card">
|
|
54
|
+
<h2>The lab's web peer</h2>
|
|
55
|
+
<p className="dim small">A server at the lab's address that holds a copy of the lab and passes changes between members who are never online together. It has no key, so it cannot change anything.</p>
|
|
56
|
+
<Ask onAsk={(data) => act("setPeer", String(data.get("peer") ?? ""))} className="row">
|
|
57
|
+
<input name="peer" placeholder="wss://your-lab.example/sync" defaultValue={state.peer.url ?? ""} spellCheck={false} />
|
|
58
|
+
<button type="submit" className="quiet">Use this peer</button>
|
|
59
|
+
</Ask>
|
|
60
|
+
{state.peer.problem !== null && <p className="note">{state.peer.problem}</p>}
|
|
61
|
+
<div className="keybox">
|
|
62
|
+
<div><span className="label">This lab's ID</span>{lab.id !== null && <Copy words={lab.id} label="Copy ID" />}</div>
|
|
63
|
+
<code className="wrap">{lab.id}</code>
|
|
64
|
+
<p className="dim small">Whoever runs the lab's peer sets this as <code>BIONET_LAB</code>, so that it serves this lab and no other.</p>
|
|
65
|
+
</div>
|
|
66
|
+
</section>
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
}
|