From 2df162b085e49d28bfe40bef7a270ff833ba2bc8 Mon Sep 17 00:00:00 2001 From: jgunstone Date: Wed, 28 May 2025 17:00:03 +0100 Subject: [PATCH 1/5] add system filters --- .../dashboard/src/index.md | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/packages/document-issue-data/dashboard/src/index.md b/packages/document-issue-data/dashboard/src/index.md index b19ca0a9..3dc6dcc8 100644 --- a/packages/document-issue-data/dashboard/src/index.md +++ b/packages/document-issue-data/dashboard/src/index.md @@ -1,26 +1,44 @@ --- title: Latest Issued Documents theme: dashboard -# theme: [light, dark, alt, wide] toc: false --- ## Latest Issued Documents ```js -const docs = FileAttachment("data/latest_found.csv").csv({typed: true}); +const data = FileAttachment("data/latest_found.csv").csv({typed: true}); ``` ```js -const search_docs = view(Inputs.search(docs, {placeholder: "Search docs"})); +const unique_systems = [...new Set(data.map(d => d.system))].filter(d => d != null && d !== ""); ``` ```js -Inputs.table(search_docs, { - format: { - project: d3.format("d"), // format as "1960" rather than "1,960" - link: id => htl.html`🔗` - }, - rows : 40 -}) +const filters = view(Inputs.form({ + search: Inputs.search(data, {placeholder: "Global search..."}), + system: Inputs.select(unique_systems, { + label: "System", + multiple: true, + unique: true, + sort: true, + placeholder: "All systems", + allowClear: true // <-- Add this line + }) +})); +``` + +```js +const filtered = data.filter(d => { + // Global search + const search = filters.search?.value?.toLowerCase() ?? ""; + const matchesSearch = !search || Object.values(d).some(v => (v + "").toLowerCase().includes(search)); + // System filter + const matchesSystem = !filters.system?.length || filters.system.includes(d.system); + return matchesSearch && matchesSystem; +}); +``` + +```js +Inputs.table(filtered, {rows: 40}) ``` From e5e7b3902f2fdb65f57ac1ad2995b9e5169dc5d8 Mon Sep 17 00:00:00 2001 From: jgunstone Date: Wed, 28 May 2025 17:21:37 +0100 Subject: [PATCH 2/5] wip --- .../document-issue-data/dashboard/src/index.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/document-issue-data/dashboard/src/index.md b/packages/document-issue-data/dashboard/src/index.md index 3dc6dcc8..278824f0 100644 --- a/packages/document-issue-data/dashboard/src/index.md +++ b/packages/document-issue-data/dashboard/src/index.md @@ -30,10 +30,14 @@ const filters = view(Inputs.form({ ```js const filtered = data.filter(d => { - // Global search - const search = filters.search?.value?.toLowerCase() ?? ""; + // Robustly extract the search string + let search = ""; + if (typeof filters.search?.value === "string") { + search = filters.search.value.toLowerCase(); + } else if (typeof filters.search === "string") { + search = filters.search.toLowerCase(); + } const matchesSearch = !search || Object.values(d).some(v => (v + "").toLowerCase().includes(search)); - // System filter const matchesSystem = !filters.system?.length || filters.system.includes(d.system); return matchesSearch && matchesSystem; }); @@ -42,3 +46,8 @@ const filtered = data.filter(d => { ```js Inputs.table(filtered, {rows: 40}) ``` + + +```js +filters +``` \ No newline at end of file From 09417b10b7cb51fc4ff14b43f427562ef4b6242e Mon Sep 17 00:00:00 2001 From: jgunstone Date: Wed, 28 May 2025 17:23:15 +0100 Subject: [PATCH 3/5] add clickable link --- packages/document-issue-data/dashboard/src/index.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/document-issue-data/dashboard/src/index.md b/packages/document-issue-data/dashboard/src/index.md index 278824f0..7e04e427 100644 --- a/packages/document-issue-data/dashboard/src/index.md +++ b/packages/document-issue-data/dashboard/src/index.md @@ -44,10 +44,12 @@ const filtered = data.filter(d => { ``` ```js -Inputs.table(filtered, {rows: 40}) +Inputs.table( + filtered, { + format: { + project: d3.format("d"), // format as "1960" rather than "1,960" + link: id => htl.html`🔗` + }, + rows: 40}) ``` - -```js -filters -``` \ No newline at end of file From 38fe564fbe14479b79f7292b1d30b8f0d6c85c79 Mon Sep 17 00:00:00 2001 From: jgunstone Date: Wed, 28 May 2025 17:42:31 +0100 Subject: [PATCH 4/5] update instructions --- packages/document-issue-data/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/document-issue-data/README.md b/packages/document-issue-data/README.md index 594b273d..384ce5e5 100644 --- a/packages/document-issue-data/README.md +++ b/packages/document-issue-data/README.md @@ -6,10 +6,17 @@ Copy the scripts in `SECRETS` folder into the gitignored `SECRETS` folder in the Run the following `pixi` tasks, from the project ROOT folder, in the order shown to update the data. ```bash +# execute line by line in the root of the project +# ------------------------- pixi run chmod-scripts pixi run mnt-jdrive pixi run get-data # gets raw doc issue data pixi run pull-data # get previously found data pixi run find-files pixi run push-data # push found files back to jobs folder +pixi run cp-to-dashboard # copy data to dashboard directory + +# view the dashboard +pixi run dashboard-install # if not already installed +pixi run dashboard-preview ``` From 70f93224deb6c0ad836a6c77a3ece2f0e030a519 Mon Sep 17 00:00:00 2001 From: jgunstone Date: Wed, 28 May 2025 17:43:23 +0100 Subject: [PATCH 5/5] simplify main dashboard to be a simple search only. TODO: add more comprehensive search functionality --- .../dashboard/src/_index_wip.txt | 55 +++++++++++++++++++ .../dashboard/src/index.md | 38 ++----------- 2 files changed, 60 insertions(+), 33 deletions(-) create mode 100644 packages/document-issue-data/dashboard/src/_index_wip.txt diff --git a/packages/document-issue-data/dashboard/src/_index_wip.txt b/packages/document-issue-data/dashboard/src/_index_wip.txt new file mode 100644 index 00000000..7e04e427 --- /dev/null +++ b/packages/document-issue-data/dashboard/src/_index_wip.txt @@ -0,0 +1,55 @@ +--- +title: Latest Issued Documents +theme: dashboard +toc: false +--- + +## Latest Issued Documents + +```js +const data = FileAttachment("data/latest_found.csv").csv({typed: true}); +``` + +```js +const unique_systems = [...new Set(data.map(d => d.system))].filter(d => d != null && d !== ""); +``` + +```js +const filters = view(Inputs.form({ + search: Inputs.search(data, {placeholder: "Global search..."}), + system: Inputs.select(unique_systems, { + label: "System", + multiple: true, + unique: true, + sort: true, + placeholder: "All systems", + allowClear: true // <-- Add this line + }) +})); +``` + +```js +const filtered = data.filter(d => { + // Robustly extract the search string + let search = ""; + if (typeof filters.search?.value === "string") { + search = filters.search.value.toLowerCase(); + } else if (typeof filters.search === "string") { + search = filters.search.toLowerCase(); + } + const matchesSearch = !search || Object.values(d).some(v => (v + "").toLowerCase().includes(search)); + const matchesSystem = !filters.system?.length || filters.system.includes(d.system); + return matchesSearch && matchesSystem; +}); +``` + +```js +Inputs.table( + filtered, { + format: { + project: d3.format("d"), // format as "1960" rather than "1,960" + link: id => htl.html`🔗` + }, + rows: 40}) +``` + diff --git a/packages/document-issue-data/dashboard/src/index.md b/packages/document-issue-data/dashboard/src/index.md index 7e04e427..c762d18e 100644 --- a/packages/document-issue-data/dashboard/src/index.md +++ b/packages/document-issue-data/dashboard/src/index.md @@ -11,45 +11,17 @@ const data = FileAttachment("data/latest_found.csv").csv({typed: true}); ``` ```js -const unique_systems = [...new Set(data.map(d => d.system))].filter(d => d != null && d !== ""); -``` +const filtered = view(Inputs.search(data)); -```js -const filters = view(Inputs.form({ - search: Inputs.search(data, {placeholder: "Global search..."}), - system: Inputs.select(unique_systems, { - label: "System", - multiple: true, - unique: true, - sort: true, - placeholder: "All systems", - allowClear: true // <-- Add this line - }) -})); ``` -```js -const filtered = data.filter(d => { - // Robustly extract the search string - let search = ""; - if (typeof filters.search?.value === "string") { - search = filters.search.value.toLowerCase(); - } else if (typeof filters.search === "string") { - search = filters.search.toLowerCase(); - } - const matchesSearch = !search || Object.values(d).some(v => (v + "").toLowerCase().includes(search)); - const matchesSystem = !filters.system?.length || filters.system.includes(d.system); - return matchesSearch && matchesSystem; -}); -``` ```js -Inputs.table( - filtered, { +Inputs.table(filtered, { format: { - project: d3.format("d"), // format as "1960" rather than "1,960" + project: d3.format("d"), link: id => htl.html`🔗` }, - rows: 40}) + rows: 40 +}) ``` -