summaryrefslogtreecommitdiff
path: root/public/App.js
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-21 16:06:48 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-21 16:06:48 +0800
commit8a1e79e46605291234314bd1a02dcab7a8c9bdc1 (patch)
tree4ee6e820a07f6ce52ccddf6fb7ffe2d26fa86f8c /public/App.js
parentd2a4cb4e645979f20c22a5c46c1c767db460f54a (diff)
downloadsomhairles-dream-fsharp-8a1e79e46605291234314bd1a02dcab7a8c9bdc1.tar.gz
feat(ui): replace id form with clickable model library cards
Diffstat (limited to 'public/App.js')
-rw-r--r--public/App.js47
1 files changed, 41 insertions, 6 deletions
diff --git a/public/App.js b/public/App.js
index 4716bb3..f63ae7e 100644
--- a/public/App.js
+++ b/public/App.js
@@ -6,7 +6,7 @@ import { sortBy, map, equalsWith, tryFind, iterateIndexed, item } from "./fable_
import { join, isNullOrWhiteSpace, printf, toText } from "./fable_modules/fable-library-js.4.24.0/String.js";
import { MeshData_triangleIndices, MeshData_positionData } from "./SomhairlesDream.Shared/Domain.js";
import { min, max } from "./fable_modules/fable-library-js.4.24.0/Double.js";
-import { defaultArg } from "./fable_modules/fable-library-js.4.24.0/Option.js";
+import { some, defaultArg } from "./fable_modules/fable-library-js.4.24.0/Option.js";
import { awaitPromise, startImmediate } from "./fable_modules/fable-library-js.4.24.0/Async.js";
import { singleton } from "./fable_modules/fable-library-js.4.24.0/AsyncBuilder.js";
@@ -867,8 +867,29 @@ export function inputValue(id) {
return element(id).value;
}
+export const probeSelection = new RunSelection("probe-001", "run-probe-real-2", "probe-base-000", "probe-target-007", false);
+
+export const shipSelection = new RunSelection("ship-001", "run-ship-001", "ship-base-000", "ship-target-007", false);
+
+export let activeModel = createAtom(probeSelection);
+
export function selectedRun() {
- return new RunSelection(inputValue("project-id-input"), inputValue("run-id-input"), inputValue("base-id-input"), inputValue("target-id-input"), element("run-render-input").checked);
+ return activeModel();
+}
+
+export function highlightActiveCard(selection) {
+ const library = element("model-library");
+ for (let index = 0; index <= (library.children.length - 1); index++) {
+ const card = library.children.item(some(index));
+ if (card.classList.contains("model-card")) {
+ if ((card.getAttribute("data-project") === selection.ProjectId) && (card.getAttribute("data-run") === selection.RunId)) {
+ card.classList.add("is-active");
+ }
+ else {
+ card.classList.remove("is-active");
+ }
+ }
+ }
}
export function freshLiveRunId(base_) {
@@ -993,6 +1014,14 @@ export function loadBootHistory() {
loadHistoryFor(selectedRun());
}
+export function selectModel(card) {
+ const selection = new RunSelection(card.getAttribute("data-project"), card.getAttribute("data-run"), card.getAttribute("data-base"), card.getAttribute("data-target"), false);
+ activeModel(selection);
+ highlightActiveCard(selection);
+ setText("run-message", "载入模型历史");
+ loadHistoryFor(selection);
+}
+
export function boot() {
showFrameMetadata(item(0, frames));
try {
@@ -1010,10 +1039,16 @@ export function boot() {
element("viewport-note").addEventListener("click", (_arg_2) => {
retryFailedLoad();
});
- element("run-controls").addEventListener("submit", (event) => {
- event.preventDefault();
- startRun(selectionForLiveStart(selectedRun()));
- });
+ const library = element("model-library");
+ for (let index = 0; index <= (library.children.length - 1); index++) {
+ const card = library.children.item(some(index));
+ if (card.classList.contains("model-card")) {
+ card.addEventListener("click", (_arg_3) => {
+ selectModel(card);
+ });
+ }
+ }
+ highlightActiveCard(activeModel());
loadBootHistory();
renderTimeline();
}