Sessions
The Sessions widget is a complete sessions page in a single widget. The left column holds the list of sessions sent by the flow, with search, sorting and pages. Clicking a row selects the session and fills the right column: the configured fields, the configuration, download and delete buttons, a line chart of the numeric results of the saved pieces, a bar chart of the errors, and a list of errors in which each error opens a dialog with the images of its pieces. An Options button on the list bar sets the global image saving mode. Its height follows the browser window (minus the dashboard header), so it fills the page.
The session list comes from msg.payload. Charts, images and downloads come from the files the flow saved for each piece under Sessions dir, which the widget reads through HTTP routes of the node. The same page can also be built from separate widgets fed by the flow: ui-session-details, ui-sessions-header and ui-sessions-images.
Palette: category Renders, label sessions. 1 input, 2 outputs.
Configuration
The edit dialog has six tabs. A text or number property left empty takes its default value, except Name and the footbar texts of the Images tab.
General
| Property | Description | Default |
|---|---|---|
| Name | Node name shown in the editor. | "" |
| Group | Dashboard group the widget is placed in. | (required) |
| Locale | Optional Locale Config node. Only its image dialog footbar texts are used, for the texts left empty in the Images tab. | none |
| Size | Width and height in the group grid. | 0 / 0 |
| Title | Text of the bar above the session list. | SESSIONS |
| Info title | Text of the bar above the details column. | SESSION INFO |
| Class | CSS classes added to the widget root. | "" |
| Sessions dir | Folder on the Node-RED server with one subfolder per session (see Files on disk). Read by the line chart, the image dialog and the downloads; the delete button removes the session's subfolder. | /opt/storage/images/sessions |
| Images URL | Path under the Node-RED HTTP root (httpNodeRoot) where Sessions dir is served. Used for the image links of the image dialog and of the downloads. The node does not serve the folder: the Node-RED server must. | local/images/sessions |
Table
| Property | Description | Default |
|---|---|---|
| Columns | Columns of the session list. Each has a title, a value path inside the session row (dot notation, for example startedBy.email) and an alignment (left, center or right). Rows without a path are dropped on save. Every column can be sorted; date, endDate and duration sort by the timestamps, a running session counting as ending now. | Date (date), Configuration (configName), Total (totalCounter), Errors (noClassCounter) |
| Rows per page | Rows per page of the list. 0 shows as many rows as fit in the column height. | 0 |
| Search | Shows a search box above the list. | on |
Details
| Property | Description | Default |
|---|---|---|
| Fields | Values shown for the selected session. Each has a label, a value path inside the session row (dot notation), a format and a Hide empty box. Formats: text as is; number locale formatted with up to 2 decimals; date a millisecond timestamp as day/month/year hour:minute; duration milliseconds as 1 h 5 min 3 s. A value that cannot be converted is shown as is, a missing one as -. With Hide empty the field disappears when the session has no value for it. Rows without a path are dropped on save. | Configuration (configName), Duration (duration), Total (totalCounter), Start date (date), Finish date (endDate), Errors (noClassCounter), Batch (batch), Started by (startedBy.email, hide empty); all text |
| Delete label | Text of the delete button and title of its confirmation dialog. | Delete |
| Confirm text | Message of the confirmation dialog. | This will permanently delete the selected session and all its files. Continue? |
| Configuration | Shows the button that opens the configuration the session was started with. | on |
| Config label | Text of that button and title of its dialog. | Configuration |
| Config path | Path inside the session row of the configuration object. The button is disabled when there is no non-empty object at that path. | config |
| Download | Shows the download button. | on |
| Download label | Text of the download button. | Download |
| Formats | Entries of the download menu: Summary CSV, Pieces CSV, JSON and Report (PDF). See Downloads. | all on |
| Separator | CSV separator: ; writes decimal commas, , decimal points. | ; |
The configuration dialog has three tabs. Summary shows the plain values first, then one section per nested object or list. For a recipe, a configuration with an errors list or a format object, it shows instead the name, the creation date, the main format values, how many rules are active, and a table of the models per view built from the <view>_<kind>_model keys of format.models. Rules, present when errors is a non-empty list, shows each rule with its conditions and whether it is on (status not false). All lists every value by its path, with a search box.
Report
Texts of the PDF report (see PDF report).
| Property | Description | Default |
|---|---|---|
| Title | Report title. The PDF document title is this text followed by the session id. | Session report |
| Generated | Text before the generation date, top right. | Generated |
| Summary title | Title of the summary section. | Summary |
| Start | Label of the start date. | Start |
| End | Label of the end date. | End |
| In progress | Value of End while the session runs. | In progress |
| Duration | Label of the duration. | Duration |
| Configuration | Label of the configuration name. | Configuration |
| Batch | Label of the batch, shown only when the session has one. | Batch |
| Inspected | Label of the number of inspected pieces. | Inspected |
| OK | Label of the OK count. | OK |
| NOK | Label of the NOK count. | NOK |
| Saved pieces | Label of the number of saved pieces. | Saved pieces |
| First piece | Caption of the first saved piece. | First piece |
| Last piece | Caption of the last saved piece. | Last piece |
| No image | Text of the grey box drawn where an image is missing. | No saved image |
| Errors title | Title of the errors section. | Error count |
| Grade label | Name of the grade figure. | Grade |
| Limiting label | Text before the limiting parameters. | Limited by |
| Score label | Name of the score figure. | Score |
| Defects label | Name of the defects figure. | Defects per label |
| Defect size label | Name of the maxDimension figure. | Largest defect |
| Mean | Word before the mean of a figure that varies. | mean |
| Reasons label | Text before the failure reasons. | Reasons |
| Grade letters label | Text before the grade letters. | Grade letters |
| Warnings label | Text before the warnings. | Warnings |
| Read label | Text before the value read on the sample piece. | Read |
| Expected label | Text before the expected value. | Expected |
Charts
| Property | Description | Default |
|---|---|---|
| Line chart | Shows the line chart. | on |
| Title | Title of the line chart. | LINE CHART |
| Defaults (Title, Legend) | Initial state of the line chart title and legend. | on, on |
| Max points | Number of saved pieces plotted, the most recent ones. Values below 1 fall back to 1000. | 1000 |
| Variable 1 label | Label of the first variable selector in the chart settings. | Variable 1 |
| Variable 2 label | Label of the second, optional, variable selector. | Variable 2 |
| Save label | Text of the save button of the chart settings. | SAVE |
| Bar chart | Shows the bar chart. | on |
| Title | Title of the bar chart. | BAR CHART |
| Defaults (Title, Legend) | Initial state of the bar chart title and legend. | on, off |
| Bar layout | Initial orientation of the bars: Columns or Rows. | Columns |
| Errors list | Shows the errors list. | on |
| Title | Title of the errors list. | ERRORS |
The line chart plots the numeric values of the resume of the saved pieces, one point per piece in save order (see Files on disk); its settings pick one or two of them, and switch the title, the legend, Normalize (each series scaled to 0–100 %, on at first) and Stats (average, minimum and maximum, on at first). The bar chart shows the errorCounter of the session; its settings switch the title, the legend and the layout. Both charts have a button that opens them in a larger dialog. What a user changes in the chart settings is remembered by each browser and overrides the defaults above.
The errors list shows each error of errorCounter with its count and its share of all errors, most frequent first. Clicking an error opens the image dialog.
Images
| Property | Description | Default |
|---|---|---|
| Dialog title | Title of the image dialog when there is no error name. The dialog opened from the errors list is titled with the error name. | IMAGES |
| Max images | Maximum number of pieces loaded in the dialog. Values below 1 fall back to 60. | 60 |
| Checkboxes (Mask, Bbox, Polygons) | Toggles shown in the dialog footbar. | all on |
| Thumbnails | Initial state of the Show annotations button of the dialog, which draws the boxes over the thumbnails. | on |
| Mask checkbox text | Label of the Mask toggle. | "" (MASK) |
| Bbox checkbox text | Label of the Bbox toggle. | "" (BBOX) |
| Polygon checkbox text | Label of the Polygons toggle. | "" (POLYGONS) |
| Hover label text | Title of the labels on hover option of the footbar menu. | "" (Labels on hover) |
| Hover label hint | Subtitle of that option. | "" (Show a label only while pointing at its detection) |
| Box fill text | Title of the box fill option of the footbar menu. | "" (Bounding box fill) |
| Box fill hint | Subtitle of that option. | "" (Tint the inside of each bounding box) |
An empty footbar text takes the text of the Locale config node, and without one the built-in text in brackets. A text equal to the built-in one also counts as empty.
The dialog shows a grid of thumbnails, newest first, marked green or red by isAnomalous. Clicking one opens it beside the grid with zoom (up to 8x), previous and next arrows (also the left and right keys), a maximized view with a strip of thumbnails, a selector of the image type when the piece has several, and the piece's result, date and resume per model. The node sends the bounding boxes saved with each image; it does not send masks or polygons. The toggles and the Show annotations choice are remembered by each browser.
Input
msg.payload | Effect |
|---|---|
| array | Replaces the session list in every browser. Each element is a session row (below). Rows without sessionId, without a numeric startDate, or with an endDate earlier than startDate are dropped. The list is stored: a browser that opens the page later receives it. |
| anything else | Refreshes the running session from the global context (see Running session). Send it periodically, and throttle it before this node. |
Session row
Usually one row of the sessions table of a database. The node reads these fields; every other field of the row is kept and can be shown by a column or a field.
| Field | Type | Use |
|---|---|---|
sessionId | number or string | Required. Identifies the session. The line chart, the image dialog and the downloads accept only ids made of digits. |
startDate | number | Required. Start time, Unix milliseconds (a numeric string is accepted). |
endDate | number or null | End time in milliseconds; null or missing while the session runs. |
configName | string | Configuration name. Without it, config.name, else No configuration. |
config | object | Configuration the session was started with, shown by the configuration button (Config path). |
batch | any | Batch, shown in the details and in the PDF report. |
startedBy, stoppedBy | object | Who started and stopped the session, for example startedBy.email. |
totalCounter | number | Inspected pieces. |
noClassCounter | number | NOK pieces. |
tagCounter | object | { "OK": n, "NOK": n }, used by the downloads. |
errorCounter | object | Count per error name, for example { "Scratch": 11 }. Feeds the errors list, the bar chart, the image dialog and the downloads. The errors list and the bar chart also accept an object { count, color } as the value; the downloads count only plain numbers. |
param | object | Statistics per numeric result field, { "<model>.<field>": { min, max, mean, count } }, for the summary CSV. |
The node adds or replaces these fields, which columns and fields can show:
| Field | Value |
|---|---|
date | Start as text, day/month/year hour:minute, in the server's time zone. |
endDate | End as text in the same format, or En curso while the session runs. |
duration | Duration as text, for example 1 h 5 min 3 s; up to now while the session runs. |
startTs, endTs | Start and end in milliseconds; endTs is null while the session runs. |
Missing totalCounter, noClassCounter, errorCounter and tagCounter become 0; missing config, batch, startedBy and stoppedBy become null.
Running session
The flow that runs the inspection keeps these values in the global context. A session is running when global status is true and global sessionId equals the row's sessionId, with the same type (number or string).
- The delete button of the running session is disabled, with the hint
Stop the session before deleting it, and the node refuses to delete it. - A message whose
msg.payloadis not an array copies globaltotalCounter,noClassCounter,tagCounter,errorCounterandparaminto the running row, if it has no end, and recomputes its duration. The browsers update that row.
Files on disk
The line chart, the image dialog and the downloads read what the flow saved for each piece:
<Sessions dir>/<sessionId>/stats.json optional, read by the PDF report
<Sessions dir>/<sessionId>/classes/<class>/<ts>.json metadata of one saved piece
<Sessions dir>/<sessionId>/classes/<class>/<file> the images named in the metadataFor the image dialog, <class> is the error name as it appears in errorCounter, with / and \ replaced by _. Metadata of one piece:
{
"ts": 1753600123456,
"name": "1753600123456",
"date": 1753600123400,
"result": "Scratch",
"isAnomalous": true,
"resume": {
"detector": { "score": 0.93, "minScore": 0.5, "result": "NOK" }
},
"images": {
"join": {
"file": "1753600123456_join.webp",
"bbox": [
{ "x_rel": 0.42, "y_rel": 0.18, "w_rel": 0.06, "h_rel": 0.05, "tag": "Scratch", "score": 0.93 }
]
}
}
}| Field | Use |
|---|---|
ts | Save time in milliseconds. Orders the pieces. |
name | Caption of the piece in the image dialog. |
date | Capture time, milliseconds or date text. Without it, ts. |
result | Class of the piece. Without it, the downloads use the folder name. |
isAnomalous | true marks the piece red in the dialog, false green. |
resume | Results per model, shown in the dialog. Every value, nested keys joined with dots, becomes a column of the pieces CSV, and every numeric value a line chart variable; for the line chart, an entry of a ruleResults list contributes its measured value under the rule's name (or param). |
images | One entry per image type (the dialog opens join first when present): file, the image in the same folder, and bbox, the boxes in coordinates relative to the image, with tag, score and an optional color. |
The dialog loads the Max images metadata files of the folder that come last by file name, which are the newest when the files are named by timestamp. A folder without metadata files shows its .webp, .jpg, .jpeg and .png files as plain images. When the class folder does not exist under Sessions dir, the node looks in /opt/storage/sessions/<sessionId>/classes/<class> and sends its images inline. Thumbnails come from the same address with local/ replaced by local/fit/400/ when Images URL starts with local/, a resizing route the server must provide; otherwise the dialog uses the full images.
stats.json holds what the flow accumulated per region over every inspected piece, saved or not: { "regions": { "<region>": { "numbers": { "<key>": { "min", "max", "mean" } }, "counts": { "reasons", "gradeLetter", "limiting", "result" } } } }, where each entry of counts maps a value to how many times it occurred (result.warn is the number of warnings). A region matches an error by its name, or by its name with /, \ and .. replaced by _.
Output
Both outputs send only on actions of the user in the widget.
| Output | When | Message |
|---|---|---|
| 1, delete session | The user confirms the deletion of a session of the current list that is not running. The node removes <Sessions dir>/<sessionId> and /opt/storage/sessions/<sessionId> and sends the message. | { "sessionId": 1753600000000, "payload": 1753600000000 } |
| 2, save images mode | The user saves the Image saving dialog. The node has already stored the mode in global saveImagesMode and shown it in every browser. | { "payload": { "saveImagesMode": "nok" } } |
The deleted row stays in the list until the flow sends the list again: on output 1, delete the session from the database and send the new list.
The Options button opens the Image saving dialog with four modes: Do not save images (none), All images (all), Only correct images (ok) and Only incorrect images (nok). When a browser loads the widget it shows global saveImagesMode, or all when it is not set. The node only stores the value: the flow that saves the pieces must read it.
Downloads
The download menu lists the formats ticked in Formats. The node builds each file from the selected session row, as the browser holds it, and from the files of the session under Sessions dir. Dates are written as dd/mm/yyyy hh:mm:ss in the browser's time zone, and decimals with the mark of Separator: a comma with ;, a point with ,, also in the PDF report. Image links are the dashboard address seen by the browser, followed by httpNodeRoot, Images URL, the session id, classes, the class and the file name. OK and NOK come from tagCounter; without it NOK is noClassCounter and OK the rest of totalCounter.
- Summary (CSV),
session_<sessionId>_summary.csv: label and value lines without a header, in sections separated by a blank line. Session, Start, End (In progresswhile the session runs), Duration and Configuration; Inspected pieces, OK and NOK with their percentage (for example14 (17,28%)), and Saved pieces; aClassessection with the count of eacherrorCounterentry; aParameterssection with the min, max, mean and count of eachparamfield, or a single value when its min equals its max. - Pieces (CSV),
session_<sessionId>_pieces.csv: one row per saved piece, oldest first. Columns: Date, Class, one perresumevalue, and per image type a<type> URLcolumn plus a<type> detectionscolumn (number of boxes) when some piece has boxes on that type. Theresumefieldsscore,minScore,resultandisAnomalousare named<model> · Score,<model> · Threshold,<model> · Resultand<model> · Anomalous; the others keep their dotted key. - Full data (JSON),
session_<sessionId>.json:{ "exportedAt", "session", "pieces" }.sessionis the session row withstartTs,endTs,durationMs,activeandsavedPiecesadded;piecesholds every metadata file with itsclassDirand aurlon each image. - Report (PDF): see below.
The CSV files are UTF-8 with a byte order mark and CRLF line ends. Booleans are written Yes or No, objects as JSON. A value that looks like a number or a date starts with an invisible zero-width space, so spreadsheets keep it as text: every value stays left aligned and long ids keep all their digits.
PDF report
The report opens in a new browser tab as an A4 PDF, which can be saved or printed from the browser's PDF viewer. The browser draws it from content prepared by the node; the images are read from Sessions dir and embedded. It contains:
- A header with the title, the generation date, and the configuration name and start date.
- The summary: start, end, duration, configuration and batch (when the session has one), and the inspected pieces, OK and NOK with their percentage, and the saved pieces.
- The first and the last saved pieces that have an image, with their capture date and class, and their boxes drawn green when the region passed and red otherwise. A box passes when its
tagends in[pass]or[ok], or when the piece'sresumeentry for the region named by the tag has the resultpassorok, in any letter case. - One row per error of
errorCounterwith a count above zero, most frequent first: the error name, the count over the inspected pieces (for example4 / 81 (4,94%)) and a sample image. The sample is cut out around the first box tagged with that error in a saved piece (atagequal to the error name, or starting with the name and:, a final[...]ignored); without one, it is the image of a saved piece of that class. With astats.json, the row adds the reasons, warnings, grade letters and limiting parameters of the region with their counts, and its figures (grade, score, defects and largest defect first, then the rest), each one a single value when constant or the mean followed by the minimum and maximum. When the sample piece'sresumeentry for the region has avalue, the row addsRead: <value>, andExpected: <expected>when present. - Page numbers.
Status and errors
After a deletion the node status shows a green dot with <n> folder(s) deleted, or Nothing to delete when no folder was removed.
| Message | Kind | Cause |
|---|---|---|
No group configured | error | The node has no dashboard group. |
ui-sessions: delete rejected, unknown session <sessionId> | warning | The session to delete is not in the current list. |
ui-sessions: delete rejected, session <sessionId> is running | warning | The session to delete is the running one. |
ui-sessions: could not delete <folder>: <reason> | error | A session folder could not be removed. |
ui-sessions: invalid JSON <file>: <reason> | warning | A metadata file of the image dialog is not valid JSON; the piece is skipped. |
ui-sessions: no images for <class>: <reason> / <reason> | warning | Neither class folder exists; the dialog stays empty. |
ui-sessions: series failed: <reason> | error | The line chart data could not be read. |
ui-sessions: images failed: <reason> | error | The image dialog data could not be read. |
Export failed for session <sessionId>: <reason> | error | A download could not be built. |
ui-sessions: <reason> | error | A widget action failed. |
The widget shows Download failed: <reason> under the buttons when a download fails, for example Download failed: Invalid session for a sessionId that is not made of digits, or Download failed: the browser blocked the new tab for the report. Empty states: No sessions, Select a session to see its errors, No errors recorded in this session and, in the charts, No data available.
HTTP endpoints
The widget reads the line chart data, the images of an error and the downloads from routes of the node under the Node-RED HTTP root (httpNodeRoot), so the browser must reach them at the dashboard's address. <id> is the id of the node.
| Route | Purpose |
|---|---|
GET /ui-sessions/<id>/series | Data of the line chart of a session. |
GET /ui-sessions/<id>/images | Pieces of one error class, for the image dialog. |
POST /ui-sessions/<id>/export | The downloads and the content of the PDF report. |
A request for a sessionId that is not made of digits is answered 400 Invalid session, which the widget shows as Download failed: Invalid session.
Usage example
The flow queries the sessions table and sends the rows to the widget, for example on deploy and after each start, stop or deletion. A function node between the query and the widget:
// msg.payload: rows of the sessions table returned by the database query
msg.payload = msg.payload.map((row) => ({
sessionId: Number(row.sessionId),
startDate: Number(row.startDate),
endDate: row.endDate == null ? null : Number(row.endDate),
configName: row.configName,
batch: row.batch,
totalCounter: row.totalCounter,
noClassCounter: row.noClassCounter,
tagCounter: JSON.parse(row.tagCounter || '{}'), // { "OK": 1182, "NOK": 18 }
errorCounter: JSON.parse(row.errorCounter || '{}'), // { "Scratch": 11, "Missing label": 7 }
param: JSON.parse(row.param || '{}'),
config: JSON.parse(row.config || 'null')
}));
return msg;While a session runs, the inspection flow keeps global.status at true, global.sessionId at the running id (a number, like the rows above) and updates the global counters; an Inject node every 5 seconds wired to the widget refreshes the running row. Output 1 goes to a query that deletes the session row, followed by the list query again; output 2 goes to whatever stores the image saving mode across restarts.