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 ``` 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 b19ca0a9..c762d18e 100644 --- a/packages/document-issue-data/dashboard/src/index.md +++ b/packages/document-issue-data/dashboard/src/index.md @@ -1,26 +1,27 @@ --- 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 filtered = view(Inputs.search(data)); + ``` + ```js -Inputs.table(search_docs, { +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 }) ```