Skip to content

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.

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).

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.

Source: models/statistics-queries/statistic-query.model.ts.

FieldTypeRequiredNotes
idUUID—Assigned on create
specificationVersionnumberyesDefaults to 1
nameLocalizedValueyesLocalized display name
normalizedNamestringnoAuto-generated from name if omitted; unique per entity
descriptionNullableLocalizedValueno
dataEntityUUIDyesPinned by the server from the route entity — clients cannot set/override it
iconIconyes
sourceDataEntrySourceyesWhere to read from: all entries (Store), a collection, or a query
sourceOptionsStatisticQuerySourceOptionsnoParameter values for a parameterized query source
aggregationStatisticsQueryAggregationyesThe grouping + function (see below)
orderBynumber (SortDirEnum)yes0 = Asc, 1 = Desc — applied to the category of the result
showAsnumber (StatisticsQueryDisplayEnum)yes0 = Number, 1 = List, 2 = Chart
chartTypenumber (ChartTypeEnum)no0 Column, 1 Bar, 2 Line, 3 Pie, 4 Donut
optionsStatisticQueryOptionsno{ colors?: string[] }
showInEntityOverviewbooleanyesWhether it appears in the entity overview
filterFieldstringnoThe one field an execution caller is allowed to filter on at run time

The aggregation object (statistics-query-aggregation.model.ts):

FieldTypeNotes
fieldstringThe field the aggregation function operates on
groupByFieldstring[]Fields to group by; the first is the main category, the rest become subCategory
groupByOperatornumber | null (GroupByOperatorEnum)Date bucketing operator (year, quarter, month, week, day, hour, …)
aggregationFunctionnumber (AggregationFunctionEnum)0 Count, 1 Sum, 2 Min, 3 Max, 4 Average

StatisticQueryController.validateQuery enforces (throws StatisticQueryValidationExcpetion otherwise):

  • chartType must be null/undefined unless showAs === Chart.
  • If there is a groupByField and showAs === Chart, chartType must be provided.
  • If there is no groupByField, showAs must be Number.
  • If there is a groupByField, showAs must not be Number.
  • name is validated for all configured languages and checked for duplicates within the same dataEntity.
  • source is validated via DataSourceService.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
}

The showAs setting controls how a summary card renders, in one of three forms:

  1. Number — the result as a single KPI value.
  2. List — the top values as a list.
  3. Chart — one of the following chart types (chartType):
Chart typeNotes
ColumnVertical bars; supports stacked multi-group.
BarHorizontal bars.
LineTrends over a group key.
PieProportions.
DoughnutProportions 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.

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.

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 hash diff).
  • 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.

All entity-scoped routes are authorized by entityVoterFactory() at the class level.

MethodPathPurpose
POST/v1/entities/{entity}/statistic-queriesCreate a query for an entity
GET/v1/entities/{entity}/statistic-queriesList queries for an entity
GET/v1/entities/{entity}/statistic-queries/countCount 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-queriesList all queries in the system
GET/v1/statistic-queries/countCount 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-idsSince 1.10 — the batch form of the route above; see Batch load by id
GET/v2/entities/{entity}/statistic-queries/{id}/executeExecute 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.

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 (SystemViewer or Restricted); each query found is then checked against its own dataEntity with 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 by id.
  • 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.

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
}
  • where from the request is narrowed to the query’s filterField only (Utils.extractAllowedFilters) — any other filter keys are dropped.
  • The query field is the resolved criteria of the stored query referenced by the source (or undefined when the source is not a query).
  • hash is Utils.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.

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.enabled must be true, otherwise ViewDashboardConfigurationNotEnabledException.
  • If statisticQueriesMatchingSource is set and overrideSourceForStatisticQuery is not, the query’s source must match the view’s dataSource, otherwise StatisticQuerySourceNotSameAsViewException.
  • If overrideSourceForStatisticQuery is true and the query source is Store (all entries), the source is replaced by the view’s dataSource before execution.
  • If the view’s dataSource.type === Query and mergeViewSourceQueryWithStatisticQuery is 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.

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 authoredOn a dashboard, or the entity’s dashboard tabOn the entity’s own Aggregators tab
How it is computedIts own execute endpoint, one query at a timeThe entries-list summary endpoint, alongside every other aggregate that view enabled
What it producesA standalone card — a number, a list, or a chart, with its own category breakdownFigures on an entries list: a grand total, and a subtotal per group when the list is grouped
How it is groupedIts own category / date-bucket grouping, independent of any viewThe view’s own entries-list grouping, shared by every aggregate on that list
LifecycleOwned by the dashboard that carries it; removing the element can remove the queryOwned 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.

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.

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.

DashboardEntryValue (dashboard-entry-value.model.ts):

