Linked widgets and apps
Widgets that share a parameter can move together: choose a company in one, and the other follows. An app is a ready-made dashboard that the backend describes in apps.json, and it can declare such a link as a parameter group.
Two widgets with the same parameter
Both widgets declare the parameter company with the same optionsEndpoint. That alone makes FINOS Workspace link them on a dashboard.
{
"company_profile": {
"name": "Company profile",
"description": "The profile of the chosen company",
"category": "Reference backend",
"subCategory": "Linked widgets",
"type": "markdown",
"endpoint": "company_profile",
"gridData": {
"w": 20,
"h": 12
},
"source": "Invented sample data",
"params": [
{
"paramName": "company",
"type": "endpoint",
"label": "Company",
"description": "The company",
"value": "alder",
"optionsEndpoint": "company_options"
}
]
},
"company_performance": {
"name": "Company performance",
"description": "Three years of revenue and growth of the chosen company, with its rows for the Agent",
"category": "Reference backend",
"subCategory": "Linked widgets",
"type": "html",
"endpoint": "company_performance",
"gridData": {
"w": 20,
"h": 12
},
"source": "Invented sample data",
"raw": true,
"params": [
{
"paramName": "company",
"type": "endpoint",
"label": "Company",
"description": "The company",
"value": "alder",
"optionsEndpoint": "company_options"
}
]
}
}
- Python
- TypeScript
@app.get("/company_profile")
def company_profile(company: str = "alder") -> PlainTextResponse:
found = company_or_404(company)
return markdown(
f"## {found['name']}\n\n{found['summary']}\n\n"
f"- Sector: {found['sector']}\n- Founded: {found['founded']}\n- Headquarters: {found['headquarters']}"
)
@app.get("/company_performance", response_model=None)
def company_performance(
company: str = "alder", theme: str = "dark", raw: bool = False
) -> HTMLResponse | list:
found = company_or_404(company)
if raw:
return found["performance"]
rows = [
[row["year"], row["revenue"], row["growth"]] for row in found["performance"]
]
return page(
theme,
f"<h3>{found['name']}</h3>" + table(["Year", "Revenue ($M)", "Growth"], rows),
)
"/company_profile": ({ query }) => {
const c = companyOr404(query.get("company") ?? "alder");
return markdown(
`## ${c.name}\n\n${c.summary}\n\n` +
`- Sector: ${c.sector}\n- Founded: ${c.founded}\n- Headquarters: ${c.headquarters}`,
);
}
"/company_performance": ({ query }) => {
const company = companyOr404(query.get("company") ?? "alder");
if (flag(query.get("raw"))) return json(company.performance);
const rows = company.performance.map((row) => [row.year, row.revenue, row.growth]);
return page(query.get("theme") ?? "dark", `<h3>${company.name}</h3>` + table(["Year", "Revenue ($M)", "Growth"], rows));
}
The app
apps.json returns a list of apps. This one has three tabs. On the tab Linked widgets, the group Group 1 links the two widgets through their company parameter: its type is endpointParam because the parameter takes its options from an endpoint, and the group's widgetIds, each widget's groups and the parameter's paramName must agree. apps.json lists every field.
[
{
"name": "Reference backend tour",
"description": "Every widget type, parameter and setting of the reference backend, with invented data",
"img": "",
"img_dark": "",
"img_light": "",
"allowCustomization": true,
"tabs": {
"widget-types": {
"id": "widget-types",
"name": "Widget types",
"layout": [
{
"i": "html_widget",
"x": 0,
"y": 0,
"w": 20,
"h": 12
},
{
"i": "html_table_widget",
"x": 20,
"y": 0,
"w": 20,
"h": 12
},
{
"i": "markdown_widget",
"x": 0,
"y": 12,
"w": 20,
"h": 10
},
{
"i": "newsfeed_widget",
"x": 20,
"y": 12,
"w": 20,
"h": 16
},
{
"i": "pdf_widget",
"x": 0,
"y": 22,
"w": 20,
"h": 20
},
{
"i": "iframe_widget",
"x": 20,
"y": 28,
"w": 20,
"h": 10
}
]
},
"parameters": {
"id": "parameters",
"name": "Parameters",
"layout": [
{
"i": "param_text",
"x": 0,
"y": 0,
"w": 20,
"h": 8
},
{
"i": "param_number",
"x": 20,
"y": 0,
"w": 20,
"h": 10
},
{
"i": "param_date",
"x": 0,
"y": 8,
"w": 20,
"h": 8
},
{
"i": "param_dropdown",
"x": 20,
"y": 10,
"w": 20,
"h": 8
},
{
"i": "param_endpoint_dropdown",
"x": 0,
"y": 16,
"w": 20,
"h": 10
},
{
"i": "param_dependent_dropdown",
"x": 20,
"y": 18,
"w": 20,
"h": 8
}
]
},
"linked": {
"id": "linked",
"name": "Linked widgets",
"layout": [
{
"i": "company_profile",
"x": 0,
"y": 0,
"w": 20,
"h": 12,
"groups": [
"Group 1"
]
},
{
"i": "company_performance",
"x": 20,
"y": 0,
"w": 20,
"h": 12,
"groups": [
"Group 1"
]
}
]
}
},
"groups": [
{
"name": "Group 1",
"type": "endpointParam",
"paramName": "company",
"widgetIds": [
"company_profile",
"company_performance"
],
"defaultValue": "alder"
}
],
"prompts": [
"Which company in the holdings has the largest weight?",
"Summarize the performance of the chosen company."
]
}
]
Both routes in the backend return the file as it is:
- Python
- TypeScript
@app.get("/widgets.json")
def widgets() -> dict:
return WIDGETS
@app.get("/apps.json")
def apps() -> list:
return APPS
"/widgets.json": () => json(WIDGETS)
"/apps.json": () => json(APPS)