Skip to content

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 ​

PropertyDescriptionDefault
NameNode name shown in the editor.""
GroupDashboard group the widget is placed in.(required)
LocaleOptional Locale Config node. Only its image dialog footbar texts are used, for the texts left empty in the Images tab.none
SizeWidth and height in the group grid.0 / 0
TitleText of the bar above the session list.SESSIONS
Info titleText of the bar above the details column.SESSION INFO
ClassCSS classes added to the widget root.""
Sessions dirFolder 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 URLPath 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 ​

PropertyDescriptionDefault
ColumnsColumns 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 pageRows per page of the list. 0 shows as many rows as fit in the column height.0
SearchShows a search box above the list.on

Details ​

PropertyDescriptionDefault
FieldsValues 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 labelText of the delete button and title of its confirmation dialog.Delete
Confirm textMessage of the confirmation dialog.This will permanently delete the selected session and all its files. Continue?
ConfigurationShows the button that opens the configuration the session was started with.on
Config labelText of that button and title of its dialog.Configuration
Config pathPath inside the session row of the configuration object. The button is disabled when there is no non-empty object at that path.config
DownloadShows the download button.on
Download labelText of the download button.Download
FormatsEntries of the download menu: Summary CSV, Pieces CSV, JSON and Report (PDF). See Downloads.all on
SeparatorCSV 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).

PropertyDescriptionDefault
TitleReport title. The PDF document title is this text followed by the session id.Session report
GeneratedText before the generation date, top right.Generated
Summary titleTitle of the summary section.Summary
StartLabel of the start date.Start
EndLabel of the end date.End
In progressValue of End while the session runs.In progress
DurationLabel of the duration.Duration
ConfigurationLabel of the configuration name.Configuration
BatchLabel of the batch, shown only when the session has one.Batch
InspectedLabel of the number of inspected pieces.Inspected
OKLabel of the OK count.OK
NOKLabel of the NOK count.NOK
Saved piecesLabel of the number of saved pieces.Saved pieces
First pieceCaption of the first saved piece.First piece
Last pieceCaption of the last saved piece.Last piece
No imageText of the grey box drawn where an image is missing.No saved image
Errors titleTitle of the errors section.Error count
Grade labelName of the grade figure.Grade
Limiting labelText before the limiting parameters.Limited by
Score labelName of the score figure.Score
Defects labelName of the defects figure.Defects per label
Defect size labelName of the maxDimension figure.Largest defect
MeanWord before the mean of a figure that varies.mean
Reasons labelText before the failure reasons.Reasons
Grade letters labelText before the grade letters.Grade letters
Warnings labelText before the warnings.Warnings
Read labelText before the value read on the sample piece.Read
Expected labelText before the expected value.Expected

Charts ​

PropertyDescriptionDefault
Line chartShows the line chart.on
TitleTitle of the line chart.LINE CHART
Defaults (Title, Legend)Initial state of the line chart title and legend.on, on
Max pointsNumber of saved pieces plotted, the most recent ones. Values below 1 fall back to 1000.1000
Variable 1 labelLabel of the first variable selector in the chart settings.Variable 1
Variable 2 labelLabel of the second, optional, variable selector.Variable 2
Save labelText of the save button of the chart settings.SAVE
Bar chartShows the bar chart.on
TitleTitle of the bar chart.BAR CHART
Defaults (Title, Legend)Initial state of the bar chart title and legend.on, off
Bar layoutInitial orientation of the bars: Columns or Rows.Columns
Errors listShows the errors list.on
TitleTitle 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 ​

PropertyDescriptionDefault
Dialog titleTitle 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 imagesMaximum 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
ThumbnailsInitial state of the Show annotations button of the dialog, which draws the boxes over the thumbnails.on
Mask checkbox textLabel of the Mask toggle."" (MASK)
Bbox checkbox textLabel of the Bbox toggle."" (BBOX)
Polygon checkbox textLabel of the Polygons toggle."" (POLYGONS)
Hover label textTitle of the labels on hover option of the footbar menu."" (Labels on hover)
Hover label hintSubtitle of that option."" (Show a label only while pointing at its detection)
Box fill textTitle of the box fill option of the footbar menu."" (Bounding box fill)
Box fill hintSubtitle 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.payloadEffect
arrayReplaces 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 elseRefreshes 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.

