Summary and dashboard API reference
Section titled “Summary and dashboard API reference”This page is for integrators and developers who create or execute summaries through the API, read dashboards or counter widgets, or need the exact server behaviour behind a card. In the API a summary is a statistic query.
Everything on this page is OSOS‘s own dashboarding. Since 1.6 the same
statistic queries can also feed Grafana panels through the Apptomator data
source, which is the right tool when you need Grafana’s visualization and
transformation range, or a single dashboard spanning OSOS and other systems
— see Grafana Dashboards. Choose the in-product
dashboard when the audience already lives in the portal; choose Grafana when the
audience lives in Grafana.
Overview
Section titled “Overview”Three related building blocks in the OSOS data-service let you present aggregated numbers over your entities:
- Statistic queries (summaries) — the reusable, server-side aggregation definitions (count / sum / min / max / average, optionally grouped) that produce a single number, a list, or a chart series. In the builder these surface as summary cards.
- Dashboards — ordered collections of statistic-query elements (optionally arranged into named groups) attached to the system, a module, or a data entity.
- Counter widgets — lightweight “count of entries matching a view (and an optional query)” tiles surfaced to end users.
All three live in backend/services/data-service. Every endpoint requires the
Auth2 authentication strategy (@authenticate at the controller class level).
Statistic queries (summaries)
Section titled “Statistic queries (summaries)”A statistic query is the unit of aggregation. It is defined per data entity
and stored in its own collection (StatisticQueryRepository). Each dashboard
card is built on one statistic query.
In the designer, Display in overview tab sets showInEntityOverview: the summary appears in a dedicated overview tab in the gallery, which the gallery/view settings must enable.
Data model
Section titled “Data model”Source: models/statistics-queries/statistic-query.model.ts.
| Field | Type | Required | Notes |
|---|---|---|---|
id | UUID | — | Assigned on create |
specificationVersion | number | yes | Defaults to 1 |
name | LocalizedValue | yes | Localized display name |
normalizedName | string | no | Auto-generated from name if omitted; unique per entity |
description | NullableLocalizedValue | no | |
dataEntity | UUID | yes | Pinned by the server from the route entity — clients cannot set/override it |
icon | Icon | yes | |
source | DataEntrySource | yes | Where to read from: all entries (Store), a collection, or a query |
sourceOptions | StatisticQuerySourceOptions | no | Parameter values for a parameterized query source |
aggregation | StatisticsQueryAggregation | yes | The grouping + function (see below) |
orderBy | number (SortDirEnum) | yes | 0 = Asc, 1 = Desc — applied to the category of the result |
showAs | number (StatisticsQueryDisplayEnum) | yes | 0 = Number, 1 = List, 2 = Chart |
chartType | number (ChartTypeEnum) | no | 0 Column, 1 Bar, 2 Line, 3 Pie, 4 Donut |
options | StatisticQueryOptions | no | { colors?: string[] } |
showInEntityOverview | boolean | yes | Whether it appears in the entity overview |
filterField | string | no | The one field an execution caller is allowed to filter on at run time |
The aggregation object (statistics-query-aggregation.model.ts):
| Field | Type | Notes |
|---|---|---|
field | string | The field the aggregation function operates on |
groupByField | string[] | Fields to group by; the first is the main category, the rest become subCategory |
groupByOperator | number | null (GroupByOperatorEnum) | Date bucketing operator (year, quarter, month, week, day, hour, …) |
aggregationFunction | number (AggregationFunctionEnum) | 0 Count, 1 Sum, 2 Min, 3 Max, 4 Average |
Validation rules
Section titled “Validation rules”StatisticQueryController.validateQuery enforces (throws
StatisticQueryValidationExcpetion otherwise):
chartTypemust be null/undefined unlessshowAs === Chart.- If there is a
groupByFieldandshowAs === Chart,chartTypemust be provided. - If there is no
groupByField,showAsmust beNumber. - If there is a
groupByField,showAsmust not beNumber. nameis validated for all configured languages and checked for duplicates within the samedataEntity.sourceis validated viaDataSourceService.validateDataSource.
normalizedName uniqueness is enforced per entity on both create and update. On
create, if omitted, it is generated with the statistic_query prefix via
generateUniqueNormalizedName. Since 1.6 — the normalizedName field and its
generation/uniqueness handling were added in the 1.6 line.
API authoring pitfalls: source.store and field paths
Section titled “API authoring pitfalls: source.store and field paths”The builder fills source and aggregation for you; when creating statistic
queries directly over the HTTP API, two conventions are easy to get wrong, and
neither produces a helpful error.
source.store must be the entity’s normalized name. For a Store source
(type: 0), DataSourceService.validateDataSourceStore resolves the entity by
normalizedName only — not by entity id and not by display name. Any other
value fails at create/update with DataSourceEntityNotExist — message
Entity <store> not found, error code ENTITY_NOT_FOUND — which is misleading
when the value is a real entity id or display name: the entity exists, it just
isn’t registered under that string as a normalized name. Additionally, the
store property carries the schema pattern
(^[a-zA-Z_s][a-zA-Z0-9_]{2,127}$|^$), which rejects UUIDs (they contain
hyphens) and display names with spaces at the schema level. At execution time
there is no existence check at all — the store string is used verbatim as
the MongoDB collection name (DataEntryRepositoryFactoryService.getDataEntryRepository
sets settings.mongodb.collection to it), and the platform’s entity-to-collection
mapping is exactly entity.normalizedName. For a Query source (type: 2) you
do not set the store yourself — it is taken from the referenced query’s
dataSource.store.
Aggregation field paths need the value. prefix. Entry field data is stored
under the value property of every DataEntry, so aggregation.field and each
aggregation.groupByField entry must be written as value.<fieldName> (entry
metadata paths such as creationInfo.doneAt are used as-is; this is the
convention the frontend always sends). The API does not enforce it:
StatisticQueryService.getFieldParts strips value. only to look the field up
in the entity metadata, swallows any lookup failure (logged, never thrown), and
interpolates the raw path verbatim into the $group stage — the category
from $<groupByField> and the aggregated value from $<fullLookupPath>. A bare
path such as amount therefore builds a pipeline over $amount, a key absent
from every document, and fails silently: MongoDB evaluates the missing path
as null, so all rows collapse into a single ungrouped null-category bucket,
and Sum/Average over the missing path yields 0/null — with no error
anywhere.
A minimal correct create body (POST /v1/entities/{entity}/statistic-queries),
using the numeric enum values from the quick-reference table at the end of this
page:
{ "name": { "en": "Total amount by status" }, "icon": { /* … */ }, "source": { "type": 0, "store": "purchase_order" }, // 0 = Store; the entity's normalizedName "aggregation": { "field": "value.amount", // value. prefix required "groupByField": ["value.status"], // value. prefix required "aggregationFunction": 1 // 1 = Sum }, "orderBy": 0, // 0 = Asc "showAs": 2, // 2 = Chart (groupByField present) "chartType": 0, // 0 = Column — required when showAs is Chart "showInEntityOverview": false}Display types and chart formats
Section titled “Display types and chart formats”The showAs setting controls how a summary card renders, in one of three forms:
- Number — the result as a single KPI value.
- List — the top values as a list.
- Chart — one of the following chart types (
chartType):
| Chart type | Notes |
|---|---|
| Column | Vertical bars; supports stacked multi-group. |
| Bar | Horizontal bars. |
| Line | Trends over a group key. |
| Pie | Proportions. |
| Doughnut | Proportions with a centre label. |
Charts use theme-aware colours, an external HTML legend, and a segment limit with an “Other values” bucket for high-cardinality group-bys.
Note: two chart capabilities are currently disabled in the code — gradient fill and brightness-based segment sorting — so charts render with flat theme colours.
Summary colors: copy and paste Since 1.10
Section titled “Summary colors: copy and paste Since 1.10”A summary’s Select Colors field (stored as options.colors) holds at most
20 colors. Each color chip now has copy and remove buttons (shown on
hover, keyboard focus and touch), and a copy all action copies the whole
list as #a, #b, … in list order. Paste appends every token that is a
#RGB or #RRGGBB color — split on commas or whitespace, case kept, short
forms not expanded, duplicates kept — until the 20-color limit is reached;
anything else is ignored. So you can carry a palette from one summary to
another, or from a design tool, in one step. A long list collapses to two rows
with a +N more / Show less toggle. This is a designer convenience only;
the stored shape of the summary did not change.
Card interactions
Section titled “Card interactions”Each summary card also supports:
- Drill-down (click-to-browse): clicking a value or chart segment opens the matching entries.
- Enlarge: open the card in a larger dialog.
- Auto-refresh: the card refreshes its data automatically (change detected via
the result
hashdiff). - Additional time filters: narrow the card to this week, this month, or a custom date range.
In preview mode (see below), dashboards and summaries are fed deterministic fake data, so builder previews will not match production numbers.
Endpoints
Section titled “Endpoints”All entity-scoped routes are authorized by entityVoterFactory() at the class
level.
| Method | Path | Purpose |
|---|---|---|
POST | /v1/entities/{entity}/statistic-queries | Create a query for an entity |
GET | /v1/entities/{entity}/statistic-queries | List queries for an entity |
GET | /v1/entities/{entity}/statistic-queries/count | Count queries for an entity |
GET | /v1/entities/{entity}/statistic-queries/{id} | Get one (view-aware, see below) |
PATCH | /v1/entities/{entity}/statistic-queries/{id} | Update one |
DELETE | /v1/entities/{entity}/statistic-queries/{id} | Delete one |
GET | /v1/statistic-queries | List all queries in the system |
GET | /v1/statistic-queries/count | Count all queries in the system |
GET | /v1/statistic-queries/{id} | Get one as StatisticQueryDTO, without an entity in the path |
GET | /v1/statistic-queries/by-ids | Since 1.10 — the batch form of the route above; see Batch load by id |
GET | /v2/entities/{entity}/statistic-queries/{id}/execute | Execute and return the aggregated result |
{entity} is resolved by id or normalized name within the current space
(getEntityByIdOrNormalizedNameInSpace).
GET /v1/statistic-queries/{id} is the route dashboards use to resolve their
elements. Its authorization is against the query’s own dataEntity (voter
voteByLoadedEntityFactory('repositories.StatisticQueryRepository', 'dataEntity', 0)),
because the class-level entityVoterFactory would otherwise misread the query id
as an entity id and deny a Restricted user. It returns a StatisticQueryDTO
which additionally carries relatedData ({ dataEntity?, dataModule? }) with the
lite entity/module the query belongs to.
Create and update publish service-bus events (StatisticQueryCreatedEvent,
StatisticQueryUpdatedEvent, StatisticQueryDeletedEvent). On create, the query
is also auto-attached to relevant dashboards via
DashboardRepository.addStatisticQueryToDashboard, and each touched dashboard
emits a dashboard-updated event.
Batch load by id Since 1.10
Section titled “Batch load by id Since 1.10”A dashboard used to resolve each card’s definition with its own
GET /v1/statistic-queries/{id} — one request per card, an N+1 on a busy
module portal. GET /v1/statistic-queries/by-ids?ids=…&ids=… returns the same
StatisticQueryDTO (with relatedData) for several ids in one request, and the
portal now batches every id requested in the same tick into one call per request
scope (plain, public view, preview).
- At most 100 ids per request, duplicates included; more answers HTTP 400.
- Authorization is per query, not per request. The route itself only requires
a signed-in role (
SystemViewerorRestricted); each query found is then checked against its owndataEntitywith the same rule as the single-id route. A query the caller cannot read — or an id that does not exist — is left out of the array rather than failing the batch. Do not rely on the response order or length matching the request; match byid. - Through a data view, a query is kept only if it belongs to the view’s entity
and passes the same view checks as the entity-scoped read and execute routes
(see View-scoped execution); the view’s existing
allow-list for
/v1/statistic-queries/{id}already covers the path. In preview mode, fake ids still return their fabricated definitions. - In the portal, an id the backend leaves out fails only that card, with the same error state a 403 / 404 on the single route produced; the rest of the dashboard renders.
Executing a statistic query
Section titled “Executing a statistic query”GET /v2/entities/{entity}/statistic-queries/{id}/execute returns:
{ "result": [ /* StatisticQueryResult[] */ ], "count": 123, // total matching rows "query": { /* FilterExpression | undefined */ }, "hash": "…" // hash of result, for change detection}wherefrom the request is narrowed to the query’sfilterFieldonly (Utils.extractAllowedFilters) — any other filter keys are dropped.- The
queryfield is the resolved criteria of the stored query referenced by the source (orundefinedwhen the source is not a query). hashisUtils.hashString(JSON.stringify(result)).
Each StatisticQueryResult row (statistic-query-result.model.ts) has:
category, originalCategory, optional subCategory[]
({ field, result, originalCategory? }), and result (the aggregated value).
Under the hood (StatisticQueryService.execute) the service builds a MongoDB
aggregation pipeline: it always filters to state = Active and excludes
invalidReason = Obsolete, applies the source-query criteria and the caller
where, unwinds array/relation fields, $groups by the resolved category/
sub-categories, and maps aggregationFunction to the Mongo operator
(Count → {$sum: 1}, Sum → $sum, Min → $min, Max → $max,
Average → $avg). Category and switch/collection values are resolved to their
labels afterwards, numeric categories/results are rounded to two decimals, and
rows are sorted by category honouring orderBy (localized values compared by
the user’s language).
Date group-by operators map to $dateToString formats or arithmetic
(GroupByOperatorEnum): year, biannual, quarter, month, ISO week (01–53), day of
week/month/year, and hour/minute/second buckets. BiannualOfYear and
QuarterOfYear additionally carry the $year so results are prefixed as
year.bucket.
View-scoped execution
Section titled “View-scoped execution”When the request is made through a data view middleware (a view is bound),
checkAgainstDataView and the view’s dashboardConfiguration change behaviour:
- The view’s
dashboardConfiguration.enabledmust betrue, otherwiseViewDashboardConfigurationNotEnabledException. - If
statisticQueriesMatchingSourceis set andoverrideSourceForStatisticQueryis not, the query’ssourcemust match the view’sdataSource, otherwiseStatisticQuerySourceNotSameAsViewException. - If
overrideSourceForStatisticQueryis true and the query source isStore(all entries), the source is replaced by the view’sdataSourcebefore execution. - If the view’s
dataSource.type === QueryandmergeViewSourceQueryWithStatisticQueryis true, the view’s source query is merged (AND-ed) into the aggregation as an additional criteria. Since 1.6.
The “N Entries” caption counts with the view query Since 1.4
Section titled “The “N Entries” caption counts with the view query Since 1.4”When a view merges its own source query into its summaries
(mergeViewSourceQueryWithStatisticQuery, above), the count behind a card’s
“N Entries” caption now applies that same merged query, exactly as the
aggregation and the Click to browse list do — so the caption equals the number
of entries the user sees after clicking through. Before the fix the caption
counted without the view query and could be larger. A parameterized view
query takes its values from the view’s own source options; the summary’s own
parameter resolution remains the fallback for any name the view does not
resolve. This correction was also delivered to the 1.4, 1.6 and 1.8 lines as an
update.
Preview mode
Section titled “Preview mode”Since 1.8 — when the PREVIEW_MODE_BINDING is set, the execute route still
performs the real entity / statistic-query / view lookups and view-scope
enforcement, but the aggregated result/count are produced by
FakeStatisticQueryGeneratorService instead of the real aggregation. The query
field is still resolved from the real referenced query.
Statistic query vs. entity aggregate Since 1.10
Section titled “Statistic query vs. entity aggregate Since 1.10”A summary (a StatisticQuery — everything on this page) and an entity aggregate are two
different resources. They are easy to confuse because both end up computing a Count, Sum, Min, Max
or Average over an entity’s entries, and both draw on the same set of five functions. The model for
aggregates — the field-type rules, how a view enables one, how grouping works, and how protected
fields behave — lives on Entity Aggregates & Entry Grouping
and is not restated here. This section only draws the boundary:
| Summary (statistic query) | Entity aggregate | |
|---|---|---|
| Where it is authored | On a dashboard, or the entity’s dashboard tab | On the entity’s own Aggregators tab |
| How it is computed | Its own execute endpoint, one query at a time | The entries-list summary endpoint, alongside every other aggregate that view enabled |
| What it produces | A standalone card — a number, a list, or a chart, with its own category breakdown | Figures on an entries list: a grand total, and a subtotal per group when the list is grouped |
| How it is grouped | Its own category / date-bucket grouping, independent of any view | The view’s own entries-list grouping, shared by every aggregate on that list |
| Lifecycle | Owned by the dashboard that carries it; removing the element can remove the query | Owned by the entity; deleted on its own, and dropped leniently from any view that had enabled it |
Choose a summary when you want a card that stands on its own and can sit on a dashboard. Choose an aggregate when the figure belongs to an entries list the reader is already looking at.
Sensitive-data access policy on a summary Since 1.10
Section titled “Sensitive-data access policy on a summary Since 1.10”A summary can now carry a sensitive-data access policy, the same setting reactions and export templates carry: it decides whether this summary may read protected values at all, always, or only according to the person running it. The control appears on the summary’s own form, and only when the entity actually declares a sensitive field. See Sensitive Fields for what each policy means.
Three things are specific to summaries:
- An unset policy behaves exactly as before. Every summary authored before this setting existed keeps its previous behaviour; nothing was migrated or re-evaluated.
- The “Auto” option is not offered. A summary has no scheduled or automatic run that is distinct from someone opening it, so there is nothing for that policy to distinguish; saving it is rejected.
- A summary the policy denies shows no figure. The reader gets no chart, no number and no
****— the card frame stays, with a lock and the message You do not have permission to view this summary, so a manager can still see (and edit) that the summary exists; the rest of the dashboard renders normally around it. A User-Based summary the reader may see, but whose sensitive fields they have not unmasked yet, shows a prompt to unmask instead. This is deliberately unlike a masked aggregate, which stays visible under its name with****in place of the value: an aggregate sits in a row of figures where a gap would itself say something, while a dashboard card can simply withhold its figure. Where the policy is per-executor, the reader must hold a grant for every sensitive field the summary reads — a partly revealed figure is still treated as a leak. If the policy service itself cannot be reached, enforcement is skipped and the summary is allowed through — this one path fails open, unlike the matching aggregate/grouping enforcement on entries lists, which fails closed (masks rather than reveals) under the same failure — worth knowing if you are debugging why a summary and an aggregate over the same field disagree during an outage.
Duplicating a summary Since 1.10
Section titled “Duplicating a summary Since 1.10”Every summary card in the dashboard builder carries a Duplicate icon next to Enlarge, alongside the duplicate affordance the reactions and views lists already offer. Duplicate opens the summary editor in create mode against the original’s id — it is never an update to the original, and the original is untouched whether you save or cancel.
- Everything is carried over except the name — source, aggregation, grouping, display type,
colors,
showInEntityOverview, description, and the sensitive-data access policy above. - The suggested name is the original’s name with a localized “Copy” suffix appended, in the language you are currently working in — if the original has no text in that language, the suffix is applied to whichever language it does have, rather than proposing an empty name. You can still edit the suggestion before saving, and the usual name-uniqueness check applies.
- Duplicate follows the same permission gate as Edit — if you cannot edit a summary, you cannot duplicate it either.
Dashboards
Section titled “Dashboards”A dashboard is a DataEntry stored in the dashboard collection. Its value
(DashboardEntryValue) holds the ordered elements array and describes what the
dashboard is attached to. It presents a set of cards (summaries), organized into
groups that can be rearranged by drag-and-drop.
Data model
Section titled “Data model”DashboardEntryValue (dashboard-entry-value.model.ts):
| Field | Type | Notes |
|---|---|---|
id | UUID | |
name | LocalizedValue | Dashboard name |
normalizedName | string | Auto-generated from name; unique per relatedTo scope |
elements | (DashboardElement | DashboardGroup)[] | The ordered contents |
relatedTo | ReferenceProperty | What the dashboard is attached to (see below) |
sharing | ApplicationSharing | Sharing settings |
relatedTo determines the dashboard’s scope:
- undefined → a system dashboard.
{ dataEntity: 'DataModule', dataEntry: '<module-uuid>' }→ a module dashboard.{ dataEntity: 'DataEntity', dataEntry: '<entity-uuid>' }→ an entity dashboard.
checkSupportedRelatedTo rejects any other relatedTo.dataEntity with a
DataNotSupportedException (“Only related to DataModule or DataEntity is
supported”).
Fixed — dashboard fields no longer vanish on save Since 1.8. The
DASHBOARD entity now declares name, elements/relatedTo, and sharing
as real fields on its schema, not just normalizedName. Before this fix, a
fresh install’s system dashboard carried no field definitions beyond
normalizedName, so the generic write path silently stripped every other
key — including name — the moment the dashboard was first saved. Because a
client always round-trips whatever value it last fetched, the very first
edit to a brand-new dashboard (adding a summary, adding a group) failed with
a validation error demanding the name that had just been stripped away. A
migration repairs existing installs, restoring the fields on any dashboard
that lost them without touching dashboards that still have a name.
Each element is one of two shapes (elements is stored as loose objects and
discriminated by elementType):
DashboardElement (elementType: 'Element') — dashboard-element.model.ts:
| Field | Type | Notes |
|---|---|---|
id | UUID | Unique within the dashboard |
elementType | 'Element' | Fixed |
element | ReferenceProperty | { dataEntity: 'StatisticQuery', dataEntry: '<query-uuid>' } |
group | UUID | The DashboardGroup this element belongs to (optional) |
index | number | Position in the dashboard |
DashboardGroup (elementType: 'DashboardGroup') — a named block that other
elements can be nested under: id, name (localized, required), description,
icon, index, optional group (a group may nest under another group). In the
builder, related summaries are dragged into a group and the group is given a
distinctive name so it renders as a single block.
Dashboard levels
Section titled “Dashboard levels”A dashboard can be built at three scopes:
- Entity level — the entity’s Dashboard tab holds its summaries; you can add, modify or delete a summary or group there, and it can also be shown from the gallery/view settings.
- Module level — the module’s Dashboard tab aggregates summaries from the entities of the module; when adding a summary you pick the entity to pull a pre-built summary from.
- System level — the system dashboard (
relatedToundefined) is edited at Administration › Applications › Dashboards. A page can show a dashboard’s summaries through its Summary widget.
Default dashboard provisioning
Section titled “Default dashboard provisioning”Dashboards are never shipped as seed or fixture JSON — no seed files create
system entities. Instead they are provisioned reactively, event-driven via
node-ts service-bus handlers (data-service/src/handlers/events/):
- Per new data entity —
DefaultDashboardDataEntityCreatedHandlercreates one default dashboard for each newly createdDataEntity:relatedTothe entity, an emptyelementsarray, sharing level Private,spaces = ROOT_SPACE_ID, and stateActive(name.en = 'dashboard'). - Per new module —
CreateDefaultDashboardOnModuleCreatedHandlercreates a default dashboardrelatedTothe module onDataModuleCreatedEvent(skipped if one already exists), alongside the default module page/generic view.
Both handlers run CoreEntryNormalizedNameService.ensureForCreate and publish a
DashboardCreatedEvent. This is why DashboardController exposes no create
endpoint (see below) — the initial dashboard already exists by the time a user
opens the Dashboard tab.
Endpoints
Section titled “Endpoints”| Method | Path | Purpose |
|---|---|---|
GET | /v1/dashboards | List dashboards (access-right filtered, or view-scoped) |
GET | /v1/dashboards/{id} | Get one dashboard |
PUT | /v1/dashboards/{id} | Replace a dashboard’s contents |
There is no create or delete endpoint on DashboardController — dashboards
are provisioned/managed elsewhere; this controller only reads and updates. PUT
is authorized by voteByRelatedToFactory('value.relatedTo', 1).
GET /v1/dashboards behaves differently depending on context:
- No view →
DashboardRepository.findWithAccessRight(userId, filter)returns the dashboards the logged-in user can access (English collation). - Through a data view → the view must be a
DataViewsinstance (InvalidDataViewExceptionotherwise) withdashboardConfiguration.enabled === true(DashboardConfigurationNotEnabledExceptionotherwise), thenDashboardService.getDashboardForEndUsersreturns only the view’s allowed dashboards, with elements optionally filtered by matching source (see below).
GET /v1/dashboards/{id} validates the id is a UUID (InvalidDashboardId) and
returns the single access-right-filtered dashboard.
Update rules (PUT)
Section titled “Update rules (PUT)”updateById performs a full replace of value.elements and applies extensive
validation:
- id validity — the path id must be a UUID.
relatedTois preserved from the existing dashboard (clients cannot re-target a dashboard), andsharingis forced toPublicwith no spaces.normalizedNameis also fully server-ownedSince 1.8— alongsiderelatedToandsharing, saving a dashboard now takesnormalizedNamefrom the persisted record unconditionally; a client has no business rewriting the identifier its uniqueness is built on. Previously a save silently erased it, because the client’s model never carries that field and the update replaces the dashboard’s contents outright.namestays something you supply, but it now falls back to the previously saved value when a save omits it, so a client that doesn’t round-trip the name can no longer erase it.- Unique element ids (
checkElementsMostHaveUniqueId) — every element/group must have a valid UUIDid, with no duplicates (InvalidElementID). - No duplicate statistic query (
checkElementsMostHaveUniqueElement) — the sameelement.dataEntrycannot appear in two elements (DashboardElementUsedMoreThanOneException). - Group integrity — every element’s
groupmust reference a group present in the dashboard (InvalidDashboardGroup); group names must be non-empty for all languages and unique across languages (EmptyLocalizedException/DashboardElementDuplicateException). - Statistic-query scope — for module/entity dashboards, every referenced
statistic query’s entity must belong to the dashboard’s module/entity, else
DashboardStatisticQueryNotInModule(collected and thrown asDashboardValidationException).
Permission checks (checkUserPermission):
| Dashboard scope | Who may edit |
|---|---|
System (relatedTo undefined) | System admin or system developer only (SystemDashboardEditNotAllowedException) |
| Module | System admin/developer, or a module editor (EditModuleDashboardNotAllowedException) |
| Entity | System admin/developer, a module editor, or the entity editor (EntityDashboardEditNotAllowedException) |
A user with no system access at all (isSystemNone) is rejected with
DataNotSupportedException.
Cleanup of orphaned statistic queries — for entity dashboards, when
elements are removed on update, handleUnusedStatisticQueries deletes the
statistic queries backing the removed elements, but only if that query is not
still referenced by another element in the dashboard. This runs only for
interactive users; service-to-service calls (e.g.
packaging import) skip both this cleanup and the permission checks, because the
import manages statistic queries independently and element ids may still
reference source-environment ids.
View source filtering of elements
Section titled “View source filtering of elements”DashboardService.getAllowedDashboardSameSourceElements (only when
dashboardConfiguration.statisticQueriesMatchingSource is set) filters each
dashboard’s elements down to statistic queries whose source matches the view’s
dataSource — dashboard groups are always retained, and if the view’s data
source type is Store (all entries) every query is allowed. Access to a
dashboard through a view is gated by getDashboardQueryFilter against the view’s
dashboardConfiguration.dashboards allow-list, throwing
DashboardAccessNotAllowedException (or a plain Error) for a disallowed id.
View dashboard configuration reference
Section titled “View dashboard configuration reference”DashboardConfiguration (on a DataViews) controls all of the above:
In the view designer: enabled is Dashboard, clickToBrowse is Click to browse, statisticQueriesMatchingSource is Summaries to show (Show all summaries or matching-source only), overrideSourceForStatisticQuery is Apply view’s source query to summaries that have all entries as a source, mergeViewSourceQueryWithStatisticQuery is Append view’s source query to summaries that have different query as a source. isDefaultLandingPage is deprecated and has no switch in the view designer: the screen a view opens on is set under Behavior › Default landing screen. A view exposes a counter through its Counter view display (MiniCard in availableDisplays).
| Property | Default | Meaning |
|---|---|---|
enabled | — | Dashboards enabled for this view (requires viewConfiguration.enabled) |
clickToBrowse | false | Whether clicking a statistic query drills into entries |
dashboards | — | Allow-list of dashboards exposed through the view |
statisticQueriesMatchingSource | — | Filter dashboard elements to queries whose source matches the view source |
overrideSourceForStatisticQuery | false | Replace a Store query source with the view source at execution |
mergeViewSourceQueryWithStatisticQuery | false | AND the view’s source query into the statistic query (used when matching-source is off) — Since 1.6 |
showEntityOverview | — | Show entity overview in the entries list |
isDefaultLandingPage | false | Deprecated — dashboard as the view’s landing page |
Counter widgets
Section titled “Counter widgets”A counter widget is a small “count of entries” tile bound to a data view and,
optionally, a query. It is a DataEntry stored under the entity name
counter_widget (StringConstants.COUNTER_WIDGET_ENTITY_NAME). Long-standing
— the counter-widget entity predates the 1.2 milestone.
Data model
Section titled “Data model”CounterWidgetDataEntryValue (counter-widget-data-entry-value.model.ts):
| Field | Type | Notes |
|---|---|---|
name | LocalizedValue | |
normalizedName | string | Auto-generated, unique per related entity |
description | NullableLocalizedValue | |
icon | Icon | |
moduleId | string | The owning module |
dataEntity | string | The entity whose entries are counted |
view | ReferenceProperty | { dataEntity: 'DataViews', dataEntry: '<view-uuid>' } |
displayOrder | number | Sort order among widgets |
query | ReferenceProperty | Optional query used to filter/mark entries |
Creation and validation
Section titled “Creation and validation”In the UI, counters are managed at Administration › Applications › Counters (New Counter: Name, Icon, View, Counting Criteria, Description). Over the API, counter widgets are created and updated through the generic data-entry CRUD
for the counter_widget entity — CounterWidgetController itself only exposes
read endpoints. CounterWidgetValidator runs on the CREATE and UPDATE
phases and enforces:
- A view must exist matching
view.dataEntryand the widget’sdataEntityandmoduleId(DataViewNotExistExceptionotherwise). - The view’s
viewConfiguration.enabledmust be true (EntriesConfigurationMustBeEnabled). - The view must expose a MiniCard display in
availableDisplays(CounterViewMissedMiniCardException). - If a
queryis set, it must exist for the samedataEntity(DataQueryNotFound).
Endpoints
Section titled “Endpoints”| Method | Path | Auth | Purpose |
|---|---|---|---|
GET | v1/counter-widgets/end-user | any authenticated user (authorize: skip) | List the widgets visible to the user in the space |
GET | v1/counter-widgets/{id}/count | view middleware voter | The current count for a widget |
GET | v1/counter-widgets/{id}/entries | view middleware voter | The entries behind a widget (with match flags) |
GET | v1/counter-widgets | system admin voter | Admin listing as CounterWidgetDataEntryDto (resolved view/module names) |
Note: the counter-widget routes are registered without a leading slash (
v1/counter-widgets/...), unlike the dashboard and statistic-query routes.
The {id}/count and {id}/entries routes require the request to come through a
view middleware (onlyViewMiddlewareVoter) and additionally check that the
widget’s value.view.dataEntry equals the current middleware view id, throwing
CounterViewNotMatchedWithMiddlewareException on mismatch.
End-user listing
Section titled “End-user listing”getCounterWidgets (behind /end-user) returns widgets that are:
- in a module of the current space,
- bound to a view that is both allowed for the user and present in the
space (
intersectionof user-allowed and space views), state === Active,
ordered by value.displayOrder DESC.
Since 1.4 — the listing no longer loads every view of the tenant to compute
that intersection. It fetches the candidate widgets first (the space’s modules ×
the user’s entitled views, Active, ordered by displayOrder) and then checks
only their view ids for space visibility; a user with no entitled views gets
[] immediately. The result is unchanged, but the cost no longer grows with the
tenant’s view count (the fix measured the view lookup falling from about 1.9 s to
about 2 ms on 3,000 views). Also delivered to the 1.4, 1.6 and 1.8 lines as an
update.
Counting and entries
Section titled “Counting and entries”getCounterCount loads the widget’s view, verifies entry access
(checkCanAccessEntries), resolves the entity in the space, and — if the widget
has a query — wraps that query’s criteria in an AND FilterExpression
before delegating to DataSourceService.countV2. Returns { count }.
getCounterEntries similarly loads view + entity, forces
order = ['value.updateInfo.doneAt DESC'], fetches entries via
DataSourceService.findV2, and returns CounterWidgetDataEntryEndUserDto[].
Each DTO adds a boolean isIncludedInQueryResult: when the widget has a
query, the service spins up a temporary collection, inserts the fetched entries,
runs the parsed query criteria as a $match, and flags which entries matched —
then drops the temp collection. Entries that do not match the query are still
returned but flagged false. Long-standing — the isIncludedInQueryResult
flag predates the 1.2 milestone.
Admin listing DTO
Section titled “Admin listing DTO”GET v1/counter-widgets (system admin only) runs a MongoDB aggregation directly:
it applies text search / filter parsing, a default _id sort (plus any requested
order), skip/offset/limit, resolves creationInfo.doneBy and
updateInfo.doneBy from the entry index, and joins the view and module names,
returning CounterWidgetDataEntryDto objects (widget + viewName + moduleName).
Quick reference: enums
Section titled “Quick reference: enums”Source: packages/osos-shared/src/models/enums.ts.
| Enum | Values (index) |
|---|---|
DataCollectionTypeEnum | 0 Store, 1 Collection, 2 Query |
AggregationFunctionEnum | 0 Count, 1 Sum, 2 Min, 3 Max, 4 Average |
StatisticsQueryDisplayEnum | 0 Number, 1 List, 2 Chart |
ChartTypeEnum | 0 Column, 1 Bar, 2 Line, 3 Pie, 4 Donut |
SortDirEnum | 0 Asc, 1 Desc |
GroupByOperatorEnum | 0 FullDate, 1 Year, 2 Biannual, 3 BiannualOfYear, 4 Quarterly, 5 QuarterOfYear, 6 Month, 7 MonthOfYear, 8 Week, 9 WeekWithMonth, 10 WeekWithYear, 11 WeekWithMonthAndYear, 12 DayOfWeek, 13 DayOfMonth, 14 DayOfYear, 15 Hours, 16 Minutes, 17 MinutesAndHours, 18 Seconds, 19 SecondsAndMinutes, 20 SecondsAndHours |
Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27