Skip to content

Commit 8431c5d

Browse files
committed
docs: add editRoles to dashboard plugin
1 parent e378cd8 commit 8431c5d

2 files changed

Lines changed: 25 additions & 11 deletions

File tree

adminforth/documentation/docs/tutorial/09-Plugins/27-0-dashboard.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,19 @@ export const globalPlugins = [
187187
];
188188
```
189189

190+
#### Control Dashboard Editing Permissions
191+
192+
By default, only users with the `superadmin` role can edit dashboards (add, rename, reorder, and remove groups or widgets). Use the `editRoles` option to grant editing to other roles:
193+
194+
```ts title="./globalPlugins.ts"
195+
new DashboardPlugin({
196+
dashboardConfigsResourceId: 'dashboard_configs',
197+
editRoles: ['superadmin', 'admin'], // allow 'admin' users to edit dashboards too
198+
});
199+
```
200+
201+
Users whose role is not listed in `editRoles` can view dashboards but are not shown the editing controls and cannot modify dashboards, groups, or widgets through the API.
202+
190203
Then pass it to the AdminForth configuration:
191204

192205
```ts title="./index.ts"
@@ -216,7 +229,7 @@ widgets: []
216229
If you need to configure dashboards without using the AI Agent, you can do so manually via the AdminForth interface:
217230
218231
1. **Access Dashboards**: Open the **Dashboards** group in the sidebar and choose a dashboard page.
219-
2. **Interactive UI Editor**: Superadmins can add, rename, reorder, and remove groups or widgets directly from the user interface.
232+
2. **Interactive UI Editor**: Users with a role listed in the plugin's `editRoles` option (defaults to `superadmin`) can add, rename, reorder, and remove groups or widgets directly from the user interface.
220233
3. **YAML Configuration Editor**: The dashboard builder has built-in code editors. When editing a widget or a group manually, you write configurations using a YAML-based DSL.
221234

222235
For the complete schema specifications of queries, formulas, custom variables, layout fields, and advanced chart configurations, see the **[Dashboard Query Reference](/docs/tutorial/Plugins/dashboard-reference)**.

adminforth/documentation/docs/tutorial/09-Plugins/27-1-dashboard-reference.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ query:
3030
direction: desc
3131
```
3232
33-
Step-based charts use a `steps` query when each step needs its own resource, metric, and filters. Funnel charts always use this query shape.
33+
Step-based charts use a `steps` query when each step needs its own resource, measure, and filters. Funnel charts can also use this query shape; like every other chart, they accept a single-resource query as well.
3434

35-
Depending on the widget, `query` can also use `limit`, `offset`, `calcs`, `time_series`, `period`, `bucket`, and `formatting`.
35+
Depending on the widget, `query` can also use `limit`, `offset`, `calcs`, `bucket`, and `formatting`.
3636

3737
Widget-scoped constants can be defined with `variables`. They are available inside `query.calcs` through `lookup($variables.path, field, default)`.
3838

@@ -50,19 +50,20 @@ chart:
5050
y:
5151
field: adjusted_value
5252
query:
53+
source: steps
5354
steps:
5455
- name: SQLite
5556
resource: cars_sl
56-
metric:
57-
agg: avg
58-
field: price
59-
as: value
57+
select:
58+
- agg: avg
59+
field: price
60+
as: value
6061
- name: MySQL
6162
resource: cars_mysql
62-
metric:
63-
agg: avg
64-
field: price
65-
as: value
63+
select:
64+
- agg: avg
65+
field: price
66+
as: value
6667
calcs:
6768
- calc: value * lookup($variables.price_multipliers, resource, 1)
6869
as: adjusted_value

0 commit comments

Comments
 (0)