FieldTypeUse
sessionIdnumber or stringRequired. Identifies the session. The line chart, the image dialog and the downloads accept only ids made of digits.
startDatenumberRequired. Start time, Unix milliseconds (a numeric string is accepted).
endDatenumber or nullEnd time in milliseconds; null or missing while the session runs.
configNamestringConfiguration name. Without it, config.name, else No configuration.
configobjectConfiguration the session was started with, shown by the configuration button (Config path).
batchanyBatch, shown in the details and in the PDF report.
startedBy, stoppedByobjectWho started and stopped the session, for example startedBy.email.
totalCounternumberInspected pieces.
noClassCounternumberNOK pieces.
tagCounterobject{ "OK": n, "NOK": n }, used by the downloads.
errorCounterobjectCount 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.
paramobjectStatistics 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:

FieldValue
dateStart as text, day/month/year hour:minute, in the server's time zone.
endDateEnd as text in the same format, or En curso while the session runs.
durationDuration as text, for example 1 h 5 min 3 s; up to now while the session runs.
startTs, endTsStart 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.payload is not an array copies global totalCounter, noClassCounter, tagCounter, errorCounter and param into 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:

text
<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 metadata

For the image dialog, <class> is the error name as it appears in errorCounter, with / and \ replaced by _. Metadata of one piece:

json
{
  "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 }
      ]
    }
  }
}
FieldUse
tsSave time in milliseconds. Orders the pieces.
nameCaption of the piece in the image dialog.
dateCapture time, milliseconds or date text. Without it, ts.
resultClass of the piece. Without it, the downloads use the folder name.
isAnomaloustrue marks the piece red in the dialog, false green.
resumeResults 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).
imagesOne 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.

OutputWhenMessage
1, delete sessionThe 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 modeThe 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 progress while the session runs), Duration and Configuration; Inspected pieces, OK and NOK with their percentage (for example 14 (17,28%)), and Saved pieces; a Classes section with the count of each errorCounter entry; a Parameters section with the min, max, mean and count of each param field, 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 per resume value, and per image type a <type> URL column plus a <type> detections column (number of boxes) when some piece has boxes on that type. The resume fields score, minScore, result and isAnomalous are named <model> · Score, <model> · Threshold, <model> · Result and <model> · Anomalous; the others keep their dotted key.
  • Full data (JSON), session_<sessionId>.json: { "exportedAt", "session", "pieces" }. session is the session row with startTs, endTs, durationMs, active and savedPieces added; pieces holds every metadata file with its classDir and a url on 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:

  1. A header with the title, the generation date, and the configuration name and start date.
  2. 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.
  3. 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 tag ends in [pass] or [ok], or when the piece's resume entry for the region named by the tag has the result pass or ok, in any letter case.
  4. One row per error of errorCounter with a count above zero, most frequent first: the error name, the count over the inspected pieces (for example 4 / 81 (4,94%)) and a sample image. The sample is cut out around the first box tagged with that error in a saved piece (a tag equal 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 a stats.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's resume entry for the region has a value, the row adds Read: <value>, and Expected: <expected> when present.
  5. 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.

MessageKindCause
No group configurederrorThe node has no dashboard group.
ui-sessions: delete rejected, unknown session <sessionId>warningThe session to delete is not in the current list.
ui-sessions: delete rejected, session <sessionId> is runningwarningThe session to delete is the running one.
ui-sessions: could not delete <folder>: <reason>errorA session folder could not be removed.
ui-sessions: invalid JSON <file>: <reason>warningA metadata file of the image dialog is not valid JSON; the piece is skipped.
ui-sessions: no images for <class>: <reason> / <reason>warningNeither class folder exists; the dialog stays empty.
ui-sessions: series failed: <reason>errorThe line chart data could not be read.
ui-sessions: images failed: <reason>errorThe image dialog data could not be read.
Export failed for session <sessionId>: <reason>errorA download could not be built.
ui-sessions: <reason>errorA 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.

RoutePurpose
GET /ui-sessions/<id>/seriesData of the line chart of a session.
GET /ui-sessions/<id>/imagesPieces of one error class, for the image dialog.
POST /ui-sessions/<id>/exportThe 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:

js
// 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.