|
1 | 1 | # Dashy |
2 | 2 |
|
3 | 3 | LibrisLog can be integrated into [Dashy](https://dashy.to/), a self-hosted |
4 | | -dashboard for your services, using its |
5 | | -[HTML embedded widget](https://dashy.to/docs/widgets#html-embedded-widget). |
| 4 | +dashboard for your services, using one of its widget types: |
6 | 5 |
|
7 | | -This widget displays your reading statistics as styled stat cards directly on |
8 | | -your Dashy dashboard. |
| 6 | +- **[Custom API widget](#custom-api-widget-recommended)** (Dashy ≥4.3.1) — |
| 7 | + a simple, built-in widget that fetches your stats directly (recommended). |
| 8 | +- **[HTML embedded widget](#html-embedded-widget)** — a fully customizable |
| 9 | + widget with styled stat cards. |
9 | 10 |
|
10 | 11 | ## Prerequisites |
11 | 12 |
|
12 | 13 | - A running LibrisLog instance reachable from your Dashy server |
13 | 14 | - An [API key](/api/integrations/#api-keys) with access to the |
14 | 15 | statistics endpoint |
15 | | -- **CORS must be configured** — add your Dashy URL to the |
16 | | - [`CORS_ORIGINS`](/guide/configuration#core-settings) environment variable |
17 | | - of the LibrisLog backend so that the browser can fetch the API directly |
18 | 16 |
|
19 | | -## Configuration |
| 17 | +## Custom API Widget (Recommended) |
| 18 | + |
| 19 | +Since Dashy v4.3.1 you can use the built-in |
| 20 | +[custom API widget](https://dashy.to/docs/widgets#api-response). |
| 21 | +Add the following to your Dashy `conf.yml`: |
| 22 | + |
| 23 | +```yaml |
| 24 | +widgets: |
| 25 | + - type: customapi |
| 26 | + options: |
| 27 | + url: <LIBRISLOG-URL>/api/books/stats |
| 28 | + headers: |
| 29 | + X-API-Key: "<API-KEY>" |
| 30 | + refreshInterval: 60000 |
| 31 | + display: block |
| 32 | + mappings: |
| 33 | + - field: books_read |
| 34 | + label: Read |
| 35 | + format: number |
| 36 | + - field: books_reading |
| 37 | + label: Reading |
| 38 | + format: number |
| 39 | + - field: books_want_to_read |
| 40 | + label: Want to read |
| 41 | + format: number |
| 42 | + - field: total_books |
| 43 | + label: Total |
| 44 | + format: number |
| 45 | +``` |
| 46 | +
|
| 47 | +The `refreshInterval` is specified in milliseconds. `60000` equals 1 minute. |
| 48 | + |
| 49 | +## HTML Embedded Widget |
20 | 50 |
|
21 | | -Add the following to the Dashy `conf.yml` under the section or item where you |
22 | | -want the widget to appear: |
| 51 | +For full control over the appearance you can use the |
| 52 | +[HTML embedded widget](https://dashy.to/docs/widgets#html-embedded-widget). |
| 53 | + |
| 54 | +Add the following to your Dashy `conf.yml`: |
23 | 55 |
|
24 | 56 | ```yaml |
25 | 57 | widgets: |
@@ -112,26 +144,35 @@ widgets: |
112 | 144 | })(); |
113 | 145 | ``` |
114 | 146 |
|
| 147 | +The `updateInterval` is specified in seconds. `300` equals 5 minutes. |
| 148 | + |
| 149 | +## Placeholders |
| 150 | + |
115 | 151 | Replace the placeholders with your own values: |
116 | 152 |
|
117 | 153 | | Placeholder | Example | Description | |
118 | 154 | |---|---|---| |
119 | 155 | | `<LIBRISLOG-URL>` | `http://192.168.1.100:8000` | The base URL of your LibrisLog instance (http or https) | |
120 | 156 | | `<API-KEY>` | `lk_nRHsF3jxIBDa9u....` | An API key with access to the statistics endpoint | |
121 | 157 |
|
122 | | -The `updateInterval` is specified in seconds. `300` equals 5 minutes. |
123 | | - |
124 | 158 | ## CORS |
125 | 159 |
|
126 | | -Since the widget runs inside the Dashy iframe and fetches the LibrisLog API |
127 | | -directly from the browser, you must add your Dashy URL to the |
| 160 | +The embed widget runs inside the Dashy iframe and fetches the API directly from |
| 161 | +the browser. You must add your Dashy URL to the |
128 | 162 | [`CORS_ORIGINS`](/guide/configuration#core-settings) environment variable of |
129 | | -the LibrisLog backend. For example: |
| 163 | +the LibrisLog backend: |
130 | 164 |
|
131 | 165 | ``` |
132 | | -CORS_ORIGINS=["https://dashy.YOUR-DOMAIN"] |
| 166 | +CORS_ORIGINS=["<LIBRISLOG-URL>"] |
133 | 167 | ``` |
134 | 168 |
|
135 | | -## Result |
| 169 | +The custom API widget also requires CORS if Dashy is configured to render |
| 170 | +widgets client-side. If CORS errors occur, add the origin as shown above. |
| 171 | + |
| 172 | +## Results |
| 173 | + |
| 174 | +### Custom API (API Response) Widget |
| 175 | + |
136 | 176 |
|
137 | | - |
| 177 | +### HTML Embed Widget |
| 178 | + |
0 commit comments