Links into a report¶
A link can open a view in a report. pivotkit makes such links with create_link;
a link to rows from a server can also carry parameters of the source.
Links from pivotkit (create_link)¶
pivotkit's MCP tool create_link and its REST route POST /views/link make a link that opens a view
in a page; a model or a program that worked out a view with a pivotkit-server can hand a person that
link, and the person sees the view over the app's data with their own rights. The report opens such
a link when the pivotkit-server's source names the page and the report:
{
"sources": {
"tickets": {
"file": "data/tickets.csv",
"link": "https://psu.example.com/tickets/report",
"linkKey": "tickets"
}
}
}
New-UDPivotReport -Id 'tickets' -SourceId 'tickets' -Data $tickets
linkis the address of the PSU page,linkKeythe report's-Id: the link then ends in#pivot-tickets=1.<view>(pivotkit's share format). WithoutlinkKeyit ends in#pivot=1.<view>, which the report whose data the link names takes, and removes from the address.- The link names the data it was made for (the source's id). The report opens it only when that is
its own
-SourceId(default its-Id); a link for other data is left alone, the report starts as without it, and the browser console says why. Give the PSU report the source's id as-SourceId. A link that names no data (a view file withoutsource.id, made by hand) is loaded without that check: the report still checks its fields against the data, as for every view. - Once the report shows the link's view, it writes its own entry in place of pivotkit's, so a reload, the light/dark switch and a copied address keep the view.
- The link holds the layout only, never data; the report checks the view against the rows the
person may see, as for every link.
-NoAddressBarignores links, also these.
pivotkit's side: create_link and
sources (sources.<id>.link, .linkKey).
A source only the server can reach opens with the person's own rows: New-UDPivotReport -Uri -Source
fetches them on the PSU server, with the link's parameters from the page's query string
(rows from a server).
Links with parameters¶
A link from create_link names the source's parameters in the page's query string, such as
/orders?customer=acme#pivot-orders=1.<view>. The view stays in the fragment, and the report reads
it in the browser as every link (links from pivotkit).
- The module reads
$Queryof the page. It passes on only the names the server lists as the source'slinkParamsinGET /sources. Other names in the query string stay out. - Pass
-Query $Querywhere the call runs in a script block or function defined in the app script. -Parameterreplaces the query string:-Parameter @{ customer = $Query.customer }narrows what a link may set. A value that is$nullis left out.-Paramsis another name for it.- The server checks every value again with the rights of the person who opens the page.
- The report writes its view into the fragment and keeps the query string. A link a person copies from the address bar still names the customer.
- Values in a query string land in access logs, the browser history and the
Refererheader. List only parameters whose values may show up there. Let the reverse proxy in front of PSU send a strictReferrer-Policyheader, such assame-origin(pivotkit's security notes). - Give the report an
-Id. Without it, the key the reader's view is kept under follows the server's columns, and a person with another profile gets another key.
A view the server publishes for the source goes by its name: -View 'by-region'. Then only the fields
it uses leave the server. The server lists its views' names, not the views, so the report starts with
the view of the link, else empty.