FieldTypeNotes
idUUID
nameLocalizedValueDashboard name
normalizedNamestringAuto-generated from name; unique per relatedTo scope
elements(DashboardElement | DashboardGroup)[]The ordered contents
relatedToReferencePropertyWhat the dashboard is attached to (see below)
sharingApplicationSharingSharing 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:

FieldTypeNotes
idUUIDUnique within the dashboard
elementType'Element'Fixed
elementReferenceProperty{ dataEntity: 'StatisticQuery', dataEntry: '<query-uuid>' }
groupUUIDThe DashboardGroup this element belongs to (optional)
indexnumberPosition 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.

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 (relatedTo undefined) is edited at Administration › Applications › Dashboards. A page can show a dashboard’s summaries through its Summary widget.

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 — DefaultDashboardDataEntityCreatedHandler creates one default dashboard for each newly created DataEntity: relatedTo the entity, an empty elements array, sharing level Private, spaces = ROOT_SPACE_ID, and state Active (name.en = 'dashboard').
  • Per new module — CreateDefaultDashboardOnModuleCreatedHandler creates a default dashboard relatedTo the module on DataModuleCreatedEvent (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.

MethodPathPurpose
GET/v1/dashboardsList 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 DataViews instance (InvalidDataViewException otherwise) with dashboardConfiguration.enabled === true (DashboardConfigurationNotEnabledException otherwise), then DashboardService.getDashboardForEndUsers returns 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.

updateById performs a full replace of value.elements and applies extensive validation:

  • id validity — the path id must be a UUID.
  • relatedTo is preserved from the existing dashboard (clients cannot re-target a dashboard), and sharing is forced to Public with no spaces.
  • normalizedName is also fully server-owned Since 1.8 — alongside relatedTo and sharing, saving a dashboard now takes normalizedName from 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. name stays 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 UUID id, with no duplicates (InvalidElementID).
  • No duplicate statistic query (checkElementsMostHaveUniqueElement) — the same element.dataEntry cannot appear in two elements (DashboardElementUsedMoreThanOneException).
  • Group integrity — every element’s group must 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 as DashboardValidationException).

Permission checks (checkUserPermission):

Dashboard scopeWho may edit
System (relatedTo undefined)System admin or system developer only (SystemDashboardEditNotAllowedException)
ModuleSystem admin/developer, or a module editor (EditModuleDashboardNotAllowedException)
EntitySystem 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.

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.

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).

PropertyDefaultMeaning
enabled—Dashboards enabled for this view (requires viewConfiguration.enabled)
clickToBrowsefalseWhether 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
overrideSourceForStatisticQueryfalseReplace a Store query source with the view source at execution
mergeViewSourceQueryWithStatisticQueryfalseAND 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
isDefaultLandingPagefalseDeprecated — dashboard as the view’s landing page

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.

CounterWidgetDataEntryValue (counter-widget-data-entry-value.model.ts):

FieldTypeNotes
nameLocalizedValue
normalizedNamestringAuto-generated, unique per related entity
descriptionNullableLocalizedValue
iconIcon
moduleIdstringThe owning module
dataEntitystringThe entity whose entries are counted
viewReferenceProperty{ dataEntity: 'DataViews', dataEntry: '<view-uuid>' }
displayOrdernumberSort order among widgets
queryReferencePropertyOptional query used to filter/mark entries

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.dataEntry and the widget’s dataEntity and moduleId (DataViewNotExistException otherwise).
  • The view’s viewConfiguration.enabled must be true (EntriesConfigurationMustBeEnabled).
  • The view must expose a MiniCard display in availableDisplays (CounterViewMissedMiniCardException).
  • If a query is set, it must exist for the same dataEntity (DataQueryNotFound).
MethodPathAuthPurpose
GETv1/counter-widgets/end-userany authenticated user (authorize: skip)List the widgets visible to the user in the space
GETv1/counter-widgets/{id}/countview middleware voterThe current count for a widget
GETv1/counter-widgets/{id}/entriesview middleware voterThe entries behind a widget (with match flags)
GETv1/counter-widgetssystem admin voterAdmin 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.

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 (intersection of 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.

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.

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).


Source: packages/osos-shared/src/models/enums.ts.

EnumValues (index)
DataCollectionTypeEnum0 Store, 1 Collection, 2 Query
AggregationFunctionEnum0 Count, 1 Sum, 2 Min, 3 Max, 4 Average
StatisticsQueryDisplayEnum0 Number, 1 List, 2 Chart
ChartTypeEnum0 Column, 1 Bar, 2 Line, 3 Pie, 4 Donut
SortDirEnum0 Asc, 1 Desc
GroupByOperatorEnum0 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