Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ jobs:
# where the file is, the duplicate findings, the worklist suggestions
- name: Test the rules of new items from local files
run: node scripts/desktop-new-files.test.mjs
# Update the BOM from the CAD file at check-in (#407): when the box is
# offered, the result line
- name: Test the check-in BOM rules
run: node scripts/desktop-checkin-bom.test.mjs
# files dropped on the window (#418): New, Add files… or a refusal
- name: Test the drop routing
run: node scripts/desktop-drop-route.test.mjs
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,30 @@ see the notices in the README.

### Added

- **Check-in: *Update the BOM from the CAD file*** (#407): a box in the web
check-in form and the desktop app's *Check in…*, ticked by default every
time, shown when the revision has an assembly whose references are read (an
assembly item, an assembly file, or an NX part, STEP file or SolidCraft
design with counted instances – `bom_structure` in `file-status` for the
desktop app; not for a plain part check-in). The plan of *Create BOM from
CAD references…* is applied to the version being checked in, in the
check-in's transaction: new children added, quantities the CAD file counts
corrected (never from an *assumed 1*), circular children refused, no line
removed – lines the CAD file no longer uses are kept and reported, as are
referenced files TeamCraft does not have. The result says what changed
(*BOM: 4 lines added, 1 quantity changed · …*). REST API: the multipart
field `bom_from_references` on `POST …/checkin` and in the body of
`POST /uploads/{id}/finish` (off by default), the answer adds `bom`;
audit `bom.from_references` with `"source": "checkin"`. *Park* never
changes the BOM. Parts still in the assembly but only excluded from its BOM
there are not reported as *no longer in the CAD file*; the manual plan no
longer holds a database connection while it reads the CAD files.

### Changed

- BOM from CAD references: SolidCraft designs with linked designs count as
structure files (their placements are the quantities); the guides now name
Inventor and SolidCraft as sources of instance counts too.
- Desktop: drag and drop of files from Explorer, Finder or the file manager onto the window (#418). On a revision tab you have checked out (or that *Add files…* would check out) the drop opens *Add files…*; elsewhere it opens *New item* with the files. A frame shows what the drop does; frozen revisions, revisions checked out by someone else, viewers and editors without a group are refused with the reason. Only regular files are taken (folders are skipped), with the same checks as the file dialog. Tab reordering keeps working (pointer events, not HTML5 drag and drop).
- **Getting started in the desktop app** (#422): after the first sign-in
TeamCraft Desktop opens a short wizard – server (skipped when a policy fixes
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ end-to-end tests against a real PostgreSQL.
- **Alternates and supersession** – alternate parts, superseded parts and *Replace in assemblies* with a preview.
- **BOM import** – items and BOMs from CAD BOM tables (CSV, Excel, ODS) or a
STEP assembly; preview first, one transaction.
- **BOM from the CAD file** – the parts an assembly uses, with the instance
counts of Inventor, SOLIDWORKS, NX, STEP and SolidCraft files; updated at
check-in when *Update the BOM from the CAD file* is ticked (the default),
never removing a line.
- **Pack and Go** – a ZIP of a whole assembly with all its files.

**Change and release**
Expand Down
2 changes: 1 addition & 1 deletion desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ TeamCraft server – it is a client, not an offline copy.
| Tab order | Drag a tab to move it (pointer events, an insertion bar shows the landing place, the strip scrolls at its edges, `Esc` cancels; a plain click still activates, a dragged tab keeps its state and is not activated). Keyboard: arrow keys, `Home`, `End` move the focus between the tabs (WAI-ARIA tabs, roving tabindex, `Enter`/`Space` activates), `Ctrl+Shift+PageUp/PageDown` move the active tab. Right click (or the menu key): *Move to start*, *Move to end*, *Close*, *Close others*, *Close tabs to the right*. The order is kept while the app runs (open tabs are not restored on start). Rules in `ui/js/tab-order.js`, tested by `scripts/desktop-tab-order.test.mjs` (`node`); the dragging itself is checked by hand |
| Revision tabs | Overview (with *At a glance*: the preview image from the CAD file, files, BOM lines, where used, references, change orders, open requests – and a link to the similar parts in the browser), Files (versions, restore, open), Structure (multi-level BOM, revision rules, roll-up; under your check-out *Add line…*, quantities and *Remove*), Where used, References, **Graph** (see below), Changes, History, **3D viewer** (STEP, meshes, point clouds – converted by the server), Workspace |
| Graph | A navigable reference/BOM graph around the revision: the focused item in the middle, its BOM children and references below, the assemblies that use it above. Node **colour** = lifecycle state, **size** and the ⚙ badge = the item's own BOM complexity, **×n in the top-left corner** = how many instances of that part or sub-assembly the assembly contains (summed over its BOM lines, ×1 included). Every node is clickable and takes the tab to that item – a sub-assembly shows its own graph, anything else its overview, the item in the middle its own overview – with a **back control that stays in the same place** (the left of the sub-tab row) and leads back the way you came, one step per click; `Ctrl`/`⌘`+click opens a node in a tab of its own. Mouse-wheel zooms on the cursor; drag to pan; the view fits itself while details load until you zoom or pan, a double-click on the background fits it again. More than 8 neighbours on one side are laid out in rows; above 48 only the first 48 are fetched for preview and complexity (one request each), the rest keep a basic card. Preview images and filenames on the nodes; pure SVG, no external engine |
| Working folder | One folder per project group that **mirrors the folder structure of the files** (`<workspace>/<group>/<folder>/<file>`, the folder is stored with every file on the server), one copy of each file – the revision is metadata in `<workspace>/.teamcraft/state.json` (item, revision, file id, version, SHA-256, checked out). Files you have not checked out are **read-only** on disk; *Check out* takes the lock and makes them writable; *Check in…* uploads the chosen files as new versions, releases the lock in one step and makes them read-only again (files above 32 MiB go first as chunked, resumable uploads, then join the same check-in transaction). The check-in dialog shows the progress, and **Cancel** stops the check-in until its last byte is sent – before the next STEP export, between two chunks (the upload sessions are discarded, `DELETE /uploads/{id}`) or half-way through the streamed request with the small files: nothing is stored, the revision stays checked out (`src/abortable.rs`). Every check-in names the version each file is based on, so the server refuses (409) to overwrite a version somebody else checked in meanwhile. The Workspace tab shows *up to date* / *modified* / *outdated* / *conflict* / *new* / *missing* / *name clash* per file (from the server's file status) with its path, read-only flag and the lock owner. Two items with the same folder and file name are reported, never overwritten. Lock and backup files of the CAD programs are skipped; a SolidCraft design that is open in SolidCraft (a fresh `.~<file>.lock` beside it, `src/cadlock.rs`) is marked *Open in SolidCraft* with the computer and user, and the check-in dialog warns that unsaved changes there are not checked in; Creo iterations count as one file. A tracked revision the server no longer shows (you left a restricted project group) is listed as *No longer accessible*: its local copies stay untouched and are never synced again – delete them yourself if you must In *Check in…*, a new part or assembly file next to a revision that has a model already is offered unticked, with *New item from this file* (#359) |
| Working folder | One folder per project group that **mirrors the folder structure of the files** (`<workspace>/<group>/<folder>/<file>`, the folder is stored with every file on the server), one copy of each file – the revision is metadata in `<workspace>/.teamcraft/state.json` (item, revision, file id, version, SHA-256, checked out). Files you have not checked out are **read-only** on disk; *Check out* takes the lock and makes them writable; *Check in…* uploads the chosen files as new versions, releases the lock in one step and makes them read-only again (files above 32 MiB go first as chunked, resumable uploads, then join the same check-in transaction). The check-in dialog shows the progress, and **Cancel** stops the check-in until its last byte is sent – before the next STEP export, between two chunks (the upload sessions are discarded, `DELETE /uploads/{id}`) or half-way through the streamed request with the small files: nothing is stored, the revision stays checked out (`src/abortable.rs`). Every check-in names the version each file is based on, so the server refuses (409) to overwrite a version somebody else checked in meanwhile. The Workspace tab shows *up to date* / *modified* / *outdated* / *conflict* / *new* / *missing* / *name clash* per file (from the server's file status) with its path, read-only flag and the lock owner. Two items with the same folder and file name are reported, never overwritten. Lock and backup files of the CAD programs are skipped; a SolidCraft design that is open in SolidCraft (a fresh `.~<file>.lock` beside it, `src/cadlock.rs`) is marked *Open in SolidCraft* with the computer and user, and the check-in dialog warns that unsaved changes there are not checked in; Creo iterations count as one file. A tracked revision the server no longer shows (you left a restricted project group) is listed as *No longer accessible*: its local copies stay untouched and are never synced again – delete them yourself if you must In *Check in…*, a new part or assembly file next to a revision that has a model already is offered unticked, with *New item from this file* (#359). *Update the BOM from the CAD file* in *Check in…* (#407): ticked by default every time, shown when the server reports a structure file (`bom_structure` of `file-status`), the item is an assembly, or a file is an assembly or a SolidCraft design (`js/checkin-bom.js`, tested by `scripts/desktop-checkin-bom.test.mjs`); sends `bom_from_references` with the check-in (never with *Park*) and adds the server's `bom` summary to the result |
| Get | *Get…* on a revision: the item with its BOM (revision rule *latest* or *released*) and the parts its CAD files reference, resolved by the server (`…/workset`); only missing and outdated files are downloaded (SHA-256, checked after the download), recorded one by one so an interrupted Get continues where it stopped – also inside a large file: the bytes received stay in `<name>.<sha>.teamcraft-download` and the next Get asks only for the rest (`Range` / `If-Range`, `src/resume.rs`), checks the SHA-256 of the whole file and renames it into place; progress and *Cancel* in the status bar. No browser downloads |
| Add files | *Add files…* (Files section and *More ▾*): file picker → the files are **copied** into the working folder of the revision (checked out first if needed; sub-folder selectable, originals untouched) and listed as *new* in *Check in…* (option *Check in now*; remembered in `.teamcraft/added.json` until checked in). A name that exists is a new version and asks first. The Files section says why it is unavailable (locked by someone else, in review, released = frozen → Revise). Pure logic and tests in `src/addfiles.rs`; files dropped on an open revision tab take the same way (*Drop files*) |
| Drop files | Files dragged from Explorer, Finder or the file manager onto the window (#418; Tauri's native file drop, `dragDropEnabled` on the main window): on a revision tab you have checked out – or that *Add files…* would check out – they open *Add files…* with the dropped paths instead of the picker; elsewhere *New item* with the files chosen (as *Create item* of the worklist suggestions). A frame over the window says what the drop does; a revision that takes no files (released, in review, checked out by someone else), viewers, editors without a group and an open dialog refuse it with the reason. The routing is a pure function (`ui/js/drop-rules.js`, tested by `scripts/desktop-drop-route.test.mjs`), the listener `ui/js/drop.js`. Only regular files are taken: `dropped_files` leaves folders out (with a note), and `addfiles::plan` and `new_item_copy` refuse anything that is not a regular file. The tabs are moved with pointer events, not HTML5 drag and drop, so tab dragging is unaffected |
Expand Down
5 changes: 5 additions & 0 deletions desktop/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,10 @@ pub async fn workspace_status(
}

/// Check in the chosen files (new versions) and release the lock.
/// `bom_from_references` (`bomFromReferences` in JS, off when left out): also
/// update the BOM from the CAD file on the server (#407).
#[tauri::command]
#[allow(clippy::too_many_arguments)]
pub async fn workspace_checkin(
app: AppHandle,
state: State<'_, AppState>,
Expand All @@ -856,6 +859,7 @@ pub async fn workspace_checkin(
code: String,
files: Vec<String>,
comment: String,
bom_from_references: Option<bool>,
) -> CmdResult<Value> {
usage(&state, |u| u.count("checkin"));
let api = signed_in_api(&state)?;
Expand All @@ -874,6 +878,7 @@ pub async fn workspace_checkin(
&code,
&files,
&comment,
bom_from_references.unwrap_or(false),
&transfer,
)
.await
Expand Down
1 change: 1 addition & 0 deletions desktop/src/scbridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ mod tests {
files: Vec::new(),
inaccessible: false,
released: None,
bom_structure: false,
};
let s = state(5, "PRT-000042", "A", &status);
assert_eq!(s["checked_out"]["by_name"], "Kim Lee");
Expand Down
39 changes: 30 additions & 9 deletions desktop/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,10 @@ pub struct Status {
/// last checked out (the server's `released`: `by_name`, `at`, `reason`,
/// `message`): local changes stay, but need a new check-out.
pub released: Option<Value>,
/// The server knows a structure file of the revision (`bom_structure` of
/// `file-status`, false from older servers): *Check in…* offers *Update
/// the BOM from the CAD file* (#407).
pub bom_structure: bool,
}

/// A local file of a revision: where it is and what the state says.
Expand Down Expand Up @@ -986,6 +990,7 @@ pub fn inaccessible_status(root: &Path, project: Option<&str>, item: &str, code:
locked_by_name: None,
inaccessible: true,
released: None,
bom_structure: false,
files,
}
}
Expand Down Expand Up @@ -1145,6 +1150,7 @@ pub async fn status(
locked_by_name: rev.locked_by_name,
inaccessible: false,
released: Some(server["released"].clone()).filter(Value::is_object),
bom_structure: server["bom_structure"].as_bool().unwrap_or(false),
files: out,
})
}
Expand Down Expand Up @@ -1210,6 +1216,9 @@ pub async fn locate(
/// [`crate::api::CHUNKED_ABOVE`] are sent before in resumable chunks (see
/// [`Api::send_files`]), with progress and cancel through `transfer`.
/// Afterwards the files are read-only again.
/// With `bom_from_references` the server also updates the BOM of the
/// revision from the CAD references of the checked-in version, in the same
/// transaction (#407); the answer then carries `bom`.
#[allow(clippy::too_many_arguments)]
pub async fn check_in(
api: &Api,
Expand All @@ -1219,6 +1228,7 @@ pub async fn check_in(
code: &str,
names: &[String],
comment: &str,
bom_from_references: bool,
transfer: &Transfer<'_>,
) -> Result<Value, ApiError> {
send_local(
Expand All @@ -1228,7 +1238,9 @@ pub async fn check_in(
names,
comment,
transfer,
SendMode::CheckIn,
SendMode::CheckIn {
bom_from_references,
},
)
.await
}
Expand Down Expand Up @@ -1271,8 +1283,9 @@ pub async fn park(
/// What [`send_local`] does with the lock.
#[derive(Clone, Copy, PartialEq, Eq)]
enum SendMode {
/// `…/checkin`: new versions and the lock released in one transaction.
CheckIn,
/// `…/checkin`: new versions and the lock released in one transaction
/// (with `bom_from_references`: the BOM updated from the CAD file, #407).
CheckIn { bom_from_references: bool },
/// `…/files`: new versions, the lock stays.
Park,
}
Expand Down Expand Up @@ -1394,20 +1407,28 @@ async fn send_local(
// Large files go first as resumable chunked uploads (with their base and
// folder) and join this check-in by id – one transaction on the server.
let endpoint = match send {
SendMode::CheckIn => "checkin",
SendMode::CheckIn { .. } => "checkin",
SendMode::Park => "files",
};
let mut fields = vec![
("comment", comment.to_string()),
("bases", Value::Object(bases).to_string()),
("folders", Value::Object(folders).to_string()),
];
// never on a park: the revision stays checked out, nothing is final yet
if let SendMode::CheckIn {
bom_from_references: true,
} = send
{
fields.push(("bom_from_references", "true".to_string()));
}
let result = api
.send_files(
&format!("{}/{endpoint}", rev_path(item, code)),
item,
code,
&files,
&[
("comment", comment.to_string()),
("bases", Value::Object(bases).to_string()),
("folders", Value::Object(folders).to_string()),
],
&fields,
transfer,
)
.await?;
Expand Down
Loading
Loading