Browse Source

Indigo2 claim option

main
Stian Fredrik Aune 1 year ago
parent
commit
e516c32ede
  1. 3
      webui-react/src/hooks/kpm.ts
  2. 3
      ykonsole-exporter/src/main/kotlin/net/aiterp/git/ykonsole2/infrastructure/indigo2/Indigo2.kt
  3. 2
      ykonsole-server/src/main/kotlin/net/aiterp/git/ykonsole2/Server.kt

3
webui-react/src/hooks/kpm.ts

@ -1,6 +1,5 @@
import {useContext, useEffect, useReducer} from "react";
import RuntimeContext from "../contexts/RuntimeContext";
import {Values} from "../models/Shared";
import {WorkoutState} from "../models/Workouts";
interface UseKpmReducerState {
@ -28,7 +27,7 @@ export function useKpm() {
return {
lastStates: [...inRange, newState],
kpm: inRange.length > 30
kpm: duration >= 30
? Math.round(((newState.calories || 0) - (first.calories || 0)) * 60 / duration)
: 0,
}

3
ykonsole-exporter/src/main/kotlin/net/aiterp/git/ykonsole2/infrastructure/indigo2/Indigo2.kt

@ -26,6 +26,7 @@ class Indigo2(
private val oidcTokenEndpoint: String,
private val oidcClientId: String,
private val oidcClientSecret: String,
private val autoClaim: Boolean,
) : ExportTarget {
private val om = jacksonObjectMapper().apply {
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
@ -67,7 +68,7 @@ class Indigo2(
"kind" to "ExerciseBike",
"measurements" to tm(chunks.first()),
),
"claimed" to true,
"claimed" to autoClaim,
"date" to workout.date.toString(),
"tags" to listOfNotNull(
tag("ykonsole:Version", "2"),

2
ykonsole-server/src/main/kotlin/net/aiterp/git/ykonsole2/Server.kt

@ -111,12 +111,14 @@ private data class RepositorySet(
val tokenEndpoint = strEnv("INDIGO2_OIDC_TOKEN_ENDPOINT")
val clientId = strEnv("INDIGO2_OIDC_CLIENT_ID")
val clientSecret = strEnv("INDIGO2_OIDC_CLIENT_SECRET")
val autoClaim = optStrEnv("INDIGO2_OIDC_AUTO_CLAIM").lowercase() in arrayOf("yes", "1", "true")
return Indigo2(
indigoHost = indigo2Endpoint,
oidcTokenEndpoint = tokenEndpoint,
oidcClientId = clientId,
oidcClientSecret = clientSecret,
autoClaim = autoClaim,
)
}

Loading…
Cancel
Save