diff --git a/widgets/dawarich-stats/README.md b/widgets/dawarich-stats/README.md new file mode 100644 index 00000000..5817f4a1 --- /dev/null +++ b/widgets/dawarich-stats/README.md @@ -0,0 +1,51 @@ +# Dawarich Stats + +Displays total lifetime distance, tracked points, cities, and countries from your Dawarich server. The API only provides total distance in Kilometers at this time. + +![Preview](preview.png) + +## Configuration + +You will need to copy your API key from your Dawarich account settings and provide your server URL. + +* `DAWARICH_URL` - The URL to your Dawarich instance, e.g., `http://:` or `https://` +* `DAWARICH_API_KEY` - Your personal Dawarich API Token. Click profile photo in top right then Account. + +```yaml +- type: custom-api + title: "Dawarich Stats" + cache: 1h # Adjust based on how often your data syncs + base-url: ${DAWARICH_URL} + options: + url: ${DAWARICH_URL} + key: ${DAWARICH_API_KEY} + template: | + {{ $url := .Options.StringOr "url" "" }} + {{ $key := .Options.StringOr "key" "" }} + {{- if or (eq $url "") (eq $key "") -}} +

Error: URL or API Key not configured.

+ {{- else -}} + {{- $requestUrl := printf "%s/api/v1/stats" $url -}} + {{- $dawarichData := newRequest $requestUrl | withHeader "Authorization" (printf "Bearer %s" $key) | getResponse -}} + {{- if eq $dawarichData.Response.StatusCode 200 -}} +
+
+
+
{{ $dawarichData.JSON.Float "totalDistanceKm" | formatNumber }}
+
Kilometers
+
+
+
{{ $dawarichData.JSON.Int "totalCitiesVisited" | formatNumber }}
+
Cities
+
+
+
{{ $dawarichData.JSON.Int "totalCountriesVisited" | formatNumber }}
+
Countries
+
+
+
+ {{- else -}} +

Failed: {{ $dawarichData.Response.Status }}

+ {{- end -}} + {{- end -}} +``` diff --git a/widgets/dawarich-stats/meta.yml b/widgets/dawarich-stats/meta.yml new file mode 100644 index 00000000..2ff4c481 --- /dev/null +++ b/widgets/dawarich-stats/meta.yml @@ -0,0 +1,3 @@ +title: Dawarich Stats +description: Shows lifetime Dawarich stats including distance traveled, cities visited, and countries visited. +author: taskfork diff --git a/widgets/dawarich-stats/preview.png b/widgets/dawarich-stats/preview.png new file mode 100644 index 00000000..5ca66432 Binary files /dev/null and b/widgets/dawarich-stats/preview.png differ